Repository navigation
Conversation
Co-authored-by: Sealeen Zhang <[email protected]>
839beab to
6954663
Compare
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
… K3 op_test Co-authored-by: Sealeen Zhang <[email protected]>
Co-authored-by: Sealeen Zhang <[email protected]>
Co-authored-by: Sealeen Zhang <[email protected]>
Squashed from #6498 (branch zain/kda/bwd, head 966a494), FLA chunk_kda_bwd Triton port by Micky774. Co-authored-by: Micky774 <[email protected]> Co-authored-by: Sealeen Zhang <[email protected]>
Add op_tests/test_kda_chunk_bwd.py (aiter-op-test structure): K3 shapes (H=96/48/12 x 128) graded against an fp32 chunked torch reference adapted from #8739, with a us/TFLOPS/TB/s summary table. Add 96-head cases to the Co-authored-by: Sealeen Zhang <[email protected]> #6498 pytest suite.
fast_launch moved to aiter/ops/triton/utils in #8061; the #6498 import path no longer exists on main (also fixes ruff I001). Co-authored-by: Sealeen Zhang <[email protected]>
Co-authored-by: Sealeen Zhang <[email protected]>
chunk_kimi_delta_attn(bwd_backend="flydsl") recomputes the backward's forward chunk-state recurrence (h, v_new) on the FlyDSL GDN K5 kernel (chunk_gated_delta_h, USE_GK, token-major w/u) instead of the Triton fwd_h; dhu, wy_dqkg, intra and the gate/l2norm/beta backward stay Triton. Falls back to Triton outside bf16, K=V=128, chunk 64, non-varlen. op_tests/test_kda_chunk_bwd.py benchmarks and grades both backends; the pytest suite checks flydsl against triton at H=96. Co-authored-by: Sealeen Zhang <[email protected]>
…v bwd, pluggable chunk bwd Co-authored-by: Sealeen Zhang <[email protected]>
… in-PR kernel Co-authored-by: Sealeen Zhang <[email protected]>
Co-authored-by: Sealeen Zhang <[email protected]>
bwd_backend="flydsl" now runs every backward stage on FlyDSL: - chunk-state recurrence on the GDN K5 kernel, read in its native layouts (h [B,NT,H,V,K], v_new [B,H,T,V]); the two transpose copies are gone. - new kernels in aiter/ops/flydsl/kernels/kda_chunk_bwd.py: dav, dhu, wy_dqkg, intra (+ in-kernel l2norm and beta-sigmoid backward) and gate_cumsum (+ gate activation backward, dA_log/dt_bias partials). Forward intermediates are still recomputed by the Triton fwd prologue. gfx950, bf16, K=V=128, chunk 64, no GVA, non-varlen; Triton otherwise. chunk_kda_bwd_flydsl implements #8739's register_chunk_bwd 7-tuple contract with fuses {qk_l2norm, gate, beta_sigmoid}; register_with_kda_layer() installs it. All kernels compile offline for gfx950 (no spills, LDS <= 147 KB); not run on a GPU yet. Co-authored-by: Sealeen Zhang <[email protected]>
… (no duplicate chunk fwd) Co-authored-by: Sealeen Zhang <[email protected]>
…pilogues; full-rank g_proj Co-authored-by: Sealeen Zhang <[email protected]>
In the last (partial) chunk, padded rows j >= nvalid hold g = 0, so the intra dkt exponent g[j] - g[r] was large and positive for a strongly decaying gate (gate in kernel / lower_bound) and exp2 overflowed; 0 * inf then gave NaN in dk/dg. Mask padded rows in both intra loops and clamp every decay exponent to <= 0 (causal pairs are <= 0 by construction). Add AITER_KDA_FLYDSL_CHECK=1 to name the first stage that writes a non-finite value. Tests: normalize q/k when the contract test runs without the in-kernel l2norm (unnormalized keys diverge, which was the remaining contract failures), and cover T=100 (full chunk + 36-token tail). Co-authored-by: Sealeen Zhang <[email protected]>
…t-in) for chunk fwd/bwd and conv bwd Co-authored-by: Sealeen Zhang <[email protected]>
…, Lumen#35 long-sequence block rows Co-authored-by: Sealeen Zhang <[email protected]>
…ntiguous, all as 128-bit stores Co-authored-by: Sealeen Zhang <[email protected]>
…g and intra gathers Transposed staging (wy_dqkg h / dv^T / Akk^T, dhu qg^T / w^T incl. its prefetch, dav do^T): lanes walked the source row-major, so neighbouring lanes wrote vec * ld_dst elements apart, a few banks per wave. Transposed stages now give consecutive lanes consecutive source rows, so their writes are contiguous; the 16-byte global loads are unchanged. intra off-diagonal gathers read g / q / k / dA with the four lane groups 4 rows apart on unpadded rows, i.e. the same banks (4-way). Rows are now padded by 16 bytes (g 132 fp32, q/k 136 bf16, dA 68 fp32), moving the groups 16 banks apart while keeping the b128 row reads aligned (LDS 129 -> 134 KB, still one workgroup per CU). Same values. 0 spills on all variants. Co-authored-by: Sealeen Zhang <[email protected]>
Co-authored-by: Sealeen Zhang <[email protected]>
…rnels + K5 recurrence, dense and varlen, fwd_backend switch, op_test Co-authored-by: Sealeen Zhang <[email protected]>
…the output GEMMs Co-authored-by: Sealeen Zhang <[email protected]>
… in parallel + fp32 MFMA block rows (64 -> 23 barriers) Co-authored-by: Sealeen Zhang <[email protected]>
…und gate, 128-bit row loads/stores Co-authored-by: Sealeen Zhang <[email protected]>
…uted v view's strides) Co-authored-by: Sealeen Zhang <[email protected]>
…ut staging, contiguous inputs + channel-major test layout Co-authored-by: Sealeen Zhang <[email protected]>
… the Triton prepare keywords Co-authored-by: Sealeen Zhang <[email protected]>
… with default fallback, tuner, Kimi-K3 / K3.1 shape CSVs Co-authored-by: Sealeen Zhang <[email protected]>
…e bwd forward-prepare hook (opt-in) Co-authored-by: Sealeen Zhang <[email protected]>
…ton contract) Co-authored-by: Sealeen Zhang <[email protected]>
…nd a FlyDSL vs Triton benchmark Co-authored-by: Sealeen Zhang <[email protected]>
…lve scratch in the dead g buffer) for 2 programs per CU Co-authored-by: Sealeen Zhang <[email protected]>
…e, default 64: 2x programs, 48 KB LDS) Co-authored-by: Sealeen Zhang <[email protected]>
…el_major); out_bv default 128 Co-authored-by: Sealeen Zhang <[email protected]>
…erand reads) in intra and output; qg/kg early to keep intra at 216 VGPRs Co-authored-by: Sealeen Zhang <[email protected]>
…FlyDSL bwd) + test vs Triton's disable_recompute intermediates Co-authored-by: Sealeen Zhang <[email protected]>
…ntiguous, all as 128-bit stores Co-authored-by: Sealeen Zhang <[email protected]>
…/Akk) when selected, Triton disable_recompute otherwise; save_fwd self-check graded vs an fp32 reference, self-checks no longer abort main; stub plumbing test Co-authored-by: Sealeen Zhang <[email protected]>
…raded self-check, non-aborting self-checks; #8744 13275a2) into kda-integration Conflicts in op_tests/test_kda_fused_layer_bwd.py: - test_kda_save_fwd_matches_recompute takes #8739's new signature (chunk_bwd=); #8754's config_name_of and #8757's MXFP8 tests are kept - main(): #8739's non-aborting self-checks; #8757's test_kda_mxfp8_weight_cache joins them the same way (logged and recorded in SELF_CHECK_FAILURES instead of raising) Co-authored-by: Sealeen Zhang <[email protected]>
… 0), assert every FlyDSL intermediate finite, check the FlyDSL bwd with them vs recompute Co-authored-by: Sealeen Zhang <[email protected]>
…test no longer depends on sys.modules/the real module); fall back to Triton on NaN in FlyDSL Aqk/Akk intermediates Co-authored-by: Sealeen Zhang <[email protected]>
…s files) Co-authored-by: Sealeen Zhang <[email protected]>
…ue self-checks); the mxfp8 weight-cache self-check reports the same way Co-authored-by: Sealeen Zhang <[email protected]>
… into kda-integration Conflicts in op_tests/test_kda_fused_layer_bwd.py: #8757's side of the MXFP8 block was empty (already merged), HEAD kept; its main() now has the same non-aborting mxfp8 weight-cache self-check, its wording taken. Co-authored-by: Sealeen Zhang <[email protected]>
…8744 c632635) and its stub case Co-authored-by: Sealeen Zhang <[email protected]>
Goal
Add a training backward for the whole Kimi-K3 KDA (Kimi Delta Attention) layer, and run the whole block end to end: 96 heads × 128, short conv width 4, hidden 7168. This covers two rows of ZhangDanyang-AMD/Lumen#35:
The existing fused KDA paths (#6550, #4741, #4577, #7225) are inference-only and have no backward.
What this PR has now
aiter/ops/kda_fused_layer.pykda_layer_fwdandkda_layer_bwd(dy, x, w, num_heads, backend=..., cu_seqlens=..., lower_bound=...)are the training entry points.g_proj [H*V, D].A_log,dt_biasando_normare fp32; the projections are bf16.A_logis per head, padded. The checkpoint stores fp32[128]for 96 heads: entries 0–95 are the per-head decay rates and 96–127 are zeros.modeling_kimi_linear.pyit isnn.Parameter(log(uniform(1, 16)), shape [num_heads]).kda_gateusesA_log.view(H, 1), and its Triton kernels loadA_log[i_h]withi_h < H.A_log[:H], anddA_logkeeps the padded shape with zeros in the padding.epsis the RMSNorm epsilon. The q/k L2 norm always usesL2NORM_EPS = 1e-6, on both backends, because the chunk kernels that fuse it (FLA / [Triton/Gluon] KDA: add the chunk_delta_attn backward pass #6498 / [Triton/Gluon] [HIP] [FlyDSL] [gfx950] Kimi-K3 KDA chunk backward (96 heads) #8740) hard-code that value.lower_bound(K3gate_lower_bound=-5) switches the decay gate tolower_bound * sigmoid(exp(A_log[h]) * (f_b(f_a(x)) + dt_bias)), which lies in[lower_bound, 0), as in FLAchunk_kda(safe_gate=True, lower_bound=...). Without it the gate is-exp(A_log[h]) * softplus(·).backend="torch"is the reference. It is a chunked WY implementation of the gated delta rule, with gradients from autograd.backend="fused"is a hand-written backward that recomputes the forward.kda_layer_fwd(backend="fused")is anautograd.Functionwhose backward is this path.kda_fused_layer.LAST_PIECESrecords which implementation served each stage in the latest fused call.kda_layer_fwdandkda_layer_bwdtakecu_seqlens, with x packed as[1, total, D]. The conv and the recurrence restart at every boundary.cu_seqlensfor both backends. That covers Triton, [Triton/Gluon] [HIP] [FlyDSL] [gfx950] KDA chunk forward for Kimi-K3 #8744chunk_kda_fwd_flydslsince 60a6a73, and [Triton/Gluon] [HIP] [FlyDSL] [gfx950] Kimi-K3 KDA chunk backward (96 heads) #8740chunk_kda_bwd_flydslsince cacbc1f. The conv backward, Triton or FlyDSL, getsquery_start_loc = cu_seqlens.cu_seqlensparameter still runs per sequence (chunk backward) or is skipped (chunk forward). The torch conv and chunk fallbacks loop.[H, K, V]state per chunk, instead of the[C, C, K]decay of every chunk, which is ~51 GB at T=16384 and H=96. This keeps the long shapes feasible.triton: the in-tree Tritonchunk_kimi_delta_attn(#4568/#4683).flydslselects #8744chunk_kda_fwd_flydsl. Both get contiguous token-major q/k/v/g/beta (_token_major). Triton gets fp32 q/k/v for fp32 layers and bf16 for 16-bit layers (compute_dtype). With a lower bound it getssafe_gate=True, lower_bound, the same gate mode as the backward. A kernel that rejects the call (ValueError) falls through to the next choice. The kernel is only used when a chunk backward kernel is active; otherwise the torch forward is kept so autograd can reuse its graphtriton: Tritonchunk_delta_attn_bwd(#6498 / #8740), which fuses the L2 norm, gate and beta sigmoid. With a lower bound it getssafe_gate=True, lower_bound. A kernel whose signature has nolower_bound(#8740chunk_kda_bwd_flydsltoday) gets the finished decay instead of a fused gate. Triton gets fp32 q/k/v/do for fp32 layers and bf16 for 16-bit layers. Every chunk kernel gets contiguous token-major inputs on every dtype.flydslselects #8740chunk_kda_bwd_flydsl. Without either, torch autograd over the recompute's graph.register_chunk_bwdstill overrides the selectionGEMM_EPI_KDA_GATE/_GATE_BWDfor softplus, andGEMM_EPI_KDA_SAFE_GATE/_SAFE_GATE_BWDfor the safe gate. They read an fp32 parameter vector[A_log[:H] | lower_bound | dt_bias], sodt_biasis added in fp32 inside the epilogue instead of through the bf16 GEMM bias. The fp32lris split into bf16 hi + lo halves,[hi|lo] @ [f_b|f_b]ᵀwith K=256, so the gate pre-activation keeps ~fp32 accuracy. This matters because the safe gate's derivative amplifies an input rounding by exp(A_log)GEMM_EPI_SIGMOID_MULnn/tn), always on the full-tile kernel. Every KDA GEMM pinsuse_half_tile_interleaved=False, enforced by an assert, so the HTI tn path (#8754) is never used. A shape the GEMM rejects, such as a K tail when tokens % 64 ≠ 0, falls back to torch on the same bf16-rounded inputsaiter.ops.flydsl.gated_rmsnorm_bwd; otherwise torchtriton: #8726 Tritoncausal_conv1d_split_qkv_bwd_triton_fn.flydslselects #8726aiter.ops.flydsl.causal_conv1d_bwd_flydsl.causal_conv1d_split_qkv_bwd_flydsl_fn, which has the same signature. Both are fed fp32 x/dq/dk/dv, with x as a[dim, tokens]view with unit channel stride and int32query_start_loc. Without either, torch autograd over the recompute's graphqk_l2norm; otherwise FlyDSLl2norm_bwd, or torch on CPUbeta_sigmoid; otherwise torch element-wisetorch.mm(out_dtype=float32)), so nothing is rounded to bf16 before the L2 norm and the gates. fp32 layers stay fp32.LAST_PIECES['gemm']reportstorch.bfloat16->fp32. Where this torch build lacksout_dtype, it reportstorch.bfloat16 inputs, fp32 GEMM: same numbers, slower, and the output is still never rounded to bf16Backend selection (functional first, optimize later): the chunk forward, chunk backward and conv backward stages default to Triton. FlyDSL is used only when selected:
set_kda_pieces(chunk_fwd="flydsl", chunk_bwd="flydsl", conv_bwd="flydsl");AITER_KDA_PIECES=chunk_bwd=flydsl,conv_bwd=torch.Fallback order is flydsl → triton → torch and triton → torch. A FlyDSL piece is also skipped, and recorded as
<stage>_flydsl_skipped, when the layer dtype is not one it is built for (FLYDSL_PIECE_DTYPES):kda_piece_choices()shows the active selection.LAST_PIECESrecords the backend each stage actually used (chunk_fwd,chunk_bwd,chunk_bwd_fuses,conv_bwd,l2norm_bwd,rmsnorm_bwd,proj_gemms,gemm). It also records:chunk_fwd_<backend>_skippedwhen a kernel rejected the call;<stage>_<backend>_missing, with the ImportError, when a selected kernel is not in the tree (e.g. the Triton chunk backward on this branch alone).Fusion switches, to A/B combinations by whole-network step time:
AITER_KDA_FUSIONS="save_fwd=1,concat_proj=1,chunk_fuse=qk_l2norm+gate,proj_epilogue=0"orset_kda_fusions(...).LAST_PIECESrecordsfusionsandrecompute.save_fwd=1: the training forward keeps its activations and the backward skips the whole recompute. This trades memory for time.concat_proj=1: one GEMM for x @ [w_q; w_k; w_v; f_a; w_beta (; g_proj)]ᵀ.proj_epilogue=0: torch GEMMs instead of the FlyDSL epilogues.chunk_fuse=auto|none|<subset>: which prologue stages the chunk backward absorbs.Precision modes (
AITER_KDA_PRECISION/set_kda_precision;LAST_PIECES['precision']):default: fp32 element-wise activations.megatron: matches the verified Megatron-LM [Triton/Gluon] [Config] Tune gfx1250 Gluon MXFP4 GEMMs for Llama3 70B TP4 #6872 KDA precision map:Both backends honor the mode. MXFP8 GEMMs come in through the
_proj_gemmhook, and the cuDNN FROST recurrence numerics are not reproduced.FlyDSL pieces never raise on unsupported shapes. The FlyDSL L2 norm, [FlyDSL] [gfx950] Kimi-K3 KDA gated RMSNorm backward #8741 RMSNorm and the GEMM epilogues /
proj_gemmcheck their constraints at call time and fall back to torch, recording<op>_skipped: <reason>inLAST_PIECES. A kernel that still rejects a call at runtime falls back the same way. The constraints are: row kernels need head dim % 64; GEMMs need K/N/D % 8 and 16-bit weights.One projection-GEMM entry point for the MXFP8 work stacked on this PR: every projection GEMM goes through
_proj_gemm(a, w, kind, cd, epilogue=..., name=...). That covers forward, dgrad and wgrad,concat_proj, the three epilogues and the fp32 low-rank f_b GEMMs.kindisfwd(a @ wᵀ),dgrad(a @ w) orwgrad(aᵀ @ w).register_proj_gemm(fn)installs a replacement for all of them. ReturningNotImplementedhands a call back to the default path.Why the g_proj backward is not a prologue fusion: the gfx950 GEMM moves A from global memory to LDS by async DMA, which never passes through registers, so an element-wise transform cannot be applied on load. In
dg_proj = dgpᵀ·x, dgp is also the transposed operand. Instead, [FlyDSL] [gfx950] Kimi-K3 KDA gated RMSNorm backward #8741 produces dgp and the two products run on the FlyDSL bf16 GEMM rather than torch fp32. A true prologue fusion would need a register-staged A path in the GEMM.Shared GEMM change in
aiter/ops/flydsl/kernels/gemm_a16w16_gfx950.py:epilogue/epi_group, plusepi0..2tensors. These are added to the full-tile kernel only, at the end of its arguments.split_k == 1and the full-tile kernel.The chunk contract uses fla
chunk_kdalayout and flag names:op_tests/test_kda_fused_layer_bwd.pyemits eight tables:Layer backward:
torch_chunkandfusedvs an independent recurrent fp32 reference, with all 15 gradients asserted.KDA block forward + backward (end to end):
kda_layer_fwd+ autograd backward fortorchandfused.yand all 15 gradients are asserted, both are timed, and afused piecescolumn lists which implementation served each stage.-l b,tokens,num_seqs. The defaults add the Lumen#35 long sequences at full K3 width: T=8192, B=2×4096, and varlen 8×2048 (packed,cu_seqlensthrough the layer). The short rows are 1×100, 1×256 and a varlen 2×128.-fsweeps fusion combos (-f default save_fwd=1 save_fwd=1,concat_proj=1), and each row is labeledfusion combo.refcolumn says which reference each row used.Per-piece FlyDSL (
-p): the fused backward with one stage on FlyDSL and the others on Triton, one row per stage. Columns:used: the backend that actually served the stage.skipped: why FlyDSL was skipped, if it was.failed grads: which gradients are out of tolerance.The run asserts after printing the table, so a wrong FlyDSL piece is localized. A bare
-pmeans all stages (argparse turns it into an empty list); an unknown stage is rejected. Every summary table that comes out empty is a hard error that names the empty sweep axes.Chunk forward backends, layer layout (bf16): the Triton and FlyDSL chunk forwards get the exact q/k/v views the layer builds (channel-major, out of the short conv), plus the gate and beta. Both are compared with
chunk_kda_torch, so a chunk-forward integration bug is isolated from the rest of the layer.Chunk backward backends, channel-major inputs (fp32 and bf16): the Triton and FlyDSL chunk backward adapters get channel-major q/k/v views with the fused prologue and
lower_bound, and are compared withchunk_kda_bwd_torch. This is the case that crashed in fp32.GPU-only stage diff, fp32 and bf16, with the
-glower bounds: each GPU-only stage of the fused path against its torch math on identical inputs. Each row saysranorskip: <reason>; failures are asserted after the table. The stages are:gate_proj,gate_proj_bwd(dz and per-head dA_log) andsigmoid_gate_proj, fed fp32lras the layer does;l2norm_bwd;rmsnorm_bwd;A_log/dt_bias/lower_bound, and the beta logit.g_proj bwd GEMM bit-exact (gfx950, bf16/fp16):
dx(nn) anddW_g(tn) on small-integer inputs, so the fp32 result is exact, written into NaN-filled outputs. Any wrong, racy or unwritten element fails.Projection fusion (gfx950, bf16/fp16):
gate,gate_bwd,sigmoid_mulandgproj_bwdvs a torch reference.gproj_bwdis graded on the bf16-rounded dgp it actually receives.Weights are laid out like the checkpoint (fp32 conv / A_log[128] / dt_bias / o_norm).
-gsweeps the gate lower bound: the default is-5(K3), and-g -5 noneadds the softplus gate.Block perf (Triton defaults)
Estimate for bf16, 1×8192, measured 222 ms before this change. One D×HK projection GEMM is 2·8192·7168·12288 ≈ 1.44 TFLOP.
y, fp32ydropped (−1.44 TF)x.float(), fp32 cat of the 36864×7168 q/k/v weights, twice)Validation
torchthere, as expected.AITER_KDA_PIECESandset_kda_piecesoverride them, a missing flydsl kernel falls back to triton, and invalid values are rejected. Gradients stay at ~1.6e-6 in every configuration.nn/tnbackward GEMMs compile offline for gfx950.lower_bound(gate fusion is dropped there).A_loggradient is exactly zero.auxwhile the GEMM gets it rounded to bf16, which the layer does on purpose. A CPU simulation of only that rounding gives 1.69% and max 0.154, so the FlyDSLtnGEMM is fine. The reference now uses the same bf16 input.used/skippedas expected. FlyDSL chunk pieces are skipped for fp32 and used for bf16. An injected wrong chunk_bwd is caught and its gradients are named.cu_seqlensand with one that does not.-pdied withKeyError: 'failed grads': a bare-pgave an empty piece list, so the sweep produced no rows. Fixed in 07402b2, which was checked on CPU with stubbed tests:-pruns all three pieces;-p chunk_bwdruns only that piece;-traises with the empty axis named;cu_seqlensin one call over all packed tokens.query_start_loc = cu_seqlensand a unit-channel-stride x.-ptable,chunk_fwd=flydslfailed all 15 gradients (err 0.84–0.88), whilechunk_bwdandconv_bwdon FlyDSL passed. Root cause, fixed in 9b943be:(T, 1, H·K·T, T)). That view is dense, so.to(bf16)andF.normalizekeep its strides..contiguous()themselves, so they were unaffected._token_major).o = empty_like(v)allocation.epson the torch side but not inside the fused-L2 chunk kernels. It is now fixed at 1e-6 on both.torch.mm(out_dtype)is missing, the GEMM output is no longer rounded to bf16.eps=1e-5matches between backends (3.4e-7).lower_bound=-5.chunk_bwd_triton_missing: ImportError: ...next tochunk_bwd=torch.l2norm_bwd.save_fwd×concat_proj×chunk_fuse(auto, none, qk_l2norm+gate) matches the reference: fp32 ≤ 1e-6, bf16 7e-3, and varlen fp32 ≤ 1e-6. Withsave_fwd=1,LAST_PIECESshowsrecompute: no (save_fwd).view size is not compatiblein Tritonl2norm.py:94, called fromchunk_delta_attn_bwd. Fixed in 873ada5:_token_majorused.to(dtype, memory_format=contiguous_format), which returns a same-dtype tensor unchanged. In fp32, the channel-major q/k views reached the kernel; bf16 only worked because the cast copied..contiguous()on every dtype, and the layer makes all chunk-kernel inputs (do, q, k, v, g, beta) contiguous before any chunk backward..view()s like Triton reproduces the GPU crash with the old helper and passes with the new one.gemmwastorch.bfloat16->fp32and the padded A_log gradient was 0.lower_bound=-5andchunk_bwd=torch, f_a/f_b/dt_bias got worse (1.0–1.2e-2, vs 0.7e-2 with Triton). Without a lower bound,chunk_bwd=torchimproved the gradients.chunk_bwd=torchnothing fuses the gate, so the gate backward runs in the FlyDSL safe-gate epilogue. That epilogue rounded the fp32lrto bf16, while Triton receives fp32lr @ f_bᵀ.lrgives 2.1–2.5e-3 on d f_b / d dt_bias / d A_log at the gate alone; the hi+lo split gives 3.5e-6. Fixed in ded3d7a.lr, as the layer does.register_proj_gemmhook sees every projection GEMM (forward, recompute, dgrad, wgrad, epilogues, concat).NotImplemented, results are unchanged (2e-6).l2norm row length must be a multiple of 64, got 16. Fixed in 8baabdc with the guarded fallback above; CPU stubs enforcing the real constraints fall back at K=16 (reason recorded, err 5.4e-6) and use FlyDSL at K=64. The stage-diff table skips stages whose constraints a shape cannot meet.lower_bound.defaultis unchanged.internal/kda-megatron-precision-diff.md).test_kda_projgproj_bwd[1] (dW_g, tn), m=100, bf16, had 0.70–0.71% of elements wrong (max 0.10).torch.mm(out_dtype)availability on ROCm), the long rows on GPU (time and memory), the per-piece table on device, and the epilogue numerics.TODO
save_fwd=1); the default stays as recompute until step time and memory are measured on the Lumen benchmarkbench_kimi_tiny_l13_kda.py); the next candidates are a single dx GEMM, 16-bit activations and conv+SiLU+L2normA_log([128] for 96 heads) and the safe gate (lower_bound, K3 -5) through the gate, the GEMM epilogues and the chunk kernelschunk_kda_bwd_flydslshould acceptlower_bound, so the safe gate can be fused there toocu_seqlens, convquery_start_loc)cu_seqlens)_proj_gemm/register_proj_gemm) for MXFP8megatronprecision mode matching the Megatron-LM [Triton/Gluon] [Config] Tune gfx1250 Gluon MXFP4 GEMMs for Llama3 70B TP4 #6872 KDA map (forward roundings, B2 bwd rounding, bf16 conv and norm weights)Dependencies
chunk_kda_bwd_flydsland Tritonchunk_delta_attn_bwd)