Skip to content

feat(intrinsics): add standard narrow tcgen05 MMA aliases - #1085

Merged
nihalpasham merged 1 commit into
NVIDIA:mainfrom
uurl:feat/tcgen05-standard-narrow-mma
Aug 20, 2026
Merged

nihalpasham merged 1 commit into
NVIDIA:mainfrom
uurl:feat/tcgen05-standard-narrow-mma

Conversation

@uurl

@uurl uurl commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Part of #339
Closes #1084

Summary

Add typed standard non-warp-specialized tcgen05 MMA convenience aliases for the five homogeneous narrow floating-point formats:

  • tcgen05_mma_e4m3
  • tcgen05_mma_e5m2
  • tcgen05_mma_e2m3
  • tcgen05_mma_e3m2
  • tcgen05_mma_e2m1

The generic standard tcgen05 MMA path could already express these operations through .kind::f8f6f4; this change adds the generated typed surface analogous to the existing convenience APIs.

Semantics

All five aliases select:

tcgen05.mma.cta_group::1.kind::f8f6f4.collector::a::discard

with the compatibility signature:

pub unsafe fn tcgen05_mma_<format>(
    d_tmem: u32,
    a_desc: u64,
    b_desc: u64,
    idesc: u32,
    enable_d: bool,
)

Changes

  • Add five standard tcgen05.mma variants to the tcgen05 overlay.

  • Append ABI entries i1011 through i1015.

  • Extend compact tcgen05 MMA admission from 19 to 24 generated variants:

    • 14 generic forms
    • 5 existing warp-specialized narrow aliases
    • 5 new standard narrow aliases
  • Generate the public cuda-device APIs.

  • Generate dialect, MIR importer, and lowering routes for the five aliases.

  • Generate codegen target matching for the fixed standard selectors.

  • Add five intrinsic probes.

  • Extend both tcgen05 MMA evidence profiles to cover the new aliases.

  • Preserve existing generic and warp-specialized behavior.

Generator details

The standard aliases reuse the existing tcgen05 MMA selector representation with:

kind = f8f6f4
cta_group = 1
collector_a = discard

The generated target matcher now imports the corresponding CTA-group and collector-A dialect attributes required by the new standard fixed-selector routes.

ABI

The append-only ABI ledger grows from 1010 to 1015 entries.

Validation:

intrinsics/abi-v1.toml preserves 1010 base entries and has 1015 total entries

No existing ABI entry was removed, reordered, or changed.

Evidence

Both existing tcgen05 MMA evidence profiles now cover 24 variants.

The five new generated probes pass against the pinned LLVM/NVPTX evidence route and lower to the expected standard narrow MMA form:

tcgen05.mma.cta_group::1.kind::f8f6f4.collector::a::discard

Generated artifacts

Changing the intrinsic catalog updates the catalog SHA embedded in checked-in generated outputs.

As with previous catalog-expansion PRs, this produces a large deterministic generated-file diff even though most files only change the catalog SHA header.

Five new probe files are added:

intrinsics/probes/tcgen05_mma_e2m1.ll
intrinsics/probes/tcgen05_mma_e2m3.ll
intrinsics/probes/tcgen05_mma_e3m2.ll
intrinsics/probes/tcgen05_mma_e4m3.ll
intrinsics/probes/tcgen05_mma_e5m2.ll

Validation

cargo test -p cuda-intrinsics-gen
292 passed; 0 failed

cargo run -p cuda-intrinsics-gen -- check
generated intrinsic outputs are current

cargo run -p cuda-intrinsics-gen -- check-abi-history --base-ref origin/main
preserves 1010 base entries and has 1015 total entries

cargo oxide setup
PASS

cargo oxide fmt --check
PASS

git diff --check
PASS

scripts/smoketest.sh --compile-only
216 / 216 passed

The compile-only smoketest includes successful validation of the tcgen05 path through libNVVM.

Deferred

This PR intentionally does not add:

  • mixed narrow-format aliases
  • first-class FP6/FP4 arithmetic types
  • FP6/FP4 conversion intrinsics
  • changes to the existing warp-specialized narrow API

@nihalpasham nihalpasham added enhancement New feature or request intrinsics Device intrinsics and libdevice math mappings cuda-feature A CUDA hardware/toolkit feature (TMA, tcgen05, WGMMA) labels Aug 20, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator
  • Verified end to end: 292 generator tests, check green with zero generated-file diff, check-abi-history green with all 1010 base ledger entries preserved (1015 total), cargo oxide fmt --check clean, full compile-only smoketest 216/216.
  • Main moved past the branch base with the pipe-escape reference fix (fix(intrinsics-gen): an unescaped pipe drops a column from three reference rows #1067); merged main in locally and re-ran the gates: the merge auto-resolves, check still reports current outputs, the ledger holds. No regenerate-and-recommit needed.
  • The alias arms build a Tcgen05MmaOp byte-identical to the generic shared arm with the constant selectors folded, so no mir-lower change is needed. sm_100 execution stays Unexecuted-policy like the rest of the tcgen05 surface; the compile-only lane covers it here.

@nihalpasham
nihalpasham merged commit 117ee41 into NVIDIA:main Aug 20, 2026
49 checks passed
nihalpasham pushed a commit that referenced this pull request Aug 21, 2026
…1106)

Closes #1090.

`mlir-dialects.md` states its own freshness rule:

    At catalog SHA-256 `26a9cc13` (the stamp in every `ops/generated/` file
    header), the dialect holds 570 operations across 42 modules ...
    If the header stamp no longer starts with `26a9cc13`, the counts on this
    page predate the catalog you are reading.

Nothing enforced that rule, so the rule that would expose stale counts was
itself unchecked. The page failed its own test for weeks before #1052 (560
printed against 570 in the tree), and **it is failing again right now**: the
catalog hashes to `00372dfe`, five hand-written ops and five catalog entries
after that refresh landed. Two hand audits in two batches is the pattern this
closes.

## The gate

One file hashed, one page grepped, no cargo and no network. The hash is the one
`cuda-intrinsics-gen` stamps into every generated file --
`sha256_bytes(catalog_json.as_bytes())` over the file as committed -- so a
plain `sha256sum` reproduces it, and the page prints its first eight digits.

Three checks rather than one, so each failure says which thing moved:

- The generated sources must stamp the hash `catalog.json` actually has.
  Failing here means the generated outputs are stale, and the message says to
  run `cuda-intrinsics-gen -- generate` -- not to edit the book.
- The page must print exactly one distinct stamp. It names it twice, once
  stating it and once in the rule that tells a reader what a mismatch means, so
  updating one and not the other leaves the rule contradicting the statement
  above it.
- The stamps must agree, and the failure prints both sides plus the two
  commands that re-derive the counts the stamp guards.

It refuses to report success from a check that found nothing: a page reworded
so no stamp is left fails with that stated, rather than passing vacuously. That
path needed the `|| true` on the capture rather than on a later pipeline --
under `pipefail` a grep matching nothing aborted the script before the
diagnostic, turning a reworded page into a silent non-zero exit.

## The refresh that makes it pass

Five numbers and the stamp, all re-derived from the tree:

| claim | was | now |
|---|--:|--:|
| catalog stamp (x2) | `26a9cc13` | `00372dfe` |
| total operations | 570 | 575 |
| hand-written operations | 21 | 26 |
| hand-written `wgmma` row | 9 | 14 |
| catalog entries | 1010 | 1015 |

Generated stays 549 across 35 modules and every area row is unchanged, because
#1085's five new catalog entries are aliases onto existing structural ops --
exactly what the page's "several intrinsics can share one structural op"
sentence predicts. The +5 hand-written are all `wgmma`, from #1075, #1077 and
#1079.

The `wgmma` row's description moves with its count, as in #1052: it said "the
m64n64k16 bf16/f16 shapes", and the module now holds four shape/type pairs --
`m64n64k16` bf16 and f16, `m64n128k16` bf16 (#1079), `m64n64k8` tf32 (#1077).

## Verification

- Four mutations, each failing with its own message: a stale stamp, only one of
  the two stamps updated, the page reworded so none is found, and an edited
  `catalog.json`. The healthy tree passes.
- Every count re-checked against the tree: 26 + 549 = 575, both tables sum to
  their stated totals (7 rows to 26, 11 rows to 549), and each still lists
  every module on disk.
- All eleven guard scripts pass, `check-spdx-headers.sh` accepts the new file,
  `cuda-intrinsics-gen -- check` reports outputs current, the workflow parses
  with all nine jobs on `ubuntu-latest`, and the book builds clean under
  `sphinx-build -W`.

`just check-guards` should list this script too, one line beside the other ten.
Its recipe is being restructured in #1102, so that line is left for a follow-up
rather than conflicting; no guard enforces that list, so CI is unaffected
either way.

Signed-off-by: Vyncint Ng <[email protected]>
@uurl
uurl deleted the feat/tcgen05-standard-narrow-mma branch August 22, 2026 06:09
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add typed standard narrow tcgen05 MMA aliases

2 participants