Skip to content

feat(wgmma): add 32-value SSA accumulator carrier - #685

Merged
nihalpasham merged 2 commits into
NVIDIA:mainfrom
uurl:feat/605-wgmma-value-op
Aug 8, 2026
Merged

nihalpasham merged 2 commits into
NVIDIA:mainfrom
uurl:feat/605-wgmma-value-op

Conversation

@uurl

@uurl uurl commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

This PR is stacked on #679 and is the second of six planned PRs for #605.

Summary

Add an internal value-form BF16 WGMMA group that carries the 32 per-thread
f32 accumulator values explicitly through SSA operands and results.

The new nvvm.wgmma_mma_group_values_m64n64k16_f32_bf16 operation:

  • takes 32 f32 accumulator values followed by one or more u64
    descriptor pairs;
  • returns 32 f32 accumulator values;
  • lowers the complete fence/MMA+/commit/wait_group<0> sequence into one
    convergent inline-PTX region;
  • ties each accumulator input to its corresponding output register;
  • does not materialize the accumulator through ld.f32 / st.f32 inside
    the WGMMA lifetime.

The existing pointer-form deferred group remains unchanged and available as
the fallback path.

Motivation

#679 established that a real BF16 m64n64k16 WGMMA can carry all 32
per-thread accumulator values through tied inline-asm operands/results and
reach ptxas for sm_90a without spills.

This PR turns that feasibility result into an internal dialect operation and
production lowering that later transformations can use to keep accumulators
register-resident across WGMMA regions.

Implementation

  • Add WgmmaMmaGroupValuesM64N64K16F32Bf16Op.
  • Verify:
    • exactly 32 f32 accumulator operands;
    • exactly 32 f32 results;
    • one or more descriptor pairs;
    • all descriptors are u64.
  • Register the new handwritten NVVM operation.
  • Add its MirToLlvmConversion implementation.
  • Lower it to one convergent inline-PTX statement with:
    • 32 =f outputs;
    • tied input constraints 0..31;
    • l constraints for descriptors;
    • a memory clobber.
  • Extract the 32 LLVM aggregate results back into individual SSA values.
  • Add dialect and lowering coverage for the new operation.

Validation

dialect-nvvm:
  50 passed

mir-lower:
  166 unit tests passed
  90 integration tests passed

cuda-oxide-codegen:
  137 unit tests passed
  integration tests passed

The WGMMA backend feasibility test from #679 was also re-run successfully:

ptxas info : Compiling entry function 'wgmma_value_carrier_kernel' for 'sm_90a'
0 bytes stack frame
0 bytes spill stores
0 bytes spill loads
Used 58 registers

git diff --check is clean.

Scope

This PR does not yet:

  • adapt the existing accumulator pointer path to the value-form operation;
  • change selection or fallback behavior;
  • recognize or fuse a counted K-loop;
  • support partial wait_group<N> values;
  • keep multiple committed groups in flight.

Those are left to subsequent PRs.

@uurl
uurl force-pushed the feat/605-wgmma-value-op branch from 4b9966a to 166b49e Compare August 7, 2026 09:20
@nihalpasham nihalpasham added enhancement New feature or request perf Performance of generated code or of the compiler itself IR-lowering Lowering between dialects (dialect-mir to LLVM dialect) intrinsics Device intrinsics and libdevice math mappings cuda-feature A CUDA hardware/toolkit feature (TMA, tcgen05, WGMMA) wgmma-value-path PR series threading WGMMA accumulators through registers (#605) labels Aug 8, 2026
… ptxas

The carrier probe from NVIDIA#679 only ever assembled a single wgmma.mma_async
under one fence/commit/wait. The value-form lowering template chains
multiple MMAs inside the same asm region, so the feasibility claim needs
a chained probe too.

Parametrize the carrier harness on mma_count (kernel builder, template,
constraints, and assertions) and add a second test that builds the
mma_count = 2 shape: two chained wgmma.mma_async instructions under one
fence/commit/wait, one descriptor pair per MMA. ptxas must assemble the
sm_90a PTX with zero spill bytes while keeping all 32 accumulators live.
@nihalpasham

Copy link
Copy Markdown
Collaborator

Gist: Step 2 of the #605 plan: an internal operation that carries all 32 accumulator values as plain values instead of behind a pointer, so later steps can keep them in registers across a WGMMA region. Nothing user-facing routes onto it yet, so merging it is risk-free by construction.

I pushed one commit on top:

Merging (start of the stack; #686-#689 follow in order).

@nihalpasham
nihalpasham merged commit 228dc7b into NVIDIA:main Aug 8, 2026
36 checks passed
nihalpasham added a commit to uurl/cuda-rust that referenced this pull request Aug 8, 2026
nihalpasham added a commit to uurl/cuda-rust that referenced this pull request Aug 8, 2026
@uurl
uurl deleted the feat/605-wgmma-value-op branch August 10, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda-feature A CUDA hardware/toolkit feature (TMA, tcgen05, WGMMA) enhancement New feature or request intrinsics Device intrinsics and libdevice math mappings IR-lowering Lowering between dialects (dialect-mir to LLVM dialect) perf Performance of generated code or of the compiler itself wgmma-value-path PR series threading WGMMA accumulators through registers (#605)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants