Skip to content

[None][fix] Muse modeling_v2: half-window early expert ids on Vera Rubin, and context_kv_fork under KV cache estimation - #21364

Merged
zheyuf merged 2 commits into
NVIDIA:feat/musespark-open-agentxfrom
zheyuf:musespark-open/vr-half-window-ids-ctx-kv-fork
Oct 31, 2026
Merged

zheyuf merged 2 commits into
NVIDIA:feat/musespark-open-agentxfrom
zheyuf:musespark-open/vr-half-window-ids-ctx-kv-fork

Conversation

@zheyuf

@zheyuf zheyuf commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

@coderabbitai summary

Description

Two fixes in the Muse Spark Open modeling_v2 TEP target, both found while validating DFlash2 acceptance length (AL) on Vera Rubin (R200, SM107) at the feat/musespark-open-agentx tip c55183f44.

1. pool_direct_route drops half-window experts on single-request decode steps (VR TEP4, max_batch_size <= 8)

Cause. In ops/comm/pool_direct_route.py, the early expert-id publication loop for half in cutlass.range_constexpr(2) rebinds the placement flag half = self.place == PLACE_HALF. _placed_expert(..., half) branches on that value while the kernel is traced, so:

  • the publication for verify rows 0-3 gets half = 0 and uses the two-window formula;
  • an expert that the half window moved to the ring successor gets an id >= the local window, so no rank computes it and finalize drops its term.

Rows 4-7 and the own-row local_ids store see half = 1 and are correct only by accident.

Fix. Rename the flag to place_half and pass it to both _placed_expert calls.

Where it fires. The bug needs all of the following:

  • SM107 (VR) at TEP4, with half_window_experts in the plan (max_batch_size <= 8), together with early_expert_ids and pool_into_route;
  • an 8-row (one request at K=7) CUDA-graph decode step.

So it fires on every decode step at max_batch_size 1, and on one-request steps otherwise (concurrency 1, ramp-up and tail). The disagg GEN TEP4 with max_batch_size <= 8 is affected the same way.

It does not fire on:

  • GB300 TEP4, which has neither pool_into_route nor early_expert_ids and uses pool_gather_route;
  • TEP8 (PLACE_BALANCE3);
  • max_batch_size > 8 (PLACE_OWNER; the differing ids are out of window either way).

2. context_kv_fork crashes server startup when KV cache estimation is on

Cause. With TRTLLM_SKIP_KV_CACHE_ESTIMATION=0 (what the AgentX plugin sets for DFlash workers), the estimation pass builds a probe KV cache manager and then the real one. On the final executor's first decode warmup step, the fork's side chain launched while the DFlash context was still bound to the probe manager's pool. The built-in _lazy_init_ctx_buffers then rebound the context, and the worker raised:

RuntimeError: [musespark_open] context_kv_fork: the DFlash context arena was rebuilt while a forked side chain was writing the previous one

Every modeling_v2 server with the DFlash drafter on unified target/draft KV (the TRTLLM drafter backend) died at startup.

Fix. ContextKvFork.plan() returns None while the unified context is bound to a manager other than the step's. On that step the built-in path rebinds the context, and the fork resumes on the next step. In steady state the condition is false.

Test Coverage

No new unit test. Fix 1 needs SM107 at TEP4 with the half-window plan, which pre-merge CI does not run. Validation was done on Vera Rubin (Hecate, 4x R200 per node) with the tip Python on a VR image whose C++ matches the tip:

Fix 2 (startup).

  • The tip with estimation on crashes at final-executor warmup with the error above.
  • With this PR it starts, and its outputs are byte-identical to the estimation-off run for the same request seeds (640/640).

Fix 1, accuracy. Agg TEP4 K7, modeling_v2 require, rejection sampling, SPEED-Bench coding 80 prompts, T=1, top_p 0.95, concurrency 1, 9 x 80 paired requests:

config AL tip -> this PR GSM8K (c1) tip -> this PR
max_batch_size 8 3.981 -> 4.105 (+3.1%, 95% CI of the tip deficit [-3.72%, -2.37%]) 93.75 -> 94.31
max_batch_size 1 4.001 -> 4.110 (+2.7%) 93.33 -> 94.66 (paired McNemar z = -2.55 for the tip)
  • With this PR, the full plan is byte-identical to the plan without early_expert_ids: 720/720 AL completions and 1319/1319 GSM8K completions. The tip is 0/720.
  • modeling_v2 matches modeling v1 within -0.3% [-0.70%, +0.17%].

AL vs the InferenceX golden (SPEED-Bench coding, c32, golden K7 = 4.05). With this PR, every K7 agg and disagg config measured gives 4.107-4.128:

  • agg TEP4 B1/B8/B20/B48 and TEP8 B1;
  • disagg 1P1D TEP4->TEP4, TEP4->TEP8, DEP4->TEP4 and TEP4->DEP8.

The tip at max_batch_size 1 gives 4.008, with all 7 passes below golden.

Performance. Same-node A/B with alternating tip / this PR servers, forced acceptance 3.05 (AgentX throughput mode), agg TEP4. Fix 1 adds the previously dropped expert work on single-request steps, about +0.35% per such decode step:

  • max_batch_size 1, concurrency 1: step period +0.36%.
  • max_batch_size 2/3/8/20: within +/-0.16%, i.e. noise.

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths (see test instructions)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

  • Any new dependencies have been scanned for license and vulnerabilities

  • CODEOWNERS updated if ownership changes

  • Documentation updated as needed

  • Update tava architecture diagram if there is a significant design change in PR.

  • The reviewers assigned automatically/manually are appropriate for the PR.

  • Please check this after reviewing the above items as appropriate for this PR.

GitHub Bot Help

To see a list of available CI bot commands, please comment /bot help.

🤖 Generated with Claude Code

zheyuf and others added 2 commits October 30, 2026 15:35
…_v2 pool_direct_route

The early-id publication loop `for half in cutlass.range_constexpr(2)` rebound the
placement flag `half = self.place == PLACE_HALF`, so `_placed_expert` saw the row-half
index instead of the flag. On Vera Rubin TEP4 with half_window_experts (max_batch_size
<= 8), the 8-row (single-request, K=7) CUDA-graph decode steps published verify rows 0-3
with two-window expert ids: an expert the half window moves to the ring successor got an
out-of-window local id, no rank computed it, and finalize dropped its term. Rename the
flag to `place_half`.

GB300 (no pool_into_route / early_expert_ids at TEP4) and TEP8 (PLACE_BALANCE3) never
read the flag on this path and are unaffected. On VR TEP4 B8 at concurrency 1 the fix
raises AL by 3.1% (720 paired requests) and makes the full plan byte-identical to the
plan without early_expert_ids.

Signed-off-by: Zheyu Fu <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ext is bound to a replaced KV cache manager

With KV cache estimation on (TRTLLM_SKIP_KV_CACHE_ESTIMATION=0, what the AgentX plugin
sets for DFlash workers), the final executor's first decode warmup step forked the
context-K/V side chain while the DFlash context was still bound to the probe KV cache
manager's pool. The built-in `_lazy_init_ctx_buffers` then rebinds to the real manager and
the fork raised "the DFlash context arena was rebuilt while a forked side chain was
writing the previous one", killing the server at startup.

`ContextKvFork.plan()` now declines to fork while the unified context is bound to a manager
other than the step's; the built-in rebinds on that step and the fork resumes on the next.
In steady state the condition is false, so the fork is unaffected.

Signed-off-by: Zheyu Fu <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zheyuf

zheyuf commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #81768 [ run ] triggered by Bot. Commit: f318bdb Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #81768 [ run ] completed with state SUCCESS. Commit: f318bdb
/LLM/main/L0_MergeRequest_PR pipeline #67425 completed with status: 'SUCCESS'

CI Report

Link to invocation

@zheyuf
zheyuf merged commit 51daa26 into NVIDIA:feat/musespark-open-agentx Oct 31, 2026
Tabrizian added a commit to Tabrizian/TensorRT-LLM that referenced this pull request Nov 10, 2026
…become dispatch levers

Ports the MuseSpark GB300 decode kernel stack onto feat/musespark-open-agentx and
replaces the environment switches it carried with dispatch levers.

EVERY LEVER IS DEFAULT OFF. This is the port; it changes no behaviour until a lever
is knobbed on. Proved rather than asserted: a verifier rebuilds FAST_PATHS,
DEPENDS_ON and both compositions by AST and resolves them with an EMPTY environment
-- the resolved path sets are identical to the base at all ten deployments (44 paths
at TEP8, 54/53 at TEP4), and each lever is then shown to turn on by its own knob.

WHAT IS IN. 18 of the 25 patches in the source set: staged-router-gemm,
moe-expert-balance (2), decode-g1 (parts 1-5), decode-kernel-stack (3),
kernel-stack-2 (parts 1-5), tep8-decode-stack-v2, and context-fmha-v2.

decode-g1/6 is omitted as 100% redundant -- 51daa26 (NVIDIA#21364) is already in the
base and git apply --reverse of its hunk succeeds. The rest are not kernel changes
(http-keep-alive, context-kv-retire-v2, torch-memory-reserve), already upstream
(serving-stats-off-loop, merged as NVIDIA#21907), not free (context-scheduler-aging buys
x +7.9..9.0% with y -1.0..-1.2%), or inapplicable (router-held-placement: the GB300
e2e point is all-agg, so there is no router to configure).

Substantial redundancy was found and dropped rather than re-landed: NVIDIA#21377 and
NVIDIA#21580 had already built the widened TP8 finalize transport and left it pinned at
TP8_MAX_TOKENS = 16, so that layer collapses to a reader that unpins it.

NOT LANDED, reported rather than approximated. kernel-stack-2/4's three gathers.py
hunks need a TP8 kernel table (TP8_WIDE_KERNELS / WIDE_KERNELS_BY_SM_TP) that
appears in the patches only as context -- it is in no patch and no public commit.
decode-kernel-stack/3's eight EARLY_LOADS hunks have no host class, because NVIDIA#21754
moved SwaBlockMultiAttention out of the sm103 tree.

THREE DEFECTS THIS PORT INTRODUCED, each found by running the code after static
checks passed:

  1. weights._ring_buddy_row_cap called max_rows_for with two arguments against a
     one-argument signature, on the unconditional replicated_experts install path.
     Every TP8 deployment would have raised TypeError at load_weights.
  2. moe_prologue declared _wide_direct: bool as a class attribute, shadowing
     projection_gathers' transport object (default None) through the MRO. Every
     8-row decode step raised AttributeError("'bool' object has no attribute
     'is_armed'") at warmup, inside attention_output_into_hop, which is served by
     default at TP8.
  3. pool_into_route called _wide_router_shard with four arguments against five.
     Latent, behind a default-off lever.

THIRD-PARTY LICENSING. multi_instance_context_kernel.py derives from the CUTLASS
CuTe DSL Blackwell FMHA example (v4.8.0) and declares that derivation with the full
BSD-3-Clause notice in-file, matching 51 existing files in this repository and the
sm107 sibling added in 736cfdc. CUTLASS is already attributed in
ATTRIBUTIONS-Python.md and both per-arch CPP files, so no attribution file changes.

MEASURED. With every lever off the branch is indistinguishable from its base on
GB300 TEP8 decode (11.67 vs 11.93 ms at bs3, 12.26 vs 12.28 at bs4), which is a
correctness result -- the port does not disturb the default path -- and says nothing
about what the levers are worth. Non-bitwise levers still need their acceptance,
drift and step-time gates before any of them ships on by default.

Signed-off-by: Iman Tabrizian <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants