Skip to content

config: a defensive publish must not re-project over a live process - #35904

Merged
ch-wan merged 1 commit into
mainfrom
cheng/gc-pr0-publish-once
Aug 23, 2026
Merged

ch-wan merged 1 commit into
mainfrom
cheng/gc-pr0-publish-once

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

ModelRunner and TokenizerManager publish the startup record in their constructors because either can be built standalone (a benchmark harness, the manual runner tests) with nothing published before it. Inside a real process the launcher has already published the same record, and publishing again re-projects the config bags: every get_context().override(...) taken between the two calls is discarded, and the provenance log with it.

No process opens that window today — checked, not assumed: every override(...) site in the tree runs below the publish that precedes it. But the discard is silent, both constructors are reachable inside a live process, and nothing at the call site says which case it is. Any override placed in such a window from now on would be undone without a trace.

Modifications

  • ensure_published(server_args, *, role): a no-op when this record is already published under this role, a normal publish otherwise (empty slot, a different record, or a different role). publish keeps last-publish-wins — an engine rebuild must not inherit the previous engine's runtime scaling — and now logs the overrides a re-projection drops instead of dropping them quietly.
  • ModelRunner, TokenizerManager, and the in-process encoder ask for the end state through ensure_published.
  • The census of constructor publishes is derived from the code (sglang.test.config_publishers) and keyed by owning class: a constructor that owns the runtime it publishes uses publish; one that may run inside a live process uses ensure_published. The difference is invisible in the syntax, so a new publishing constructor fails the pin until it is classified.

Independent of the rest of the stack: it fixes behavior that predates it.

Verification

  • Behavioral tests for all four publish/ensure_published cases (same record+role, different record, different role, empty slot), plus the derived constructor census (adding an unclassified publishing constructor fails; verified by injection).
  • Full guard suite and lint green at this commit.

Checklist

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): 🚫 Run #32627829089
Latest PR Test (Extra): 🚫 Run #32627828993
Latest PR Test (AMD ROCm 7.2): 🚫 Run #32627829108

@ch-wan
ch-wan force-pushed the cheng/gc-pr0-publish-once branch from c111238 to d8764b8 Compare August 21, 2026 23:33
@ch-wan
ch-wan requested a review from liusy58 as a code owner August 21, 2026 23:33
ch-wan added a commit that referenced this pull request Aug 21, 2026
The stack members #35904-#35910 share head SHAs with this branch's
commits; GitHub dedupes check suites by SHA, so without a distinct tip
this carrier PR would show the members' runs instead of running CI over
the whole stack at once.

Co-Authored-By: Claude Opus 5 <[email protected]>
@ch-wan ch-wan added ready-to-merge The PR is ready to merge after the CI is green. run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci) and removed run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci) labels Aug 22, 2026
ch-wan added a commit that referenced this pull request Aug 22, 2026
The stack members #35904-#35910 share head SHAs with this branch's
commits; GitHub dedupes check suites by SHA, so without a distinct tip
this carrier PR would show the members' runs instead of running CI over
the whole stack at once.

Co-Authored-By: Claude Opus 5 <[email protected]>
ch-wan added a commit that referenced this pull request Aug 22, 2026
The stack members #35904-#35910 share head SHAs with this branch's
commits; GitHub dedupes check suites by SHA, so without a distinct tip
this carrier PR would show the members' runs instead of running CI over
the whole stack at once.

Co-Authored-By: Claude Opus 5 <[email protected]>
@ch-wan
ch-wan force-pushed the cheng/gc-pr0-publish-once branch from aa84ade to 552e109 Compare August 22, 2026 18:25
ch-wan added a commit that referenced this pull request Aug 22, 2026
The stack members #35904-#35910 share head SHAs with this branch's
commits; GitHub dedupes check suites by SHA, so without a distinct tip
this carrier PR would show the members' runs instead of running CI over
the whole stack at once.

Co-Authored-By: Claude Opus 5 <[email protected]>
@ch-wan
ch-wan force-pushed the cheng/gc-pr0-publish-once branch from 552e109 to a876f2b Compare August 23, 2026 03:23
@ch-wan
ch-wan force-pushed the cheng/gc-pr0-publish-once branch from a876f2b to 054794f Compare August 23, 2026 03:30

@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: 054794f002

ℹ️ 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 +85 to +88
if isinstance(inner.func, ast.Name):
name = inner.func.id
elif isinstance(inner.func, ast.Attribute):
name = inner.func.attr

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 Resolve publisher symbols instead of matching method names

The census treats every attribute call whose final component is publish or ensure_published as a runtime-context publication, regardless of its receiver. Consequently, adding a constructor that calls an unrelated API such as client.publish() falsely changes the pinned census, while an actual aliased import such as from ...runtime_context import publish as install is missed entirely. Resolve imports and module-qualified calls, as the precedence guard already attempts to do, so this test reliably detects only runtime-context publishers.

Useful? React with 👍 / 👎.

`ModelRunner` and `TokenizerManager` publish the startup record in their
constructors because either can be built standalone -- a benchmark harness,
the manual runner tests -- with nothing published before it. Inside a real
process the launcher published the same record already, and publishing again
re-projects the config bags: every `get_context().override(...)` taken between
the two calls is discarded, and the provenance log with it.

No process opens that window today, and that is checked rather than assumed:
every `get_context().override(...)` site in the tree runs below the publish
that precedes it. The scheduler is the case worth naming because it looks like
a counterexample -- the grammar backend's import fallback overrides
`grammar_backend` from `init_grammar_manager()` -- and it is not one: `__init__`
builds the model worker, and with it that constructor's publish, well above the
grammar manager.

So this is the semantics, not a live bug: the discard is silent, both
constructors are reachable inside a process that is already live, and nothing
at the call site says which case it is.

Both constructors now ask for the end state -- this record, this role,
published -- through `ensure_published`, which is a no-op when that already
holds. `publish` keeps its last-publish-wins semantics, because an engine
rebuild must not inherit the previous engine's runtime scaling; it now names
the overrides a re-projection drops instead of dropping them quietly.

The census of constructor publishes is pinned, keyed by the owning class: a
constructor that owns the runtime it publishes (the engine, the Ray actor that
stands in for `run_scheduler_process`) uses `publish`, and one that may run
inside a live process uses `ensure_published`. The difference is not visible in
the syntax, so a new one fails the pin until it is classified.

One stray conversion rides along: the base grew a `get_global_server_args()`
call site (granite's attention sinks) without bumping the pinned baseline, so
the legacy-accessor ratchet is red on the base itself. The read moves to the
bag accessor its converted siblings use, keeping the pinned count.
@ch-wan
ch-wan force-pushed the cheng/gc-pr0-publish-once branch from 054794f to 526f7b6 Compare August 23, 2026 08:16
@ch-wan
ch-wan merged commit 6218d6c into main Aug 23, 2026
8 of 17 checks passed
@ch-wan
ch-wan deleted the cheng/gc-pr0-publish-once branch August 23, 2026 08:16
ch-wan added a commit that referenced this pull request Aug 23, 2026
The stack members #35904-#35910 share head SHAs with this branch's
commits; GitHub dedupes check suites by SHA, so without a distinct tip
this carrier PR would show the members' runs instead of running CI over
the whole stack at once.

Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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