Skip to content

[None][perf] Muse Spark Open modeling_v2 TEP target: Vera Rubin low-latency levers and trtllm::fp4_block_scale_moe_prerouted - #21580

Merged
Tabrizian merged 4 commits into
NVIDIA:feat/musespark-open-agentxfrom
Tabrizian:user/itabrizian/musespark-vr-frontier-pr
Nov 5, 2026
Merged

Tabrizian merged 4 commits into
NVIDIA:feat/musespark-open-agentxfrom
Tabrizian:user/itabrizian/musespark-vr-frontier-pr

Conversation

@Tabrizian

@Tabrizian Tabrizian commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

@coderabbitai summary

Description

This PR brings the Vera Rubin (sm107) low-latency fast paths of the Muse Spark Open modeling_v2 TEP target onto the
per-deployment lever resolver of #21377, which it follows. It is 3 commits:

  1. trtllm::fp4_block_scale_moe_prerouted (C++ op + 1-GPU unit test). FP4 block-scale MoE FC1 / FC2 on routing
    tables the caller already built, with the stock op's tile, config and runner choice. The target's expert placement
    kernels write those tables while they balance the replicated experts, so the stock routing kernel is skipped. The
    test checks that every (token, slot) FC2 row is bitwise the stock op's at the target's geometries.
  2. The TEP target's Vera Rubin low-latency levers (inside _experimental/modeling_v2/models/musespark_open/...__tep).
  3. Disaggregated generation: prefetch one request's KV by default. TRTLLM_DISAGG_GEN_PREFETCH_REQUESTS defaults
    to 1 instead of 0; 0 turns it off.

The levers

Every new fast path is a lever in levers.RULES / dispatch.FAST_PATHS with origin LL, served only by the two
sm107 compositions. Nothing new is served on sm103, which resolves as before; the host test pins this.

No new environment variable. Each lever has the usual MUSESPARK_OPEN_LEVER_<NAME>=auto|on|off knob. The switches
they replace are added to levers.RETIRED, so setting one raises an error naming its lever.

Rule.

baseline still selects exactly the previous composition. The new levers are off under it, and so are the nine
TP4 paths that the sm107 TEP8 composition now also serves (they get an upstream rule whose baseline leaves them out
there).

Settings.

  • Kernel modules that used to read a switch now keep a module-level setting with the old default, plus a keyword-only
    configure.
  • lever_settings.apply(plan, sm) calls each configure once, from the model constructor, right after
    dispatch.compose and before any installer. It imports a module only when one of that module's settings differs
    from its default. Off sm107 it does nothing.
group levers
Dense GEMMs splitk_pool_split8, splitk_frontier_tables (TP4); tep8_wide64_splitk, tep8_publish_splitk, tep8_drafter_wide_gemms, tep8_fc_shard_wide (TP8); weight_prefetch_after_join, next_qkv_prefetch_skip, wide_norm_gate_pdl
Attention swa_one_cluster_block, swa_prep_split, swa_eight_requests, full_attention_fold_multi, split_kv_deep_rings
Experts / routing prerouted_experts (on the new op); bf16_half_window (TP4); tep8_ring_buddy_wide, tep8_ring_buddy_pdl, tep8_tile_placement, tep8_router_push, tep8_router_prewait (TP8)
Communication finalize_entry_trigger, hop_entry_trigger; tep8_finalize_transport_64, tep8_early_multicast_hop, tep8_direct_hop, tep8_publish_join, tep8_pool_programmatic_fork, tep8_wide_projection_gathers (TP8)
Step / drafter step_commit_v2; drafter_kv_glue, the context-K/V side chain in two launches over a worker-owned arena (it yields to drafter_kv_side_chain over a dense one); drafter_kv_fork_before_head
Context context_sp_extra_parts (TP4; __PARTS from router_input, ce_gather, shard_routing): on context servers, and on aggregated servers of up to 8 requests

Also:

  • vocab_parallel_head gets a rule. On sm107 it is on up to max_batch_size 8; its fabric buffers take 151 MiB
    per TP4 rank. __MIN_ROWS is 8 on sm107 (one verify block; sm107 serves no lm_head_inbox) and 16 elsewhere. sm103
    is unchanged.
  • Split-K constants on sm107. The split-K kernels always build their conflict-free mailbox, their reduce-scatter
    epilogue for split-K 8, and their deeper stages in oversized shared memory. Each writes the same bits as the build
    it replaces.
  • Certified TP8 split-K producer key. It now carries the md5 of the reformatted device code; that code's AST is
    identical to the certified build's.

Deployment note. At the deployments where these levers are on, some of #21377's own bitwise levers are on as
well (on the aggregated TEP4 server below: the cooperative head fold, incremental block offsets and the
execution-stream step loop). The validation below runs those combinations.

Test Coverage

  • tests/unittest/.../musespark_open/...__tep/test_modeling_v2_levers.py (host only, 245 pass). It covers:
    • every region's table under auto: the low-latency levers are added up to 8 requests, and nothing changes above;
    • the replay knob sets, which turn the new levers off;
    • baseline, still the previous composition on every key;
    • the registry and the retired switches;
    • new tests for the low-latency deployments, the vocabulary-parallel head's rule, the side-chain precedence and the
      context lever.
  • tests/unittest/_torch/modeling_v2/moe/test_modeling_v2_fp4_block_scale_moe_prerouted.py (1 GPU), added to
    l0_gb300_musespark.
  • tests/unittest/_torch/executor/test_disagg_gen_prefetch.py follows the new default.

Validation on Vera Rubin. The evals the tree was validated with before the port: SPEED-Bench acceptance length
(80 rows, concurrency 1, rejection sampling) and GSM8K (1319, 5-shot, greedy), no forced acceptance. Every lever is
at auto; no lever knob is set.

layout new levers on acceptance length GSM8K before the port (AL / GSM8K)
aggregated TEP4, max_batch_size 4 all 18 that TEP4 serves 4.122 0.9780 4.118 / 0.9780
disaggregated: 1 TEP4 context server + 1 TEP8 generation server (max_batch_size 8), __ROLE set on both pending pending 4.108 / 0.9727

The disaggregated run is still to come; until then this stays a draft.

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.

…oE FC1/FC2 on caller-built routing tables

The FP4 block-scale MoE op builds its routing tables (expanded->permuted and permuted->token maps,
per-CTA expert and row limit, CTA and padded-row counts) with its routing kernel before FC1. A
placement kernel that already knows the step's routing can write those tables itself and skip that
kernel; the Muse Spark Open modeling_v2 TEP target does so at TEP4 (the wide half-window
pool_direct_route) and TEP8 (ring_buddy_assign).

- run_fp4_block_scale_moe_prerouted: run_fp4_block_scale_moe_runner's pre-routed-ids path (E2m1,
  do_finalize=false), statement for statement, on the caller's tables instead of the routing
  kernel's. Returns {gemm2_output, topk_weights, expanded_idx_to_permuted_idx}; a slot's row holds
  the stock op's bits for it.
- FP4BlockScaleMoERunner.run_moe_prerouted: run_moe's tile and config choice, its [-1, -1]
  fallback and its fine-grained runner choice, applied to the prerouted call.
  get_default_config and get_valid_configs_for_tile expose the fallback config and every config of
  a pinned tile.
- Free ops trtllm::fp4_block_scale_moe_prerouted / fp4_block_scale_moe_default_config /
  fp4_block_scale_moe_valid_configs_for_tile, through one runner per activation type.
- test_modeling_v2_fp4_block_scale_moe_prerouted.py: every slot's FC2 row bitwise equal to the
  stock op's at the target's geometries (64 local experts at 9..64 rows, 96 at 16..32, top 8),
  through each op's own expanded->permuted table; listed on l0_gb300_musespark.

Signed-off-by: Iman Tabrizian <[email protected]>
…atency levers

The sm107 low-latency fast paths of the TEP target, each a lever of the per-deployment resolver
(levers.RULES, dispatch.FAST_PATHS), served only by the two sm107 compositions. Nothing is served
on sm103, which resolves as before.

Rule: a lever of decode steps is on under auto while max_batch_size is at most 8 (__MAX_BATCH), the
region it was measured in; above that every one of them is off, so the high- and mid-concurrency
selections are unchanged. Numeric levers also need their accuracy gate (sm107 TEP4 / TEP8,
generation or aggregated servers of up to 8 requests); an unhinted disaggregated server passes
none, so set MUSESPARK_OPEN_LEVER__ROLE. baseline still selects exactly the previous composition.

- Dense GEMMs: splitk_pool_split8, splitk_frontier_tables (TP4); tep8_wide64_splitk,
  tep8_publish_splitk, tep8_drafter_wide_gemms, tep8_fc_shard_wide (TP8);
  weight_prefetch_after_join, next_qkv_prefetch_skip, wide_norm_gate_pdl.
- Attention: swa_one_cluster_block, swa_prep_split, swa_eight_requests, full_attention_fold_multi,
  split_kv_deep_rings.
- Experts and routing: prerouted_experts (on trtllm::fp4_block_scale_moe_prerouted);
  bf16_half_window (TP4); tep8_ring_buddy_wide, tep8_ring_buddy_pdl, tep8_tile_placement,
  tep8_router_push, tep8_router_prewait (TP8).
- Communication: finalize_entry_trigger, hop_entry_trigger; tep8_finalize_transport_64,
  tep8_early_multicast_hop, tep8_direct_hop, tep8_publish_join, tep8_pool_programmatic_fork,
  tep8_wide_projection_gathers (TP8).
- Step and drafter: step_commit_v2; drafter_kv_glue (the context-K/V side chain in two launches
  over a worker-owned arena; it yields to drafter_kv_side_chain over a dense one);
  drafter_kv_fork_before_head.
- Context: context_sp_extra_parts (TP4, __PARTS): the router input and the expert all-gather of
  large context steps on the row shard; on context servers, and on aggregated ones up to 8
  requests.
- vocab_parallel_head gets a rule: on sm107 up to max_batch_size 8 (151 MiB of fabric buffers per
  TP4 rank), __MIN_ROWS 8 on sm107 (one verify block) and 16 elsewhere. The sm107 TEP8 composition
  also serves nine TP4 paths; their upstream rule leaves them out of baseline there.

Settings: the kernel modules that read these levers keep module-level settings with the previous
defaults and a keyword-only configure(); lever_settings.apply(plan, sm) calls them once, from the
model constructor right after dispatch.compose and before any installer, and imports a module only
when one of its settings differs from its default. On sm107 the split-K kernels always build their
conflict-free mailbox, their reduce-scatter epilogue for split-K 8 and their deeper stages in
oversized shared memory (each writes the same bits as the build it replaces). The certified TP8
split-K producer key carries the reformatted device code's md5 (its AST is the certified one's).

The target reads no other environment variable: the switches these levers replace are in
levers.RETIRED, so setting one raises naming its lever. The host-only lever test pins every
region's table with the new levers, the baseline composition, the replays (which turn the new
levers off) and the new rules.

Signed-off-by: Iman Tabrizian <[email protected]>
… KV by default

TRTLLM_DISAGG_GEN_PREFETCH_REQUESTS now defaults to 1 (0 turns it off): a disaggregated
generation worker admits one generation-only request beyond max_batch_size, so its KV lands while
the batch decodes (pair it with the gen router's max_inflight_per_server at max_batch_size + 1).
Where prefetch does not apply (no transceiver, attention DP, PP, hybrid or MRoPE pools, KV cache
manager V1, TLLM_DISAGG_GEN_PRIORITIZE_FIRST_TOKEN=1) it resolves to 0 and warns only if the
variable was set. The unit tests follow the new default; a test that builds a disaggregated
engine on KV cache manager V2 and pins its seat count may need
TRTLLM_DISAGG_GEN_PREFETCH_REQUESTS=0.

Signed-off-by: Iman Tabrizian <[email protected]>
… security

bandit's B324 flags splitk_gemm._device_code_md5's hashlib.md5 as a weak hash for security, which
fails the pre-commit workflow. It is a fingerprint of the kernel source that keys the certified TP8
split-K producers, not a security hash: pass usedforsecurity=False, which leaves the digest unchanged.

Signed-off-by: Iman Tabrizian <[email protected]>
@Tabrizian

Copy link
Copy Markdown
Member Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82357 [ run ] triggered by Bot. Commit: 701519a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82357 [ run ] completed with state SUCCESS. Commit: 701519a
/LLM/main/L0_MergeRequest_PR pipeline #67977 completed with status: 'SUCCESS'

CI Report

Link to invocation

@Tabrizian
Tabrizian force-pushed the user/itabrizian/musespark-vr-frontier-pr branch from 701519a to f419e0a Compare November 4, 2026 22:25
@Tabrizian
Tabrizian marked this pull request as ready for review November 5, 2026 18:40
@Tabrizian
Tabrizian merged commit 6627a39 into NVIDIA:feat/musespark-open-agentx Nov 5, 2026
pcastonguay added a commit to pcastonguay/TensorRT-LLM that referenced this pull request Nov 9, 2026
…t-in MUSESPARK_OPEN_SM103_TEP8_F11=1

NVIDIA#21754 split the shared MuseSparkOpen tree: the tip sm_103__tep has no F11
composition, and the tip sm_107__tep is hard-wired to sm107 (capability
asserts, 107a builds, sm107-only tactic tables) and reads its switches through
the lever resolver only. Re-deriving every GB300 table and gate inside
sm_107__tep cannot be validated without GB300 parity runs, so this commit
adds the GB300-validated F11 tree as its own target instead.

- New target muse_spark_open_816b_a42b_nvfp4__sm_103__tep8: the F11 tree on
  sm103 with its GB300 enablement, package path and class name rewritten
  (ModelingV2MuseSparkOpen816bA42bNvfp4Sm103Tep8).
- routing.py: sm103 at TP8 with MUSESPARK_OPEN_SM103_TEP8_F11=1 returns this
  target. Unset (the default), sm103 routes to the tip sm_103__tep exactly as
  before.
- Env names: every switch of the tree (MUSESPARK_OPEN_SM103_TEP8_*,
  MUSESPARK_OPEN_TEP8_*, TRTLLM_MUSESPARK_*, MUSESPARK_OPEN_LEVER_*) is read by
  the same code as in the tree, sm107_defaults.SM103_TEP8_DEFAULTS included.
  No mapping layer.
- The ctx role (TEP4) and every other deployment never route here.
- Tests: the GB300 F11 CPU test and the split-K device test, on the new path.
- Shared-module compatibility vs the tip (checked statically): every name the
  tree imports exists; the few tensorrt_llm imports that differ do so by
  added parameters or removed fields it does not use;
  trtllm::fp4_block_scale_moe_prerouted has the same schema on the tip (NVIDIA#21580).

Signed-off-by: Patrice Castonguay <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
pcastonguay added a commit to pcastonguay/TensorRT-LLM that referenced this pull request Nov 9, 2026
…t-in MUSESPARK_OPEN_SM103_TEP8_F11=1

NVIDIA#21754 split the shared MuseSparkOpen tree: the tip sm_103__tep has no F11
composition, and the tip sm_107__tep is hard-wired to sm107 (capability
asserts, 107a builds, sm107-only tactic tables) and reads its switches through
the lever resolver only. Re-deriving every GB300 table and gate inside
sm_107__tep cannot be validated without GB300 parity runs, so this commit
adds the GB300-validated F11 tree as its own target instead.

- New target muse_spark_open_816b_a42b_nvfp4__sm_103__tep8: the F11 tree on
  sm103 with its GB300 enablement, package path and class name rewritten
  (ModelingV2MuseSparkOpen816bA42bNvfp4Sm103Tep8).
- routing.py: sm103 at TP8 with MUSESPARK_OPEN_SM103_TEP8_F11=1 returns this
  target. Unset (the default), sm103 routes to the tip sm_103__tep exactly as
  before.
- Env names: every switch of the tree (MUSESPARK_OPEN_SM103_TEP8_*,
  MUSESPARK_OPEN_TEP8_*, TRTLLM_MUSESPARK_*, MUSESPARK_OPEN_LEVER_*) is read by
  the same code as in the tree, sm107_defaults.SM103_TEP8_DEFAULTS included.
  No mapping layer.
- The ctx role (TEP4) and every other deployment never route here.
- Tests: the GB300 F11 CPU test and the split-K device test, on the new path.
- Shared-module compatibility vs the tip (checked statically): every name the
  tree imports exists; the few tensorrt_llm imports that differ do so by
  added parameters or removed fields it does not use;
  trtllm::fp4_block_scale_moe_prerouted has the same schema on the tip (NVIDIA#21580).

Signed-off-by: Patrice Castonguay <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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