Skip to content

[Refactor] Let the remaining placement consumers read the parallel context - #42348

Merged
ch-wan merged 23 commits into
mainfrom
cheng/refactor/placement-consumers-read-context
Oct 3, 2026
Merged

ch-wan merged 23 commits into
mainfrom
cheng/refactor/placement-consumers-read-context

Conversation

@ch-wan

@ch-wan ch-wan commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

This PR is part of a stack (oldest at bottom):

Motivation

Placement values (ranks, widths, process groups) are threaded through constructors and stored as copies, so a reader cannot tell which copy is authoritative and a copy can go stale. This is the last batch of consumers that were still handed placement instead of reading it where they run.

It also makes one latent class of bug loud: several layers shard their weights over the attention-TP group but all-reduce over the full TP group. The two groups differ only when attention DP or attention CP makes attention TP narrower than TP, and there the reduction mixes ranks that hold other requests.

Modifications

Consumers read their own placement.

  • MoeRunnerConfig carries the layer it belongs to, and the FlashInfer CUTLASS (standard and MXFP4) and HPC-Ops fused funcs read the MoE placement off it. Seven quant-info producers stop copying four fields on every apply. The layer is the single address: DWDP's bind_full_expert_weights updates it alone, and the CompressedTensors MXINT4 scheme follows that bind instead of recording the deployment rank at construction.
  • get_dp_tp_group() replaces six inline copies of "the attention-TP group under attention DP, otherwise the TP group".
  • Scheduler components take their groups from the parallel context. Components whose reads can land inside PD multiplexing's prefill scope keep the handle they were built with, which is the group they used before.
  • The KV cache builder, the HiCache controller, the KV senders and the LoRA memory pool read their own placement; LoRAInfo drops fields that fully_sharded being always false made dead.

A layer that shards over attention TP must reduce over it. reject_attn_tp_shard_with_tp_reduce refuses such a layer at construction, before weights load, naming both group widths and the ways out. It covers VisionAttention and the CLIP, PhiMoE, Step3 and MoonViT layers that reduce over TP, and the Qwen3-VL and MiniMax-VL layers that reduce over attention TP only under attention DP. IQuest-Q1 is checked only when its attention owns the reduction (reduce_results=True): the decoder now returns partial outputs to its attention boundary. EXAONE-MoE already delegates its attention reduction to that boundary on current main, so it is not gated. Each site keeps a TODO: the real fix is to reduce over the attention-TP group so these models can run those layouts.

Most models build their multimodal tower unconditionally, and several kinds of worker hold one they never forward: an encoder-disaggregated language instance, a language-model-only instance, and a PD decode instance, which embeds nothing. The encoder sites say they are encoders and multimodal_encoder_runs_here answers for all three, so none of them is refused over a reduction it never reaches. Adaptive dispatch is the exception on the first: it keeps the requests it does not send to the encoder and forwards the tower for them, so that layout is still checked. Text attention is checked on every worker, including a language-only one, where its output projection runs just the same.

The MiMo audio encoder is exempt for now, with a TODO: it shards over attention TP and reduces over TP, and refusing it would refuse MiMo-V2.5's documented --tp 8 --attn-dp-size 2 deployment.

Deprecation. --dp-size N under DeepSeek context parallelism still means N attention-DP groups and now logs a deprecation warning; it will be rejected after 2026-12-31. ServerArgs.resolved_dict keeps reporting the deprecated enable_dp_attention for clients that read it from /server_info, so --enable-dp-attention beside --attn-dp-size is redundant rather than rejected and a config read back resolves to the same layout.

Compatibility

Two deliberate changes in observable behaviour:

  • Some configurations now refuse to start. A model that builds one of the layers above refuses a layout where attention TP is narrower than TP, which today starts and computes the wrong reduction. Concretely, that is a multimodal model with --attn-dp-size between 1 and --tp-size, or with --attn-cp-size greater than 1, on a worker that forwards its tower; and PhiMoE text attention at the same widths; an IQuest-Q1 attention that owns its reduction is checked too. --attn-dp-size equal to --tp-size and --mm-enable-dp-encoder are unaffected. No cookbook recipe is affected: the deployments documented for these models either set --attn-dp-size equal to --tp-size or are MiMo, which is exempt for now.
  • /server_info reports enable_dp_attention again. It had become false under attention DP when --attn-dp-size replaced the flag; it now reports whether an attention-DP width is configured, as before, until the flag is removed after 2026-12-31. dp_size keeps its new meaning of replicas, so a client counting DP ranks should read dp_size * attn_dp_size.

Accuracy Tests

The results below precede the landing rebase. That rebase retains upstream DeepSeek-V4 HIP validation, conditions the IQuest-Q1 gate on ownership of the reduction, and removes the obsolete EXAONE-MoE gate/test after its boundary migration. Tests and benchmarks were not rerun for landing.

H200, this PR vs its base.

model config GSM8K this PR / base
DeepSeek-V2-Lite, --moe-runner-backend flashinfer_cutlass --tp 2 0.380 / 0.390, 0.370
same --tp 2 --ep-size 2 0.377 / 0.387, 0.367
DeepSeek-V2-Lite, default runner backend --tp 2 0.387 / 0.387, 0.380, 0.383
gpt-oss-20b, --moe-runner-backend flashinfer_mxfp4 --tp 2 0.537 / 0.557, 0.530
same --tp 2 --ep-size 2 0.580, 0.580 / 0.577, 0.570, 0.577, 0.580
Qwen3-8B --tp 2, --tp 2 --attn-dp-size 2 0.950 / 0.953, 0.947

Greedy output is not deterministic for these models, so each configuration was run several times on the base: every difference seen against this PR is reproduced between base runs alone. A probe on the kernel boundary shows the FlashInfer CUTLASS call receives identical tp_size/tp_rank/ep_size/ep_rank per rank on both sides in all four MoE configurations.

Qwen3-VL-2B with a real image answers identically to the base, md5-for-md5, at --tp 2, --tp 2 --attn-dp-size 2, and with --mm-enable-dp-encoder; Kimi-K2.5's MoonViT encoder likewise. DeepSeek CP resolution warns exactly once per deprecated spelling and rejects replicas combined with attention DP before warning. /server_info reports the same layout for both spellings, and every readback re-resolves to the same layout.

test/registered/unit at this PR's head, compared with its base: no new failures.

Not exercised. Five of the nine quant producers that stopped copying placement have no checkpoint here or need Blackwell (ModelOpt FP8 and NVFP4, CompressedTensors NVFP4 and MXINT4, SM120 CUTLASS); their kwargs are unchanged and were read from the same layer before. The gated layers in MiniMax-VL, Step3, PhiMoE and IQuest-Q1 have no checkpoint either, so the check on them is covered by unit tests against the layer classes rather than a server. DWDP's full-expert bind is covered by a unit test that runs the fused func, not by a DWDP deployment.

Speed Tests and Profiling

Not applicable.

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): 🚫 Run #37156874006
Latest PR Test (Extra): 🚫 Run #37156873918
Latest PR Test (AMD ROCm 10): 🚫 Run #37156873959

ch-wan added 5 commits October 3, 2026 14:57
The exemption sat in the shared check, so it also applied to text
attention. A language-only instance still forwards its text layers, and
their output projections shard over attention TP and reduce over the TP
group just the same, so exempting them hid the case the check exists
for.

It also missed a worker that holds a tower it never forwards: a PD
decode instance embeds nothing, and most models build their tower
unconditionally, so such an instance would refuse to start over a
reduction it never reaches.

The multimodal encoder sites say so, and `multimodal_encoder_runs_here`
answers for all three: encoder disaggregation, language-model-only, and
a decode instance. Text attention is checked on every worker.
CI's suite collection refuses a registered test file without one: the
pytest-style tests in it would silently skip under `python3 file.py`.
Constructing the text attentions reaches a rotary embedding that falls
back to a module the CPU runner does not have, so the test states only
the refused layout for them. The accepted layouts are covered by the
checks above, which build real layers on the CPU.
An encoder-disaggregated language instance was exempted outright, but
adaptive dispatch sends only some requests to the encoder instance and
forwards the tower for the rest, so that layout still has to hold.

The message now names the width that narrowed the attention TP group
instead of suggesting attention context parallelism be dropped where
none is configured.
@ch-wan
ch-wan force-pushed the cheng/refactor/placement-consumers-read-context branch from 890617c to f290646 Compare October 3, 2026 21:58
@ch-wan
ch-wan merged commit 10edb05 into main Oct 3, 2026
67 of 122 checks passed
@ch-wan
ch-wan deleted the cheng/refactor/placement-consumers-read-context branch October 3, 2026 21:59
TamirBaydasov added a commit to TamirBaydasov/sglang that referenced this pull request Oct 5, 2026
No textual conflicts. sgl-project#40591 is still not in main (dsa_npu_indexer.py
calls the v1 npu_quant_lightning_indexer), so the indexer-shard trap is
not live.

Checked the eight files both sides touched. sgl-project#42481 drops make_stages
and the _stage_* fields from DeepseekV2DecoderLayer; nothing on this
branch uses them. sgl-project#42348's handle_deprecated_dp_attention change still
leaves attn_dp_size set before our DCP nesting check reads it. sgl-project#42041's
ForwardBatch change is gated on upstream CP metadata, not DCP.

Local CPU tests (test/registered/dcp, test_npu_dcp, test_server_args):
the same 5 failures before and after the merge; none are new.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
detain added a commit to detain/sglang that referenced this pull request Oct 19, 2026
…-project#42348

Pre-existing red, A/B-proven: at 73a335b (before this batch)
`test_nvfp4_smallm_dispatch.py` reported 2 failures —
`test_false_launch_result_falls_back_once` and
`test_jit_or_launch_exception_falls_back_once` — with a node list
byte-identical to this branch's pre-fix run, so nothing here introduced
them. Both are stale-stub, not code bugs:

  * upstream 10edb05 (sgl-project#42348, "Let the remaining placement consumers
    read the parallel context") moved the CUTLASS launch's
    `{ep,tp}_{size,rank}` reads from `quant_info` onto
    `MoeRunnerConfig`, whose properties resolve over the layer
    placement. The fallback test builds a bare `SimpleNamespace` runner
    config, so the launch blew up with AttributeError before reaching
    the small-M fallback it is asserting on. Added the four placement
    fields (mirroring the copies the quant_info stub already carried —
    the small-M *gate* still validates those).
  * the same refactor made `_cutlass_moe_tune_max_num_tokens()` read
    `get_disagg()`, which raises "config namespace 'disagg' not
    published" in a bare unit-test process. Patched `get_disagg` to a
    PD-decode namespace, following the in-tree convention
    (`test_fused_draft_placement.py:183`), so the real helper still
    runs; its decode branch needs no other bag.

Post-state (CPU, .venv2, CUDA_VISIBLE_DEVICES=9): 21 passed / 51
subtests (was 19 passed, 2 failed / 51 subtests).

(cherry picked from commit 4af5c9861ef94db5b090d5983ee1950f33911b08)
detain added a commit to detain/sglang that referenced this pull request Oct 21, 2026
…nfig, and never let it fail a forward

_smallm_ineligibility_reason (fork-local, e787ec6) still read moe_tp_size /
moe_ep_rank / moe_ep_size from FlashInferCutlassMoeQuantInfo after upstream
10edb05 (sgl-project#42348) deleted those fields and rewired its own consumers onto
MoeRunnerConfig. The reads sit outside the try/except that guards the JIT
launch, so any call reaching them raised AttributeError out of
_run_flashinfer_cutlass and took down a scheduler process. The branch is
unreachable at EP>1 today only because the load-time gate refuses the
workspace, so the fault is latent, not absent: enable small-row MoE and the
first forward crashes.

- retarget the three reads to runner_config.*, already a parameter here and
  what this file's CUTLASS launches read (moe_* are properties over the layer)
- wrap the eligibility decision: a raise now degrades to CUTLASS and warns once
  per distinct text (the shared dedupe set keeps a per-layer fault from
  repeating every forward) instead of propagating
- test_nvfp4_smallm_dispatch.py builds a REAL FlashInferCutlassMoeQuantInfo in
  both fixtures; the old SimpleNamespace carried the deleted attributes and so
  satisfied the dangling reads. Red/green: 19F at HEAD, 25P/57sub here. New
  pins for the placement source and the degrade-on-raise contract.

Verdicts are unchanged for every configuration reachable today: same topology
numbers, and the new fallback reason only fires where the call used to raise.
detain added a commit to detain/sglang that referenced this pull request Oct 21, 2026
…at states its layer

Three CUDA-gated tests built FlashInferCutlassMoeQuantInfo(moe_ep_size=2). That
field is gone upstream since 10edb05 (sgl-project#42348), so each raises TypeError in
setUpClass-adjacent code on real SM120 hardware -- invisible here, because the
class is skipUnless(is_sm120_supported()) and a CPU run only executes the three
metadata tests. MoeRunnerConfig is now where both the small-row gate and the
CUTLASS launch read placement, so give those configs the layer stub the fused
funcs expect (16 routed experts over EP2, TP1), the same idiom
test_moe_runner_config_placement.py uses.

No behavior change: the placement values match the ones the deleted quant-info
field carried, so every case keeps its intended verdict.
detain added a commit to detain/sglang that referenced this pull request Oct 21, 2026
…ment leftovers (gate retarget + degrade-not-raise, MAX_EP door default-off, 3 hardware-broken tests), record both run scripts going PCIe-IPC-live with the corrected needle table and the 3 stale comment blocks, and the A/B harness re-pin + 4 arms asserting on non-existent log strings

Entry 244 = fea818f / 96a6d58 / c1323ca. One root cause, three
sites: upstream 10edb05 deleted moe_tp_size/moe_ep_rank/moe_ep_size from
FlashInferCutlassMoeQuantInfo and a fork gate, a unit fixture and a
CUDA-gated kernel test all kept reading them. Severity corrected against my
own earlier note -- SGLANG_NVFP4_MOE_SM120 defaults True, so any EP1 SM120
host loading an NVFP4 checkpoint builds a workspace and the first <=16-token
MoE forward raised AttributeError out of a fused func and killed a
scheduler; skynet2 escaped only because EP4 refuses the workspace.

Entry 245 = /root/run_sglang_qwenflashnext9{,c}.sh (not in git): 9.sh change
14 exports SGLANG_ENABLE_PCIE_IPC_ALLREDUCE=1 (first-ever boot for either
arm), 9c.sh now FOUR deltas, plus the corrected needle table, five
needle-string traps, and the three comment-only corrections (change count 6
-> 14, +30.2% -> same-code +28.51% against 6,192,832, HiCache/L3 PARKED on
both arms). Functional streams md5-identical across the comment edits.

Entry 246 = /root/ab_harness (not in git): arms 33/34/35 pulled off the
advisory NEEDLE 0 bound, and four arms (21/22/36/38) whose positive needles
reference strings that do not exist anywhere in the tree -- left un-rebound
on purpose, they need a real boot. base/ is stale vs the parked-L3 script.

Header synced to 246 / tip c1323ca; CAVEATS gains the moved CPU pins
(test_nvfp4_smallm_dispatch.py 21P/51sub -> 28P/66sub measured in the PROD
venv, test_nvfp4_moe_sm120.py 3P/15S unchanged but now hardware-correct,
kernels_namespace still 76P, rust untouched) and a BEHAVIOR WATCH bullet for
the first PCIe-IPC boot. Entries 242/243 annotated in place; NO upstream
merge in this batch and no sgl-project#45151 port claim (it is entry 232).

This branch was successfully deployed

1 active deployment
staging - docs — f2906465 Deployed Oct 3, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apple-silicon blackwell SM100/SM120 bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) deepseek documentation Improvements or additions to documentation hicache Hierarchical Caching for SGLang lora Multi-modal multi-modal language model parallel-stages CI: stages dispatch together instead of waiting on each other quant LLM Quantization run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci) unified-radix-cache

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant