Skip to content

config: read resolved config via namespace accessors - #33013

Merged
ch-wan merged 1 commit into
mainfrom
cheng/gc-c3-2-get-readers
Jul 31, 2026
Merged

ch-wan merged 1 commit into
mainfrom
cheng/gc-c3-2-get-readers

Conversation

@ch-wan

@ch-wan ch-wan commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Part 3 of the 3-PR stack (base: #33012). RFC: #30696. Re-lands the reader migration reverted in #32100, regenerated from scratch against current main with the revert's defects fixed at their origin.

  • Mechanical sweep (AST-based, alias-aware): get_server_args().FIELD / self.server_args.FIELD / local-alias reads flip to the namespace accessors (get_exec() / get_memory() / …), routed by each field's NS metadata — 628 reads across 160 files.
  • Kept by rule, not omission: parallel-namespace leaves (their own follow-up), per-runner fork fields (attention backends / context_length / load_format / skip_tokenizer_init / kv_cache_dtype — the draft worker's private copy rewrites these, so resolved values belong to the runner), per-instance manager files (tokenizer family and multimodal processors: with several engines in one process their reads must stay on self.server_args), the resolution pipeline, construction-boundary files, and parameter-form reads.
  • declare_load_time_override now writes the config bags via get_context().override (namespace readers see the declaration immediately); server_args stays the pristine startup record. During a draft build the declaration lands on — and is discarded with — the draft's own bags.
  • kv-cache dtype: the get_model().kv_cache_dtype bag leaf now always holds the RAW user intent. Resolved values are per-runner (model_runner.kv_cache_dtype_str, fix(attention): read per-runner kv cache dtype off model_runner #32251); the _record_kv_cache_dtype bag write-back is removed and resolved-value consumers (kv/pool configurators via a constructor argument, the PD handshake via kv_args) read the runner's value.
  • Writers are co-flipped with their readers in the same commit (a field whose readers read bags must be written through get_context().override): mamba pool sizing, update_model_fields, and the adaptive-speculative runtime overrides — including 27 direct *.server_args.speculative_* reads across 13 attention backends and 6 graph runners flipped to get_spec() / get_exec().graph.
  • check_cuda_graph_backend keeps its stdlib-only module contract (lazy accessor import) and its soft gate: unpublished config still returns False instead of raising.

Verification:

  • Full test/registered/unit suite vs the stack base: zero regressions in both directions (failure sets name-identical).
  • GPU smokes: EAGLE adaptive speculative serving (live step switching exercises exactly the writer/reader paths this PR rewires — clean logs, correct /get_server_info readback) and a plain dense model.
  • Mutation / writer / legacy ratchets green (writer ratchet lowered 49 → 39 by the co-flips); pre-commit clean.

Note: the ~15 unit tests module-skipped during the earlier migration remain skipped here; they are recovered with real publish fixtures in a follow-up PR of this stack (kept out of this diff to keep the mechanical sweep reviewable). This stack merges only after the follow-ups land and full CI is green.

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): 🚫 Run #30668890155
Latest PR Test (Extra): 🚫 Run #30668890010

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

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

ℹ️ 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/mem_cache/allocation_sizing.py Outdated
@ch-wan
ch-wan force-pushed the cheng/gc-c3-1-role branch from 6c4cb47 to 6e31c47 Compare July 31, 2026 05:58
@ch-wan
ch-wan requested a review from alexnails as a code owner July 31, 2026 05:58
@ch-wan
ch-wan force-pushed the cheng/gc-c3-2-get-readers branch from d69f8d2 to f587f57 Compare July 31, 2026 05:59

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

ℹ️ 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/openai/realtime/session.py Outdated
Comment thread python/sglang/srt/entrypoints/grpc_bridge.py Outdated
@ch-wan
ch-wan force-pushed the cheng/gc-c3-1-role branch from 6e31c47 to 0528fc7 Compare July 31, 2026 06:29
@ch-wan
ch-wan force-pushed the cheng/gc-c3-2-get-readers branch from f587f57 to 46dd4c0 Compare July 31, 2026 06:29
@ch-wan
ch-wan force-pushed the cheng/gc-c3-1-role branch from 0528fc7 to 1b2b750 Compare July 31, 2026 06:52
@ch-wan
ch-wan force-pushed the cheng/gc-c3-2-get-readers branch from 46dd4c0 to 8a1e7f9 Compare July 31, 2026 06:52

@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: 8a1e7f9ec4

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

is_rank_zero=is_rank_zero,
skip_tokenizer_init=self.server_args.skip_tokenizer_init,
metrics_enabled=self.server_args.enable_metrics
metrics_enabled=get_observability().enable_metrics

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 Publish config before constructing Ray schedulers

In the Ray deployment path, SchedulerActor.__init__ calls configure_scheduler_process and then constructs Scheduler directly without the publish(server_args, role="scheduler") performed by run_scheduler_process. Consequently this unconditional namespace read reaches RuntimeContext.config_bag() with no published bags and raises ValueError("config namespace 'observability' not published"), so every non-NPU Ray scheduler actor fails during startup; publish the possibly replaced server_args in the actor before constructing Scheduler.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed — real. The Ray scheduler actor now does publish(server_args, role="scheduler") (on its possibly-replaced copy, after configure_scheduler_process) before constructing Scheduler, matching the run_scheduler_process entry. Landed in the role PR of this stack (#33012), where the other process-entry publishes live.

@ch-wan
ch-wan force-pushed the cheng/gc-c3-1-role branch from 1b2b750 to 4b28cf3 Compare July 31, 2026 07:56
@ch-wan
ch-wan force-pushed the cheng/gc-c3-2-get-readers branch from 8a1e7f9 to 353c91c Compare July 31, 2026 07:56
@ch-wan
ch-wan force-pushed the cheng/gc-c3-1-role branch from 4b28cf3 to 9fe3312 Compare July 31, 2026 08:13
@ch-wan
ch-wan force-pushed the cheng/gc-c3-2-get-readers branch 2 times, most recently from 9a93c14 to 7e6dd38 Compare July 31, 2026 09:07
@ch-wan
ch-wan force-pushed the cheng/gc-c3-1-role branch from 9fe3312 to 14ea373 Compare July 31, 2026 20:50
@ch-wan
ch-wan force-pushed the cheng/gc-c3-2-get-readers branch from 7e6dd38 to 5c69631 Compare July 31, 2026 20:50
@ch-wan
ch-wan force-pushed the cheng/gc-c3-1-role branch from 14ea373 to 2a6c692 Compare July 31, 2026 20:59
@ch-wan
ch-wan force-pushed the cheng/gc-c3-2-get-readers branch from 5c69631 to 848c607 Compare July 31, 2026 21:00

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

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


def update_active_ranks(self, ranks: ActiveRanksOutput):
if self.server_args.elastic_ep_backend is not None:
if get_exec().moe.elastic_ep_backend is not None:

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 Keep Ray DP-controller config instance-scoped

When multiple Ray Engines coexist in one process, each RayDataParallelController runs in that shared Engine process (ray/engine.py starts its event loop in a thread), while get_exec() reflects whichever tokenizer most recently published its configuration. If an earlier engine uses elastic EP and a later engine does not, this handler processes the earlier engine's ActiveRanksOutput using the later engine's setting, bypassing the dp_active mask and potentially changing inactive pre-bound worker slots; retain this controller's self.server_args.elastic_ep_backend check.

Useful? React with 👍 / 👎.

Mechanical sweep (AST, alias-aware): get_server_args().FIELD /
self.server_args.FIELD / local-alias reads flip to the namespace
accessors (get_exec()/get_memory()/...), routed by each field's NS
metadata. 628 reads across 160 files.

Kept (by rule, not omission): parallel-namespace leaves (their own
unit), per-runner fork fields (attention backends / context_length /
load_format / skip_tokenizer_init / kv_cache_dtype — resolved values
belong to the runner, bags hold intent), per-instance manager files
(tokenizer family, multimodal processors — multi-engine reads stay on
self.server_args), the resolution pipeline, construction-boundary
files, and whole-object / parameter-form reads.

check_cuda_graph_backend keeps its stdlib-only module contract (lazy
accessor import) and its soft gate: unpublished config still returns
False instead of raising.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apple-silicon blackwell SM100/SM120 deepseek mthreads Multi-modal multi-modal language model npu ready-to-merge The PR is ready to merge after the CI is green. speculative-decoding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant