Repository navigation
feat(wgmma): support partial waits with multiple groups in flight - #688
Merged
nihalpasham merged 8 commits intoAug 8, 2026
Merged
Conversation
Signed-off-by: Raul Estrada <[email protected]>
Signed-off-by: Raul Estrada <[email protected]>
Signed-off-by: Raul Estrada <[email protected]>
Signed-off-by: Raul Estrada <[email protected]>
Signed-off-by: Raul Estrada <[email protected]>
Replace the bare u32 IntegerAttr on nvvm.wgmma_mma_pipeline_values_m64n64k16_f32_bf16 with a first-class WgmmaMaxPendingAttr(u8) defined via #[pliron_attr] and declared on the op through the attributes = (...) macro slot. The 1..=7 invariant now lives on the attribute's own Verify impl; the op verifier requires the attribute and delegates the range check, so N=0 and N>7 are rejected with a clear message. The u8 depth is threaded through the mir-lower pipeline plan and template, and ops_test asserts the rejection messages for 0, 8, and a missing attribute plus the attribute's own verify bounds.
… pipeline pass Same shapes fixed on the 686/687 branches: two question-mark rewrites, one redundant into_iter, and the house-style too_many_arguments allow on apply_value_plan; keeps this head's clippy CI green until the stack rebase collapses the shared file.
Collaborator
|
Gist: Step 5: partial waits ( I pushed one commit on top:
Merging after #687. |
nihalpasham
approved these changes
Aug 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is the fifth of six planned PRs for #605 and builds on the register-resident counted K-loop path introduced by #687.
Summary
Add value-threaded BF16 WGMMA support for statically known partial
wait_group<N>values and multiple committed groups in flight.The new path recognizes a restricted, provably safe pipelined sequence and
fuses the complete asynchronous lifetime into one convergent inline-PTX
statement.
For
wait_group<1>, the supported shape is conceptually:The lowering keeps two independent 32-value accumulator slots alive across the
pipeline and only exposes them back to LLVM after the final full wait.
Motivation
The previous PRs established:
Those paths still fully drain the asynchronous WGMMA lifetime with
wait_group<0>before accumulator values escape.To allow multiple groups to remain in flight, the lowering must support partial
waits while preserving the PTX accumulator lifetime rules. In particular, an
accumulator belonging to a still-pending WGMMA group must not be reused before
the corresponding wait makes that slot safe again.
This PR adds that legality model for a narrow static pipeline.
Accumulator slot model
A partial-wait pipeline uses:
independent accumulator slots.
For
wait_group<1>, that means two 32-value accumulator sets:Groups are assigned to slots round-robin.
A slot may only be reused after the preceding
wait_group<1>has retired enougholder groups to make that accumulator set safe again.
This avoids reusing the same accumulator registers while a group referencing
them may still be pending.
Internal representation
Add a value-form WGMMA pipeline operation carrying:
The verifier checks the exact accumulator/result shape, descriptor typing, and
supported pending-group depth.
The initial implementation admits statically known values in the PTX-supported
range and requires the pipeline topology to match the accumulator-slot count.
Pipeline recognition
The deferred-accumulator preparation pass now recognizes a conservative
straight-line partial-wait pipeline.
The supported region requires:
m64n64k16MMA operations;commit_groupboundaries;wait_group<N>operations;N > 0for partial waits inside the pipeline;wait_group<0>before any accumulator value escapes;[[f32; 8]; 4]accumulator storage;Unsupported shapes remain fail-closed and continue through the existing
fallback/diagnostic paths.
The existing straight-line
wait_group<0>path and counted K-loop path remainunchanged.
Lowering
The pipeline lowers to one convergent, side-effecting LLVM inline-asm statement.
For a two-slot
wait_group<1>pipeline, the resulting structure is:Each accumulator input is tied to its corresponding
=foutput.The entire asynchronous lifetime remains inside the same LLVM-visible asm
boundary, so LLVM cannot introduce a spill boundary between committed WGMMA
groups and their waits.
Accumulator element addresses are recomputed after the final
wait_group<0>instead of being kept live across the asm region, reducing unnecessary register
pressure.
Legality checks
The new path rejects unsafe pipeline shapes, including:
wait_group<0>;wait_group<N>values;These checks preserve the existing fail-closed behavior for regions that cannot
be proven safe.
Backend feasibility
A new
sm_90abackend probe exercises:ptxasaccepts the generated PTX with:This directly validates the two-slot carrier required by the initial
multiple-groups-in-flight path.
The existing 32-value carrier probe also remains green.
Tests
Coverage includes:
wait_group<1>;wait_group<0>;wait_group<8>;Validation
Backend pipeline probe:
WGMMA smoketests:
git diff --checkis clean.Scope
This PR intentionally keeps pipeline selection conservative.
It does not yet:
Those integration and hardening tasks remain for the final PR in #605.