Repository navigation
Description
Title: Value-threaded WGMMA accumulator lowering for pipelined use (wait_group, multiple groups in flight)
Labels: enhancement, cuda-feature, IR-lowering, perf
Follow-up to #598, which landed the first working WGMMA MMA lowering. That lowering fuses the whole fence/MMA/commit/wait sequence into one PTX asm block and round-trips the 32 per-thread accumulator values through memory on either side:
asm {
ld.f32 x32 acc -> regs
wgmma.fence
wgmma.mma_async
wgmma.commit_group
wgmma.wait_group 0
st.f32 x32 regs -> acc
}
That shape is sound by construction, but it forecloses everything that makes WGMMA fast in practice:
- only
wait_group<0>(no partial waits), - one group in flight at a time,
- a 32-load + 32-store memory round-trip per fused region, so a K-loop pays it every iteration.
CUTLASS and Triton instead thread the accumulator through registers as a value across separate asm statements, which enables register-resident K-loops, multiple groups in flight, and wait_group<N>. We should get there too, with two prerequisites to solve:
- Aggregate SSA. Rust MIR keeps the address-taken
[[f32; 8]; 4]accumulator in memory; we have no machinery to promote it to 32 SSA scalars across the region. Related local-aggregate work: Small runtime-indexed local arrays spill to PTX local memory #397, Scalarize small local arrays consumed through iterator adapters #399, Promote Copy aggregate arguments borrowed only by inlined device methods #400. - Spill soundness. Naive value threading across separate asm blocks is unsound at the LLVM layer: nothing stops LLVM from spilling the in-flight accumulator vregs between the
mma_asyncasm and thewait_groupasm, which the PTX ISA forbids. The design must either fuse larger regions (fence through wait including intervening descriptor arithmetic) or find a representation LLVM provably cannot spill mid-flight.
Acceptance sketch:
- a K-loop with descriptor offset arithmetic between MMAs keeps the accumulator in registers across iterations (no per-iteration ld/st of the accumulator),
wait_group<N>with N > 0 lowers, allowing multiple groups in flight,- the existing deferred-accumulator path remains the fallback for shapes the value-threaded path cannot prove.
Activity
nihalpasham commentedon Aug 2, 2026
Assigned to @uurl
uurl commentedon Aug 6, 2026
Tentative implementation plan
I plan to implement this issue as a sequence of six reviewable PRs.
The boundaries are provisional and may change based on review feedback or
findings from the loop and pipeline legality work.
Backend feasibility — test(codegen): validate spill-free 32-value WGMMA carrier #679
f32accumulator inputs/results through oneconvergent inline-PTX region.
m64n64k16WGMMA sequence forsm_90a.ptxasspills.Value-form accumulator carrier
Linear pointer-to-value adapter
Register-resident canonical K-loop
Partial waits and multiple groups in flight
wait_group<N>forN > 0.wait_group<0>before accumulator values escape.Selection, fallback, and hardening
This is the current decomposition, not a commitment to immutable PR
boundaries. The ordering reflects the technical dependencies: backend
feasibility, value representation, linear adaptation, loop fusion,
partial waits, and final integration.
uurl commentedon Aug 7, 2026
The PRs are ready for review @nihalpasham
Thanks 😀