Skip to content

config: publish before the launcher reads effective configuration - #35910

Merged
ch-wan merged 4 commits into
mainfrom
cheng/gc-pr6-publish-placement
Aug 23, 2026
Merged

ch-wan merged 4 commits into
mainfrom
cheng/gc-pr6-publish-placement

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

The launcher published last — after validating, allocating ports, and deciding whether to start the engine-info bootstrap server — so all of those read effective configuration off the record, which is exactly what the record should stop carrying.

Modifications

  • Publish moves up to just below validation, the earliest it can go: auto-parser detection is resolution that needs a tokenizer and a chat template, and validation normalizes LoRA adapter paths through late resolution — both must write the record, and a published record is read-only. The launch order is: resolve → env → plugins → auto-parser → validate → publish → ports → spawn. Validation still throws before any subprocess spawns; the launcher creates them in three helpers, all called below both.
  • The data-parallel controller, the HTTP lifespan's gRPC-mode branch, and the launcher's per-TP-rank layout read the bags / configured sizes.
  • A guard walks the other direction — from everything resolution can reach (the pipeline's imports, every pass and provider in the live registries, by-value pass call sites) to any config-bag accessor — because a bag read inside resolution raises only on the branch that reaches it. Two such reads shipped and stayed green for everything except the configuration that triggers them; both are caught by the walk (verified by putting each back). Registered entries are derived from the live registries via inspect: a decorator-keyed scan saw 39 of 65 — most providers register through a helper. A source-order pin keeps the late resolvers above the publish.

Verification

  • No-bag walk over all resolution-reachable entries; launcher source-order pin; validation-before-publish pin; configured-size call-site checks.
  • Full guard suite and lint green at the stack tip; GPU round (TP / spec / PD / PP on mock weights) and a 2-GPU Ray run green.
  • A/B: resolved end-state identical to base across the 11-configuration matrix.

Checklist

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): 🚫 Run #32627985884
Latest PR Test (Extra): ❌ Run #32627985753
Latest PR Test (AMD ROCm 7.2): 🚫 Run #32627985903

@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: fcad1db787

ℹ️ 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.soft_watchdog = Watchdog.create(
debug_name="DataParallelController",
watchdog_timeout=server_args.soft_watchdog_timeout,
watchdog_timeout=get_device().soft_watchdog_timeout,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Permit the DP controller's new namespace reads

When SGLANG_ROLE_NAMESPACES=enforce is enabled and a data-parallel controller starts, this unconditional get_device() call raises because publish(..., role="dp_controller") restricts that role to the exec namespace in ROLE_NAMESPACE_SETS. The new get_disagg() reads in the tracing branch are rejected for the same reason, so the role declaration must include both device and disagg (or these values must be obtained without crossing the enforced namespace boundary) to prevent DP startup from failing.

Useful? React with 👍 / 👎.

@ch-wan ch-wan added 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
ch-wan force-pushed the cheng/gc-pr5-ordering-pins branch from fb0fd4f to 662d397 Compare August 22, 2026 00:48
@ch-wan
ch-wan force-pushed the cheng/gc-pr6-publish-placement branch from 9f736ee to 926f5d6 Compare August 22, 2026 00:48
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-pr5-ordering-pins branch from 662d397 to a42a1db Compare August 22, 2026 05:58
@ch-wan
ch-wan force-pushed the cheng/gc-pr6-publish-placement branch from 926f5d6 to 8283034 Compare August 22, 2026 05:58
@ch-wan
ch-wan force-pushed the cheng/gc-pr5-ordering-pins branch from a42a1db to 8791e5b Compare August 22, 2026 06:08
@ch-wan
ch-wan force-pushed the cheng/gc-pr6-publish-placement branch from 8283034 to 48b021f Compare August 22, 2026 06:08
@ch-wan
ch-wan force-pushed the cheng/gc-pr5-ordering-pins branch from 8791e5b to e4398b9 Compare August 22, 2026 07:28
@ch-wan
ch-wan requested a review from liusy58 as a August 22, 2026 07:28
@ch-wan
ch-wan force-pushed the cheng/gc-pr6-publish-placement branch from 48b021f to 784fd6d Compare August 22, 2026 07:28
@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 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-pr6-publish-placement branch from 784fd6d to b589336 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: b589336cec

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

# resolution, which a published config refuses. Hence before publish.
server_args.check_server_args()

publish(server_args, role="tokenizer")

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 Clear the publication when pre-spawn setup fails

When a supplied ServerArgs instance uses LoRA and a later pre-spawn step fails (for example, PortArgs.init_new() detects a DP-attention port collision), this publication remains installed even though engine construction failed. Retrying with the same instance reaches check_server_args() before this line, where LoRA normalization calls declare_late_resolution() and now raises because that exact record is already published; previously these port failures occurred before publication and the instance remained retryable. Roll back the context on launch failure or defer publication until the remaining fallible setup has completed.

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: d2f7c53d0c

ℹ️ 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 thread python/sglang/srt/entrypoints/engine.py Resolved

@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: 96b0148d64

ℹ️ 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 thread python/sglang/srt/runtime_context.py Outdated
Comment on lines +1428 to +1429
value = getattr(_CONTEXT, name)
state[name] = list(value) if isinstance(value, list) else 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 Preserve the previous capture flag during rollback

When a previously published context has a different enable_torch_compile value and the attempted launch later fails during port allocation, bootstrap setup, or daemon startup, this snapshot stores the existing Flags object by reference. publish() then mutates that same object through set_server_args(), so restore_context() reinstalls an already-mutated flag rather than the prior value. The caller is left with the old server args and bags but the failed launch's compile setting, which can incorrectly enable or disable compilation when the previous context is reused; snapshot this mutable flag state separately or restore its prior value explicitly.

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: 0d1452016b

ℹ️ 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 thread python/sglang/srt/entrypoints/engine.py Resolved

@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: 4d23c133c3

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

)

# Needs a tokenizer and a chat template, so it cannot live in the
# pipeline; after the plugins, which may register the parser detected.
if (
server_args.reasoning_parser == "auto"
or server_args.tool_call_parser == "auto"
):
resolve_auto_parsers(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 Defer auto-parser mutation until after port allocation

When a supplied ServerArgs uses either parser value "auto" and PortArgs.init_new() subsequently fails (for example, because of a DP-attention port collision), this call has already replaced the sentinel with a detected parser or None. Retrying with the same instance therefore skips detection—even if tokenizer/model loading failed transiently—despite the rollback explicitly preserving retryability. Although validation now precedes detection, the fresh ordering still invokes detection before the fallible port allocation; allocate ports first or restore the parser fields on failure.

Useful? React with 👍 / 👎.

ch-wan and others added 4 commits August 23, 2026 08:20
The launcher published last, after validating, allocating ports and deciding
whether to start the engine-info bootstrap server -- all of which read the
effective configuration. So those reads had to come off the record, which is
the thing the record is supposed to stop carrying.

Publish moves up to just below validation, which is the earliest it can go.
Two steps above it write to the record and a published record is read-only:
the auto-parser detection is resolution that needs a tokenizer and a chat
template, so it cannot live in the pipeline, and validation normalizes LoRA
adapter paths and target modules through late resolution. Everything that was
below publish is unchanged in order; it is now downstream of it, and the
bootstrap decision reads its switch from the model bag.

Validation stays above publish for that reason, and the invariant it carried
is unchanged: it still throws before any subprocess spawns. The launcher
creates them in three helpers -- the weight-cache daemons, the schedulers, the
detokenizer and router -- and calls all three below both.

The startup-failure test hands the launcher a real record instead of a
namespace: the launcher publishes what it is given, and bags only project from a
dataclass.

Co-Authored-By: Claude Opus 5 <[email protected]>
The data-parallel controller publishes as the first thing its process does and
then lays out its schedulers, so everything it reads afterwards -- the load
balance method, the watchdog timeout, the disaggregation role for its thread
label, and the rank arithmetic over the stage, attention-CP and MoE-DP sizes --
comes from the bags. The rank arithmetic follows the configured sizes: it is
deciding what to spawn, so the groups it sizes for do not exist yet.

The HTTP lifespan's gRPC-mode branch runs after the launcher published, and
reads the same way.

The controller's publish role declares the namespaces it reads. Converting these
reads takes it past `{"exec"}`: the watchdog timeout is a `device` leaf and the
thread label reads the `disagg` mode, and `parallel` was already outside the
declared set before this series. Under `SGLANG_ROLE_NAMESPACES=enforce` a
too-narrow set fails the request rather than a test, so the set is widened to
what the module actually reads.

Co-Authored-By: Claude Opus 5 <[email protected]>
`_compute_parallelism_ranks` already read the DP topology out of the context;
the attention-CP and MoE-DP factors it divided by still came off the record. It
runs while the launcher is deciding what to spawn, so those are the configured
sizes -- the process groups it is laying out do not exist yet -- and they come
from the `configured_*` accessors like the rest of that arithmetic.

The sizes are lifted into locals rather than read four times each, which is why
the expressions get shorter rather than longer.

Co-Authored-By: Claude Opus 5 <[email protected]>
The bags are projected from what resolution decides, so anything the pipeline
calls has to read the resolving state instead. A bag read reached from
resolution raises `config namespace ... not published` — and only on the branch
that reaches it, which is why two of them were written, merged and stayed green
for everything except the configuration that triggers them: the diffusion-LM
page-size pass needed one model family, the Marlin LoRA validation needed one
MoE runner backend.

`test_publish_precedes_bag_reads.py` is the same worry from the other side, but
it walks the process entries, so it cannot see a helper the pipeline calls;
neither of those two appeared in it.

This walks the other direction: from what resolution can reach -- the symbols
`server_args.py` and the override module import, every pass and provider in
the live resolution registries, and the passes named at a by-value call site --
to whether any of them reaches a bag accessor. Both known cases are caught by
it, verified by putting each back.

The registries rather than the decorators, because that is where the coverage
was: most model-override providers register through a helper call, so keying on
`@register_model_override` found 39 entries where the registries hold 65, and a
bag read in any of the other 26 was invisible. Verified the same way -- a read
put into one of them is reported now and was not before.

What it cannot see is stated in the module: a read reached through a method
rather than a module-level function, one behind an import the walk does not
follow, and one in a callable no call site names. It is a ratchet, not a proof.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant