Repository navigation
Conversation
…next chunk fused_kernel123's K1 warps read their scanned prefix row and the chunk total from sPartialLast after the scan barrier, and the next chunk's partial sums overwrite sPartialLast before any K1 barrier (racecheck: write at fused_k123.py:1268 against reads at :1293 / :1299). A K1 warp that reached its reads late used the next chunk's sums: with one K1 warp stalled 20 us after the scan barrier, every case of test_fused_prefill_beta_sigmoid_matches_unfused_kernel changed (output max |d| up to 7e14). One K1 barrier after the reads orders them; outputs are bit-identical to before. test_fused_prefill_does_not_depend_on_k1_warp_timing runs a copy of the kernel with that stall and requires the unpatched kernel's bits; it fails without the barrier. Signed-off-by: Vasanth Sabavat <[email protected]>
…he round-up scale test_intermediate_is_mxfp8_quantized reads the MXFP8 x MXFP4 runner's FC1 intermediate out through an identity down projection. On sm_100 it now matches the round-up scale, ceil(log2(amax / 448)), bit for bit, and refutes the OCP scale, floor(log2(amax)) - 8, that _SCALE_RECIPE_BY_SM recorded for sm_100. Under the OCP reference 10 of the 18 cells fail on sm_100 (relative RMS ~5.5 ulp against a 4 ulp gate, or max abs ~0.07 against 0.031); under the round-up one all pass at the original tolerances. Record the round-up scale for sm_100, as the test's message prescribes, and update the contract's recipe text and the README. Signed-off-by: Vasanth Sabavat <[email protected]>
Kimi K3's prefill, mixed and wide steps run the built-in model, whose KDA prefill, routing and MLP activation ops had no catalog entry. Add them, each a contract, a wrapper and a GPU test at Kimi K3's shapes: - ssm/ (KDA prefill): causal_conv1d_fwd (the packed q | k | v convolution over the cache manager's conv pool), kda_post_conv (L2 norm and token-major relayout), kda_prefill (the CuTe DSL chunked delta rule over the fp32 V-first state pool, from four 64-token chunks up) and chunk_kda (FLA's chunked KDA, the layer's path below four chunks); - norm/rms_norm_gated_token_major (the KDA output gate norm); - activation/situ_and_mul (Kimi K3's SiTU MLP activation); - moe/kimi_k3_noaux_tc_mxfp8_quant (routing and MXFP8 input quantization of the routed experts in one launch). The pool-writing entries carry a State section. Their tests skip off sm_100; receipts follow. Signed-off-by: Vasanth Sabavat <[email protected]>
…entries Kimi K3's generic path calls seven existing entries at shapes their tests did not cover. Add a Kimi K3 cell to each, skipped off sm_100: thop_attention (MLA context over the bf16 latent pool, page 64, heads 6 / 12 / 24 / 96, the NoPE table), mla_rope_generation, mla_rope_append_paged_kv_assign_q and load_paged_kv_cache_for_mla (bf16, page 64, identity rope), noaux_tc_op (896 experts, top 16), mxfp8_quantize (K 3584) and the MXFP8 x MXFP4 MoE runner (SiTU, top 16, the 224-expert window at 448). Each contract notes the cell; the runner's contract gains act_type 3 (SiTU) and Kimi K3's sizes. Certifying them showed that mxfp8_quantize and noaux_tc_op accept an empty batch but launch an empty grid (invokeMxFP8Quantization's cudaLaunchKernelEx return goes unchecked), so cudaErrorInvalidValue stays pending and the next CUDA launch check in the process raises it: on sm_100 that is why test_input_not_mutated* fails after the zero-row case and passes alone. Both contracts now say so. Signed-off-by: Vasanth Sabavat <[email protected]>
…0 entries Receipts on GB200 (sm_100), from one run of every test file of this PR at its previous commit, on main's own build with this branch's Python: situ_and_mul 6, kimi_k3_noaux_tc_mxfp8_quant 6, rms_norm_gated_token_major 6, causal_conv1d_fwd 7, kda_post_conv 5, kda_prefill 5 and chunk_kda 5 tests passed; of the shared entries, the MXFP8 x MXFP4 MoE runner 19, mla_rope_generation 16, mla_rope_append_paged_kv_assign_q 7 and load_paged_kv_cache_for_mla 11. No test skipped. thop_attention, mxfp8_quantize and noaux_tc_op get no sm_100 key: their Kimi K3 cells pass, but other cells of those files fail on sm_100 for reasons the contracts state (runtime compilation of XQA / trtllm-gen generation kernels; the pending launch error after an empty batch). The new entries' tests and the Kimi K3 cells join l0_b200's pre-merge list, only the cells for those three files. Signed-off-by: Vasanth Sabavat <[email protected]>
trtllm::kda_prefill returned a view of a buffer it reuses: the output was one of the intermediate tensors _get_buffers caches per input shape, so every call with the same shapes wrote the same storage, and a caller's output changed under it at the next such call. The op's fake declares a new tensor (v.new_empty(v.shape)), so nothing orders the readers of one call's output before the next call. Allocate the output on every call, with the varlen path's one chunk of slack past the last token like the cached buffers, and wrap it for K4 there; the cache no longer holds it. Test: a second call with the same shapes and other inputs must leave the first call's output unchanged (varlen, and one padded equal-length row). Signed-off-by: Vasanth Sabavat <[email protected]>
…ensor on every call) The ssm/kda_prefill entry's test pins the op's output as a new tensor on every call, which NVIDIA#19835 makes true. NVIDIA#19826 (this branch's base) and NVIDIA#19835 touch different code in test_kda_prefill_op.py and otherwise disjoint files. Signed-off-by: Vasanth Sabavat <[email protected]>
…every call With NVIDIA#19835 merged, trtllm::kda_prefill returns a new output on every call instead of a view of its cached scratch. test_output_is_runner_scratch becomes test_output_is_a_new_tensor: later calls, with the same shapes or others, share no storage with an earlier output and leave it unchanged. The continuation test drops the copies it needed before. The contract, the wrapper's docstring and the index summary no longer describe the scratch view; the module-level cache of compiled kernels and intermediates stays the entry's A1 gap. Signed-off-by: Vasanth Sabavat <[email protected]>
Kimi K3's MLA decode steps above the fused decode kernels' bounds run the generic path's MLA generation through this entry: latent MQA over the bf16 pool, page 64, one query row per request without speculation and 8 with DSpark (bottom-right causal), at 6 heads per rank (TP16 attention, both Kimi K3 targets) and 96 (one rank). The new cell checks two steps over histories of one exact page and of 31 tokens against the fp32 latent-MQA reference, within the bf16 band, and that the pool is only read. It is listed in l0_b200.yml and skips off SM 10.0. At 24 heads per rank (TP4), the trtllm-gen FMHA kernel selection raises "Internal error numHeadsQ=24, numHeadsPerCta=16, numCtasForAllHeads=1" for these calls; the contract records it. Signed-off-by: Vasanth Sabavat <[email protected]>
The whole test file, both Kimi K3 cells included, passes on sm_100: 49 / 49 on main's build in the release container and 49 / 49 on main built inside CI's image. The contract gains the sm_100 receipt; the sm_103 receipt predates the two Kimi K3 cells and covers the other 47. Signed-off-by: Vasanth Sabavat <[email protected]>
…re's outputs test_cuda_graph_replay captured the op at 1, 8 and 64 tokens in one loop and rebound `outs` inside the next torch.cuda.graph(...), so the previous capture's outputs were freed inside another capture. Under cudaMallocAsync that is a captured free of the earlier graph's memory: "Attempting uncaptured free of a captured allocation", then "invalid argument" at graph.replay(). The loop now frees them at the end of each iteration. Test only: the op is not involved, and with the caching allocator, as in CI, the test passed before and after. Signed-off-by: Vasanth Sabavat <[email protected]>
10 tasks done
1 task done
Collaborator
Author
|
Superseded by the consolidated draft PR: #19990. Source commits and follow-ups are retained; prior reviews remain historical evidence, not approval of the replacement heads. |
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.
Description
Depends on #19826 (Kimi K3 KDA prefill: K1 warps finish reading sPartialLast before the next chunk), whose fix the
ssm/kda_prefillentry runs on. This branch is on its published head; review the last 4 commits.Kimi K3's prefill, its mixed steps and its decode steps above the K3 decode kernels' bounds run the built-in Kimi K3
model. This PR gives the ops of that path's KDA prefill, routed MoE, MLP activation and MLA context catalog entries,
or Kimi K3 cells in the entries they already have, at the TP16 / TP4 per-rank shapes on sm_100:
ssm/(KDA prefill, in the order the layer calls them):causal_conv1d_fwd(the packed q | k | v convolutionover the cache manager's conv pool),
kda_post_conv(L2 norm of q / k and the token-major relayout),kda_prefill(the CuTe DSL chunked delta rule over the fp32 V-first state pool, from four 64-token chunks up)and
chunk_kda(FLA's chunked KDA, which the layer runs below four chunks);norm/rms_norm_gated_token_major(the KDA output's gated norm);activation/situ_and_mul(Kimi K3's SiTU MLP activation);moe/kimi_k3_noaux_tc_mxfp8_quant(routing of 896 experts to 16 and the routed experts' MXFP8 input in onelaunch).
thop_attention(MLA context over the bf16 latent pool, page 64, heads6 / 12 / 24 / 96, the NoPE table),
mla_rope_generation,mla_rope_append_paged_kv_assign_q,load_paged_kv_cache_for_mla(bf16, page 64, identity rope),noaux_tc_op(896 experts, top 16),mxfp8_quantize(K 3584) and the MXFP8 x MXFP4 MoE runner (SiTU, top 16, the 224-expert window at 448).recorded the OCP scale for sm_100, so 10 of its 18 cells failed there. The identity-down-projection probe now
matches round-up bit for bit and refutes OCP, and all cells pass at the original tolerances.
Not covered here: MLA generation through
thop_attention, which the path runs for decode steps above the fusedkernels' bounds. On sm_100 its trtllm-gen generation kernel for Kimi K3's shapes
(
...HQk576HV512HVPerCta128PagedKvDenseP64VarSeqQ8Kv256StaticSwapsAbForGen) currently fails NVRTC compilation, soits Kimi K3 cell follows separately.
kda_prefillandcausal_conv1d_fwdwrite the cache manager's pools. Their contracts have a## Statesection:the pool, the call-order invariant, and a negative control. One finding is written into
kda_prefill's contractand pinned by a test: the returned
ois a view of the runner's scratch for the batch's shape, which the next callwith the same shape key overwrites (the op's fake registration describes a fresh tensor). Kimi K3's layer consumes
oat once.Design choices
## Statesection (the pool, which slots a call writes, call order, a negative control). They need no state object: the pools are the cache manager's, and the op schemas mark them written (Tensor!/mutates_args).sm_100receipts and skip off sm_100. A shared entry keeps its sm_103 receipt for the cells that predate this PR; CI'sl0_b300run re-certifies those, since the Kimi K3 cells skip there. An entry whose other cells fail on sm_100 at main (thop_attention, mxfp8_quantize, noaux_tc_op) gets no sm_100 key; its contract says why. The tests are listed inl0_b200.yml(only the Kimi K3 cells of those three files).UNCERTIFIED_GENERIC_CALLSonce it calls the entries.ssm/. New entries:moe/kimi_k3_noaux_tc_mxfp8_quant,activation/situ_and_mul.Test Coverage
New entries' tests (
tests/unittest/_torch/modeling_v2/{ssm,norm,activation,moe}/), each through the catalogwrapper at Kimi K3's per-rank shapes (TP16 and TP4):
chunk_kda against an fp64 token-by-token reference (
ssm/_kda_reference.py), fresh sequences and continuationsover scattered slots, a chunked continuation against one call plus its negative control, slots other than the
batch's left bit-unchanged, the conv under CUDA-graph replay, and the rejected inputs;
routing also under CUDA-graph replay), the latter bit for bit against
noaux_tc_op+mxfp8_quantize(one bf16ulp on the weights).
Kimi K3 cells in seven shared entries' tests, skipped off sm_100.
On GB200 (sm_100), main's own build plus this branch's Python:
ssm/test_modeling_v2_causal_conv1d_fwd.pyssm/test_modeling_v2_kda_post_conv.pyssm/test_modeling_v2_kda_prefill.pyssm/test_modeling_v2_chunk_kda.pynorm/test_modeling_v2_rms_norm_gated_token_major.pyactivation/test_modeling_v2_situ_and_mul.pymoe/test_modeling_v2_kimi_k3_noaux_tc_mxfp8_quant.pymoe/test_modeling_v2_mxe4m3_mxe2m1_block_scale_moe_runner.pyattention/test_modeling_v2_mla_rope_generation.pyattention/test_modeling_v2_mla_rope_append_paged_kv_assign_q.pyattention/test_modeling_v2_load_paged_kv_cache_for_mla.pyattention/test_modeling_v2_thop_attention.py::test_kimi_k3_mla_context_bf16_page64moe/test_modeling_v2_noaux_tc_op.py::test_kimi_k3_configquantization/test_modeling_v2_mxfp8_quantize.py::test_kimi_k3_routed_hiddenNo test skips on sm_100. The rest of the last three files fails on sm_100 at main without this PR as well (their
contracts say why);
l0_b200.ymllists only their Kimi K3 cells.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. (Catalog entries and tests only.)Any new dependencies have been scanned for license and vulnerabilities (No new dependencies;
chunk_kdawraps flash-linear-attention, already inrequirements-dev.txtand imported by Kimi K3's layer.)CODEOWNERS updated if ownership changes (No ownership change.)
Documentation updated as needed (The contracts are the documentation.)
Update tava architecture diagram if there is a significant design change in PR. (No architecture change.)
The reviewers assigned automatically/manually are appropriate for the PR. (To check once the PR is open.)
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.