Repository navigation
config: record resolution writes in a declaration stash - #35905
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5f37b0b85
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for target in targets: | ||
| if ( | ||
| isinstance(target, ast.Attribute) | ||
| and isinstance(target.value, ast.Name) | ||
| and target.value.id in names | ||
| and target.attr in _RESOLVED_FIELDS |
There was a problem hiding this comment.
Traverse destructured assignment targets
When EAGLE-family speculative decoding auto-selects its parameters, _handle_eagle_family still assigns speculative_num_steps, speculative_eagle_topk, and speculative_num_draft_tokens through a tuple target, but this guard only recognizes a top-level ast.Attribute. Consequently the test passes while those defaults never enter _resolved_overrides; a declaration-based projection therefore retains the unresolved values when the user omits these three options. Walk nested tuple/list targets or convert that assignment to declarations.
Useful? React with 👍 / 👎.
| def _bare_assignments(): | ||
| """Assignments to a converted field that never reach the stash.""" | ||
| found = [] | ||
| for path in sorted(_SRT.rglob("*.py")): |
There was a problem hiding this comment.
Record defaults from out-of-tree platform hooks
For an out-of-tree platform implementing the documented apply_server_args_defaults(server_args) lifecycle hook with ordinary field assignments, this scan cannot inspect the plugin because it only traverses the in-repository _SRT tree. Such defaults are consequently absent from the declaration stash; a stash-based projection loses them, and final declaration replay can also restore an earlier declared value over a later plugin assignment. The platform hook needs a declaration-aware contract or its writes must be captured around invocation rather than relying solely on this local source scan.
Useful? React with 👍 / 👎.
c111238 to
d8764b8
Compare
b5f37b0 to
9f3b522
Compare
9c39970 to
7b31471
Compare
42ffb79 to
aa84ade
Compare
7b31471 to
ddd6ae6
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ddd6ae6c6c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| server_args.speculative_draft_model_path, | ||
| trust_remote_code=server_args.trust_remote_code, | ||
| kwargs=kwargs, | ||
| declare_resolution( |
There was a problem hiding this comment.
Capture custom speculative hook writes
When an algorithm registered through SpeculativeAlgorithm.register overrides CustomSpecAlgo.handle_server_args, its field writes still bypass the declaration stash. This is a supported path—the existing TestServerArgsHook explicitly has the callback assign speculative_num_draft_tokens = 7—so a declaration-based projection will retain the unresolved caller/default value instead of the plugin-selected value. Capture mutations around algo.handle_server_args(server_args) or provide the callback with a declaration-aware contract.
Useful? React with 👍 / 👎.
d2a1198 to
19b2403
Compare
aa84ade to
552e109
Compare
19b2403 to
5243760
Compare
552e109 to
a876f2b
Compare
b185128 to
5b5893b
Compare
a876f2b to
054794f
Compare
5b5893b to
b0cc49e
Compare
054794f to
526f7b6
Compare
The declaration stash is what the config projection reads, so a handler that only assigns its field leaves that write invisible to it. Route the handler writes no later reader takes back off the field through `_declare(source, **fields)`, which records the write and applies it. The stash has to survive the whole pipeline for that to mean anything, and it did not: the model-override pass replaced it wholesale, discarding every declaration made ahead of it. That was invisible while the only declarations came from pass slots, which all sit at or after the pass; handlers declare from the first step. It now appends, and an instance connector -- no hf_config to key overrides on -- keeps what the stash already holds instead of emptying it. A guard pins both halves. No converted field is assigned bare anywhere a ServerArgs instance is in reach: handlers write through `self`, and a helper elsewhere in the tree writes through a `ServerArgs` parameter -- `set_default_server_args` is called from the pipeline and writes one of these fields, which is why that field is not converted here. After resolution, every declared field agrees with its stash entry, across shapes chosen to reach as many of them as a CPU fixture can. The exposure census counted assignments only, so converting a handler to a declaration read as its field having stopped being written, retiring every pinned pair that reads it. It counts both spellings now. Co-Authored-By: Claude Opus 5 <[email protected]>
The topology and expert-routing handlers -- DWDP, the a2a MoE backends, elastic EP, EPLB dispatch, the legacy context-parallel arguments, the diffusion-LM defaults, and the model capability adjustments -- write their resolved values straight onto the fields, where the projection that replaces field materialization cannot see them. They declare now. Fields with a writer outside the class are left alone: the `arg_groups` hooks and the NPU default helper assign several of these, and a declaration whose value materializes at the end of resolution would overwrite what such a writer had put there. Those writers get an entry point of their own before their fields convert. Co-Authored-By: Claude Opus 5 <[email protected]>
The rest of the handlers whose fields nothing outside the class writes: the model and tokenizer path resolution (ModelScope, GGUF), the load format, the missing-value defaults, the deprecated-argument normalization, the GPU memory fractions and CUDA-graph configuration, the deterministic-inference forcing, and the remaining per-backend defaults. `adjust_mem_fraction_for_vlm` is included: it reads as a public method but runs inside the memory handler, so its write is resolution like the rest. The alias loop in the deprecated-argument handler still assigns through a name tuple; converting a write whose field name is computed needs the declaration to name it, so it waits for its own change. Co-Authored-By: Claude Opus 5 <[email protected]>
The `arg_groups` hooks and the NPU default helper are the resolution pipeline's extension points, and they wrote their resolved values straight onto the instance they were handed. `declare_resolution(server_args, source, **fields)` is the entry point they share with the record's own handlers -- `ServerArgs._declare` is now a thin call into it -- so a hook's write reaches the declaration stash the projection reads. With those writers converted, nothing outside the class assigns a resolved field any more, and the fields the earlier steps had to leave alone -- the attention backends, the chunked prefill size, the radix cache and hicache layout switches, the speculative parameters -- convert too. The whole resolution write surface is declarations now, so the guard's source scan covers every field the pipeline resolves. A resolver that is not a real ServerArgs -- the registry tests hand the speculative hook a namespace -- declares fields no dataclass knows, so the field-name check skips it the way the model-override validation already does. The hook census counted assignments only, so a hook converting to a declaration read as its fields having stopped being written. It counts both spellings now, and covers the NPU helper, which writes through a `ServerArgs` parameter exactly like the hooks but had never been scanned. Co-Authored-By: Claude Opus 5 <[email protected]>
The deprecated attention-backend alias was the last writer that reached a field without the stash: it wrote through a name tuple, so it could not be converted by naming the field, and it now collects the renames and declares them in one call. With that the guard states the whole property instead of tracking the fields converted so far. Its scan covers every field of the record, so a resolution write that assigns instead of declaring fails the day it is written rather than when someone remembers to extend a list. A parameter named `server_args` counts as a writer whether or not it carries the annotation, so the scan does not rest on a convention it cannot enforce. The alias declaration expands a dict, which hides the field names from the keyword scan the same way the assignment loop hid them; the exposure census keeps pinning that set, with its drift guard keyed on the handler rather than on the loop's old shape. Destructured targets count as writes. The EAGLE auto-sizing assigned three fields through a tuple target -- `(sa.steps, sa.topk, sa.draft_tokens) = _auto_choose_speculative_params(...)` -- which is not an `ast.Attribute` at the top level, so the scan walked past it and the three never reached the stash. Measured on `--speculative-algorithm EAGLE` without explicit sizing: the record held 5/4/8 while the bags published `None`, and `tp_worker` calls `range()` on one of them. The assignment is a declaration now, and the scan flattens tuple/list targets. Co-Authored-By: Claude Opus 5 <[email protected]>
The source scan states that no assignment escapes the declaration stash, which is a statement about the spellings a scan can see. A computed field name, or a write through a helper the scan does not recognize as holding the record, would still move a field silently -- and the projection would then answer with the unresolved value. So this asks the other question: resolve each shape, compare every field against what the caller supplied or the field's default, and require the stash to account for each difference. It is the property the projection depends on, checked at runtime rather than inferred from the source. Co-Authored-By: Claude Opus 5 <[email protected]>
b0cc49e to
f6db340
Compare
Stack
Part of a series that moves
ServerArgsfrom "mutate the record at construction" to "resolve once, publish into config bags". Each PR stands alone (builds, passes its own tests); review bottom-up.mainWhole-series CI vehicle (not for merge): #35917
Motivation
Resolution used to write
ServerArgsfields with bare assignments, so what a handler decided was indistinguishable from what the caller passed in. To project configuration bags from resolution output (later in this stack), every resolution write must be recorded, not just applied.Modifications
self._declare(...)on handlers,declare_resolution(...)in the hooks): the write is appended to a declaration stash on the record and applied to the field immediately, so successors that read the field directly see the same value as before.declare_resolution's docstring states what routing a write through the stash changes: a declaration is replayed last, so an immediate writer that declares a field a deferred writer also decides now beats it. A resolver gating on such a field must read the resolving view, not the raw field.--enable-waterfill --moe-a2a-backend ascend_tp).Verification
Checklist
🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ❌ Run #32627932977
Latest PR Test (Extra): ❌ Run #32627932879
Latest PR Test (AMD ROCm 7.2): ❌ Run #32627932946