Repository navigation
[None][feat] Kimi K3: Rubin decode and prefill optimizations (merge back of the K3 side branch) - #21770
[None][feat] Kimi K3: Rubin decode and prefill optimizations (merge back of the K3 side branch)#21770dc3671 wants to merge 10 commits into
Conversation
|
/bot run --disable-fail-fast |
|
PR_Github #83191 [ run ] triggered by Bot. Commit: |
|
PR_Github #83191 [ run ] completed with state
|
4233ee3 to
16f13d6
Compare
…ack of the K3 side branch) Squashed from fork branch user/zhenhuanc/k3-merge-back-history (one commit per feature, each with its evidence); squashed because DCO cannot list > 250 commits. Co-authored-by: Jonas Li <[email protected]> Co-authored-by: Allison Lim <[email protected]> Co-authored-by: Mingyang Hao <[email protected]> Co-authored-by: Xin Guan <[email protected]> Co-authored-by: Zihua Wu <[email protected]> Co-authored-by: Sunny Gai <[email protected]> Co-authored-by: Lizhi Zhou <[email protected]> Co-authored-by: Lanyu Liao <[email protected]> Signed-off-by: Zhenhuan Chen <[email protected]>
16f13d6 to
c118f5c
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #83252 [ run ] triggered by Bot. Commit: |
|
PR_Github #83252 [ run ] completed with state
|
…ok as an override test_inherited_method_overrides_are_annotated requires @OverRide on every method the class redefines from KVCacheManagerV2. Signed-off-by: Zhenhuan Chen <[email protected]>
…loader NVIDIA#20703 renamed _construct_checkpoint_loader; NVIDIA#21434 still imported the old name, so every unittest/_torch/modeling run failed collection on main. Signed-off-by: Zhenhuan Chen <[email protected]>
|
/bot run --disable-fail-fast |
|
PR_Github #83278 [ run ] triggered by Bot. Commit: |
…DL BF16-core rule The SM107 parity test asserted takes_prequantized_input on an o_proj built by from_linear without post_load_weights (low-M range empty), at a weight shape the SM107 low-M GEMM table does not select (default_max_m=0). It now runs post-load, derives the PDL selection from o_proj's range, checks MXFP8 and PDL outputs against the BF16 reference, and forces the low-M side in a second case. Signed-off-by: Zhenhuan Chen <[email protected]>
…'s preprocess_inputs surface Main's DecoderInputPreparer.preprocess_inputs now calls self._kv_lens_corrected_in_preprocess() and reads self.runtime_hooks.spec_offsets_op; bind the former to the stand-in and hand it DEFAULT_RUNTIME_HOOKS. Signed-off-by: Zhenhuan Chen <[email protected]>
…ream on the bare model KimiLinearModel.forward reads self._fp4_mla_metadata_stream unconditionally; the __new__-built model in test_model_marks_the_bank_written_by_the_row_scatter never set it. Signed-off-by: Zhenhuan Chen <[email protected]>
…o occupancy probe _max_active_clusters (low_m_max_for -> _rule_split) runs HardwareInfo, whose cuKernelGetFunction needs a current driver context. A host-only tactic query that comes before the thread's first torch device work has none and raises CUDA_ERROR_INVALID_CONTEXT (55 failures in test_fp8_block_scale_low_m_gemm.py on the baked GB300 image). Retain the current device's primary context and make it current when none is, and probe that device rather than device 0. Signed-off-by: Zhenhuan Chen <[email protected]>
|
/bot run --disable-fail-fast |
|
PR_Github #83281 [ run ] triggered by Bot. Commit: |
|
PR_Github #83278 [ run ] completed with state |
Re-creating the single-rank NCCL group per case crashed Rubin whole-file runs with SIGBUS in the MegaMoE buffer barrier (deep_gemm/mega/__init__.py:70) after ~10 cases; verified Rubin job 1000175. Signed-off-by: Zhenhuan Chen <[email protected]>
…ion op On SM107 the CuteDSL MoE dispatches FC1 to the _rubin act-fusion op, so the interceptor recorded no runner identities there (assert 0 == 4). Signed-off-by: Zhenhuan Chen <[email protected]>
With warmup=0 the nested FC12 op tuned inside the outer op's CUDA-graph capture, where its pre-hook's host-to-GPU routing copy fails, so no outer tactic profiled. Serving warms up twice (AutoTuner default), so it never reaches that path. Signed-off-by: Zhenhuan Chen <[email protected]>
|
PR_Github #83281 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #83334 [ run ] triggered by Bot. Commit: |
|
PR_Github #83334 [ run ] completed with state
|
|
Hi, heads-up: #22286 has merged, so ModelingV2 now lives at Since this PR touches modeling_v2, please rebase it onto the latest main. You can use these migration commands to move any files you added under the old directory and update any remaining references to the old path. |
@coderabbitai summary
Description
Draft: code complete for review. Rubin GEN-only decode matches the side branch on every layout (table below); the ctx-only check on the corrected recipe and the end-to-end Pareto runs are in progress, and the end-to-end table is filled when they finish.
Brings the Kimi K3 Rubin (VR200, SM107) optimizations that are not yet on main and not in another open PR onto main, in main's form: no new environment variables, no model special cases in generic modules. The PR is one squashed commit (the DCO app cannot list more than 250 commits); the per-feature history, one commit per feature with its evidence in the commit message, is on
dc3671:user/zhenhuanc/k3-merge-back-history. Target: main plus the stacked PRs below runs the five K3 Rubin recipes (c24_c42, c75_c174, c240, c383, ULL c1/c2/c4) at the side branch's Pareto (table at the end).Stacked on: #21067, #20535 (included in this PR's diff until they land). #21400 (contains #21399), #20486 and #20664 have landed on main and are no longer part of the diff. One fix to stacked-PR code rides along: DFlash context block table subtracted the layer offset twice (code from #20664 / #20486, not reachable by K3; a15f308).
Not in this PR (temporary layer used only for the end-to-end runs): Mingyang's FP8 context MLA (09f50dd5c7, a3b8a0df59); no PR yet.
Ported from Xin Guan's Rubin branch (Xin kept as author, main's form, no new environment variable): FP4 MLA wave plan / split reduce / CuTe DSL split-KV plan, short-prompt recurrent-state eviction priority, bounded UCX CUDA IPC cache,
pin_executorworker affinity, ULL step-input pack, server role forwarded to MPI workers.What it brings
[f_a | b] -> f_bfront end with in-kernel forget gate, fused projection above 128 rows (helix8), QKVG weights held on chip before the PDL waitenable_min_latency: one-kernel MoE tail and persistent shared expertcontext_kv_only); opt-in FP8 context KV (context_kv_dtype: fp8); Markov chain in one CuTe DSL launch on an MNNVL TP group; per-request split-KV plan; fused block RoPE + latent store (also on a helix-sharded context); FP8 query head in one launch; step glue off the critical path; o_proj / down_proj push into their all-reduce; helix V up-projection, exchange and combine inside the K3 Helix tailmamba_state_config.low_priority_snapshot_prompt_len: recurrent state of short prompts is evicted first but still offloaded to host;pool_ratioresolved per named layer group, logged with per-group slot counts and floor-checked[q_a | kv_a]trtllm-serveforwards the disaggregated server role to MPI workers;TLLM_NUMA_AWARE_WORKER_AFFINITY=pin_executor(new value of an existing variable) pins the executor thread, andenable_min_latencyshortens the GIL switch interval and packs the decode step's input uploads; UCX/NIXL transceivers bound UCX's CUDA IPC cache to 512 regions per peer unless the user sets it; disaggregated GEN skips the idle receive-status collectives under helix CP; K3 prewarm covers the prequantized GEMMs' rows and variants; locality-domain allocation retries after emptying the PyTorch cache; curated recipekimi-k3-helix16-low-latency-gen.yaml(helix16, MoE TP4 x EP4, VR200); conversation routernew_conversation_follow_load_factor(unset keeps main's behaviour)How the side branch's switches map
TRTLLM_K3_*/TRTLLM_*switch of the side branch became a default under a natural condition (rows, SM, helix size, phase, layout), e.g.TRTLLM_K3_HELIX_TAIL_FUSED-> K3 MLA + Helix, attention TP 1, no attention DP, MNNVL all-to-all, batch fits the 16 MiB receive buffer;TRTLLM_K3_MID_AR_PUSH_MAX_M=192-> Rubin(7168, 1536)push limit 192;TRTLLM_K3_ULL_FRONT-> rows <= 32 on an MNNVL-reduced TP group, moe_sort tables, NVFP4 input;TRTLLM_MLA_DECODE_REDUCE_ROWS=4-> four rows per reduction block where there are >= 8 rows per resident decode block;TRTLLM_DISAGG_GEN_FAST_SYNC-> no attention DP and PP 1. Each commit message names the switch it replaces and the condition.MoEImplBase.allow_die_major_weights()(FC12 die-major weights),MLA.fp8_cached_kv_context_opt_in(FP8 Q/K/V on cached-KV context),MnnvlOwnWorkspace(own all-reduce workspace for one call site),inforward_snapshot_end(KDA snapshot points).enable_min_latency(existingTorchLlmArgsfield, used by Llama4) now also gates the two lossy K3 decode kernels (side branchTRTLLM_K3_ULL_TAIL1,TRTLLM_K3_ULL_SHARED_PERSIST); its description, the serve schemas and the curated ULL recipe say so. NewDSparkDecodingConfig.context_kv_onlyandcontext_kv_dtype(golden manifest updated; telemetry owner review needed).TRTLLM_FP4_MLA_PACKED_WAVE_PLAN=1([None][feat] Rubin merge back: MLA, DSpark, DWDP, Helix #21067 made the wave plan opt-in) andTRTLLM_DISAGG_SHARED_DRAFT_KV([None][feat] Rubin merge back: MLA, DSpark, DWDP, Helix #21067 / [None][feat] DSpark Unified KVCache standalone #20664). The dep16 (c383) GEN recipe setsattention_dp_config.enable_kv_balanced_admission: true, main's form of the side branch'sTRTLLM_ADP_KV_BALANCE=1. Every K3 CTX recipe listskv_cache_config.pool_ratioin this PR's layer-group order[SSM, FP4K, FP8, HP](the side branch's list was in pool order[FP8, HP, FP4K, SSM]) and setsmamba_state_config.low_priority_snapshot_prompt_len: 16384; the disaggregated server setscontext_servers.router: {type: conversation, new_conversation_min_match_blocks: 32, new_conversation_follow_load_factor: .inf}.Behaviour deltas from review (vs the side branch)
enable_min_latency: truepool_ratiois indexed per layer group in registration order (draft share inserted); a full-history group at its one-request floor while another gets >= 4x more raisesValueError(a side-branch-order list silently shrank the FP4 MLA K pool to 2 % and cut ctx-only prefix reuse from 96.8 % to 73 %)low_priority_snapshot_prompt_lenenable_min_latency; the small-batch MoE red combine is not bitwise reproducible run to run (identical across ranks); drafter projection roundingq_b/kv_bon every rank (+450 MiB per rank BF16) instead of an all-gather per drafter layerDeclined review findings: one push protocol for all pushed kernels (would change non-K3 kernels or break the C++ two-shot transport); moving
helix_outputinto K3 (adds a copy per layer on GB300 helix8); replacing the drafter buffervars()scan (needs drafter-side buffer registration); a query-producer hook inattention/for the SM107 fused query (base FP4 MLA path leaves the same buffers unfilled).Dropped: drafter low-M GEMM race (side branch
TRTLLM_DSPARK_DRAFT_GEMM) -> +651 s dep16 startup autotune (3958 tactic candidates) and no end-to-end gain at recipe row counts (dep16 drafter rows 80 / 96 > 32, helix8 warmup rows never tuned); may return as its own PR with Rubin data. Side-branch serving changes no recipe enables (tokenizer piece cache, msgspec relay, early first token) are not ported.Test Coverage
tests/unittest/_torch/{attention,modules,moe,multi_gpu,kernels/parallel,speculative,pyexecutor/kv_cache,disaggregated}), GB300 for SM100/103 paths, Rubin for SM107 paths. All pass on the final code: GB300 rounds g1-g17d (last full round 443 passed before review fixes; review-fix ids 21/23 + 2/2 reruns) and Rubin rounds r1-r13 (r1 684 passed; r12/r13 cover the zero-row push,test_small_batch_moe_output_push_without_local_experts[2|4]). ULL fixes: GB300 3612036, 3612038, 3612607, 3615891, 3616716, 3616826, 3621754 green; Rubin r14 13/15 files pass, the two failures (an outdated MXFP8 o_proj assertion, a Bus error in a MEGAMOE_DEEPGEMM case) are being fixed.generate_trtllm_serve_schemas.py --check,generate_llm_args_golden_manifest.py --check,test_trtllm_serve_config_schemas.py -m cpu_only,tests/unittest/api_stability,tests/unittest/usagepass on GB300 (143 / 64 / 439 passed) [measured Lyris job 3598191].pool_ratioorder; the first run used the side-branch order and completed 4.5x fewer requests (prefix reuse 72.9 % vs 96.8 %), with the same per-iteration CTX step time.enable_attention_dpenable_attention_dpBaselines [measured: c24_c42 / c75_c174 Hecate 880986 / 889615, c240 / c383 / ULL dl 2892104 / 2889665 / 2889664, c240 v3x Hecate run bm_c240-e2e-v3d16g5t24n640x, GSM8K Hecate 880984 / 880985].
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-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin 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