[TRTLLM-14093][feat] Eagle3 support for MiniMax-M3 on the MSA backend (consolidated, staging for #16021) - #2
Draft
zheyuf wants to merge 33 commits into
Draft
[TRTLLM-14093][feat] Eagle3 support for MiniMax-M3 on the MSA backend (consolidated, staging for #16021)#2zheyuf wants to merge 33 commits into
zheyuf wants to merge 33 commits into
Conversation
zheyuf
force-pushed
the
zheyu/feat/m3-eagle3-consolidated-main
branch
from
September 4, 2026 00:28
876fdb4 to
6b168cf
Compare
4 tasks
zheyuf
force-pushed
the
zheyu/feat/m3-eagle3-consolidated-main
branch
18 times, most recently
from
September 8, 2026 22:36
1f7ac50 to
08dbbe6
Compare
…reason guard (NVIDIA#18894) Signed-off-by: Wanli-Jiang <35160485+Wanli-Jiang@users.noreply.github.com> Signed-off-by: Wanli Jiang <35160485+Wanli-Jiang@users.noreply.github.com>
… checkpoint (NVIDIA#18823) Signed-off-by: Wanli-Jiang <35160485+Wanli-Jiang@users.noreply.github.com>
…A#18916) Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
Signed-off-by: longcheng-nv <243710427+longcheng-nv@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…st MXFP4 (NVIDIA#18709) Signed-off-by: Xin Guan <294044352+xguannv@users.noreply.github.com>
Signed-off-by: TensorRT LLM <90828364+tensorrt-cicd@users.noreply.github.com>
…itional model path (NVIDIA#18901) Signed-off-by: ADou <ikun3.1415927@gmail.com> Signed-off-by: nv-guomingz <137257613+nv-guomingz@users.noreply.github.com>
…he V2 (NVIDIA#17643) Signed-off-by: BoyueZ <301205962+BoyueZ@users.noreply.github.com> Co-authored-by: BoyueZ <301205962+BoyueZ@users.noreply.github.com>
…checks (NVIDIA#18930) Signed-off-by: Yuxian Qiu <142763828+yuxianq@users.noreply.github.com>
…hin-build reference and unwaive (NVIDIA#18386)
…ise (NVIDIA#18477) Signed-off-by: Zhenhua Wang <zhenhuaw@nvidia.com>
…a dead-end grammar state (NVIDIA#18896) Signed-off-by: ZhaoyangWang <zhaoyangw@nvidia.com>
…`; cache a per-(layer,module) rank… (NVIDIA#18527) Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com> Signed-off-by: Lori Ren <lorir@nvidia.com> Co-authored-by: Lori Ren <lorir@nvidia.com>
…IA#18804) Signed-off-by: Yueh-Ting Chen <yueh.ting.chen@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jiagan Cheng <jiaganc@nvidia.com>
NVIDIA#18557) * Why? Including the live generation batch size in FlashInfer plan keys created a separate eager wrapper and large block-table allocation for every observed batch size, exhausting device memory on long runs. * What? Key decode plans only by their required query width and static attention configuration. CUDA-graph metadata keeps private wrapper caches per captured batch size, while eager execution safely replans shared wrappers for each iteration. Signed-off-by: William Zhang <133824995+2ez4bz@users.noreply.github.com>
…r teardown (NVIDIA#18182) Signed-off-by: qgai <qgai@nvidia.com>
…)` gated on get_sm_version() in (120… (NVIDIA#18678) Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
…A#18958) Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
Signed-off-by: Ivy Zhang <25222398+crazydemo@users.noreply.github.com>
… preprocessing (NVIDIA#18925) Signed-off-by: Yuxian Qiu <142763828+yuxianq@users.noreply.github.com>
…NVIDIA#18752) Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
…re-enable seven cases (NVIDIA#18949) Signed-off-by: Yi Zhang <187001205+yizhang-nv@users.noreply.github.com>
Signed-off-by: Robin Kobus <19427718+Funatiq@users.noreply.github.com>
…ework (NVIDIA#17069) Signed-off-by: Tyler Burt <195370667+tburt-nv@users.noreply.github.com>
…Cache families (NVIDIA#18784) Signed-off-by: Lori Ren <lorir@nvidia.com>
Signed-off-by: Guiju Zhang <7135567+cascade812@users.noreply.github.com>
…x-M3 on the MSA backend Add one-model Eagle3 support to the MiniMax-M3 MSA sparse attention path: spec-metadata capture hooks in the decoder layers, SpecDecOneEngineForCausalLM as the model base, multi-token (1 + draft_len) decode/verify in the MSA metadata (per-token cache slots, valid-block counts and plan rows, proxy scratch sized by the worst-case decode token count), and a sync-free on_update_kv_lens that re-derives slots, counts and the plans' length mirrors on device after the overlap scheduler corrects kv_lens, clamped to the staged lengths (which also covers the draft loop advancing kv_lens_cuda between CUDA-graph warmup runs). The staging and the patch only run when speculative decoding is active, so non-speculative steps are unchanged. The dense SDPA reference path gains the causal-ladder verify mask. Signed-off-by: Zheyu Fu <zheyuf@nvidia.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…the target manager MiniMax-M3 keeps its one-model Eagle3 draft layer in the target KV cache manager (unified draft KV cache) in every supported configuration. The base manager appends the draft layer after the target's; the M3 manager derives that layout from the same speculative config and layer mask the base uses. The draft layer runs the generic TRTLLM attention op, which addresses K/V through pool pointers, index scales and block offsets and assumes a uniform per-layer stride within a pool. KVCacheManagerV2 groups sub-pages by size alone, and at M3's production geometry the per-sparse-layer index-K page is the same size as a K or V page, so K, V and index-K coalesce into one pool whose slot is non-uniform (three sub-pages per sparse layer, two per dense or draft layer). M3's own kernels address their layers through per-layer views and never notice; the draft layer would be addressed wrongly. The M3 manager therefore presents each shared draft layer to the attention op as its own virtual pool rooted at the layer's K page, with the slot's sub-page count as the index scale and V one page after K, the same pattern DeepseekV4CacheManager and the SWA scratch-reuse path use. The draft loop then runs on the shared manager exactly like every other unified-KV model: no draft-side manager, no metadata swap, no change to the speculative-decoding code. trtllm-gen accepts the manager's P128 draft shapes through an opt-in it consults only once its allowlist has rejected the page size. Adds the GQA Eagle3 head accuracy test with aggregated and disaggregated (NIXL) arms plus a chat-GSM8K acceptance probe, and unit tests for the virtual pool tables, the block-offset copy and the layout derivation. Signed-off-by: Zheyu Fu <zheyuf@nvidia.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…port - Mirror the fmha_sm100 plan's seqused_k in the CUDA-graph-stable plan buffers; the planner allocates it per step and the kernel reads it at launch, so the captured address must not move. - Force the shared draft KV cache only for MiniMax-M3 one-model Eagle3, and reject the triton reference backend with CUDA graphs: its multi-token verify goes through the prefill builder, which cannot be captured. Drop the unreachable multi-token dense decode branch and the decode_qo_len field. - Reject NVFP4 pool pointers in the virtual attention-op pool builder instead of writing a null block-scale pointer. - Size the MSA proxy scratch from the KV cache manager's draft length, so runs without speculative decoding size by max_num_sequences. - Document why per-token seqused_k mirrors the planner (0 for an empty row) while the valid-block count is clamped to 1. - Drop the pinned cuda_graph/use_msa axes of test_nvfp4_eagle3 and list the disagg/overlap combinations explicitly; update the test lists. Signed-off-by: Zheyu Fu <zheyuf@nvidia.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
zheyuf
force-pushed
the
zheyu/feat/m3-eagle3-consolidated-main
branch
from
September 9, 2026 21:33
4e7ac75 to
9f73051
Compare
Parametrize disagg and overlap_scheduler independently instead of listing combinations; the disaggregated arm no longer skips any of them. Test list ids follow the new axis order. Signed-off-by: Zheyu Fu <zheyuf@nvidia.com>
…mp decode valid blocks Review follow-ups on the consolidated MiniMax-M3 Eagle3 PR: - Remove the disaggregated arm of test_nvfp4_eagle3 (disagg does not take new end-to-end accuracy tests); test_disaggregated_serving.py is back to main. The grid is now overlap_scheduler x attention_dp. - CI runs one combination (attention_dp=False, overlap_scheduler=True, the production shape) and inherits the stage timeout; the explicit TIMEOUT (180) annotations are gone from both lists. - Clamp the decode-path valid-block counts to at least one block, matching the eager path and on_update_kv_lens. Signed-off-by: Zheyu Fu <zheyuf@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
One-model Eagle3 speculative decoding for MiniMax-M3 on the MSA sparse-attention backend, with CUDA graphs, the overlap scheduler, aggregated and disaggregated serving. This consolidates the Eagle3 work validated on the
feat/m3_with_msaside branch — NVIDIA#16021 (this PR's original content), NVIDIA#17341, NVIDIA#17457, NVIDIA#17656 and NVIDIA#18066 — into the design those follow-ups converged on, rebased on currentmain.What this enables
SpecDecOneEngineForCausalLMas the model base, multi-token (1 + draft_len) decode/verify in the MSA metadata: per-token cache slots, valid-block counts and plan rows, proxy scratch sized by the worst-case decode token count.on_update_kv_lensre-derives cache slots, valid-block counts and the fmha_sm100 plans' per-row length mirrors on device after the scheduler correctskv_lens, clamped to the staged lengths: sync-free, capture-safe, idempotent. The clamp also covers the draft loop advancingkv_lens_cudabetween CUDA-graph warmup runs. The staging and the patch only run when speculative decoding is active, so non-speculative MiniMax-M3 steps are unchanged.DeepseekV4CacheManagerand the SWA scratch-reuse path use. The draft loop runs on the shared manager like every other unified-KV model: no draft-side manager, no metadata swap, no change to the speculative-decoding code. trtllm-gen accepts the P128 draft shapes via an opt-in consulted only after its allowlist rejects the page size.Differences from the side-branch commits
supports_shared_draft_layers=False,draft_manager_tokens_per_block=32, the draft-manager V2 promotion helper, the dummy-request draft-manager pass-through) is not carried: [None][perf] wrap up eagle changes in m3 side branch NVIDIA/TensorRT-LLM#18066 retired it, andmainalready promotes draft managers via_validate_or_fallback_kv_cache_manager_v2.speculative/utils.pyandSpecWorkerBaseare not needed.eagle_hidden_states_copy, multi-stream DAG edge) is not ported: it was shown to be inert on the piecewise context path._msa_page_size,msa_qo_lens_devand the live batch/token counters are gone (the metadata'stokens_per_block,seq_lens_cuda,num_seqs/num_tokensare used); mixed steps no longer rebuild with a D2H copy.flashinfer_trtllm_gen.py, consulted only after the allowlist rejects the page size) and the one-line MiniMax-M3 policy inpy_executor_creator.py.speculative/,kv_cache_manager_v2.py,_util.py,eagle3.pyand the other executor files are untouched; for every model other than MiniMax-M3 the two touched paths return exactly whatmainreturns today.mainroutes the draft layer's BF16 context (small batches everywhere, all batches on SM103) to the C++ attention op; on a wheel built for SM100 only that op finds no SM103 kernel and falls back to unfused MHA, whose O(seq_len^2) workspace OOMs on MiniMax-M3 (see [None][fix] build SM103 cubins in the local perf harness wheel NVIDIA/TensorRT-LLM#18831 for the SM103-cubin gap in local wheels).MiniMaxM3KVCacheManagerV2: once V2 can keep a buffer role in its own pool, the K/V pool is uniform again and the virtual pools plus the P128 opt-in can be deleted.Test Coverage
TestMiniMaxM3::test_nvfp4_eagle3(GQA Eagle3 head, MMLU + GSM8K + chat-GSM8K acceptance probe), aggregated arms with/without attention DP and a disaggregated (context TP2 -> generation TP2, NIXL) arm; scheduled inl0_dgx_b200and the QA list.on_update_kv_lensslot/count/plan-mirror re-derivation (incl. mixed plans, the staged-length clamp and the speculative-decoding gate), the virtual attention-op pool tables and the block-offset copy into them, shared-draft layout derivation.Validation on
main(this branch, GB300 TP4/EP4, MSA, FP8 KV, CUDA graphs, overlap scheduler)tests/unittest/_torch/attention/sparse/test_minimax_m3_*.py).draft_len=3, GQA head, 200 chat-GSM8K prompts, greedy: acceptance rate 0.832, mean acceptance length 3.50 (test floors 0.80 / 3.4; drafter card 0.839 / 3.518). GSM8K exact match 0.860 with Eagle3 vs 0.850 for the plain target on the same prompts.Validation (side branch, same design)
4xB200, TP4/EP4, Eagle3
draft_len=3, GQA head: chat-GSM8K acceptance 0.832-0.835 / mean acceptance length 3.50 aggregated (ADP off/on), 0.827-0.828 / 3.48 disaggregated (NVIDIA#18066). Reference: 0.839 / 3.518 on vLLM (Inferact/MiniMax-M3-EAGLE3 card).PR Checklist
[JIRA/NVBUG/None][type]format/bot run)