Skip to content

[CUDA][TIRx] Add collector-qualified tcgen05.mma block_scale forms and bind tcgen05.ld.red redval as output - #20266

Merged
spectrometerHBH merged 1 commit into
apache:mainfrom
spectrometerHBH:pr/tcgen05-block-scale-collectors-ld-red-redval
Sep 4, 2026
Merged

[CUDA][TIRx] Add collector-qualified tcgen05.mma block_scale forms and bind tcgen05.ld.red redval as output#20266
spectrometerHBH merged 1 commit into
apache:mainfrom
spectrometerHBH:pr/tcgen05-block-scale-collectors-ld-red-redval

Conversation

@spectrometerHBH

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #20261 for two tcgen05 forms in the T.ptx table (python/tvm/backend/cuda/ptx/table.py), per the CUDA 13.4 / PTX ISA 9.4 manual.

  • tcgen05.mma block-scaled with explicit block size (tcgen05_mma_block_scale_block_{ss,ts}): the entries move from the base table into _PTX_94_ENTRIES and gain optional collector_a / collector_b slots, so each entry owns both the no-collector (ISA 9.7.18.10.10.1 syntax form 2) and collector-qualified (form 4) variants, which share the same operand shape per A location. Table 68 block sizes are unchanged (block32 for kind::mxf8f6f4 and kind::mxf4, block16/block32 for kind::mxf4nvf4). The check additionally rejects collector B without collector A. The entries certify at sm_107f because collector B is SM107-only; the no-collector and collector-A-only forms keep their sm_100f floor.
  • tcgen05.ld.red: redval is now bound as an output operand (rw="w"). ISA 9.7.18.8.3 writes the reduction result into it; with an input binding the kernel compiles but never observes the hardware max (measured on GB300).

Tests (tests/python/tirx/codegen/test_ptx_dialect.py)

  • test_ptx_tcgen05_mma_block_size_collector_legality: collector A/B legality and ptxas certification of the collector forms at sm_107f.
  • test_ptx_tcgen05_mma_block_size_no_b_certifies_at_sm100f: no-collector and collector-A-only forms still certify at sm_100f.
  • test_ptx_94_sm107_arch_floors_and_delta (renamed from test_ptx_94_family_specific_arch_floors_and_delta): entries owning SM107 variants certify at sm_107f and remain in the 9.4 delta.
  • test_ptx_tcgen05_ld_red_binds_redval_as_output: redval is rendered with an output constraint.

Downstream

The FP4 FlashAttention-4 port in mlc-ai/tirx-kernels uses tcgen05.ld.red...max.f32 and depends on the redval binding fix.

@spectrometerHBH
spectrometerHBH merged commit 48242ec into apache:main Sep 4, 2026
8 checks passed
spectrometerHBH added a commit that referenced this pull request Sep 4, 2026
…#20270)

## Summary

`test_ptx_tcgen05_mma_block_size_form` assembles the collector-qualified
`tcgen05.mma ... block_scale` forms at `sm_107f`. Those are PTX ISA 9.4
forms (#20266) and need the CUDA 13.4 ptxas; on a CUDA 13.2 host the
test fails with `Unknown modifier '.collector::b::fill'` instead of
skipping.

This moves that half into
`test_ptx_tcgen05_mma_block_size_collector_form`, guarded by
`env.has_nvcc_version(13, 4)`, the same gate the whole-table
certification tests already use. The `sm_100a` block32 certification and
the `mxf4` block16 legality check stay in the original test and keep
running on older toolchains.

## Testing

On a CUDA 13.2 host (B200):

```
tests/python/tirx/codegen/test_ptx_dialect.py -k tcgen05_mma_block_size
3 passed, 1 skipped (collector form: need nvcc >= 13.4)
```

The full `tests/python/tirx/` suite on the same host previously had this
as its only failure (2749 passed, 321 skipped).
spectrometerHBH added a commit that referenced this pull request Sep 5, 2026
….async wait_group immediates (#20271)

## Summary

Two `T.ptx` table follow-ups to #20266
(`python/tvm/backend/cuda/ptx/table.py`).

- **Collector-A-only SM107 block-scale MMA.** On the SM107 `tcgen05.mma`
block-scale entries `collector_b` becomes optional, so the
activation-stationary FP8 form with collector A alone is accepted
alongside the A+B form.
- **Open `cp.async` wait-group immediates.** `cp.async.wait_group N` and
`cp.async.bulk.wait_group[.read] N` no longer restrict `N` to `0..7`.
PTX ISA 9.7.10.28.3.3 / 9.7.10.28.6.2 define `N` only as an integer
constant with no value domain, and CUDA 13.4 ptxas at sm_107a accepts
values beyond 7 (measured: 8, 9, 16, 255; the bulk `.read` form also
2147483647 and -1). Each call-site constant still becomes its own
helper; enumeration and full-table certification sample the open operand
at 0 and certify the instruction shape.

## Tests (`tests/python/tirx/codegen/test_ptx_dialect.py`)

- New `test_ptx_tcgen05_mma_block_scale_collector_a_without_block_size`:
SM107 activation-stationary FP8 accepts collector A without `.block*`.
- Wait-group tests updated for the open immediate.

## Downstream

Needed by the Rubin masked grouped GEMM and block-scaled fused-MoE
SwiGLU ports in mlc-ai/tirx-kernels.
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.

2 participants