Skip to content

feat(intrinsics): add TMA tensor reduction intrinsics - #770

Merged
nihalpasham merged 2 commits into
NVIDIA:mainfrom
uurl:feat/intrinsics-tma-reduce-stacked
Aug 10, 2026
Merged

nihalpasham merged 2 commits into
NVIDIA:mainfrom
uurl:feat/intrinsics-tma-reduce-stacked

Conversation

@uurl

@uurl uurl commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Depends on #721.
Closes #660.

Summary

Add ABI-stable support for the 64 cp.reduce.async.bulk.tensor reduction variants across tile and im2col addressing modes.

This PR is stacked on #721 (cf96d6c2ae2e3869b6b95f863049cd6a4658fc88). Until #721 is merged, the GitHub diff against main also includes its changes; the #660-specific delta is the single commit on top of that revision.

Changes

  • Add 64 TMA tensor-reduction intrinsics covering:

    • operations: add, and, dec, inc, max, min, or, and xor;
    • tile modes for dimensions 1D through 5D;
    • im2col modes for dimensions 3D through 5D.
  • Extend compact TMA admission with reduction-specific metadata and fail-closed validation.

  • Preserve schema 61 compatibility for existing TMA admissions while requiring schema 62 for TMA reductions.

  • Add ABI entries i0923 through i0986.

  • Add generated cuda-device APIs and dialect operations.

  • Extend MIR importer and lowering support for TMA reductions.

  • Lower through:

    • typed NVVM intrinsics for the LLVM NVPTX backend;
    • inline PTX for the libNVVM backend.
  • Map Rust/LLVM im2col forms to the PTX im2col_no_offs spelling.

  • Add target gating for PTX 8.0 / SM90+.

  • Add 64 generated intrinsic probes.

Evidence

TMA reductions use dedicated evidence profiles rather than modifying the existing #721 TMA evidence:

  • rust-llvm-22.1.2-1cb4e383-tma-reduce
  • cuda-13.3-libnvvm-13.3.73-tma-reduce

Both selected backend routes were independently validated across all 64 variants.

LLVM TypedNvvm validation:

  • 64/64 variants generated PTX successfully.
  • 64/64 variants assembled successfully with ptxas.

libNVVM validation:

  • 64/64 variants generated PTX successfully.
  • 64/64 variants assembled and linked successfully.

Hardware runtime execution was not performed; runtime validation remains unexecuted.

Generated artifacts

This change adds:

  • 64 new reduction probe files;
  • 2 new evidence profiles;
  • 64 ABI entries, increasing the registry from 922 to 986 entries.

The catalog schema changes from 45 to 46. As a result, deterministic regeneration updates the catalog schema/hash header across existing generated files.

Of the 1019 modified tracked files:

  • 16 contain semantic changes;
  • 1003 contain only the deterministic generated catalog schema/hash update.

These generated hash-only changes are intentionally retained so that the checked-in outputs exactly match cuda-intrinsics-gen.

Validation

  • cargo fmt --all -- --check

  • cargo run -p cuda-intrinsics-gen -- check

  • cargo run -p cuda-intrinsics-gen -- check-abi-history --base-ref cf96d6c2ae2e3869b6b95f863049cd6a4658fc88

  • cargo test -p cuda-intrinsics-gen

    • 289 passed
  • cargo check -p cuda-intrinsics -p dialect-nvvm -p mir-importer -p mir-lower -p cuda-oxide-codegen

  • cargo test -p cuda-intrinsics -p dialect-nvvm -p mir-importer -p mir-lower -p cuda-oxide-codegen

  • cargo test --manifest-path crates/rustc-codegen-cuda/Cargo.toml

    • 22 passed
  • cargo clippy -p cuda-intrinsics-gen -p cuda-intrinsics -p dialect-nvvm -p mir-importer -p mir-lower -p cuda-oxide-codegen --all-targets -- -D warnings

  • git diff --check

  • All commits signed off

Review note

Because this PR is stacked on #721, the intended #660 review range is:

cf96d6c2ae2e3869b6b95f863049cd6a4658fc88..81f5af7d28adb7d86e798d5623b2bc14f2969458

@nihalpasham nihalpasham added enhancement New feature or request Depends Blocked on another PR/issue or an upstream dependency intrinsics Device intrinsics and libdevice math mappings cuda-feature A CUDA hardware/toolkit feature (TMA, tcgen05, WGMMA) codegen Device code-generation pipeline (Rust MIR to IR to PTX) IR-lowering Lowering between dialects (dialect-mir to LLVM dialect) labels Aug 10, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

Gist: full delivery of #660, all 64 reduce variants at the same 1:1 wrapper layer as cuda::ptx, wired end to end with fail-closed policy validation and evidence on both backends. The review found nothing wrong with the reduce work itself.

It has to wait for #721: this diff carries #721's entire commit, and the ABI ledger anchor at i0923 assumes #721 lands byte-identical.

Labeled Depends.

Related to #604, which this makes more urgent: another positionally derived ID block just landed at i0923-i0986.

uurl and others added 2 commits August 10, 2026 12:46
Rebuild resolve.rs, render.rs, and model.rs from origin/main's copies
plus only the semantic hunks of the PR delta (git diff -w guided), so
formatting matches main wherever the PR merely re-indented lines.
git diff -w against the previous head is empty for all three files,
proving no semantic change. resolve.rs shrinks from 806 to 674 changed
lines vs main (the residual 66-line indent shift is rustfmt-forced by
the new shard closure wrapping an existing struct literal); render.rs
from 644 to 98; model.rs stays at its 61-line semantic floor.
@nihalpasham nihalpasham removed the Depends Blocked on another PR/issue or an upstream dependency label Aug 10, 2026
@nihalpasham
nihalpasham force-pushed the feat/intrinsics-tma-reduce-stacked branch from 81f5af7 to da08ef7 Compare August 10, 2026 07:35
@nihalpasham
nihalpasham merged commit 73d0df3 into NVIDIA:main Aug 10, 2026
38 checks passed
@uurl
uurl deleted the feat/intrinsics-tma-reduce-stacked branch August 10, 2026 08:27
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 intrinsics Device intrinsics and libdevice math mappings IR-lowering Lowering between dialects (dialect-mir to LLVM dialect)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cp.reduce.async.bulk.tensor family: imported.json carries all 64 records, none are generated into cuda-device

2 participants