Repository navigation
Compress the agent conventions file and document two modular pitfalls - #48586
Conversation
`.ai/AGENTS.md` is what code agents are handed as the repo's conventions (serge injects it into every patch prompt), and its modular section stops at "edit the modular file, not the generated one". Two things it does not say cost two wrong patches on the same PR (#48536): - `_no_split_modules = AttributeError()` was read as an invalid placeholder and replaced with `[]`, which changes how the model may be sharded. The idiom is documented in `modular_transformers.md`, but nothing pointed there from here. - the generated `modeling_deepseek_vl.py` was hand-edited to match, and `modeling_deepseek_vl_hybrid.py` — generated from the same modular file — was left stale, so `Check repository consistency` went red on a model the patch never mentioned. Both bullets link to the existing sections rather than restating them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
This file loads for every agent (the root `AGENTS.md` / `CLAUDE.md` symlinks point here, and serge injects it into every patch prompt), so its length is a fixed cost on every session's context. Same rules, same commands, same links, tighter prose: 4,738 -> 3,160 chars, i.e. 439 chars BELOW what it was before the two modular bullets were added. The three "before opening a PR" sections are merged into one, since coordination, duplicate checks and busywork were all answering the same question. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
molbap
left a comment
There was a problem hiding this comment.
SGTM, better to reduce the prefix indeed!
| Model files in `src/transformers/models/` avoid inheriting from each other, so duplication is managed two ways: | ||
|
|
||
| ## Copies and Modular Models | ||
| 1. `# Copied from ...` marks a copied class or function. `make fix-repo` re-syncs it, so editing inside such a block is reverted — edit the source it copies from, or deliberately break the link. |
There was a problem hiding this comment.
specify that more Copied from statements should not be added though
There was a problem hiding this comment.
Done in 16c5305 — item 1 now ends with Do not add new # Copied from statements; write a modular file instead, and the intro says which of the two mechanisms is current:
Model files in
src/transformers/models/avoid inheriting from each other, so duplication is managed two ways — modular is the current one, copies are legacy
Review feedback: the section explained how to live with an existing copy but not that the mechanism is closed to new code. Modular is the current one; copies are legacy. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
CI recapDashboard: View test results in Grafana |
…huggingface#48586) * Document two modular pitfalls in the agent conventions `.ai/AGENTS.md` is what code agents are handed as the repo's conventions (serge injects it into every patch prompt), and its modular section stops at "edit the modular file, not the generated one". Two things it does not say cost two wrong patches on the same PR (huggingface#48536): - `_no_split_modules = AttributeError()` was read as an invalid placeholder and replaced with `[]`, which changes how the model may be sharded. The idiom is documented in `modular_transformers.md`, but nothing pointed there from here. - the generated `modeling_deepseek_vl.py` was hand-edited to match, and `modeling_deepseek_vl_hybrid.py` — generated from the same modular file — was left stale, so `Check repository consistency` went red on a model the patch never mentioned. Both bullets link to the existing sections rather than restating them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Compress the file: every rule kept, 12% smaller than before This file loads for every agent (the root `AGENTS.md` / `CLAUDE.md` symlinks point here, and serge injects it into every patch prompt), so its length is a fixed cost on every session's context. Same rules, same commands, same links, tighter prose: 4,738 -> 3,160 chars, i.e. 439 chars BELOW what it was before the two modular bullets were added. The three "before opening a PR" sections are merged into one, since coordination, duplicate checks and busywork were all answering the same question. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Say that new `# Copied from` statements should not be added Review feedback: the section explained how to live with an existing copy but not that the mechanism is closed to new code. Modular is the current one; copies are legacy. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
.ai/AGENTS.mdis the target of the rootAGENTS.md/CLAUDE.mdsymlinks, so it loads at the start of every agent session (serge also injects it verbatim into every patch prompt — uncapped). Its length is a fixed cost on every one of those sessions, which is the main thing this PR fixes.Compression
4,738 → 3,160 chars, which is 439 chars below the 3,599 it was before the additions below. Every rule, command,
ghinvocation and link is kept — verified one by one. The three separate "coordination / duplicate-work / no busywork" sections are merged into one "Before opening a PR", since they were all answering the same question.Two modular pitfalls added
The modular section stopped at "edit the modular file, not the generated one". Two things it did not say cost two wrong changes in a single patch (#48536):
_no_split_modules = AttributeError()was read as an invalid placeholder and replaced with[], which changes how the model may be sharded across devices. The idiom is documented inmodular_transformers.md, but nothing pointed there from here.modeling_deepseek_vl.pywas then hand-edited to match, leavingmodeling_deepseek_vl_hybrid.py— generated from the same modular file — stale, soCheck repository consistencywent red on a model the patch never mentioned:Both bullets link to the existing sections rather than restating them. Docs only — no code change.