Skip to content

test(codegen): validate spill-free two-slot WGMMA counted pipeline - #933

Merged
nihalpasham merged 1 commit into
NVIDIA:mainfrom
uurl:test/wgmma-counted-pipeline-carrier
Aug 17, 2026
Merged

nihalpasham merged 1 commit into
NVIDIA:mainfrom
uurl:test/wgmma-counted-pipeline-carrier

Conversation

@uurl

@uurl uurl commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Fixes #932

Summary

Add a backend feasibility probe for composing the existing register-resident counted WGMMA loop with a two-slot partial-wait pipeline.

The test keeps 64 tied f32 accumulator values live across a counted PTX loop while also carrying:

  • four WGMMA descriptor bases;
  • four affine descriptor increments;
  • one loop trip counter.

Each loop iteration issues two statically assigned accumulator slots, commits both groups independently, and uses wait_group<1> before reusing the slots. A final wait_group<0> drains the remaining asynchronous work.

Why

CUDA Oxide already tests the two required properties independently:

  • wgmma_counted_loop_ptx.rs validates a counted K-loop with one 32-value register-resident accumulator;
  • wgmma_pipeline_carrier_ptx.rs validates two 32-value accumulator slots with partial waits.

The remaining backend risk is their composition.

This test isolates that question before introducing a combined MIR recognizer or NVVM carrier operation.

Validation

Tested with CUDA 13.3 ptxas targeting sm_90a.

wgmma_counted_loop_kernel:
    0 bytes stack frame
    0 bytes spill stores
    0 bytes spill loads
    Used 58 registers

wgmma_pipeline_carrier_kernel:
    0 bytes stack frame
    0 bytes spill stores
    0 bytes spill loads
    Used 90 registers

wgmma_counted_pipeline_carrier_kernel:
    0 bytes stack frame
    0 bytes spill stores
    0 bytes spill loads
    Used 90 registers

The combined probe therefore retains the same reported register count as the existing two-slot straight-line pipeline while adding the counted loop and descriptor recurrences.

The new test also checks that the generated PTX contains:

  • one WGMMA fence;
  • one counted loop;
  • two static wgmma.mma_async instructions;
  • two wgmma.commit_group instructions;
  • two wgmma.wait_group 1 instructions;
  • one final wgmma.wait_group 0;
  • four affine descriptor recurrences;
  • no .local, ld.local, or st.local.

Scope

This PR only adds the backend feasibility test.

It does not change:

  • WGMMA dialect operations;
  • MIR lowering or recognition;
  • public APIs;
  • accumulator scheduling;
  • supported wait depths;
  • supported WGMMA data types or shapes.

A follow-up change can use this result to implement the actual pipelined counted K-loop lowering.

@nihalpasham nihalpasham added enhancement New feature or request tests Adds or improves test coverage codegen Device code-generation pipeline (Rust MIR to IR to PTX) cuda-feature A CUDA hardware/toolkit feature (TMA, tcgen05, WGMMA) labels Aug 17, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

Gist: the feasibility probe #932 asked for: two BF16 WGMMA accumulator slots (64 tied f32 values), four descriptor recurrences, and a trip counter, all live inside one counted inline-PTX loop, checked against ptxas.

What I verified:

  • ran the new test locally: ptxas -arch=sm_90a accepts the loop with 0 bytes stack frame, 0 spill stores/loads, no .local, and the same 90-register footprint as the straight-line two-slot probe
  • operand numbering checks out: 64 =f outputs, 64 tied inputs, 9 l controls at $128-$136, and the descriptor updates go through asm-local .reg .u64 temporaries so no input constraint gets clobbered
  • wait protocol is sound: each wait_group 1 retires the other slot's group before its registers are reused
  • CI fully green

Closes #932 on merge. The lowering itself is #934, reviewed over in #935.

@nihalpasham
nihalpasham merged commit f8c31e5 into NVIDIA:main Aug 17, 2026
44 checks passed
@uurl
uurl deleted the test/wgmma-counted-pipeline-carrier branch August 19, 2026 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codegen Device code-generation pipeline (Rust MIR to IR to PTX) cuda-feature A CUDA hardware/toolkit feature (TMA, tcgen05, WGMMA) enhancement New feature or request tests Adds or improves test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate spill-free two-slot WGMMA counted pipeline lowering

2 participants