Skip to content
Closed
Show file tree
Hide file tree
Changes from 119 commits
Commits
Show all changes
193 commits
Select commit Hold shift + click to select a range
1c1d49d
[None][perf] Cut host work between speculative decoding steps
vsabavat Oct 1, 2026
f6cb23b
[None][feat] KDA verify: optional per-token states in the V2 hybrid c…
vsabavat Oct 1, 2026
b44c537
[None][fix] spec_step_copies: store zeros past a row's accepted tokens
vsabavat Oct 2, 2026
92d67f3
[None][test] spec_step_copies tests: side stream waits for the curren…
vsabavat Oct 2, 2026
f3cf23f
[None][fix] KV cache manager V2: keep the SSM pool at its live floor …
vsabavat Oct 2, 2026
67d93e9
[None][fix] multi_stream_utils: record the calling stream on fn1's ou…
vsabavat Oct 2, 2026
5e16d82
[None][fix] MNNVL all-reduce: keep a grown workspace's predecessor al…
vsabavat Oct 2, 2026
f0ff9a8
MNNVL all-reduce: run the workspace-growth graph test in the GB200 mu…
vsabavat Oct 2, 2026
551ca16
[None][chore] MNNVL all-reduce test: yapf the workspace-growth test
vsabavat Oct 2, 2026
df9d9bf
[None][test] MNNVL all-reduce: one-rank test of the workspace's captu…
vsabavat Oct 2, 2026
fd1bddc
MNNVL all-reduce: count Lamport arrivals per CTA in the RMSNorm-fused…
vsabavat Oct 2, 2026
7a7ccf3
MNNVL all-reduce: start every CTA of the cluster before the RMSNorm c…
vsabavat Oct 2, 2026
f467211
[None][fix] Kimi K3 attn_res_fwd online kernel: order the ws_stats re…
vsabavat Oct 2, 2026
26cb3c3
[None][fix] Kimi K3 attn_res: cross-proxy fence before a consumer rel…
vsabavat Oct 2, 2026
05e9e4f
[None][test] Kimi K3 attn_res: check the cross-proxy fence before eac…
vsabavat Oct 2, 2026
c5a4eaa
Kimi K3 KDA prefill: K1 warps finish reading sPartialLast before the …
vsabavat Oct 2, 2026
af3e384
[None][fix] kdaDecode legacy: __syncwarp before the lane-0 block-redu…
vsabavat Oct 2, 2026
1e0dceb
DFlash: start the dummy slot at context length 0 every step
vsabavat Oct 2, 2026
ee0dc11
Merge #19830's head af3e384175 (kdaDecode legacy: __syncwarp before t…
vsabavat Oct 3, 2026
5db6a14
[None][feat] Kimi K3 decode: KDA and MLA CuTe DSL kernels with their …
vsabavat Oct 3, 2026
b45a946
[None][feat] Kimi K3 MLA attention: a caller-owned workspace
vsabavat Oct 3, 2026
f51e780
[None][feat] modeling_v2 catalog: Kimi K3's stateful KDA and MLA deco…
vsabavat Oct 3, 2026
373b10b
[None][chore] Kimi K3 KDA / MLA decode: format with main's hooks
vsabavat Oct 3, 2026
ce2b3c3
[None][fix] modeling_v2 ssm/kda_decode: the op supports only the prod…
vsabavat Oct 3, 2026
95fbc35
[None][test] modeling_v2 K3 KDA / MLA entries: sm_100 only, measured …
vsabavat Oct 3, 2026
8ce0792
[None][test] Kimi K3 KDA / MLA decode: sm_100 receipts and l0_b200 en…
vsabavat Oct 3, 2026
0ca3a9f
[None][feat] Kimi K3 decode kernels (CuTe DSL): CTM GEMVs, decode GEM…
vsabavat Oct 3, 2026
a6828d2
[None][perf] Kimi K3 attn_res decode RMSNorm: release the next kernel…
vsabavat Oct 3, 2026
b6a8fb5
[None][feat] Kimi K3 head GEMV: a caller-owned workspace
vsabavat Oct 3, 2026
11cefbd
[None][feat] modeling_v2 catalog: the Kimi K3 single-GPU decode entries
vsabavat Oct 3, 2026
c69ed9c
[None][chore] Kimi K3 decode kernels: format with the repo's pre-comm…
vsabavat Oct 3, 2026
2700b9d
[None][test] Kimi K3 MLA op tests: drop the batch-1 identity cases
vsabavat Oct 3, 2026
9bc4dae
[None][test] modeling_v2 attn_res entries: replay once before poisoni…
vsabavat Oct 3, 2026
b280442
[None][test] modeling_v2 Kimi K3 decode entries: sm_100 receipts
vsabavat Oct 3, 2026
b4fddc8
[None][fix] modeling_v2 MoE runner test: sm_100's FC1 epilogue uses t…
vsabavat Oct 3, 2026
3ed9de7
[None][feat] modeling_v2 catalog: Kimi K3's generic-path entries
vsabavat Oct 3, 2026
8fa0e05
[None][test] modeling_v2 catalog: Kimi K3 sm_100 cells on the shared …
vsabavat Oct 3, 2026
adb6618
[https://nvbugs/6852473][fix] Skip zero-row launches in fp4_quantize,…
vsabavat Oct 3, 2026
41702cb
[None][test] Kimi K3 generic-path catalog: sm_100 receipts and l0_b20…
vsabavat Oct 3, 2026
5e23844
[None][fix] kda_prefill: return a new output tensor on every call
vsabavat Oct 3, 2026
936f38f
[None][fix] Kimi Linear / Kimi K3: make fla-core a runtime dependency
vsabavat Oct 3, 2026
516bb11
Merge #19835's head 5e238440d7 (kda_prefill: return a new output tens…
vsabavat Oct 3, 2026
35b4d73
[None][test] modeling_v2 ssm/kda_prefill: pin a new output tensor on …
vsabavat Oct 3, 2026
06e5078
[None][doc] modeling_v2 catalog: state the 6 sm_100 receipts
vsabavat Oct 3, 2026
0102a35
[None][fix] MNNVL all-reduce: keep a replaced workspace only if a cap…
vsabavat Oct 3, 2026
b122103
[None][fix] Kimi K3 k3_kda_attn: refuse a device with fewer than 128 SMs
vsabavat Oct 3, 2026
49a9715
[None][test] Kimi K3 MLA decode view test: list it in l0_cpu, not l0_…
vsabavat Oct 3, 2026
0ad2406
[None][test] modeling_v2 kda_decode entry test: drop the import-time …
vsabavat Oct 3, 2026
ba20fa1
[None][fix] DSpark GQA drafter: keep the checkpoint's trained mask-to…
vsabavat Oct 3, 2026
e30477f
[None][fix] KV cache manager V2: take the per-token KDA states out of…
vsabavat Oct 3, 2026
86eac6c
[None][test] modeling_v2 thop_attention: Kimi K3 MLA generation cell
vsabavat Oct 3, 2026
73692a6
[None][test] modeling_v2 thop_attention: sm_100 receipt
vsabavat Oct 3, 2026
ea84b23
[None][perf] Mamba state metadata: skip unchanged per-step uploads
vsabavat Oct 3, 2026
546e567
[None][perf] DFlash: skip unchanged slot-buffer copies on decode steps
vsabavat Oct 3, 2026
a9938c2
[None][fix] KV cache manager V2: count the live-floor KDA token-state…
vsabavat Oct 4, 2026
54b87a2
[None][fix] KV cache manager V2: refuse per-token KDA states off the …
vsabavat Oct 4, 2026
c954d6a
[None][test] Kimi K3 noaux_tc MXFP8 quant graph test: free each captu…
vsabavat Oct 4, 2026
1e6eb67
[None][fix] KV cache manager V2: keep a suspended request's KDA repla…
vsabavat Oct 4, 2026
10fd5cf
[None][fix] KV cache manager V2: refuse a KV pool rebalance with the …
vsabavat Oct 4, 2026
50ac9d6
[None][fix] kda_prefill: release evicted scratch with its cache entry
vsabavat Oct 4, 2026
a0509b3
[None][fix] LoRA overlap: leave the output record to maybe_execute_in…
vsabavat Oct 6, 2026
77a450e
[None][doc] multi_stream_utils: note the compiled path and the error'…
vsabavat Oct 6, 2026
c3ced8d
[None][test] test_multi_stream_utils: bound the capture's block count
vsabavat Oct 6, 2026
f39f875
[None][perf] Kimi K3 attn_res_fwd online kernel: double-buffer ws_sta…
vsabavat Oct 6, 2026
b2a6af4
Kimi K3 KDA prefill: K1 warps finish reading sPartialLast before the …
vsabavat Oct 2, 2026
2e598e1
[None][feat] One-model speculative decoding: the worker produces the …
vsabavat Oct 1, 2026
b12bfad
DFlash: empty the dummy slot in the drafting step, not in prepare()
vsabavat Oct 6, 2026
ce1ae63
[None][feat] KDA: commit pending accepted drafts into the live pools
vsabavat Oct 6, 2026
f9d32b4
[None][fix] KV cache manager V2: commit a suspended request's KDA rep…
vsabavat Oct 6, 2026
93c0b28
MNNVL all-reduce: remove LamportFlags' unused cluster-arrival mode
vsabavat Oct 7, 2026
0c9ab14
Merge main 70193ec43b into k3-up/u1-engine-host-gap
vsabavat Oct 7, 2026
eda9db2
[None][fix] DSpark GQA drafter: check the kept mask row at load and c…
vsabavat Oct 7, 2026
a0fa306
[None][fix] Mamba2 metadata: upload CPU-tensor state indices through …
vsabavat Oct 7, 2026
fd37763
[None][test] copy_to_device_if_changed: check skipped copies in debug…
vsabavat Oct 7, 2026
bea6002
[None][perf] spec_step_copies: run on the SM 100 family (SM 100, 103,…
vsabavat Oct 7, 2026
0e29964
[None][perf] spec_step_copies: drop the staged host-to-device copies,…
vsabavat Oct 7, 2026
0cbb559
[None][fix] DSpark GQA drafter: keep no mask row for DFlash's default…
vsabavat Oct 7, 2026
b83f960
[None][fix] DSpark GQA drafter: keep the trained row of the worker's …
vsabavat Oct 7, 2026
2c331d5
[None][fix] Kimi K3 KDA verify: kda_state_tok holds the drafts' records
vsabavat Oct 7, 2026
c95eac1
[None][fix] KDA suspend: read the drafts' records as [slots, 3, num_s…
vsabavat Oct 7, 2026
dc903ae
[None][fix] KDA verify: size kda_state_tok for the drafts' records
vsabavat Oct 7, 2026
c05a0c3
[None][fix] KDA verify: drop the replay caches the drafts' records re…
vsabavat Oct 7, 2026
44a06db
Merge main a1f562a696 into k3-up/u1-engine-host-gap
vsabavat Oct 7, 2026
003f8d0
[None][fix] KDA suspend: commit and relocate without the replay caches
vsabavat Oct 7, 2026
de2f7e1
[None][fix] KV cache manager V2: count every live-floor SSM slot in t…
vsabavat Oct 7, 2026
fd476e7
Merge main 4a36c5b2fb into k3-up/u4-g3-stateful
vsabavat Oct 7, 2026
547f6bf
Merge #19831 (P1) at c3ced8d8c1 into the main fixes branch
vsabavat Oct 8, 2026
70bb2a3
Merge #19828 (P2) at 0102a35eea into the main fixes branch
vsabavat Oct 8, 2026
0778b55
Merge #19836 (P3) at 93c0b28bbd into the main fixes branch
vsabavat Oct 8, 2026
adce84a
Merge #19829 (P4) at f39f875fa8 into the main fixes branch
vsabavat Oct 8, 2026
cb4a371
Merge #19826 (P5) at b2a6af4680 into the main fixes branch
vsabavat Oct 8, 2026
2cc72d5
Merge #19827 (P7) at b12bfad22c into the main fixes branch
vsabavat Oct 8, 2026
21462e1
Merge #19840 (P8) at adb66182fa into the main fixes branch
vsabavat Oct 8, 2026
ddff9e8
Merge #19835 (P9) at 5e238440d7 into the main fixes branch
vsabavat Oct 8, 2026
ca4918f
Merge #19837 (P10) at 936f38fbe7 into the main fixes branch
vsabavat Oct 8, 2026
67a3ad5
Merge #19842 (P11) at b83f960a1d into the main fixes branch
vsabavat Oct 8, 2026
989766a
Merge #19846 (P12a) at f9d32b4c4d into the main fixes branch
vsabavat Oct 8, 2026
347d22f
Merge #19854 (P13) at 50ac9d64e4 into the main fixes branch
vsabavat Oct 8, 2026
dc76338
Merge #19816 (U1) at 44a06db574 into the runtime branch
vsabavat Oct 8, 2026
8002879
Merge #19814 (U3) at 2e598e10cb into the runtime branch
vsabavat Oct 8, 2026
a0712cb
Merge #19846 (P12) at 003f8d088d into the runtime branch: its two com…
vsabavat Oct 8, 2026
fa41a16
Merge #19817 (U2) at de2f7e12ef into the runtime branch
vsabavat Oct 8, 2026
bbd3d04
Merge #19833 (G2) at b28044256d into the specialized kernels branch
vsabavat Oct 8, 2026
d67d88e
Merge #19832 (G3) at fd476e7662 into the specialized kernels branch
vsabavat Oct 8, 2026
b803497
Merge #19834 (G5) at c954d6ad6f into the specialized kernels branch
vsabavat Oct 8, 2026
84dfe86
Merge k3-cons/b-runtime (format fix) into k3-cons/c-kernels
vsabavat Oct 8, 2026
0d83ef5
Runtime branch: the blank line ruff-format wants between two merged t…
vsabavat Oct 8, 2026
e4b9968
modeling_v2 catalog: count G5's sm_100 receipts in the receipt status
vsabavat Oct 8, 2026
35433fb
[None][fix] thop_attention catalog test: do not probe a context lengt…
vsabavat Oct 8, 2026
eedff8c
Merge k3-cons/a-main-fixes (thop_attention test fix) into k3-cons/b-r…
vsabavat Oct 8, 2026
c9d0cd4
Merge k3-cons/b-runtime (thop_attention test fix) into k3-cons/c-kernels
vsabavat Oct 8, 2026
bcef591
Merge main f891b3d9ba into k3-cons/a-main-fixes
vsabavat Oct 8, 2026
338f9d0
Merge k3-cons/a-main-fixes (main f891b3d9ba) into k3-cons/b-runtime
vsabavat Oct 8, 2026
73a9e90
Merge k3-cons/b-runtime (main f891b3d9ba) into k3-cons/c-kernels
vsabavat Oct 8, 2026
c53ffc8
Merge main 3beeef3a5f into k3-cons/b-runtime
vsabavat Oct 8, 2026
3ac75a7
Merge k3-cons/b-runtime (main 3beeef3a5f) into k3-cons/c-kernels
vsabavat Oct 8, 2026
bdadd40
[None][test] List the MNNVL capture-guard test in l0_dgx_b200.yml
vsabavat Oct 9, 2026
305118f
Merge k3-cons/a-main-fixes (l0_dgx_b200 move) into k3-cons/b-runtime
vsabavat Oct 9, 2026
b395762
Merge k3-cons/b-runtime (l0_dgx_b200 move) into k3-cons/c-kernels
vsabavat Oct 9, 2026
cd21be6
[None][fix] Enable the spec step-copy kernels on SM 100 only
vsabavat Oct 9, 2026
54ff61f
[None][fix] Make the attn_res decode kernels' early PDL trigger opt-in
vsabavat Oct 9, 2026
97f7072
[None][fix] Reject linear_beta=0.0 in trtllm::k3_situ_mul
vsabavat Oct 9, 2026
55f0635
Merge k3-cons/b-runtime (SM 100 step-copy fix) into k3-cons/c-kernels
vsabavat Oct 9, 2026
c14508c
[None][chore] Move k3_mla_decode_view into the Kimi K3 MLA kernel pac…
vsabavat Oct 9, 2026
3a990dc
Merge main 24d0f2716f into k3-cons/b-runtime
vsabavat Oct 9, 2026
4612146
Merge k3-cons/b-runtime (main 24d0f2716f) into k3-cons/c-kernels
vsabavat Oct 9, 2026
9190f8b
Merge k3-cons/b-runtime (main 24d0f2716f) into k3-cons/c-kernels
vsabavat Oct 9, 2026
4552c8d
[None][feat] DSpark: load speculators-format drafter checkpoints
vsabavat Oct 6, 2026
c6cd921
Merge main (01a3a967a9) into k3-cons/a-main-fixes
vsabavat Oct 9, 2026
c44c900
Merge k3-cons/a-main-fixes (speculators DSpark loader, main 01a3a967a…
vsabavat Oct 9, 2026
edc6351
Merge k3-cons/b-runtime (new A c6cd921256) into k3-cons/c-kernels
vsabavat Oct 9, 2026
0fd5a3a
[None][fix] Ragged spec sampler tests: give the stub sampler B's stor…
vsabavat Oct 9, 2026
6157fb8
Merge k3-cons/b-runtime (ragged sampler test fix) into k3-cons/c-kernels
vsabavat Oct 9, 2026
d639ec5
Merge main fcc4432bef into k3-cons/b-runtime
vsabavat Oct 10, 2026
bca86ba
Merge k3-cons/b-runtime (main fcc4432bef) into k3-cons/c-kernels
vsabavat Oct 10, 2026
145def6
Merge main 16df7eaf25 into k3-cons/a-main-fixes
vsabavat Oct 11, 2026
0ed2dfd
Merge k3-cons/a-main-fixes (main 16df7eaf25) into k3-cons/b-runtime
vsabavat Oct 11, 2026
23a02c1
Merge k3-cons/b-runtime (main 16df7eaf25) into k3-cons/c-kernels
vsabavat Oct 11, 2026
6a95a9e
[None][fix] KV cache manager V2: do not commit an unseeded disagg gen…
vsabavat Oct 12, 2026
6b07622
Merge k3-cons/a-main-fixes (unseeded disagg KDA replay suspend fix) i…
vsabavat Oct 12, 2026
ee481ee
Merge k3-cons/b-runtime (unseeded disagg KDA replay suspend fix) into…
vsabavat Oct 12, 2026
63aa7a2
[None][chore] KV cache manager V2: separate KDA draft-record accounti…
vsabavat Oct 12, 2026
83becf9
Merge k3-cons/b-runtime (KDA draft-record accounting review follow-up…
vsabavat Oct 12, 2026
a486e00
Merge main fced9ff984 into k3-cons/a-main-fixes
vsabavat Oct 13, 2026
52a3283
Merge k3-cons/a-main-fixes latest-main compatibility into k3-cons/b-r…
vsabavat Oct 13, 2026
520ae9c
Merge branch 'mr11/b' into mr11/c
vsabavat Oct 13, 2026
379cdf6
Preserve K3 numeric contracts through model-owned operation migration
vsabavat Oct 13, 2026
cdbba03
test: isolate MNNVL workspace lifecycle from CUDA capture state
vsabavat Oct 13, 2026
0202519
test: align hybrid fixtures and CUDA requirements with main
vsabavat Oct 13, 2026
40df45e
Merge commit 'cdbba03f749f6012d8288d71c915c7af7f863ea6' into mr11/b
vsabavat Oct 13, 2026
be9f0e4
Merge commit '40df45e324fdeb290aa058d4a0af4e571d729bb5' into mr11/c
vsabavat Oct 13, 2026
72bb8ca
test: remove obsolete MNNVL workspace dictionary assertion
vsabavat Oct 13, 2026
951048b
Merge commit '72bb8ca0b8ad4f5086f6fe4e1162afc6de533f61' into mr11/b
vsabavat Oct 13, 2026
1cf3ae6
Merge commit '951048b17591f880cf89bd63161cf70dd0ec4921' into mr11/c
vsabavat Oct 13, 2026
a1fb5ba
Merge upstream after A #19988 while preserving B runtime records
vsabavat Oct 14, 2026
44c31f6
Merge repaired B predecessor after A #19988
vsabavat Oct 14, 2026
9afa851
Merge current upstream main for K3 B CI
vsabavat Oct 14, 2026
fd2bb56
Merge updated predecessor for K3 C CI
vsabavat Oct 14, 2026
1f94ed5
Own cached host-to-device copies and share metadata buffer snapshots
vsabavat Oct 14, 2026
15d5054
Merge reviewed B buffer ownership into C kernel stack
vsabavat Oct 14, 2026
b279e48
Admit K3 MLA spin barriers using the actual stream SM resources
vsabavat Oct 14, 2026
597e23a
Reject malformed DSpark auxiliary layer IDs before translation
vsabavat Oct 14, 2026
3a51287
Merge strict B DSpark config validation into C
vsabavat Oct 14, 2026
f1d74e3
Merge main Qwen catalog additions into K3 kernels
vsabavat Oct 15, 2026
3261a6f
Address speculative runtime review nits
vsabavat Oct 15, 2026
97d8936
Merge speculative runtime review nits into K3 kernels
vsabavat Oct 15, 2026
6b3d878
[None][fix] Align Kimi cache test fixture with upstream mapping fields
vsabavat Oct 16, 2026
28d1e2a
[None][chore] Merge current main after the Kimi fixture correction
vsabavat Oct 16, 2026
6b38abc
[None][chore] Propagate the Kimi fixture correction through the K3 stack
vsabavat Oct 16, 2026
413ee68
[None][chore] Merge current main dac84b01a6 into the K3 runtime branch
vsabavat Oct 16, 2026
3e46156
[None][chore] Propagate the current-main merge through the K3 stack
vsabavat Oct 16, 2026
14a76b0
[None][fix] Refresh serving configuration schemas (By Agent)
VALLIS-NERIA Oct 16, 2026
cb9aa92
[None][chore] Merge current main c226e2d77c into the K3 runtime branch
vsabavat Oct 16, 2026
97811d8
[None][chore] Propagate the current-main merge through the K3 stack
vsabavat Oct 16, 2026
7bc9de8
[None][chore] Merge latest main into K3 runtime branch (By Agent)
VALLIS-NERIA Oct 19, 2026
27a60ad
[None][test] Fix KDA admission fixture indices (By Agent)
VALLIS-NERIA Oct 19, 2026
cd4d74c
[None][chore] Merge decoder refactor from main (By Agent)
VALLIS-NERIA Oct 19, 2026
7487caf
[None][test] Initialize decoder input preparer fixture config (By Agent)
VALLIS-NERIA Oct 19, 2026
9595d2f
[None][chore] Propagate the latest K3 runtime branch into the K3 kern…
vsabavat Oct 20, 2026
be8488e
[None][chore] Merge current main d6bb0609df into the K3 kernels branch
vsabavat Oct 20, 2026
423c804
[None][chore] Merge current main 66ff20f205 into the K3 kernels branch
vsabavat Oct 20, 2026
0f9ee92
[None][chore] Merge main kernel directory reorganization (By Agent)
VALLIS-NERIA Oct 20, 2026
45aabf9
[None][chore] Merge the K3 runtime branch with the kernel directory s…
vsabavat Oct 20, 2026
ea00015
[None][chore] Apply ruff to the relocated Kimi K3 kernel imports
vsabavat Oct 20, 2026
c7b667d
[None][test] Account for generation KV cache events (By Agent)
VALLIS-NERIA Oct 20, 2026
996bb14
[None][chore] Merge main KV cache retention updates (By Agent)
VALLIS-NERIA Oct 20, 2026
653a47a
[None][chore] Merge the K3 runtime branch with the KV cache retention…
vsabavat Oct 20, 2026
c60ee69
[None][feat] Express the Kimi K3 catalog entries as #19977 OpWrapper …
vsabavat Oct 21, 2026
a43e651
[None][chore] Merge main kernel test relocations (By Agent)
VALLIS-NERIA Oct 22, 2026
f5d9d73
[None][chore] Merge the K3 runtime branch with the kernel test reloca…
vsabavat Oct 22, 2026
8c2cefa
[None][chore] Merge main speculative decoding cleanup (By Agent)
VALLIS-NERIA Oct 22, 2026
a688df8
[None][chore] Merge the K3 runtime branch with main 53edc7d4b1 into t…
vsabavat Oct 22, 2026
73ca651
[None][chore] Merge main dd63b36fcf into the K3 kernels branch
vsabavat Oct 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 13 additions & 51 deletions cpp/tensorrt_llm/common/lamportUtils.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
#include <cuda_runtime.h>
#include <type_traits>

#include <cooperative_groups.h>

#include "tensorrt_llm/common/cudaTypeUtils.cuh"

TRTLLM_NAMESPACE_BEGIN
Expand Down Expand Up @@ -196,17 +194,16 @@ struct LamportBufferLayout
(lamportIndex * numStages + stageIndex) * static_cast<size_t>(bytesPerBuffer / numStages)));
}
};

// Current Index
// Dirty Index
// bytes_per_buffer
// Dirty num_stages
// Dirty bytes_to_clear = {stage0, stage1, stage2, stage3} # We fix this to 4 stages
// offset_access_ptr

namespace cg = cooperative_groups;

// PackedType is the one used in kernel for Lamport buffer (LDG.128 or LDG.64)
template <typename PackedType = float4, bool UseCGA = false>
template <typename PackedType = float4>
struct __attribute__((aligned(32))) LamportFlags
{
public:
Expand Down Expand Up @@ -258,63 +255,28 @@ public:

__device__ void ctaArrive()
{
if constexpr (UseCGA)
#if (defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 700))
uint32_t const barrierThreads
= ((static_cast<uint32_t>(blockDim.x) + kWARP_SIZE - 1U) / kWARP_SIZE) * kWARP_SIZE;
if (threadIdx.x < kWARP_SIZE)
{
#if (defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 900))
cg::cluster_group cluster = cg::this_cluster();
__cluster_barrier_arrive();
if (cluster.block_rank() == 0 && threadIdx.x < kWARP_SIZE)
{
__cluster_barrier_wait();
arriveCounter(threadIdx.x);
}
#else
__syncthreads();
asm volatile("barrier.cta.sync 1, %0;" ::"r"(barrierThreads) : "memory");
arriveCounter(threadIdx.x);
#endif
}
else
{
#if (defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 700))
uint32_t const barrierThreads
= ((static_cast<uint32_t>(blockDim.x) + kWARP_SIZE - 1U) / kWARP_SIZE) * kWARP_SIZE;
if (threadIdx.x < kWARP_SIZE)
{
asm volatile("barrier.cta.sync 1, %0;" ::"r"(barrierThreads) : "memory");
arriveCounter(threadIdx.x);
}
else
{
asm volatile("barrier.cta.arrive 1, %0;" ::"r"(barrierThreads) : "memory");
}
asm volatile("barrier.cta.arrive 1, %0;" ::"r"(barrierThreads) : "memory");
}
#else
__syncthreads();
arriveCounter(threadIdx.x);
__syncthreads();
arriveCounter(threadIdx.x);
#endif
}
}

__device__ void waitAndUpdate(uint4 bytesToClearPerStage)
{
bool isLastCtaT0{false};
int targetCount{0};
if constexpr (UseCGA)
{
#if (defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 900))
cg::grid_group grid = cg::this_grid();
// Use the first thread instead of the last thread as the last thread may exit early.
isLastCtaT0 = grid.thread_rank() == 0;
targetCount = grid.num_clusters();
#else
isLastCtaT0 = threadIdx.x == 0 && blockIdx.x == 0 && blockIdx.y == 0 && blockIdx.z == 0;
targetCount = gridDim.x * gridDim.y * gridDim.z;
#endif
}
else
{
isLastCtaT0 = threadIdx.x == 0 && blockIdx.x == 0 && blockIdx.y == 0 && blockIdx.z == 0;
targetCount = gridDim.x * gridDim.y * gridDim.z;
}
bool const isLastCtaT0 = threadIdx.x == 0 && blockIdx.x == 0 && blockIdx.y == 0 && blockIdx.z == 0;
int const targetCount = gridDim.x * gridDim.y * gridDim.z;
if (isLastCtaT0)
{
uint4* flagPtr = reinterpret_cast<uint4*>(mBufferFlagsPtr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,9 @@ __global__ void __launch_bounds__(1024) oneshotAllreduceFusionKernel(MnnvlAllRed
int threadOffset = token * params.tokenDim + packedIdx * kELTS_PER_THREAD;
#endif

// We only use 1 stage for the oneshot allreduce
LamportFlags<PackedType, true> flag(params.bufferFlags, 1);
// We only use 1 stage for the oneshot allreduce. Arrivals are counted per CTA: the RMSNorm epilogue's cluster
// reduction below must be each thread's only phase of the cluster barrier.
LamportFlags<PackedType> flag(params.bufferFlags, 1);
T* stagePtrMcast = reinterpret_cast<T*>(flag.getCurLamportBuf(params.mcastPtr, 0));
T* stagePtrLocal = reinterpret_cast<T*>(flag.getCurLamportBuf(params.inputPtrs[params.rank], 0));
bool const inBounds = packedIdx * kELTS_PER_THREAD < params.tokenDim;
Expand Down Expand Up @@ -710,11 +711,12 @@ __global__ void __launch_bounds__(1024) oneshotAllreduceFusionKernel(MnnvlAllRed
fullSum = 0.F;
// Need to reduce over the entire cluster
int const blockRank = cluster.block_rank();
// Every CTA of the cluster must have started before another CTA writes its shared memory.
cluster.sync();
if (threadIdx.x < numBlocks)
{
cluster.map_shared_rank(&sharedVal[0], threadIdx.x)[blockRank] = blockSum;
}
// cluster.sync();
cluster.barrier_wait(cluster.barrier_arrive());
for (int i = 0; i < numBlocks; ++i)
{
Expand Down Expand Up @@ -890,7 +892,7 @@ __global__ __launch_bounds__(128) void twoshotAllreduceKernel(MnnvlAllReduceKern
#if (defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 900))
cudaGridDependencySynchronize();
#endif
LamportFlags<PackedType, false> flag(params.bufferFlags, MNNVLTwoShotStage::NUM_STAGES);
LamportFlags<PackedType> flag(params.bufferFlags, MNNVLTwoShotStage::NUM_STAGES);

T* scatterBufLocal
= reinterpret_cast<T*>(flag.getCurLamportBuf(params.inputPtrs[params.rank], MNNVLTwoShotStage::SCATTER));
Expand Down Expand Up @@ -1016,7 +1018,9 @@ __global__ __launch_bounds__(1024) void rmsNormLamport(MnnvlAllReduceKernelParam
T* smemResidual = reinterpret_cast<T*>(&smem[smemBufferSize]);
T* smemGamma = reinterpret_cast<T*>(&smem[2 * smemBufferSize]);

LamportFlags<float4, UseCGA> flag(params.bufferFlags, MNNVLTwoShotStage::NUM_STAGES);
// Arrivals are counted per CTA: with UseCGA the RMSNorm cluster reduction below must be each thread's only phase
// of the cluster barrier.
LamportFlags<float4> flag(params.bufferFlags, MNNVLTwoShotStage::NUM_STAGES);
T* input = reinterpret_cast<T*>(
flag.getCurLamportBuf(reinterpret_cast<void*>(params.bufferInputPtr), MNNVLTwoShotStage::BROADCAST));

Expand Down Expand Up @@ -1137,11 +1141,12 @@ __global__ __launch_bounds__(1024) void rmsNormLamport(MnnvlAllReduceKernelParam
fullSum = 0.F;
// Need to reduce over the entire cluster
int const blockRank = cluster.block_rank();
// Every CTA of the cluster must have started before another CTA writes its shared memory.
cluster.sync();
if (threadIdx.x < numBlocks)
{
cluster.map_shared_rank(&sharedVal[0], threadIdx.x)[blockRank] = blockSum;
}
// cluster.sync();
cluster.barrier_wait(cluster.barrier_arrive());
for (int i = 0; i < numBlocks; ++i)
{
Expand Down
61 changes: 47 additions & 14 deletions cpp/tensorrt_llm/kernels/kimiK3AttnRes/attnResFwd.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1046,12 +1046,18 @@ __global__ void __launch_bounds__(256, 1) attn_res_fwd_s1_single_cta_kernel(bf16
bf16_t const* __restrict__ layer_res, bf16_t const* __restrict__ layer_res_add, bf16_t const* __restrict__ res_w,
bf16_t const* __restrict__ rms_w, bf16_t const* __restrict__ output_rms_w, bf16_t* __restrict__ updated_layer_res,
bf16_t* __restrict__ output, float* __restrict__ rsigma_out, float* __restrict__ probs_out,
float* __restrict__ logits_out, float rms_eps, float output_rms_eps, int num_tokens)
float* __restrict__ logits_out, float rms_eps, float output_rms_eps, int num_tokens, bool early_trigger)
{
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 1000
if constexpr (ENABLE_PDL)
{
cudaGridDependencySynchronize();
// The dependent grid still waits for this one to complete before reading its
// output; triggering here lets it launch and stream its weights while this kernel runs.
if (early_trigger)
{
cudaTriggerProgrammaticLaunchCompletion();
}
}

constexpr int H = 7168;
Expand Down Expand Up @@ -1321,7 +1327,10 @@ __global__ void __launch_bounds__(256, 1) attn_res_fwd_s1_single_cta_kernel(bf16

if constexpr (ENABLE_PDL)
{
cudaTriggerProgrammaticLaunchCompletion();
if (!early_trigger)
{
cudaTriggerProgrammaticLaunchCompletion();
}
}
#else
if (cute::thread0())
Expand All @@ -1331,11 +1340,17 @@ __global__ void __launch_bounds__(256, 1) attn_res_fwd_s1_single_cta_kernel(bf16
#endif
}

// Decode handoff options for the s1 kernels (see AttnResFwdParams).
struct S1Handoff
{
bool early_trigger = false;
};

template <int N, bool FUSE_OUTPUT_RMS_NORM = false, bool FUSE_LAYER_ADD = false>
static void launch_s1_single_cta(bf16_t const* block_residual, bf16_t const* layer_residual,
bf16_t const* layer_residual_add, bf16_t const* res_weight, bf16_t const* rms_weight,
bf16_t const* output_rms_weight, bf16_t* updated_layer_residual, bf16_t* output, float* rsigma, float* probs,
float* logits, float rms_eps, float output_rms_eps, int num_tokens, cudaStream_t stream)
float* logits, float rms_eps, float output_rms_eps, int num_tokens, cudaStream_t stream, S1Handoff handoff = {})
{
if (tensorrt_llm::common::getEnvEnablePDL())
{
Expand All @@ -1351,14 +1366,14 @@ static void launch_s1_single_cta(bf16_t const* block_residual, bf16_t const* lay
config.numAttrs = 1;
cudaLaunchKernelEx(&config, kernel, block_residual, layer_residual, layer_residual_add, res_weight, rms_weight,
output_rms_weight, updated_layer_residual, output, rsigma, probs, logits, rms_eps, output_rms_eps,
num_tokens);
num_tokens, handoff.early_trigger);
}
else
{
attn_res_fwd_s1_single_cta_kernel<N, FUSE_OUTPUT_RMS_NORM, FUSE_LAYER_ADD, false>
<<<num_tokens, 256, 0, stream>>>(block_residual, layer_residual, layer_residual_add, res_weight, rms_weight,
output_rms_weight, updated_layer_residual, output, rsigma, probs, logits, rms_eps, output_rms_eps,
num_tokens);
num_tokens, false);
}
}

Expand All @@ -1380,13 +1395,22 @@ __global__ void __launch_bounds__(256, 1) attn_res_fwd_s1_splitk_kernel(bf16_t c
bf16_t const* __restrict__ layer_res, bf16_t const* __restrict__ layer_res_add, bf16_t const* __restrict__ res_w,
bf16_t const* __restrict__ rms_w, bf16_t const* __restrict__ output_rms_w, bf16_t* __restrict__ updated_layer_res,
bf16_t* __restrict__ output, float* __restrict__ rsigma_out, float* __restrict__ probs_out,
float* __restrict__ logits_out, float rms_eps, float output_rms_eps, int num_tokens)
float* __restrict__ logits_out, float rms_eps, float output_rms_eps, int num_tokens, bool early_trigger)
{
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 1000
if constexpr (ENABLE_PDL)
auto const wait_for_previous_grid = [&]
{
cudaGridDependencySynchronize();
}
if constexpr (ENABLE_PDL)
{
cudaGridDependencySynchronize();
// See attn_res_fwd_s1_single_cta_kernel.
if (early_trigger)
{
cudaTriggerProgrammaticLaunchCompletion();
}
}
};
wait_for_previous_grid();

namespace cg = cooperative_groups;
constexpr int H = 7168;
Expand Down Expand Up @@ -1439,6 +1463,7 @@ __global__ void __launch_bounds__(256, 1) attn_res_fwd_s1_splitk_kernel(bf16_t c

float sq[N] = {};
float dot[N] = {};
// Every candidate in one pass, so all loads are in flight together.
#pragma unroll
for (int ki = tid; ki < K_PER_CTA; ki += THREADS)
{
Expand Down Expand Up @@ -1638,7 +1663,10 @@ __global__ void __launch_bounds__(256, 1) attn_res_fwd_s1_splitk_kernel(bf16_t c

if constexpr (ENABLE_PDL)
{
cudaTriggerProgrammaticLaunchCompletion();
if (!early_trigger)
{
cudaTriggerProgrammaticLaunchCompletion();
}
}
#else
if (cute::thread0())
Expand All @@ -1652,13 +1680,14 @@ template <int N, int GROUPS = 8, bool FUSE_OUTPUT_RMS_NORM = false, bool FUSE_LA
static void launch_s1_splitk(bf16_t const* block_residual, bf16_t const* layer_residual,
bf16_t const* layer_residual_add, bf16_t const* res_weight, bf16_t const* rms_weight,
bf16_t const* output_rms_weight, bf16_t* updated_layer_residual, bf16_t* output, float* rsigma, float* probs,
float* logits, float rms_eps, float output_rms_eps, int num_tokens, cudaStream_t stream)
float* logits, float rms_eps, float output_rms_eps, int num_tokens, cudaStream_t stream, S1Handoff handoff = {})
{
constexpr int K_PER_CTA = 7168 / GROUPS;
constexpr int WARPS = 8;
constexpr size_t smem_size
= (size_t) N * K_PER_CTA * sizeof(float) + (size_t) WARPS * N * sizeof(float2) + (size_t) N * sizeof(float);
bool const enable_pdl = tensorrt_llm::common::getEnvEnablePDL();
bool early_trigger = enable_pdl && handoff.early_trigger;
auto kernel = enable_pdl ? &attn_res_fwd_s1_splitk_kernel<N, GROUPS, FUSE_OUTPUT_RMS_NORM, FUSE_LAYER_ADD, true>
: &attn_res_fwd_s1_splitk_kernel<N, GROUPS, FUSE_OUTPUT_RMS_NORM, FUSE_LAYER_ADD, false>;
static std::once_flag attrs_set[2][64];
Expand All @@ -1678,7 +1707,7 @@ static void launch_s1_splitk(bf16_t const* block_residual, bf16_t const* layer_r
void* args[] = {const_cast<bf16_t**>(&block_residual), const_cast<bf16_t**>(&layer_residual),
const_cast<bf16_t**>(&layer_residual_add), const_cast<bf16_t**>(&res_weight), const_cast<bf16_t**>(&rms_weight),
const_cast<bf16_t**>(&output_rms_weight), &updated_layer_residual, &output, &rsigma, &probs, &logits, &rms_eps,
&output_rms_eps, &num_tokens};
&output_rms_eps, &num_tokens, &early_trigger};
cudaLaunchConfig_t config{};
// One cluster per token. clusterDim stays GROUPS, so clusters are contiguous
// spans of the grid and each token's DSM exchange stays within its own.
Expand Down Expand Up @@ -1887,18 +1916,22 @@ static void launchAttnResDecodeRmsNorm(AttnResFwdParams const& params, cudaStrea

auto const* layer_residual_add = FUSE_LAYER_ADD ? params.layerResidualAdd : nullptr;
auto* updated_layer_residual = FUSE_LAYER_ADD ? params.updatedLayerResidual : nullptr;
// The dependent kernel launches (and streams its weights) while this one runs: it waits for
// this grid before reading the output.
constexpr bool early_trigger = true;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes an existing model path: trtllm::attn_res_rmsnorm_fwd / attn_res_add_rmsnorm_fwd are called by modeling_kimi_linear.py on main.

The benefit targets the new GEMVs, which nothing calls yet. Could we pass early_trigger from the caller so only the new decode path sets it? .

S1Handoff const handoff{early_trigger};

if constexpr (N <= 4)
{
launch_s1_single_cta<N, true, FUSE_LAYER_ADD>(params.blockResidual, params.layerResidual, layer_residual_add,
params.resWeight, params.rmsWeight, params.outputRmsWeight, updated_layer_residual, params.output, nullptr,
nullptr, nullptr, params.rmsEps, params.outputRmsEps, params.seqLen, stream);
nullptr, nullptr, params.rmsEps, params.outputRmsEps, params.seqLen, stream, handoff);
}
else
{
launch_s1_splitk<N, 8, true, FUSE_LAYER_ADD>(params.blockResidual, params.layerResidual, layer_residual_add,
params.resWeight, params.rmsWeight, params.outputRmsWeight, updated_layer_residual, params.output, nullptr,
nullptr, nullptr, params.rmsEps, params.outputRmsEps, params.seqLen, stream);
nullptr, nullptr, params.rmsEps, params.outputRmsEps, params.seqLen, stream, handoff);
}
}

Expand Down
10 changes: 8 additions & 2 deletions cpp/tensorrt_llm/kernels/noAuxTcKernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@ void invokeNoAuxTc(InputT* scores, BiasT* bias, OutputT* topk_values, IdxT* topk

if (is_single_group || is_multi_group)
{
// No tokens: there is nothing to write, and a grid of zero blocks is an invalid launch.
if (num_tokens == 0)
{
return;
}

cudaLaunchConfig_t config;
auto* kernel_instance = &deepseek_v3_topk_kernel<InputT, BiasT, OutputT, IdxT, NumDeepseekExperts, true>;
int num_threads = NumDeepseekExperts;
Expand Down Expand Up @@ -344,8 +350,8 @@ void invokeNoAuxTc(InputT* scores, BiasT* bias, OutputT* topk_values, IdxT* topk
config.numAttrs = 1;
config.attrs = attrs;

cudaLaunchKernelEx(&config, kernel_instance, scores, topk_values, topk_indices, bias, num_tokens, n_group,
topk_group, topk, num_experts, num_experts / n_group, routed_scaling_factor);
TLLM_CUDA_CHECK(cudaLaunchKernelEx(&config, kernel_instance, scores, topk_values, topk_indices, bias,
num_tokens, n_group, topk_group, topk, num_experts, num_experts / n_group, routed_scaling_factor));
sync_check_cuda_error(stream);
}
else
Expand Down
Loading