[Ops] Add fused_recurrent kernel for Triadic Gated DeltaNet #1737
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.57) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.57 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #1737"
general
weight: 0.35
ischencheng
Summary
Adds
fused_recurrent_triadic_gdn, the decoding kernel for Triadic Gated DeltaNet, after the chunk kernels in #1625 (design in #1370). It takes the same tensors and[N, H, E, K, V]fp32 state aschunk_triadic_gdnand is forward-only likefused_recurrent_gated_delta_rule, so inference can prefill with the chunk op and decode from its final state.Each program keeps all
Eslices of one value block of the state in registers, since every step's delta update sumsS_eᵀ κ_eover the slices. Tiles come from a BV × num_warps sweep on H100 and B200 at decode shapes (B=32, H=32, T=1 and 4, K=128 and 256). The two prefer different sizes, so Hopper holds up to 32K state values per program (BV=32 up to two slices, 16 beyond) and other GPUs up to 16K (BV=32 up to four slices), with BV halved past that and up to 8 warps. At B=32, H=32 this is the fastest swept tile on B200 at every K=128 shape and within 4% of the fastest elsewhere at T=1. At T=4 the worst cases take 1.08x the fastest tile's time on H100 (K=128, E=16), and at K=256 1.09x on B200 (E=8) and 1.18x on H100 (E=4).Supported: K, V <= 256, varlen, initial/final states; the tiles are tuned for E up to 16. Not supported yet: GVA,
state_v_first, in-kernel L2 norm and gate activation.Test plan
test_fused_recurrentandtest_fused_recurrent_varlenintests/ops/test_triadic_gdn.pycompare outputs and final states againstnaive_recurrent_triadic_gdn. Cases cover one and four decoding steps, E = 1, 2, 4, 8, 12, 16, K = 8, 60, 64, 100, 128, 256, V = 12, 64, 96, 128, 256, strong decay, fp32/fp16/bf16, initial and final states each on and off, a state block narrowed to BV=8, and varlen with one token per sequence.test_chunk_then_fused_recurrentprefills withchunk_triadic_gdnand decodes from its final state. The one-step decode case is markedsmoke.| GPU | torch / Triton | Result |
|---|---|---|
| H100 80GB | 2.12.1 / 3.7.1 | 32 passed |
| H100 80GB | 2.9.1 / 3.5.1 | 32 passed |
| B200 | 2.12.1 / 3.7.1 | 32 passed |
scripts/find_dependent_tests.pyselects onlytests/ops/test_triadic_gdn.py. I also rantests/test_public_api.pyfor the new export, plustests/ops/test_gdn2.py,tests/ops/test_dplr_tilelang.pyandtests/test_dispatch.py: 247 passed and 56 skipped on H100 80GB (2.12.1 / 3.7.1). The TileLang routes skip since TileLang isn't installed in the test env, and the rest are Ascend-only.pre-commitandscripts/check_header.py --checkpass.Benchmark / NCU
This is a new op, so the reference is
fused_recurrent_gated_delta_rulewithH * Eheads, which reads and writes the same state bytes but has no coupling between slices. Decode with initial and final states, K=V=128, bf16 q/k/v, fp32 state, B=32 and H=32, timed withtriton.testing.do_benchthrough the public APIs ata29dd439. H100 80GB and B200, both torch 2.12.1 / Triton 3.7.1.| T | E | H100 (us) | H100 reference (us) | B200 (us) | B200 reference (us) |
|---|---|---|---|---|---|
| 1 | 1 | 51.8 | 52.9 | 30.8 | 35.9 |
| 1 | 2 | 97.7 | 98.7 | 49.0 | 61.2 |
| 1 | 4 | 190.6 | 191.2 | 90.9 | 110.6 |
| 1 | 8 | 371.8 | 376.6 | 181.4 | 215.0 |
| 1 | 16 | 729.0 | 748.4 | 467.1 | 421.5 |
| 4 | 1 | 69.2 | 69.4 | 54.8 | 58.2 |
| 4 | 2 | 123.8 | 127.3 | 82.8 | 104.4 |
| 4 | 4 | 230.3 | 239.5 | 159.7 | 188.9 |
| 4 | 8 | 479.7 | 461.4 | 318.6 | 359.3 |
| 4 | 16 | 1136.0 | 906.4 | 763.2 | 707.8 |
Varlen, 32 sequences of 1 to 8 tokens (142 in total), H=32:
| E | H100 (us) | H100 reference (us) | B200 (us) | B200 reference (us) |
|---|---|---|---|---|
| 1 | 71.1 | 72.1 | 57.3 | 63.8 |
| 2 | 127.5 | 132.5 | 88.1 | 112.6 |
| 4 | 244.4 | 253.7 | 163.7 | 210.6 |
| 8 | 499.4 | 498.6 | 326.8 | 399.8 |
| 16 | 1147.7 | 975.7 | 802.7 | 785.2 |
At one step with E = 2 to 8, the state is read and written at 2.7 to 2.9 TB/s on H100 and 5.5 to 5.9 TB/s on B200. Up to E = 8 it is within 4% of the reference on H100 and faster on B200, where the reference uses BV=8. At E = 16 it takes up to 1.25x the reference time on H100 at four steps and 1.11x on B200 at one step.
python -m benchmarks.ops.run --op fused_recurrent_triadic_gdn fused_recurrent_triadic_gdn_varlenruns the registry shapes.Breaking changes
None. Adds
fused_recurrent_triadic_gdn(also exported fromfla.ops) and two benchmark registry entries.Checklist