Repository navigation
Description
The PyTorch baseline (#106) is +12.4% on the trainer at B=16 with no CUDA graphs, and eager PyTorch is −39.6%. Everything between those two numbers is Inductor. This issue is the enumeration of what Inductor actually did, taken from its own debug dump on our model, and mapped kernel-for-kernel onto gpu/model's launch sequence.
No implementation here. The deliverable is the classified table and the ranking.
How it was measured
torch.compile(mode="default"), TORCH_COMPILE_DEBUG=1, B=16, three steps, TORCHINDUCTOR_FX_GRAPH_CACHE=0 so codegen actually ran. torch 2.13.0+cu130, one B200, bf16 masters, cuda_graphs=False, 87,300 tok/s under the tracer (vs 91,669 untraced — the tracer costs, the codegen does not change). Three graphs came out:
| graph | triton kernel variants | total launches |
|---|---|---|
model__0_forward_1 |
22 | 283 |
model__0_backward_3 |
23 | 333 |
model__1_inference_4 (the compiled MasterAdamW step) |
10 | 87 |
| 55 | 703 |
Against the trainer's measured launch sequence at the same shape (L=12 B=16 T=2048 N=32768 D=3072 H=24 HD=128 E=8 K=2 FF=4096 C=8192 VP=50432):
| forward | backward | optimizer | total | |
|---|---|---|---|---|
| Inductor | 283 | 333 | 87 | 703 |
| trainer | 415 | 703 | 88 | 1206 |
At default mode Inductor does not touch the GEMMs — every matmul is extern_kernels.mm / bmm and attention is aten::_scaled_dot_product_flash_attention. Its entire contribution is the glue: 55 generated Triton kernels covering every elementwise, reduction, scatter/gather and cast in the model.
Shape reference used throughout (MiB, B=16):
| tensor | fp32 | bf16 |
|---|---|---|
[N, D] |
384 | 192 |
[N, 3D] |
1152 | 576 |
[E, C, D] |
768 | 384 |
[E, C, 2FF] |
2048 | 1024 |
[E, C, FF] |
1024 | 512 |
[N, VP] |
6304 | 3152 |
1. The inventory
31 fusion groups. Classification counts: 13 ALREADY-FUSED, 8 APPLICABLE, 4 SUPERSEDED-BY-BF16, 6 NOT-APPLICABLE.
1.1 Embedding and classifier
| # | Inductor kernel | what it fused | trainer counterpart | class |
|---|---|---|---|---|
| 1 | triton_red_fused__fused_rms_norm__to_copy_embedding_0 |
embedding + to(bf16) + rms_norm, one launch, writes both the residual and the normalized row |
embedding_forward → rms_norm_forward_tile, 2 launches, [N,D] fp32 round-trip between them |
APPLICABLE (A7) |
| 2 | triton_red_fused__log_softmax_prepare_softmax_online_slice_20 |
online max+logsumexp over [N, VOCAB] read out of the [N, VP] panel with a stride — the clone of the slice is elided, no fp32 logits, no softmax buffer |
fused_classifier_forward_bf16 does it in one pass; Inductor needs two over 3.08 GiB |
ALREADY-FUSED (trainer ahead) |
| 3 | triton_red_fused..._nll_loss_forward_slice_view_21 |
second logits pass + nll gather + all 12 aux losses summed + coefficient * aux + final add + the 1/N — one kernel, one scalar out |
sum + scale + 12×(moe_probability_sums, moe_aux_loss) = 26 launches, moe_aux_loss at 1 thread |
APPLICABLE (A6) |
| 4 | triton_red_fused__log_softmax__log_softmax_backward_data...nll_loss_backward..._0 |
recompute log_softmax from the saved (amax, logsumexp) pair + nll backward → dlogits |
fused_classifier_backward_in_place_bf16 — in place over the logits buffer, no dlogits allocation at all |
ALREADY-FUSED (trainer ahead) |
| 5 | triton_poi_fused_slice_backward_1 |
zero-pads dlogits [N, VOCAB] → [N, VP]: reads 3.08 GiB, writes 3.15 GiB, 6.2 GiB for 175 columns |
the fused classifier is handed VOCAB and VP separately and writes at VP width | NOT-APPLICABLE (PyTorch artifact) |
| 6 | triton_poi_fused_embedding_dense_backward_20/21/22 |
scatter-add of the embedding gradient | embedding_backward_scatter, atomics, 1 launch |
NOT-APPLICABLE (parity) |
1.2 Attention glue
| # | Inductor kernel | what it fused | trainer counterpart | class |
|---|---|---|---|---|
| 7 | triton_poi_fused__to_copy__unsafe_view_add_mul_split_stack_sub_unbind_view_1 |
qkv split + RoPE(q) + RoPE(k) + fp32 rotate + to(bf16) + head relayout, both q and k in one launch, and V is never copied — flash gets reinterpret_tensor(qkv, …, stride 9216, offset 6144) |
stage_qkv_heads_bf16 — same fusion, already landed in #88/#90. Difference: the trainer does materialize a V panel, and reads a fp32 [N,3D] GEMM output where Inductor reads bf16 |
ALREADY-FUSED; V-elision → A8 |
| 8 | triton_poi_fused__to_copy_add_cat_mul_neg_select_stack_transpose_view_16 |
inverse RoPE on dQ and dK + 3-way concat with dV + transpose into the [N, 3D] weight-GEMM operand |
join_group3_rope_bf16 — the same kernel, #89 |
ALREADY-FUSED |
| 9 | — (no counterpart) | Inductor's flash backward extern takes dY directly: no row-dot pass, no dY staging pass | flash_attention_backward_dot and stage_attention_heads_bf16 are two launches that read d_model_0 back-to-back |
APPLICABLE (A3) |
1.3 Norm and residual — the largest group
| # | Inductor kernel | what it fused | trainer counterpart | class |
|---|---|---|---|---|
| 10 | triton_red_fused__fused_rms_norm__to_copy__unsafe_view_add_{2,17,18,19} |
residual add + rms_norm in one launch, 4 boundary variants, ×23 sites | add then rms_norm_forward_tile, always two launches. The MoE side already folds the residual into moe_gather_combine_add_quad, but the norm after it is still separate |
APPLICABLE (A2) |
| 11 | triton_per_fused__fused_rms_norm__fused_rms_norm_backward__to_copy_{view_2,add_view_15,add_view_17,..._19} |
rms_norm backward dx + the residual-branch add + the dW column partials, all in one launch. Reads x and dy exactly once | rms_norm_backward_x_fast → rms_norm_backward_weight_fast → add: three launches, x and dy read twice, plus a norm_backward_inv fp32[N] buffer written only to be re-read |
APPLICABLE (A1 — top item) |
| 12 | triton_poi_fused__fused_rms_norm__to_copy_t_view_12 |
recomputes the MoE RMSNorm forward in the backward, from the saved residual + rsqrt, and writes it already transposed and in bf16 as the router dW operand. ffn_normalized is never saved |
the trainer saves ffn_normalized fp32 [N,D] in every one of the 12 GpuBlockActs — 4.5 GiB held all step for one backward read |
APPLICABLE (A5, memory-shaped) |
1.4 MoE routing
| # | Inductor kernel | what it fused | trainer counterpart | class |
|---|---|---|---|---|
| 13 | triton_per_fused__softmax_prepare_softmax_online_3 + extern topk + the renorm folded into #17 |
softmax (in place on the logits buffer), then top-k as a separate extern, then the gate renormalization deferred | router_softmax_topk does softmax + top-k + renorm in one launch |
ALREADY-FUSED (trainer ahead) |
| 14 | triton_red_fused__to_copy_arange_cumsum_div_eq_sum_unsqueeze_view_5 |
one_hot + cumsum + per-expert counts + the aux-loss fractions |
folded into moe_bin_assign_parallel + assignment_counts |
ALREADY-FUSED |
| 15 | triton_per_fused__to_copy_add_arange_clamp_eq_lt_mul_scalar_tensor_sub_sum_unsqueeze_view_where_6 |
slot index + kept mask + destination + clamp | same kernel | ALREADY-FUSED |
| 16 | triton_poi_fused..._index_copy_index_select_..._9 + triton_poi_fused__to_copy_slice_view_10 |
dispatch gather + scatter into fp32 bins, then a separate fp32→bf16 cast of the whole [E,C,D] panel |
moe_scatter_bf16_quad scatters straight to packed bf16 — no fp32 bin, no cast launch |
ALREADY-FUSED (trainer ahead) |
| 17 | triton_poi_fused__to_copy_div_index_select_mul_sum_unsqueeze_view_13 |
top-k renorm + drop mask + expert-output gather + gate multiply | moe_gather_combine_add_quad does all of that plus the residual add |
ALREADY-FUSED (trainer ahead) |
| 18 | triton_red_fused__to_copy_div_index_select_mul_sum_unsqueeze_view_4 |
combine backward: gather dY + gate multiply + the per-pair gate-gradient row dot | moe_scatter_dy_bf16 — same, plus the bf16 round |
ALREADY-FUSED |
| 19 | triton_poi_fused__to_copy_index_add_index_select_new_zeros_view_8 |
dispatch backward gather/scatter | moe_gather_dx_add_quad — same, plus the router-dx add |
ALREADY-FUSED (trainer ahead) |
| 20 | triton_poi_fused..._scatter_squeeze_sum_view_10 + triton_per_fused__softmax_backward_data..._11 |
gate/top-k backward scatter, then softmax backward + aux-loss gradient. Two launches | router_backward does gate renorm backward + softmax backward + aux gradient in one |
ALREADY-FUSED (trainer ahead) |
| 21 | — | Inductor's router dW is a single mm against the recomputed transposed norm |
router_backward_weight_split writes a 25 MiB [256,E,D] partial buffer that router_backward_weight_merge immediately reads |
APPLICABLE (A4) |
| 22 | triton_poi_fused_new_zeros_8/12, triton_poi_fused_new_zeros_5, _scatter_9 |
zero-fills. Inductor zeroes the entire [E·C+1, D] fp32 bin buffer — 768 MiB per layer, ~9 GiB/step |
moe_zero_dead_bins_bf16 clears only the dead capacity tail |
NOT-APPLICABLE (trainer strictly ahead) |
| 23 | triton_red_fused__assert_async_all_ge_lt_view_4 |
F.one_hot's bounds assertion, ×12 |
none | NOT-APPLICABLE |
| 24 | triton_poi_fused_arange_clone_expand_unsqueeze_7 |
the sources arange, CSE'd to a single launch across all 12 layers |
none needed | NOT-APPLICABLE |
| 25 | triton_red_fused_mean_14, _15, triton_per_fused_mean_mul_sum_16 |
aux-loss probability mean, two-stage split reduction | moe_probability_sums + moe_aux_loss — but the trainer's moe_aux_loss is a 1-thread grid, ×12 |
APPLICABLE (A6) |
1.5 Expert FFN
| # | Inductor kernel | what it fused | trainer counterpart | class |
|---|---|---|---|---|
| 26 | triton_poi_fused_mul_silu_split_11 |
split the interleaved [E,C,2FF] GEMM output + silu(gate) * up, one pass, bf16 in / bf16 out |
swiglu_forward_interleaved_bf16 — same fusion. The trainer's input is fp32 (2048 MiB vs 1024) |
ALREADY-FUSED; dtype → S3 |
| 27 | triton_poi_fused_cat_mul_silu_silu_backward_split_6 |
silu′ + the dgate/dup product + the concat of both halves into one interleaved panel | swiglu_backward_interleaved_bf16 — same |
ALREADY-FUSED; dtype → S3/S5 |
| 28 | extern_kernels.bmm |
all 8 experts in one batched launch (2 fwd, 4 bwd per layer) | expert_linear_forward / expert_linear_backward loop E=8 on the host: 16 fwd + 32 bwd launches per layer |
APPLICABLE (A-launch, batching not fusion) |
1.6 Optimizer
| # | Inductor kernel | what it fused | trainer counterpart | class |
|---|---|---|---|---|
| 29 | triton_poi_fused__to_copy_add_copy_copy__div_fma_mul_sqrt_sub_0..9 |
the whole AdamW update for one parameter in one launch — m/v in place, fp32 arithmetic on a widened bf16 master, fma for both moments, round back to bf16. 10 codegen variants, 87 launches (one per parameter) |
adamw_bf16_master_transposed already fuses update + round + the transposed compute operand + zeroing the gradient. 88 launches |
ALREADY-FUSED (parity) |
| 30 | — (no zero_grad kernel exists) | set_to_none=True frees the gradients: zero bytes |
AdamW clears the gradient it consumed: zero bytes | ALREADY-FUSED (parity, and #99 is closed) |
| 31 | — | Inductor never writes a transposed weight copy; reinterpret_tensor(w, (K,N), (1,K)) hands cuBLAS the transposed view |
transpose_bf16_pairs for the lm-head, plus the transposed operand written inside every adamw_bf16_master_transposed. Deliberate (lib.rs:2697 measures the fused alternative at 3.93 ms vs 0.68+0.22) |
NOT-APPLICABLE (tcgen05 descriptor constraint, decided) |
2. Ranking of the APPLICABLE items
Bytes are DRAM traffic eliminated per step at B=16 (writes + reads of the intermediates that disappear). Launches are per step. No timing runs — these are shape arithmetic.
| # | fusion | Rust kernels that merge | GiB/step | launches |
|---|---|---|---|---|
| A1 | RMSNorm backward absorbs the dW pass and the residual add | rms_norm_backward_x_fast + rms_norm_backward_weight_fast + add → one kernel (gpu/ops :397, :563; lib.rs:2409/2422, 4800/4810, 4876/4889, 5268) |
36.75 | 49 |
| A2 | RMSNorm forward absorbs the residual add / is absorbed by the gather-combine | add + rms_norm_forward_tile (lib.rs:4438/4447); moe_gather_combine_add_quad + rms_norm_forward_tile (lib.rs:4569, next block :4388) |
9.00 | 24 |
| A3 | Flash-backward row dot folds into the dY staging pass | flash_attention_backward_dot + stage_attention_heads_bf16 (lib.rs:6203, :6220) — both read d_model_0 back to back |
4.50 | 12 |
| A4 | Router dW as one accumulating GEMM instead of split+merge | router_backward_weight_split + router_backward_weight_merge (ops:3451, :3529) — the MN-major TMA-view trick already used for the head (lib.rs:3994) removes the partial buffer |
0.59 | 12 |
| A5 | Recompute ffn_normalized in the backward instead of saving it |
drop it from GpuBlockActs (lib.rs:3805); recompute inside the norm backward, transposed, as Inductor's _t_view_12 does |
~0 (4.5 GiB VRAM) | 0 |
| A6 | Collapse the aux-loss / loss tail | 12× moe_aux_loss (1-thread grid, ops:2421) + sum + scale (lib.rs:5168, 6456, 6464) fold into the classifier reduction; the 12 moe_probability_sums batch into one launch |
~0.01 | 24 |
| A7 | Embedding gather + RMSNorm in one launch | embedding_forward + rms_norm_forward_tile (lib.rs:2465, 5079, :2374) |
0.38 | 1 |
| A8 | Stop materializing the V head panel | stage_qkv_heads_bf16 (flash-attn/src/lib.rs:168) writes a V panel flash could address in place. Hard — needs flash's TMA descriptor over the qkv panel, which is fp32 row-major [N,3,D]; #88 already declined the GEMM-epilogue half of this |
6.75 (if reachable) | 0 |
| A9 | Batch the E=8 expert GEMM loop (batching, not fusion) | expert_linear_forward lib.rs:1579, expert_linear_backward :1672/:1690 — 576 launches where a batched form is 72 |
0 | 504 |
Actionable total: ~51 GiB/step and ~560 launches removed (~626 with A9).
Two honest caveats. The launch column does not convert to time linearly — at 1206 launches over a ~360 ms step the average kernel is 300 µs and launch latency is mostly hidden; the exception is the 1-thread moe_aux_loss and the other sub-microsecond kernels in A6, where launch cost is the kernel. And #63 already recorded that no single non-GEMM kernel exceeds ~2.1% of step — this is a many-small-wins area, which is exactly what the table shows: one item worth ~36 GiB and eight worth ~15 GiB between them.
3. SUPERSEDED-BY-BF16
These chains exist in the trainer only because a buffer is fp32 where Inductor's is bf16. The bf16-activation work retires them; they are not fusion targets. Listed because together they are larger than the entire fusion table, which is worth knowing before anyone prices A1–A9 against them.
| # | trainer buffer / kernel | fp32 today | bf16 | GiB/step |
|---|---|---|---|---|
| S1 | convert_f32_to_bf16_pairs — 5 per layer (lib.rs:904, 953, 959, 1131, 1191) + head quantize/dequantize (5121, 5261). Inductor has none: its producers already write bf16 |
62 launches | 0 | 34.9 |
| S2 | acts.experts.gate_up [E,C,2FF] — written by the GEMM, read by SwiGLU forward, read again by SwiGLU backward (#59 item 1) |
2048 MiB | 1024 | 36.0 |
| S3 | scratch.qkv [N,3D] — the GEMM epilogue's output, read once by stage_qkv_heads_bf16. Inductor's mm writes bf16 (#80's epilogue question) |
1152 MiB | 576 | 13.5 |
| S4 | scratch.experts.d_activated [E,C,FF] and d_bin_input [E,C,D] — each written by one GEMM, read by exactly one kernel (#59 items 2/3) |
1792 MiB | 896 | 21.0 |
~105 GiB/step, against the fusion table's ~51.
4. Buffer planning — what Inductor does that the workspace does not
The workspace (GpuMoeWorkspace, lib.rs:3934) never reuses an allocation: every field is its own cuMemAlloc, held for the whole run, and TMA descriptors are encoded against fixed device addresses (lib.rs:1508, 3992, 588) so any future allocator must preserve addresses or re-encode maps. Reuse is structural — one shared GpuBlockScratch for all 12 blocks, the d_model_0..4 set hand-rotated like registers, linear_scratch.rows deliberately not rewritten between the weight and input GEMMs. That is genuinely good and gets most of the benefit. What the dump shows on top of it:
Allocation counts. The backward runs 333 launches on 58 fresh allocations with 263 buffers rebound to an existing one (buf36 = buf8; del buf8 # reuse). The forward: 220 allocations, 141 reuses. Peak 95.5 GiB at B=16.
-
True in-place kernels. Inductor marks
in_out_ptr0and mutates: the router softmax runs in place on the logits buffer; the AdamW kernel mutatesm,vand the master in place; the norm backward'sin_outis the incoming gradient. The trainer has exactly one in-place kernel —fused_classifier_backward_in_place_bf16— and it is the right idea applied once. -
Views instead of copies (
reinterpret_tensor, 245 uses forward / 206 backward). The one that matters: V is a strided view into the qkv panel, so V costs zero bytes and zero kernels on both the forward and the operand-prep path. The trainer's equivalent already exists in a different form — the four persistent TMA descriptors that give K-major and MN-major views of the same head bytes (lib.rs:3994) — but it is used only for the head, not for the block linears or the attention panels. -
A reused scratch workspace for reductions. Every rms_norm backward writes its dW column partials into a
workspace_Nthat is threaded through all 25 sites by rebinding (workspace_1 = workspace_0). One allocation, 25 users. The trainer's analogue,router_dweight_partials, is a dedicated 25 MiB buffer used by one kernel pair, and the norm dW path uses atomics instead of a partial buffer at all. -
Recompute chosen over saving (§1.3 Fuse packed QKV projection for milestone 7e1 #12).
ffn_normalizednever exists; it is regenerated from the residual and the rsqrt, in bf16 and transposed, at the point of use. That is a memory decision the workspace has no mechanism to express — everyGpuBlockActsfield is allocated whether or not the backward reads it once or never. -
Gradients freed, not zeroed.
set_to_none=Truemeans the gradient tensors do not exist between steps; the trainer folds zeroing into AdamW, which costs the same zero bytes but keeps 4.39B parameters' worth of gradient storage resident. Traffic parity, VRAM difference.
5. Things in the dump that were not expected
-
Inductor does not materialize fp32 logits. An external reference for the trainer's MFU: the same model and precision policy in PyTorch — +12.4% at B=16, +0.99% at the matched B=32 #106's body says
F.cross_entropymaterializes them. It does not: the logits stay bf16[N, VP](3.08 GiB), the log-softmax result is never written at all — only a per-row max and logsumexp,[N]fp32 each — and the backward recomputes the softmax from that pair. The trainer's fused classifier is still ahead (one pass vs two, and an in-place backward), but the margin is one extra read of 3.08 GiB, not a 6.16 GiB fp32 buffer. -
Inductor spends 6.2 GiB per step on
slice_backward. Padding dlogits from VOCAB back to VP is a full read-and-write of the logit panel, and Inductor did not eliminate it. That is roughly 1.2 ms of pure waste it is carrying, and the trainer does not have it. Whatever the 12.4% is made of, some of it is being given back here. -
It recomputes the MoE norm rather than saving it, and fuses the transpose into the recompute. The trainer saves the same tensor in fp32 in all 12 blocks. This is the one place the dump inverts the usual assumption that the compiled baseline is trading memory for speed.
-
Inductor zeroes 768 MiB of expert bins per layer where
moe_zero_dead_bins_bf16clears only the tail — about 9 GiB/step the trainer already does not pay. -
The routing chain is the trainer's strongest area, not its weakest. Of the 9 MoE groups, 7 are ALREADY-FUSED with the trainer ahead:
router_softmax_topkbeats softmax+topk+deferred-renorm,moe_scatter_bf16_quadbeats scatter-to-fp32-then-cast,moe_gather_combine_add_quadandmoe_gather_dx_add_quadeach carry a residual add Inductor leaves separate, androuter_backwardis one kernel where Inductor needs two. Router fp32 kernels run ~30x off bandwidth-bound at D=3072 #44/moe_scatter_dy: one thread per slot serializes a 3072-float row copy + dot #45/Router phase 2: weight-reuse pass for backward input/weight #54/scatter_dy phase 2: vectorized row copy + fold zero_dy_bins #55 did their job. -
The gap is concentrated in one op. RMSNorm accounts for A1 + A2 = 45.75 of the ~51 actionable GiB. Inductor writes one kernel for
residual + rms_normand one forrms_norm_backward + residual_add + dW; the trainer writes five. Nothing else on the list is close. -
Launch count is dominated by something that is not a fusion at all. 576 of the trainer's 1206 launches are the
E=8expert-GEMM loop unrolled on the host, against 72bmmcalls. It is invisible in the profile because all 8 sit inside oneprofiler.measurespan.
Reproducing the dump
Add to modal_app.py (this was done on the pytorch-throughput-baseline branch in a throwaway worktree and not pushed):
@app.function(gpu=DEFAULT_GPU, image=torch_image, timeout=4*3600, volumes={"/data": wiki_volume})
def torch_inductor_dump(batch: int = 16, steps: int = 2, warmup: int = 1) -> None:
environment = dict(os.environ, TORCH_COMPILE_DEBUG="1",
TORCH_COMPILE_DEBUG_DIR="/data/inductor-debug",
TORCHINDUCTOR_FX_GRAPH_CACHE="0", TORCHINDUCTOR_AUTOGRAD_CACHE="0")
subprocess.run(["python", "/root/pytorch_baseline.py", "--batch", str(batch),
"--steps", str(steps), "--warmup", str(warmup),
"--compile", "default", "--random-tokens"], cwd="/root", env=environment, check=True)Then tar the directory onto the volume and modal volume get. The useful files per graph are output_code.py (the launch sequence with every buffer's shape, dtype and reuse), ir_pre_fusion.txt / ir_post_fusion.txt (what merged into what), and fx_graph_readable.py (the saved-activation list, which is what settles save-versus-recompute).
Activity
The router weight gradient's loads share a basic block, and 64 partit…
Merge pull request #109 from feitreim/fusion-a6-aux-loss-tail
Merge pull request #112 from feitreim/a9-batch-expert-gemm
Merge pull request #113 from feitreim/rmsnorm-fusions
feitreim commentedon Aug 6, 2026
A8 — implemented, in #118. The descriptor was never the obstacle.
The item's own framing is what needs correcting first, because it is the reason
A8 sat marked HARD for the whole campaign.
Right about the panel, wrong about what blocks it. Two facts already in the tree
when this was written:
Tcgen05Gemm::storewrites a packed-bf16C. The qkv projection calledf32_storeonly because its consumer read fp32.kittens::global::GlobalLayout::stridedencodes a strided view at rank 1through 5. Nothing about a descriptor requires a densely packed operand.
And what the staging pass actually did to V's third of the panel was: read it
fp32, round it to bf16, transpose token against head. Nothing else — RoPE is
Q and K's, the scale is Q's, nothing accumulates. A packed epilogue already
rounds and a descriptor already transposes. So the question was never "can a
descriptor address V inside the fp32 panel" — it cannot, and that is a real
constraint — but "can V's group have its own bf16 destination", which needed no
new machinery at all.
#118 splits the qkv projection into two GEMMs over the one transposed weight
operand, read through descriptors over its two row bands: Q/K into the fp32
[N, 2D]panel the rotate-and-stage pass still needs, V's group's packed bf16straight into the saved panel flash reads. Flash addresses head
has a columnband of that row-major panel through a rank-3 strided layout over
[HD, B*T, H]at strides
[1, H*HD, HD];(batch, token)folds into the row coordinatebecause
batch * T + tokenis the row index, so the kernels change by theircoordinates alone. The driver accepts the non-monotonic strides (head stride
256 B inside a 6144 B row stride) — verified on device.
This is not the epilogue half #88 declined. #88 rejected fusing RoPE into
the epilogue (MN-major tile mapping, rotations crossing column pairs inside a
tile). Nothing is fused into the epilogue here.
Bit-exact: splitting the output's
Nleaves each tile's K walk alone, so V'sfp32 accumulator is the unsplit GEMM's to the bit and the epilogue's RNE lands
where
f32_to_bf16_rnedid. The flash harness's exact-match gate stays exact,now over Q/K, and every tcgen05 parity shape feeds V through the new descriptor
against a head-major CPU reference.
The pricing needs correcting too
A8 was priced at 6.75 GiB/step. The real figure is larger — the GEMM's fp32 V
store goes with it, so it is
8 · N · Dbytes a block, 9 GiB/step at B=16 and18 GiB/step at B=32 — and the time is much smaller than either. Same-container
profile at B=32:
forward.qkv_proj.gemm(+ newgemm_v)forward.attention.stage_qkv→stage_qkforward.attention.flashbackward.attention.flash_kvThe qkv GEMM is not store-bound at this shape. Halving a third of its output
bytes bought nothing measurable, and the split's extra wave gave 0.37 ms back —
so only the staging third of the 18 GiB converts, at −1.07 ms. Net −0.70 ms of a
720 ms step.
train_abover six paired rounds in two containers reads+0.39% (baseline 92013.7, candidate 92369.4 tok/s), candidate ahead in 5 of 6.
That number is worth carrying back into §2's table as a calibration: the ranking
converts DRAM bytes to time at a fixed rate, and this item shows the rate is not
fixed. A1/A2's 45.75 GiB were bytes moved by bandwidth-bound elementwise
kernels and #113 duly collected them; A8's bytes were two thirds inside a GEMM
epilogue that is pipeline-bound, and those two thirds did not convert. Anything
else on the list whose bytes live inside a GEMM's
C— S1's quantize chain andS3 most obviously — should expect the same discount before being scheduled.
The descriptor result is the durable part: a strided view into a projection's
output panel is a working flash operand, at no cost to the flash kernels (all
three flash rows flat or better, registers 128/128/138 with zero spill, forward
residency unchanged at 2 CTA/SM). That unblocks the Q/K half too, if RoPE is ever
folded somewhere else — the panel addressing is no longer the reason not to.
With this, every APPLICABLE item in §2 is landed or has a PR.
V is read where its GEMM left it, because a descriptor transposes and…
Merge pull request #118 from feitreim/a8-elide-v-panel