Skip to content

config: pin two orderings resolution relies on - #35909

Merged
ch-wan merged 2 commits into
mainfrom
cheng/gc-pr5-ordering-pins
Aug 23, 2026
Merged

ch-wan merged 2 commits into
mainfrom
cheng/gc-pr5-ordering-pins

Conversation

@ch-wan

@ch-wan ch-wan commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

Stack

Part of a series that moves ServerArgs from "mutate the record at construction" to "resolve once, publish into config bags". Each PR stands alone (builds, passes its own tests); review bottom-up.

# PR base
0 #35904 main
1 #35905 #35904
2 #35906 #35905
3 #35907 #35906
4 #35908 #35907
5 #35909 #35908
6 #35910 #35909

Whole-series CI vehicle (not for merge): #35917

Motivation

Two orderings inside resolution hold today by accident, and nothing would notice them breaking. Tests only — no production change.

Modifications

  • ModelConfig is built from resolved input: the pin derives both sides from source — the fields ModelConfig.from_server_args reads, and the pipeline step each is declared at — and fails if a field it reads is declared after the first build. Two documented exceptions are named and asserted with equality, not membership:
    • is_embedding is read for what the caller asked for (passed through, never stored) — resolution later overwrites the field with a different quantity sharing the name;
    • four fields the model-override registries decide after the handler builds and caches the configuration (dtype, quantization, enable_multi_layer_eagle, disable_hybrid_swa_memory). The build/collect positions are read from the one handler body that contains both, and the registry-declared set is imported from the chain ratchet's derivation rather than re-derived — a copy that drifts narrower would make the check quietly vacuous. A fifth field arriving in that position fails; so does fixing the ordering — either way someone has to look.
  • The chain-read ratchet unions all four declaration channels (handler keywords, live registries, pass returns, late resolution) with per-channel floors, so a channel whose derivation collapses fails loudly instead of narrowing the check.

Verification

  • Both pins verified by injection: reversing the build/collect comparison reports exactly the four named fields; a shape reaching a stale field reddens the main assertion.
  • Guard suite and lint green at this boundary.

Checklist

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): 🚫 Run #32627965669
Latest PR Test (Extra): 🚫 Run #32627965537
Latest PR Test (AMD ROCm 7.2): ⏳ Run #32627965670

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b5e39c5fe1

ℹ️ 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".

Comment on lines +199 to +203
if not (
isinstance(base, ast.Attribute)
and base.attr == "server_args"
and not (isinstance(base.value, ast.Name) and base.value.id == "self")
):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle borrowed records parked on self

When a class parks a borrowed record as self.server_args (for example, GrammarManager assigns self.server_args = scheduler.server_args), this condition excludes every later self.server_args.<field> read. The companion supplied-instance census does not cover that case because it only marks attributes assigned directly from a parameter named server_args; therefore, adding a resolution-written read to such a class would pass both ratchets even though it is precisely a borrowed-record chain read. Only exclude self.server_args after confirming that the companion census recognizes its assignment source.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8791e5bee6

ℹ️ 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".

It forwards `**fields` to `declare_late_resolution`, so the keywords sit at
its call sites and a scan for the declarer's own name finds none of them.
"""
tree = ast.parse((_SRT / "server_args.py").read_text(encoding="utf-8-sig"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Track dynamic late-resolution fields

This scans only server_args.py, but parser/template_detection.py calls declare_late_resolution(..., **detected) for the known reasoning_parser and tool_call_parser fields (the companion supplied-instance test explicitly records that set). _declared_by_keyword() cannot recover keys from this expansion, so neither field enters _resolution_written(); a borrowed read such as manager.server_args.reasoning_parser would therefore pass this ratchet even though it reads a late-resolved value.

Useful? React with 👍 / 👎.

Comment on lines +431 to +435
stale = sorted(
field
for field in _READ_BEFORE_RESOLUTION
if field not in wanted or field not in declared
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Verify the exception remains after the first build

This companion check only verifies that is_embedding is both read and declared somewhere, not that its declaration still occurs after the first ModelConfig build. If that declaration is moved before the build, the check remains green while _READ_BEFORE_RESOLUTION continues excluding the field unconditionally from the main ordering assertion, allowing a later timing regression for this field to bypass the ratchet; compare its declaration position with the first build just as the stale-field pin does.

Useful? React with 👍 / 👎.

@ch-wan
ch-wan force-pushed the cheng/gc-pr4-borrowed-record-reads branch from 902f0f8 to d9d3103 Compare August 22, 2026 07:28
@ch-wan
ch-wan force-pushed the cheng/gc-pr5-ordering-pins branch from 8791e5b to e4398b9 Compare August 22, 2026 07:28

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e4398b9c34

ℹ️ 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".

Comment on lines +343 to +345
declared_at[keyword.arg] = max(
declared_at.get(keyword.arg, index), index
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Track declaration order within each pipeline handler

If a newly constructor-read field is declared earlier in the same handler that performs the first get_model_config() call—for example, _declare(model_path=...) immediately before that call—both events receive the same pipeline index here. The later >= check therefore reports the field as late even though declare_resolution applies it immediately and the build observes it, blocking valid ordering fixes; retain statement-level ordering within each reached handler rather than collapsing all its calls to index.

Useful? React with 👍 / 👎.

@ch-wan
ch-wan force-pushed the cheng/gc-pr5-ordering-pins branch from e4398b9 to 3c56ce7 Compare August 22, 2026 07:32
@ch-wan
ch-wan force-pushed the cheng/gc-pr4-borrowed-record-reads branch from d9d3103 to 8ab79d3 Compare August 22, 2026 07:32

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c56ce790d

ℹ️ 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".

Comment on lines +168 to +174
def _resolution_written():
"""Every field resolution can write, by any of its four mechanisms."""
return (
_declared_by_keyword()
| _declared_by_registry_and_passes()
| _declared_by_late_resolution()
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include post-publish overrides in the chain-read set

When a field is written only after publication through get_context().override(...)—for example cuda_graph_bs_decode, max_mamba_cache_size, or pp_max_micro_batch_size—it never enters this union, although test_supplied_instance_exposure_ratchet.py::_override_written_fields already enumerates this write channel. A new runner.server_args.cuda_graph_bs_decode read therefore passes this ratchet because the field is absent from written, and passes the companion census because that census ignores arbitrary chains; once the record remains raw, the read observes the startup value rather than the runtime override. Union the post-publish override targets into this written set as well.

Useful? React with 👍 / 👎.

@ch-wan
ch-wan force-pushed the cheng/gc-pr5-ordering-pins branch from 3c56ce7 to b21e489 Compare August 22, 2026 09:38
@ch-wan
ch-wan force-pushed the cheng/gc-pr4-borrowed-record-reads branch from 8ab79d3 to 0170ec4 Compare August 22, 2026 09:38

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b21e489761

ℹ️ 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".


register_cpu_ci(est_time=5, suite="base-a-test-cpu")

_SRT = pathlib.Path(sglang.__file__).resolve().parent / "srt"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Expand the chain-read census beyond the srt subtree

When the raw-record change this ratchet is intended to guard lands, borrowed reads in shipped modules outside sglang/srt remain unchecked because both the written-field derivation and _chain_reads start at _SRT. For example, python/sglang/benchmark/one_batch.py currently reads model_runner.server_args.page_size, disable_cuda_graph, and disable_overlap_schedule at lines 490 and 545-552; these are resolution-written fields and can therefore expose startup defaults in the benchmark without failing this test. Scan the full sglang package, excluding only explicitly justified owner subtrees.

Useful? React with 👍 / 👎.

Comment on lines +223 to +227
if (
isinstance(inner, ast.Call)
and isinstance(inner.func, ast.Name)
and inner.func.id == "declare_resolution"
):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Pin opaque direct writes reached through imported hooks

When a custom speculative algorithm callback rewrites a constructor input such as dtype or model_path, this scan sees no declaration because it only collects literal declare_resolution calls from the imported module. Fresh evidence beyond the platform hook is that arg_groups/speculative_hook.py already invokes declare_direct_writes with algo.validate_server_args and algo.handle_server_args after the first model-config build (lines 155-159 and 175-179), while the new platform-specific position check covers only the callback passed directly by the dispatcher. Pin every opaque callback's position or constrain/model its possible writes so such a stale cached configuration cannot leave the ratchet green.

Useful? React with 👍 / 👎.

@ch-wan
ch-wan force-pushed the cheng/gc-pr5-ordering-pins branch from b21e489 to f17bd05 Compare August 22, 2026 10:48
@ch-wan
ch-wan force-pushed the cheng/gc-pr4-borrowed-record-reads branch from 0170ec4 to ed1bccc Compare August 22, 2026 10:48

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f17bd05d73

ℹ️ 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".

imported[alias.asname or alias.name] = node.module

out = {}
for node in ast.walk(dispatch):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Follow hooks called from pipeline handlers

When a ModelConfig input is declared by an imported hook called inside a self handler after the first build, this scan never records it because it only searches bare imported calls in dispatch. For example, _handle_model_specific_adjustments builds the config and then calls the Kimi and DeepSeek hooks, which declare fields such as enable_symm_mem and enable_dp_attention; adding one of those fields to ModelConfig.from_server_args would therefore leave the ordering test green despite the cached config reading its pre-resolution value. Traverse imported hooks reached from handler bodies as well, preserving their position within the handler.

Useful? React with 👍 / 👎.

Comment on lines +223 to +228
if not (
isinstance(target, ast.Attribute)
and target.attr == "server_args"
and isinstance(target.value, ast.Name)
and target.value.id == "self"
):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Track borrowed records parked under arbitrary attributes

When a class parks a borrowed record under another attribute, such as self.args = scheduler.server_args, and later reads self.args.dtype, neither census sees it: this helper only recognizes a target literally named self.server_args, while the supplied-instance census only recognizes parking directly from a server_args parameter. That spelling has the same stale-default behavior this ratchet is intended to prevent, so record the assigned target attribute and match reads through any borrowed parked alias.

Useful? React with 👍 / 👎.

@ch-wan
ch-wan force-pushed the cheng/gc-pr5-ordering-pins branch from f17bd05 to 7547c7a Compare August 22, 2026 17:43
@ch-wan
ch-wan force-pushed the cheng/gc-pr4-borrowed-record-reads branch from ed1bccc to cf351f7 Compare August 22, 2026 17:43

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7547c7aeeb

ℹ️ 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".

Comment on lines +222 to +223
if not isinstance(node, ast.Assign):
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include annotated borrowed-record assignments

When a class parks the record with the common typed spelling self.args: ServerArgs = scheduler.server_args, this loop ignores the ast.AnnAssign, so parked_alias never recognizes subsequent self.args.<resolved_field> reads. The companion census also only handles ast.Assign, leaving this borrowed-record path outside both ratchets; handle annotated assignments alongside ordinary assignments.

Useful? React with 👍 / 👎.

Comment on lines +279 to +280
names = {alias.asname or alias.name for alias in node.names}
if names & {"ServerArgs", "server_args", "prepare_server_args"}:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recognize aliased imports of the startup record

Inside a subtree that defines another ServerArgs, importing the startup record with an alias causes this predicate to return false because it records alias.asname and then compares it only with the original spellings. The current multimodal_gen/runtime/managers/gpu_worker.py already uses ServerArgs as SrtServerArgs, so any borrowed startup-record chain read added to that mixed-record module would be skipped wholesale by _chain_reads; inspect alias.name as well as the local alias.

Useful? React with 👍 / 👎.

Comment on lines +77 to +81
for node in ast.walk(function):
if isinstance(node, ast.Dict):
for key in node.keys:
if isinstance(key, ast.Constant) and isinstance(key.value, str):
names.add(key.value)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict provider keys to the returned override mapping

When a registered provider returns a dict-valued field, this unrestricted walk also adds every literal key from the field's nested value as though it were a ServerArgs field. It likewise collects unrelated local mapping literals in the provider body, so _resolution_written() can acquire arbitrary names and reject valid borrowed reads of fields resolution never writes; track the mapping used as the provider's declaration result rather than every ast.Dict descendant.

Useful? React with 👍 / 👎.

@ch-wan
ch-wan force-pushed the cheng/gc-pr4-borrowed-record-reads branch from cf351f7 to 339d28f Compare August 22, 2026 18:25
@ch-wan
ch-wan force-pushed the cheng/gc-pr5-ordering-pins branch from 7547c7a to 6b9de1d Compare August 22, 2026 18:25

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b9de1d0b4

ℹ️ 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".

self.assertGreater(
len(registry), 20, "the registry-declared set collapsed; nothing to compare"
)
late = frozenset(reads & registry) if collect_line > build_line else frozenset()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Compare registry collection with the actual first build

When registry collection is moved above the local get_model_config() call in _handle_model_specific_adjustments, this classifies every registry field as early, even though _handle_gpu_memory_settings already calls get_model_config() earlier in the pipeline when the default mem_fraction_static is None (server_args.py:5328, dispatched at line 3857). Retiring the stale-set pin after that apparent ordering fix would therefore leave the tests green while the registry still runs after a commonly cached configuration; compare collection against the first pipeline-wide build returned by _declaration_positions() instead of only the build in the collection handler.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9f334c11d9

ℹ️ 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".

Comment on lines +129 to +133
for arg in node.args:
if not isinstance(arg, ast.Dict):
raise AssertionError(
f"opaque overrides.update() argument in {function.name}"
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Collect keys from positional update dictionaries

When a registered provider builds its returned mapping with overrides.update({"field": value}), this branch accepts the literal dictionary but never passes it to top_level_keys, despite the comment claiming those keys are collected. The field is therefore absent from _resolution_written(), so a borrowed read of that resolution-written field can be introduced without failing the chain-read ratchet; collect the keys from each accepted positional dictionary.

Useful? React with 👍 / 👎.

Comment on lines +409 to +415
for node in ast.walk(ast.parse(path.read_text(encoding="utf-8-sig"))):
if (
isinstance(node, ast.Call)
and isinstance(node.func, ast.Name)
and node.func.id == "declare_resolution"
):
fields |= {kw.arg for kw in node.keywords if kw.arg}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict hook declarations to the called function

When an imported module exposes multiple resolver hooks, _hook_declared_fields(name) ignores the requested callable and attributes every declare_resolution in the module to every call from that module. The current kimi_k3_hook.py already has an early disable_kimi_k3_symm_mem hook and later apply_kimi_k3_* hooks, so if ModelConfig.from_server_args begins reading enable_symm_mem, the later calls are falsely treated as redeclarations and the max at the caller marks an actually early value as late, blocking a valid change. Limit the traversal to the named function and helpers it reaches.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 909e4834c0

ℹ️ 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".

Comment on lines +143 to +146
if isinstance(node, ast.Attribute)
and isinstance(node.value, ast.Name)
and node.value.id in names
and isinstance(node.ctx, ast.Load)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Follow aliases of the constructor input

When from_server_args assigns the record to a local alias (for example, args = server_args) and then reads args.dtype, this direct-Name matcher omits the read. That field consequently never enters wanted or the registry intersection, so a resolution declaration after the first ModelConfig build can remain undetected; propagate simple aliases of server_args through the constructor census.

Useful? React with 👍 / 👎.

Comment on lines +340 to +345
if (
not in_srt
and rel.split("/")[0] in other_records
and not _reads_the_startup_record(tree)
):
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scope alternate ServerArgs exclusions to defining modules

When any module in a top-level subtree defines another class named ServerArgs, this condition skips every other module in that subtree unless it directly imports one of three SRT symbols. A borrowed startup record can arrive transitively without such an import, so adding an unrelated ServerArgs under a subtree such as benchmark would silently remove existing borrowed-record reads in sibling modules from the ratchet; distinguish records per module or trace the relevant value instead of excluding the entire top-level root.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3bca1b4e42

ℹ️ 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".

Comment on lines +140 to +146
reads = {
node.attr
for node in ast.walk(constructor)
if isinstance(node, ast.Attribute)
and isinstance(node.value, ast.Name)
and node.value.id in names
and isinstance(node.ctx, ast.Load)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Follow constructor reads delegated to helpers

When from_server_args passes server_args to a helper that reads a field—for example, after extracting construction of a kwargs dictionary—this census sees only the call and never traverses the helper body. A newly delegated read of a late-resolved field would therefore be absent from wanted, allowing every ordering assertion in this file to remain green even though the cached ModelConfig observes the pre-resolution value; follow local helpers that receive the record or explicitly reject that shape.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7520fdf950

ℹ️ 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".

Comment on lines +369 to +370
if through_self and not parked_alias(node.lineno, base.attr):
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scan self-held startup records outside srt

When an SRT ServerArgs is stored directly as self.server_args outside the srt subtree, this branch skips all of its reads even though the companion supplied-instance census scans only python/sglang/srt. The existing lang/backend/runtime_endpoint.py flow already constructs the startup record at line 395 and later reads the resolution-written self.server_args.tokenizer_path at line 462, so both ratchets remain green while that read would observe raw input after the planned record change; only exclude self.server_args when the companion census actually covers the module/assignment.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7e17c2320a

ℹ️ 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".

and getattr(node.func, "id", None) == "declare_direct_writes"
),
)
for node in ast.walk(dispatch):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Traverse self handlers for opaque callbacks

When declare_direct_writes is placed inside a named self._handle_* method, this scan never discovers it: it searches the dispatcher itself and modules behind bare imported calls, but does not traverse the self-handler graph returned by _pipeline(). This is especially likely because _run_resolution_pipeline explicitly requires integrations to be hidden behind named self handlers (server_args.py:3751-3765); moving the existing platform wrapper into such a handler, or adding a new opaque resolver there, would leave positions unchanged and let the ordering ratchet pass without checking whether that resolver runs before or after the first ModelConfig build. Fresh evidence in the updated code is that the newly added callback census still iterates only over ast.walk(dispatch) at this point.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2352da9063

ℹ️ 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".

collection_is_late = min(collecting_steps) > first_build[0] or (
build_line is not None and collect_line > build_line
)
late = frozenset(reads & registry) if collection_is_late else frozenset()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Track post-process passes at their invocation sites

registry includes every POST_PROCESS_PASSES return field, but this line classifies that entire union solely from the position of collect_model_override_declarations(). If registry collection is moved before the first build and the stale pin is retired as the test requests, quantization will be considered early even though _gguf_quantization is still invoked much later in _handle_load_format (server_args.py:8072); the main declaration scan cannot see that pass's dict-returned write, so a cached ModelConfig can remain stale while both checks pass. Determine post-process fields from each run_post_process_pass invocation position separately from provider collection.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7e3f8b7cfc

ℹ️ 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".

Comment on lines +424 to +425
same_body = index == build_index and method == build_method
rank = 0 if same_body and node.lineno < build_line_in_body else 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve helper call order before the first build

When a pipeline handler calls a self helper that declares a constructor-read field before the handler's get_model_config() call, this new same_body condition still assigns the helper's declaration rank 1 because its method name differs from build_method. The test consequently reports the field as late and blocks a valid ordering fix or helper extraction; preserve call-site ordering through reached self helpers rather than treating every declaration outside the build method as post-build.

Useful? React with 👍 / 👎.

ch-wan and others added 2 commits August 23, 2026 08:19
Resolution builds a `ModelConfig` partway through and keys later decisions off
it, so the pipeline reads its own output through that object. That loop is
benign exactly while every field the constructor reads has been decided before
the build -- and today it is, because the path and quantization handlers run
early in the pipeline and nothing builds a model configuration until several
steps after them. (The pin derives the positions; absolute step numbers are not
quoted here because a handler inserted upstream shifts them all.)

Nothing said so. The ordering held by luck, and a handler moved a few steps
later would have produced a model configuration describing a half-resolved
input, silently, for every decision downstream of it.

So both sides are derived from the source: the fields
`ModelConfig.from_server_args` reads, and the step each is last declared at.
Last, not first -- a second declaration after the build is precisely the
staleness at issue, and a first-declaration check would have missed it.

One field is pinned as the exception with its reason. `is_embedding` is read
for what the caller asked for -- passed as `is_embedding_requested`, never
stored -- and resolution later overwrites the field with what the architecture
implies. Two quantities sharing a name; the constructor wanting the earlier one
is the design, not an ordering bug.

Two spellings the census had to learn. `getattr(server_args, "field", default)`
is a `Call`, not an `Attribute`, and is the normal shape for an optional input,
so a field read that way was invisible. And late resolution is a channel of its
own: it writes at the launcher's validation stage, after every build, but its
fields never entered the per-step map, so the check could not even consider
them. Verified by making the constructor read a late-resolved field through
`getattr`: it is reported now.

Co-Authored-By: Claude Opus 5 <[email protected]>
The supplied-instance census counts three spellings, all starting from a
`server_args` parameter -- the caller chose the object, which is the contract
that makes those reads defensible. The fourth spelling has no contract:
`model_runner.server_args.field` lifts the record off whatever object happened
to be holding it, and no census saw it, which is how it reached 105 reads
across 36 files.

They are converted. This is what keeps them converted, and it is derived rather
than listed: the fields resolution writes come from the declaration sites, so a
field that stops being resolution-written drops out on its own -- and one that
stops being *declared* cannot leave that way, because bare assignment during
resolution is already refused.

Raw fields are deliberately not pinned. Reading `server_args.host` off a
borrowed record answers with what the caller asked for, which is what the
record is for.

The ModelConfig pin also derives from the registries now. It read
`self._declare(...)` keywords only, so it could not see that the model-specific
handler builds the configuration and *then* collects the model-override
declarations: four fields it reads -- `dtype`, `quantization`,
`enable_multi_layer_eagle`, `disable_hybrid_swa_memory` -- are decided by
providers after the object that read them was built. Both positions come from
inside that one handler body, the only scope where comparing them means
anything.

Those four are named rather than fixed, and the assertion is equality: a fifth
field arriving in that position fails, and so does moving the build or the
collection. The registry-declared set comes from the chain ratchet's derivation
by path rather than a second copy of it, because the copy that drifts narrower
is the one that makes this pass quietly.

The chain census counts the `getattr` spelling too. `getattr(runner.server_args,
"field", default)` reaches the same borrowed record with the same stale default,
but the outer node is a `Call`, so an `Attribute`-only matcher walked past it.
There are 42 literal `getattr` reads of record fields in the tree today and none
of them is a resolution-written field reached through another object, so this
closes a hole rather than reporting one.

Co-Authored-By: Claude Opus 5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2817d1b897

ℹ️ 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".

Comment on lines +251 to +253
for cls in (n for n in ast.walk(tree) if isinstance(n, ast.ClassDef)):
parked_names = set()
for node in ast.walk(cls):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Propagate parked aliases into subclasses

When a base class parks the record (for example, self.args = scheduler.server_args) and a subclass later reads self.args.<resolved_field>, this class-local span model misses the read because the assignment belongs to the base class while the read's line belongs to a separate subclass span. The supplied-instance census also computes parked attributes independently per class, so neither ratchet covers inherited parked records; carry parked aliases through the inheritance graph or conservatively associate base-class aliases with subclasses.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseek npu quant LLM Quantization ready-to-merge The PR is ready to merge after the CI is green.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant