Skip to content

[None][feat] Qwen3.5 GB300 round 2: decode/prefill kernels, KVCM2 remote tier, disagg GEN admission - #21997

Merged
dc3671 merged 9 commits into
NVIDIA:mainfrom
dc3671:user/zhenhuanc/q35-r2-upstream
Nov 16, 2026
Merged

dc3671 merged 9 commits into
NVIDIA:mainfrom
dc3671:user/zhenhuanc/q35-r2-upstream

Conversation

@dc3671

@dc3671 dc3671 commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Round 2 of the Qwen3.5-397B (NVFP4, GB300) optimizations, after round 1 (#20815), in main form. The optimizations were first developed behind 184 environment switches; this PR adds none — each became a default, a value derived from the layout, a Qwen3.5-declared opt-in, an llm_args field (deployment-dependent only), or was dropped when no reference config ran it. Other models keep main's behaviour; the exceptions are listed under "Changes for every model".

Areas: decode MoE engines (NVFP4, and a BF16 engine for Qwen3.5's MTP draft experts: un-finalized logits-routed SwiGLU calls of up to 32 rows without attention DP take one launch instead of bf16_moe_runner) + fused GEMM/all-reduce/norm kernels; GDN prefill/verify kernels; GQA KV-replica decode attention with in-kernel q all-gather; MTP draft path (kept rows, fused sample+accept); stage-KV FP8 context FMHA (h256, precompiled cubins, see below); KV cache manager V2 remote tier over fabric/NIXL; GEN admission by online output-length prediction, pooled GEN dispatch, and ADP home-wait routing.

Gates: Qwen3.5's decode kernels run only on attention-DP layouts or TP groups with MNNVL, so HGX TP layouts (B200 TEP8, Qwen3.6 TP1/TP2) take main's paths; the prefill kernels run only on SM100/SM103.

Scope (owner decision, PR owner and reviewers' thread, 2026-11-13). One PR: output-length prediction (coordinator route /output_length), the aging priority waiting queue, the KVCM2 remote tier, the deferred GEN KV release and pooled GEN dispatch stay in it. Reason for the remote tier and the deferred release: the results below are the parity measurement of this port against the reference configs, and those configs run them (the remote tier at 12 of the 14 points, the deferred release at 4; table below); without them in the same PR the measured points cannot be reproduced from main plus one PR, and the kernels' parity would be measured on configs nobody deploys. Pooled GEN dispatch was off at every point and has not been measured; it is opt-in (generation_servers.router.max_requests_per_server, unset = off) and touches only tensorrt_llm/serve/seat_pool.py, PooledLoadBalancingRouter in serve/router.py, the coordinator's pooled select / expiry in serve/disagg_coordinator.py, the 503 mapping for NoGenerationSeatError, the max_requests_per_server / max_queue_wait_s checks in llmapi/disagg_utils.py and tests/unittest/disaggregated/test_seat_pool.py, so it can be reverted alone.

Its four dependencies (#21785, #21862, #21799, #21863) have all landed on main and main is merged in, so none of their code is in this diff any more.

Results

Multi-turn agentic coding trace replay (up to 256k-token contexts), GB300, 3600 s window per point, each point against the reference run of the same config (round-1 release image plus the round-2 changes before the port; two GB300 clusters, which agree within 0.8 % tok/$ on the reference image). Tolerance (round 1): tok/$ ≥ −1.5 %, P90 tok/s/user ≥ −5 %, P90 TTFT ≤ +8 %. Point names: <CTX instances><CTX layout>_<GEN instances><GEN layout>b<GEN batch cap>_c<concurrency> (_ctxmtp: MTP on CTX; _w1: wave-1 rerun).

Point Head Cluster tok/$ P90 tok/s/user P90 TTFT Verdict
2TEP2_TEP8b64_c112 a1b55a0 jhb +0.10 % +6.94 % −0.92 % pass
3TEP2_TEP8b128_c520_w1 a1b55a0 jhb −0.13 % +0.05 % +7.23 % pass
2TEP2_DEP4b48_c448 a1b55a0 jhb −0.35 % +0.26 % +1.53 % pass
TEP2_2TEP8b2_c96 a1b55a0 jhb −0.55 % −0.10 % −17.3 % pass
TEP2_2TEP8b5_c200 a1b55a0 jhb −0.19 % +1.10 % −4.7 % pass
TEP2_TEP16b1_c32 a1b55a0 jhb −1.46 % −0.66 % −19.4 % pass
3DEP4_2DEP4b52_c1160_ctxmtp a1b55a0 jhb +3.88 % +3.94 % −14.0 % pass
2TEP2_TEP8b64_c192 f561022 jhb +0.22 % +4.57 % −2.27 % pass
2TEP2_TEP8b64_c352 f561022 Lyris +0.56 % +5.20 % −0.84 % pass
2TEP2_TEP8b64_c416 f561022 jhb +2.07 % +5.15 % −8.59 % pass
3TEP2_TEP8b128_c520 f561022 jhb +3.47 % +14.32 % −35.49 % pass
3TEP2_2TEP8b32_c512 f561022 jhb +0.25 % +1.35 % −1.19 % pass
TEP2_TEP8b16_c192 f561022 Lyris +1.15 % +2.80 % −0.4 % pass
2TEP2_3TEP8b8_c384 f561022 jhb −0.18 % +2.04 % +4.28 % pass

[2TEP2_TEP8b64_c352 tok/$ derived from output throughput. a1b55a0 rows: flashinfer 0.7.3 (main's pin); CTX workers run with TRTLLM_DISAGG_ROLE=context, which main #21324 needs for a hybrid MTP context worker started by trtllm-llmapi-launch (see the Qwen3.5 deployment guide). TEP2_TEP16b1_c32's GEN b1 step is +2.7 % vs f561022 with flashinfer 0.7.2 as well; it is run-to-run autotuner variance (reruns, jhb jobs 1808451–1808454).]

Opt-in features per point (from each run's configs; "–" = off). Prediction is always output_length_prediction: {predictor: ridge_gbm} with waiting_queue_policy: priority on GEN and the cap shown as waiting_queue_max_wait_s; it ran where the reference config orders GEN admission by shortest predicted decode first. The remote tier is always the fabric transport (CTX claims, GEN donates); in this head's config shape that is remote_cache_config.transport: {kind: fabric, compact_host_memory: true}. Home-wait is kv_cache_routing_home_wait_rounds on the attention-DP CTX servers.

Point Prediction + priority queue (cap) defer_generation_only_release (GEN) Remote tier Home-wait
2TEP2_TEP8b64_c112 – – fabric –
3TEP2_TEP8b128_c520_w1 – – fabric –
2TEP2_DEP4b48_c448 – – fabric –
TEP2_2TEP8b2_c96 ridge_gbm (120 s) on – –
TEP2_2TEP8b5_c200 ridge_gbm (120 s) on fabric –
TEP2_TEP16b1_c32 ridge_gbm (120 s) on – –
3DEP4_2DEP4b52_c1160_ctxmtp – – fabric 100
2TEP2_TEP8b64_c192 – – fabric –
2TEP2_TEP8b64_c352 ridge_gbm (60 s) – fabric –
2TEP2_TEP8b64_c416 ridge_gbm (120 s) – fabric –
3TEP2_TEP8b128_c520 – – fabric –
3TEP2_2TEP8b32_c512 – – fabric –
TEP2_TEP8b16_c192 ridge_gbm (60 s) – fabric –
2TEP2_3TEP8b8_c384 ridge_gbm (60 s) on fabric –
accuracy TEP8 b4 – on – –
accuracy DEP4 b52 – – fabric 100

Unmeasured end to end: remote_cache_config.transport: nixl (the default), output_length_prediction with the default predictor: ridge, pooled GEN dispatch, and home-wait outside the DEP4-CTX points.

Accuracy at a1b55a0 vs the reference: TEP8 b4 GSM8K 0.9507 / 0.9538 vs 0.9538 / 0.9538, MTP acceptance length on the trace replay −0.10 %; DEP4 b52 0.9530 / 0.9515 vs 0.9538 / 0.9538, AL +0.04 %.

Not re-measured end to end at the head: the round-11 and round-12 review fixes and the main merges after a1b55a0: c93bfda (main e9120c5), 8de9107 (main 9af5da0), 9ed133e (main 8868674), 9cb6a62 (main 0ebb7fd), d7b87c2 (main f8d0b05). Two of them change kernels a reference layout runs:

  • 9ed133e: the gated RMSNorm of every GDN layer takes main's CONTIG / EVEN launch hints on top of this PR's multi-tile rows (layernorm_gated.py); bitwise equal to the earlier head at every reference shape, per call TEP8 b5 GEN 1.53 → 1.56 µs, TP2 CTX 16k-token step 81.6 → 74.4 µs [measured, GB300 job 3695695]. It also takes main's use_cp choice for the chunked GDN scan: a single context sequence of ≤ 4k tokens now runs FlashInfer's non-CP kernel (not bitwise to the earlier head, max abs diff 4.9e-4 on the output; 4k tokens 234.6 → 153.5 µs), 16k-token and multi-sequence steps are bitwise and equal in time [same job].
  • 8de9107: the BF16 decode MoE engine moved onto main's native BF16 TRTLLM-gen MoE; MTP draft-expert calls above 32 rows now run main's BF16 cubins instead of the earlier FlashInfer path.
    d7b87c2 keeps this PR's kept-rows MTP draft path for Qwen3.5 (main [None][perf] Run the draft layer after attention only on drafting rows #22008's row pick is used only by models that declare it).

GEN-only / CTX-only step time, same harness, reference image vs this branch at 91067c5cd5, an earlier head of this PR (median of 2 runs; not re-run since):

Layout Reference (ms) This PR (ms) Delta
TEP8 GEN, batch 5 4.475 4.457 −0.40 %
TEP8 GEN, batch 64 11.628 10.985 −5.53 %
TEP16 GEN, batch 1 2.726 2.672 −2.00 %
DEP4 GEN, batch 52 27.022 25.200 −6.74 %
TP2 CTX, 16k-token step 265.634 259.949 −2.14 %

New configuration (prototype; telemetry/privacy CODEOWNER approval: QiJune, 2026-11-13)

Field Default Purpose
output_length_prediction (disagg server) unset (off) {predictor: ridge} (default) or ridge_gbm (needs scikit-learn): online output-length prediction per conversation sets each GEN request's priority (never reads max_tokens); context-first scheduling only
scheduler_config.waiting_queue_max_wait_s unset with waiting_queue_policy: priority: starvation cap (aged requests go first); cannot be combined with TLLM_GEN_ADMISSION_TTFT_PERCENTILE admission
generation_servers.router.max_requests_per_server / max_queue_wait_s unset (off) pooled GEN dispatch: requests wait at the orchestrator for a free GEN seat
attention_dp_config.kv_cache_routing_home_wait_rounds unset (off) ADP: wait for the rank holding the conversation's KV
kv_cache_config.remote_cache_config unset KVCM2 remote tier: directory (rendezvous); transport: {kind: nixl, ucx_devices, transfer_timeout_s} (default, through BaseTransferAgent) or {kind: fabric, donor_reserve_size, compact_host_memory}; donor: {size} donates host memory; level: {size, pool_ratio, expected: {num_donors, claim_size}, donor_wait_timeout_s} claims it as a level below host
kv_cache_config.defer_generation_only_release false GEN: release finished requests' KV after the next forward is enqueued

Changes for every model

  • NCCL-fallback BF16 residual + RMSNorm + FP8 quantize is one fused kernel (bitwise, pinned by test_nccl_residual_rms_norm_quant_fp8_bitwise).
  • serve/router.py: select retries 2 → 4; coordinator UDS backlog 16384.
  • New op trtllm::fp4_block_scale_moe_decode_runner for calls that carry decode-kernel buffers; fp4_block_scale_moe_runner keeps main's schema.
  • GDN / KDA layers (Qwen3-Next, Qwen3.5, Kimi-Linear) share three changed kernels, each numerically equal to main's: rms_norm_gated_token_major (modules/mamba/layernorm_gated.py; from 65536 rows one program runs four prefetched row tiles, per-row arithmetic unchanged, test_layernorm_gated.py); reset_recurrent_state_rows (modules/mamba/recurrent_state_cache.py; early exit for rows with an initial state, 4096-element blocks); the FlashInfer chunked-GDN adapter (modules/fla/flashinfer_chunk.py; skips the state gather when the state is already packed in the kernel's dtype, and the final-state copy when FlashInfer's own buffer is already in the pool dtype).
  • KV cache manager V2 (every model on V2): resume, resize and _copyPageToTreeBlock roll back on any exception, not only OutOfPagesError (4d9fcbd), releasing the deferred SSM slot, excess scratch slots, held blocks and a failed snapshot slot first. Error-free runs unchanged.
  • Disaggregated serving: new coordinator route POST /output_length, called only when output_length_prediction is set (route snapshot 94ba436). Like the other coordinator routes it has no authentication; disagg-serving.md states the trust assumptions and that the client's conversation ID sets the GEN priority. Non-committed API review committee: approved (QiJune). A server's /server_info also reports its cache_transceiver_config.kv_transfer_timeout_ms, which a pooled generation router uses to bound the seat wait.
  • NVFP4 TRTLLM-gen MoE (every model on that backend): non-decode calls build the runner and call run_moe / run_moe_prerouted as on main (5044af0); the decode-option env read and kernel selection run only on decode calls.
  • Request broadcast (_torch/pyexecutor/request_utils.py, single-round transports such as TorchDist with MPI disabled): with sync_clock (main's auto GEN admission, or waiting_queue_policy: priority with waiting_queue_max_wait_s), rank 0's clock rides the single-round envelope instead of a count probe, so an iteration with new requests takes one broadcast.
  • torch.compile models: the Dynamo recompile limit (16) is applied on the executor worker thread too (it is per-thread; main left the worker at 8).

Known limitations

  • Stage-KV FP8 context FMHA uses 4 precompiled trtllm-gen cubins generated by scripts/trtllm_gen_fmha_stage_kv/ (one-statement reorder of the h256 kernel) until the change lands in trtllm-gen / FlashInfer. They are a local trtllm-gen patch: a trtllm-gen header refresh must regenerate them on GB200 and GB300 (the header-fingerprint test in test_fmha_paged_context_fp8 fails until then; there is no runtime skip of mismatched cubins).
  • KVCM2 remote tier: fail-fast claims trust level.expected.num_donors; a transfer that never quiesces keeps its staging and claims until process exit.
  • Per-row-count CuTe DSL kernels compile on first use; an eager step at a row count no CUDA graph captured compiles once. Under CUDA graph capture the resident / split-K / MoE engine caches raise if not yet filled, while the lru_cache compiles (low_m_mma_gemm, mnnvl_fused_allreduce, gdn_verify_tcgen05) compile during capture.

Test Coverage

New unit tests per area under tests/unittest/_torch/{moe,attention,modules,speculative,models,pyexecutor}, tests/unittest/kv_cache_manager_v2_tests/, tests/unittest/llmapi/test_llm_args.py; bitwise tests against the existing path for every new kernel whose numerics must match; wired into l0_a10, l0_b200, l0_b300, l0_h100, l0_gb300, l0_cpu, l0_dgx_b200 and qa/llm_function_core.txt (test_bf16_mtp_adp2); waives.txt drops the three Qwen3.5 hybrid test_kv_cache_v2_vocab_size waives. GB300 pre-merge (4-GPU block) runs test_gqa_kv_replica.py, test_mnnvl_fused_allreduce_norm.py and test_ll_exchange.py (group sizes 2 and 4); they no longer run again post-merge. That stage runs pre-merge only when a multi-GPU file changes, so jenkins/L0_MergeRequest.groovy getMultiGpuFileChanged now also matches the GQA KV-replica backends, the MNNVL / TP2 all-reduce + norm kernels, remote_donor.py, tests/unittest/_torch/attention/multi_gpu/ and tests/unittest/kv_cache_manager_v2_tests/. The NCCL-fallback fused residual + RMSNorm + FP8 bitwise tests live in tests/unittest/_torch/modules/test_fused_add_rms_norm_quant.py, so the H100, B200 and B300 single-GPU pre-merge stages run them. Disaggregated serving: tests/unittest/disaggregated/test_output_length_predictor.py, test_output_length_service.py, test_seat_pool.py, new cases in test_openai_disagg_service.py and test_coordinator_worker.py, and serve-config schema rows. LLM-API smoke tests: test_priority_wait_cap_admits_an_aged_request_first (1 GPU) and test_llm_attention_dp_home_wait_tp2 (2 GPUs). Remote-tier tests: GB300 (l0_gb300) runs the fabric-transport cases, l0_a10 / l0_b200 (pre-merge) and l0_h100 (post-merge) the NIXL cases, l0_cpu the host-only (cpu_only) cases. l0_cpu also lists tests/unittest/_torch/kv_cache_compression/test_quantization_for_cold_page.py, whose tests are all cpu_only and were deselected everywhere before. Shared GDN/KDA kernels: tests/unittest/_torch/modules/mamba/test_layernorm_gated.py (multi-tile rows) plus the existing GDN / KDA mixer tests. Touched-suite regression ran per round-12 fix area before integration (Lyris jobs 3702538, 3702720, 3702427, 3702522, 3702196, 3703749); the integrated head 6e7703e runs in CI. The earlier full run (jobs 3653088 / 3653255 / 3653288) was at the first main merge and predates review rounds 8-12.

PR Checklist

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

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #85060 [ run ] triggered by Bot. Commit: ab1a633 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #85059 [ run ] completed with state ABORTED. Commit: ab1a633

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #85060 [ run ] completed with state SUCCESS. Commit: ab1a633
/LLM/main/L0_MergeRequest_PR pipeline #70402 completed with status: 'SUCCESS'

CI Report

Link to invocation

@dc3671
dc3671 merged commit c654904 into NVIDIA:main Nov 16, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown

✅ LFS objects already in storage (4 files) — no sync needed.

These LFS-tracked files are already present in this repository's LFS storage:

  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/cubin/FmhaSm100aKernel_QkvE4m3OBfloat16H256PagedKvCausalP64VarSeqQ128Kv128PersistentContextStageKv256E4.cubin.tar.zst
  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/cubin/FmhaSm100aKernel_QkvE4m3OBfloat16H256PagedKvCausalP64VarSeqQ128Kv128StaticContextStageKv256E4.cubin.tar.zst
  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/cubin/FmhaSm103aKernel_QkvE4m3OBfloat16H256PagedKvCausalP64VarSeqQ128Kv128PersistentContextStageKv256E4.cubin.tar.zst
  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/cubin/FmhaSm103aKernel_QkvE4m3OBfloat16H256PagedKvCausalP64VarSeqQ128Kv128StaticContextStageKv256E4.cubin.tar.zst

VALLIS-NERIA added a commit to VALLIS-NERIA/TensorRT-LLM that referenced this pull request Nov 16, 2026
Resolve the conflicts with main's Qwen3.5 GB300 round 2 (NVIDIA#21997) and
adapt its new in-forward split code to this branch's GDN classes:
- modeling_qwen3_next.py: keep main's new imports and class attributes
  and this branch's GDNMambaMetadata declaration.
- decoder graphs.py / metadata.py: keep main's split warmup
  (_plans_inforward_splits, _warm_inforward_split) and resolve the
  metadata class with the KV cache manager; the split plan, its rows and
  bounds are GDNMambaMetadata's and Qwen35HybridCacheManager's.
- gdn_inforward_split.py: InforwardSnapshotSplit comes from
  fla.gdn_metadata.
- Tests: test_gdn_inforward_snapshot.py keeps both sides' imports;
  test_gdn_direct_launch.py builds GDNMambaMetadata;
  test_mamba_cache_manager.py imports model_config's KVCacheLayerSpec
  under its own name, since kv_cache_manager_v2's shadowed it.

Signed-off-by: Xiwen Yu <13230610+VALLIS-NERIA@users.noreply.github.com>
bastianhagedorn added a commit to bastianhagedorn/TensorRT-LLM that referenced this pull request Nov 17, 2026
main (c654904, NVIDIA#21997) restructured the cross-CTA norm sum of
mnnvl_slot_allreduce_norm.py into a two-shot path and the original path;
both spin on the mbarrier that the peers' st.async completes. Both waits
now use _mbar_wait_cluster_acquire (relaxed cluster-scope wait followed by
fence.acquire.sync_restrict::shared::cluster.cluster).

Signed-off-by: Bastian Hagedorn <bhagedorn@nvidia.com>
yihwang-nv added a commit to yihwang-nv/TensorRT-LLM that referenced this pull request Nov 17, 2026
…er-trtllm-gen

The update brings origin/main's Qwen3.5 GB300 round 2 (NVIDIA#21997), which builds new
decode and context features on the FlashInfer trtllm-gen FMHA library this branch
removes. They are carried over to the native trtllm-gen path:

- Attention-DP decode with a minimum KV split per sequence: GqaDecodeFmha plans the
  prepared-query generation for splits x KV heads x batch SMs through the new
  FmhaParams.multi_processor_count, which the native generation uses for kernel
  selection and its multi-CTA scratch size.
- context_fmha_head_dim_per_stage_kv: the native context passes the head dim per
  K/V stage to the trtllm-gen runner when that staged kernel is precompiled.
- context_last_rows_only: in a context-only step with paged context FMHA, the native
  context attends from each request's last row only and zeros the other rows.
- KV-replica: main's q all-gather in the RoPE kernel, gated E4M3 output and new
  exchange channels are kept on the native segmented / fused decode.

FlashInfer-only pieces are dropped: the private decode-op wrapper and its signature
probe, the segment softmax-stats workspace extension and module preloading, and
their tests. The MiniMax-M3 drafter and dense decode keep this branch's native
versions under the relocated modeling_v2 package (NVIDIA#22286); DFlash reads its page
sizes from the native block decode.

Signed-off-by: yihwang-nv <yihwang@nvidia.com>
ziyixiong-nv added a commit to ziyixiong-nv/TensorRT-LLM that referenced this pull request Nov 17, 2026
…C1-only TRTLLM-Gen runs, a CuTe DSL FC2, one-cluster routing and dynamic EP

DeepSeek-V4.1 decode at attention TP spends its MoE time in small TRTLLM-Gen calls whose FC2 cubins
run in rounds and whose routing sits on the critical path. This change builds on the FC1-only
TRTLLM-Gen run and the bit-identical CuTe DSL FC2 (moe_lowm_fc2, decode_moe) of NVIDIA#21997:

- MoEDecodeOptions.cute_fc2_rows lets a model take that CuTe FC2 alone, without the decode tuning
  and engine: un-finalized attention-TP calls of up to that many rows on SM100/SM103, also on the
  runner's routing tables (FC1-only run_moe_routing_tables_fc1 and run_moe_bounded_fc1).
- moe_lowm_fc2 re-applies the +0 of a cubin's zero-filled K tail where it has no tail of its own,
  so it also stands in for the FC2 cubins with 512-column K tiles.
- Routes up to 8 tokens (384 experts, top-6) in one 8-CTA cluster that also lays out TRTLLM-Gen's
  routing tables with one warp and releases the expert GEMM right after its wait.
- Splits each call's used experts home-first over the two EP ranks on batch-1 workers (dynamic EP);
  both ranks hold their MoE-TP shard of all routed experts, and the GEMMs launch with the dynamic
  tables' CTA bound (run_moe_bounded) instead of the worst case. ModelConfig carries the executor's
  max_batch_size for this (filled by the model loader; no LLM API change).
- Serves the router GEMM as K-chunk partials from 12 rows per rank instead of 65 on SM100/SM103
  for a model that opts in; every other caller keeps 65.

Gating: DeepSeek-V4.1 declares MoEDecodeOptions(cute_fc2_rows=16, one_cluster_route=True) and
sets extra_attrs "moe_dynamic_ep" (which also needs attention TP, MoE EP2 with MoE TP >= 4, batch-1
workers, sqrt-softplus routing, TRTLLM-Gen NVFP4 and no EPLB or DWDP, on SM100/SM103) and
"moe_router_partials_small_m". The one-cluster route kernel takes the 384-expert top-6 tables:
bit-identical to the CuTe route kernel's up to the row order in an expert's block. Qwen3.5 and every
other model, DeepSeek-V4 included, keep their kernels and outputs, except that the shared CuTe FC2
now adds a 512-column K tile cubin's +0 tail where the intermediate size is an odd multiple of 256
(an exactly zero output takes the cubin's sign); SM107 is unchanged. The MXFP4 x MXFP8 runner is
unchanged: its CuTe FC2 is left to NVIDIA#22371, which needs it for the DSpark draft's MXFP4 experts.

Numerics: bit-identical, except that dynamic EP changes which rows fall into each rank's BF16
partial (FP32 summation order, like an EPLB placement change): the all-reduced MoE output stays
within 8.7e-3 of the call's largest value of the static split's.

Measured on GB300, DeepSeek-V4.1 decode at TEP8 batch 1 with DSpark (k=5):
- CuTe FC2 with the one-cluster route kernel: decode step 2.803 / 2.777 -> 2.670 ms.
- Dynamic EP: MoE half of a layer -1.44 us (-58 us per step); EP-rank imbalance 2.8 -> 0.7 us.
- Early GEMM release and one-warp tables: -10..-30 us and -11 us per step.
- CTA-bounded GEMMs: FC1 grid 324 -> 162 CTAs at 6 rows; FC2 no longer waits for FC1's end.
Router partials from 12 rows, DEP32 at 48 rows per rank: step 7.06 -> 7.00 ms (-0.9%).

Tests: test_moe_lowm_fc2.py adds the opt-in on the one-cluster route kernel's tables against the
FC2 cubin (eager and CUDA graph replay) and a 768-column shape;
test_one_cluster_route_matches_the_cute_kernel; test_moe_ep_dynamic_matches_static_split (4 GPUs,
dynamic against static split, both route kernels, finalized and un-finalized, CUDA graph replay);
test_megamoe_e2e gains the 48-row shape for the router partials.

Signed-off-by: ziyixiong-nv <219238287+ziyixiong-nv@users.noreply.github.com>
ziyixiong-nv added a commit to ziyixiong-nv/TensorRT-LLM that referenced this pull request Nov 17, 2026
…C1-only TRTLLM-Gen runs, a CuTe DSL FC2, one-cluster routing and dynamic EP

DeepSeek-V4.1 decode at attention TP spends its MoE time in small TRTLLM-Gen calls whose FC2 cubins
run in rounds and whose routing sits on the critical path. This change builds on the FC1-only
TRTLLM-Gen run and the bit-identical CuTe DSL FC2 (moe_lowm_fc2, decode_moe) of NVIDIA#21997:

- MoEDecodeOptions.cute_fc2_rows lets a model take that CuTe FC2 alone, without the decode tuning
  and engine: un-finalized attention-TP calls of up to that many rows on SM100/SM103, also on the
  runner's routing tables (FC1-only run_moe_routing_tables_fc1 and run_moe_bounded_fc1).
- moe_lowm_fc2 re-applies the +0 of a cubin's zero-filled K tail where it has no tail of its own,
  so it also stands in for the FC2 cubins with 512-column K tiles.
- Routes up to 8 tokens (384 experts, top-6) in one 8-CTA cluster that also lays out TRTLLM-Gen's
  routing tables with one warp and releases the expert GEMM right after its wait.
- Splits each call's used experts home-first over the two EP ranks on batch-1 workers (dynamic EP);
  both ranks hold their MoE-TP shard of all routed experts, and the GEMMs launch with the dynamic
  tables' CTA bound (run_moe_bounded) instead of the worst case. ModelConfig carries the executor's
  max_batch_size for this (filled by the model loader; no LLM API change).
- Serves the router GEMM as K-chunk partials from 12 rows per rank instead of 65 on SM100/SM103
  for a model that opts in; every other caller keeps 65.

Gating: DeepSeek-V4.1 declares MoEDecodeOptions(cute_fc2_rows=16, one_cluster_route=True) and
sets extra_attrs "moe_dynamic_ep" (which also needs attention TP, MoE EP2 with MoE TP >= 4, batch-1
workers, sqrt-softplus routing, TRTLLM-Gen NVFP4 and no EPLB or DWDP, on SM100/SM103) and
"moe_router_partials_small_m". The one-cluster route kernel takes the 384-expert top-6 tables:
bit-identical to the CuTe route kernel's up to the row order in an expert's block. Qwen3.5 and every
other model, DeepSeek-V4 included, keep their kernels and outputs, except that the shared CuTe FC2
now adds a 512-column K tile cubin's +0 tail where the intermediate size is an odd multiple of 256
(an exactly zero output takes the cubin's sign); SM107 is unchanged. The MXFP4 x MXFP8 runner is
unchanged: its CuTe FC2 is left to NVIDIA#22371, which needs it for the DSpark draft's MXFP4 experts.

Numerics: bit-identical, except that dynamic EP changes which rows fall into each rank's BF16
partial (FP32 summation order, like an EPLB placement change): the all-reduced MoE output stays
within 8.7e-3 of the call's largest value of the static split's.

Measured on GB300, DeepSeek-V4.1 decode at TEP8 batch 1 with DSpark (k=5):
- CuTe FC2 with the one-cluster route kernel: decode step 2.803 / 2.777 -> 2.670 ms.
- Dynamic EP: MoE half of a layer -1.44 us (-58 us per step); EP-rank imbalance 2.8 -> 0.7 us.
- Early GEMM release and one-warp tables: -10..-30 us and -11 us per step.
- CTA-bounded GEMMs: FC1 grid 324 -> 162 CTAs at 6 rows; FC2 no longer waits for FC1's end.
Router partials from 12 rows, DEP32 at 48 rows per rank: step 7.06 -> 7.00 ms (-0.9%).

Tests: test_moe_lowm_fc2.py adds the opt-in on the one-cluster route kernel's tables against the
FC2 cubin (eager and CUDA graph replay) and a 768-column shape;
test_one_cluster_route_matches_the_cute_kernel; test_moe_ep_dynamic_matches_static_split (4 GPUs,
dynamic against static split, both route kernels, finalized and un-finalized, CUDA graph replay);
test_megamoe_e2e gains the 48-row shape for the router partials.

Signed-off-by: ziyixiong-nv <219238287+ziyixiong-nv@users.noreply.github.com>
ziyixiong-nv added a commit to ziyixiong-nv/TensorRT-LLM that referenced this pull request Nov 17, 2026
…C1-only TRTLLM-Gen runs, a CuTe DSL FC2, one-cluster routing and dynamic EP

DeepSeek-V4.1 decode at attention TP spends its MoE time in small TRTLLM-Gen calls whose FC2 cubins
run in rounds and whose routing sits on the critical path. This change builds on the FC1-only
TRTLLM-Gen run and the bit-identical CuTe DSL FC2 (moe_lowm_fc2, decode_moe) of NVIDIA#21997:

- MoEDecodeOptions.cute_fc2_rows lets a model take that CuTe FC2 alone, without the decode tuning
  and engine: un-finalized attention-TP calls of up to that many rows on SM100/SM103, also on the
  runner's routing tables (FC1-only run_moe_routing_tables_fc1 and run_moe_bounded_fc1).
- moe_lowm_fc2 re-applies the +0 of a cubin's zero-filled K tail where it has no tail of its own,
  so it also stands in for the FC2 cubins with 512-column K tiles.
- Routes up to 8 tokens (384 experts, top-6) in one 8-CTA cluster that also lays out TRTLLM-Gen's
  routing tables with one warp and releases the expert GEMM right after its wait.
- Splits each call's used experts home-first over the two EP ranks on batch-1 workers (dynamic EP);
  both ranks hold their MoE-TP shard of all routed experts, and the GEMMs launch with the dynamic
  tables' CTA bound (run_moe_bounded) instead of the worst case. ModelConfig carries the executor's
  max_batch_size for this (filled by the model loader; no LLM API change).
- Serves the router GEMM as K-chunk partials from 12 rows per rank instead of 65 on SM100/SM103
  for a model that opts in; every other caller keeps 65.

Gating: DeepSeek-V4.1 declares MoEDecodeOptions(cute_fc2_rows=16, one_cluster_route=True) and
sets extra_attrs "moe_dynamic_ep" (which also needs attention TP, MoE EP2 with MoE TP >= 4, batch-1
workers, sqrt-softplus routing, TRTLLM-Gen NVFP4 and no EPLB or DWDP, on SM100/SM103) and
"moe_router_partials_small_m". The one-cluster route kernel takes the 384-expert top-6 tables:
bit-identical to the CuTe route kernel's up to the row order in an expert's block. Qwen3.5 and every
other model, DeepSeek-V4 included, keep their kernels and outputs, except that the shared CuTe FC2
now adds a 512-column K tile cubin's +0 tail where the intermediate size is an odd multiple of 256
(an exactly zero output takes the cubin's sign); SM107 is unchanged. The MXFP4 x MXFP8 runner is
unchanged: its CuTe FC2 is left to NVIDIA#22371, which needs it for the DSpark draft's MXFP4 experts.

Numerics: bit-identical, except that dynamic EP changes which rows fall into each rank's BF16
partial (FP32 summation order, like an EPLB placement change): the all-reduced MoE output stays
within 8.7e-3 of the call's largest value of the static split's.

Measured on GB300, DeepSeek-V4.1 decode at TEP8 batch 1 with DSpark (k=5):
- CuTe FC2 with the one-cluster route kernel: decode step 2.803 / 2.777 -> 2.670 ms.
- Dynamic EP: MoE half of a layer -1.44 us (-58 us per step); EP-rank imbalance 2.8 -> 0.7 us.
- Early GEMM release and one-warp tables: -10..-30 us and -11 us per step.
- CTA-bounded GEMMs: FC1 grid 324 -> 162 CTAs at 6 rows; FC2 no longer waits for FC1's end.
Router partials from 12 rows, DEP32 at 48 rows per rank: step 7.06 -> 7.00 ms (-0.9%).

Tests: test_moe_lowm_fc2.py adds the opt-in on the one-cluster route kernel's tables against the
FC2 cubin (eager and CUDA graph replay) and a 768-column shape;
test_one_cluster_route_matches_the_cute_kernel; test_moe_ep_dynamic_matches_static_split (4 GPUs,
dynamic against static split, both route kernels, finalized and un-finalized, CUDA graph replay);
test_megamoe_e2e gains the 48-row shape for the router partials.

Signed-off-by: ziyixiong-nv <219238287+ziyixiong-nv@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-compatible Accepted LLM API contract change that is backwards-compatible ci: full pre-merge approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.