Skip to content

[TIRx][CUDA] Support predicated gemm_async - #20072

Closed
jinhongyii wants to merge 1 commit into
apache:mainfrom
jinhongyii:upstream/tirx-predicated-gemm-async
Closed

[TIRx][CUDA] Support predicated gemm_async#20072
jinhongyii wants to merge 1 commit into
apache:mainfrom
jinhongyii:upstream/tirx-predicated-gemm-async

Conversation

@jinhongyii

Copy link
Copy Markdown
Contributor

Motivation and context

Blackwell tcgen05.mma is issued by a single thread, while one Tx.gemm_async tile call may expand into multiple dense or block-scaled MMA instructions over its M, N, and K iterations. Persistent kernels sometimes need to keep the surrounding state machine warp-uniform, so they compute a one-lane predicate and apply it at the instruction level:

mma_issue = T.ptx.elect_sync()
Tx.gemm_async(
    C,
    A,
    B,
    dispatch="tcgen05",
    pred=mma_issue,
)
mma_bar.arrive(stage, pred=mma_issue)

Before this PR, the pred configuration was not forwarded by the gemm_async tcgen05 dispatcher to every MMA it generated. In addition, the block-scaled MMA path and TCGen05Bar.arrive did not support forwarding the same predicate. Predicating only the matching commit is not sufficient: the active lanes may still issue all internal MMA instructions.

Changes

  • Read the optional pred value from the gemm_async tile-call configuration and forward it to every generated dense or block-scaled tcgen05 MMA.
  • Add optional instruction-predicate support to ptx_tcgen05_mma_block_scale and its CUDA helper generation.
  • Generate a predicated PTX instruction by converting the runtime uint32 value to a PTX predicate and emitting @p_issue tcgen05.mma....
  • Add pred to TCGen05Bar.arrive and forward it to both the single-CTA and multicast tcgen05.commit forms.
  • Document the supported thread-scope pattern and the requirement that the MMA sequence and matching commit use the same predicate.

The existing behavior remains unchanged when pred is omitted.

Testing

  • Verify predicated single-CTA and two-CTA multicast TCGen05Bar commits in CUDA codegen.
  • Verify that block-scaled MMA codegen emits @p_issue tcgen05.mma....
  • Verify that one dense or block-scaled tile call expands to four internal MMA calls and that all calls receive the same predicate as the matching commit.
  • Run changed-files pre-commit checks.

Focused result: 5 tests passed.

Forward an optional instruction predicate to every dense and block-scaled tcgen05 MMA emitted by gemm_async, and let TCGen05Bar use the same predicate for its commit.

Add codegen coverage for block-scaled MMA and unicast/multicast commits, plus tile-level checks that all internal MMAs and the matching commit share one predicate.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@jinhongyii
jinhongyii marked this pull request as draft July 29, 2026 05:22
@jinhongyii

Copy link
Copy Markdown
Contributor Author

Closing this in favor of the existing explicit single-lane guard form (if mma_issue:). On the current grouped FP8 kernel, a like-for-like B200 A/B benchmark found no measurable regression from the explicit guard, and the generated SASS still uses uniform registers for the MMA descriptor path. The additional pred API therefore does not appear justified by this use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant