Skip to content

feat(intrinsics): add f32 redux.sync family - #1032

Merged
nihalpasham merged 4 commits into
NVIDIA:mainfrom
almightychang:redux-f32-generator
Aug 19, 2026
Merged

nihalpasham merged 4 commits into
NVIDIA:mainfrom
almightychang:redux-f32-generator

Conversation

@almightychang

Copy link
Copy Markdown
Contributor

Summary

  • Add all eight redux.sync f32 min/max variants: min/max × optional .abs × optional .NaN.
  • Carry the family end to end through the intrinsic catalog, ABI, device compatibility API, dialect/importer/lowering pipeline, generated target metadata, probes, and reference output.
  • Restrict the family to Blackwell family 10x targets and add an sm_100a compile-only example lane that checks the emitted PTX.

Target matrix rationale

Pinned LLVM defines hasReduxSyncF32 as accelerator family {100} at PTX 8.6 or family {100} at PTX 8.8. Direct llc verification selects these intrinsics on sm_100a, sm_100f, sm_103a, and sm_103f, while sm_110a and sm_120a fail with Cannot select.

The catalog therefore records the PTX 8.6 accelerator instruction floor with the sm_100a|sm_100f|sm_103a|sm_103f target union. Per-target effective PTX floors are handled by target.rs, which raises family and later 10x targets as required by LLVM.

Verification

  • cargo run -p cuda-intrinsics-gen -- check — generated outputs are current.
  • cargo run -p cuda-intrinsics-gen -- probe --all — all 1010 catalog routes pass.
  • Candidate probes — all 8 f32 redux variants pass with pinned llc at sm_100a +ptx86.
  • Full relevant generator, dialect, importer, lowering, intrinsic, and device test suites are green; cargo test -p cuda-intrinsics-gen reports 291 passing tests.
  • The sm100-compile lane asserts .version 8.6, .target sm_100a, and all 8 total and unique redux.sync f32 forms in each example kernel.
  • Root and example formatting checks pass.

Deferred follow-ups

  • The libNVVM route remains ungated, a pre-existing family-wide property shared with integer redux.
  • Update the book documentation separately.
  • GPU execution validation is pending B200 access. The example is compile-only in CI, matching the existing blackwell-compile posture.

@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 19, 2026
Teach the generator the f32 carrier through closed recipes, a fail-closed hasReduxSyncF32 gate, and typed probe and dialect rendering, targeting sm_100a|sm_100f|sm_103a|sm_103f at the PTX 8.6 accelerator floor from the pinned LLVM predicate while leaving integer redux outputs unchanged.

Signed-off-by: almightychang (Sam, Joochul Chang) <[email protected]>
Add eight overlay entries, ABI IDs i1003-i1010, pinned-llc evidence from sm_100a +ptx86, and cuda-device compatibility stubs.

Signed-off-by: almightychang (Sam, Joochul Chang) <[email protected]>
Record the mechanical output of cuda-intrinsics-gen generate.

Signed-off-by: almightychang (Sam, Joochul Chang) <[email protected]>
Add a compile-only sm_100a lane asserting .version 8.6, .target sm_100a, and eight total and unique redux.sync f32 forms per kernel, plus dialect construct-and-verify coverage for all eight operations.

Signed-off-by: almightychang (Sam, Joochul Chang) <[email protected]>
@nihalpasham

Copy link
Copy Markdown
Collaborator
  • Rebased onto main (f2a6220) and force-pushed; the only conflict was the import list in dialect-nvvm/tests/ops_test.rs, resolved by union with main's two new wgmma ops. Your four commits are intact on top.
  • Verified after the rebase: check reports generated outputs current; check-abi-history shows 1002 base entries preserved with i1003-i1010 appended; 291 generator + 51 dialect-nvvm tests pass; all 8 forms probe to the expected redux.sync.{min,max}[.abs][.NaN].f32 for sm_100a; smoketest.sh redux_f32 passes compile-only on this sm_120 host, which matches the blackwell-compile precedent for landing.
  • GPU execution of the NaN-policy check stays outstanding until we get time on a B200. Book docs deferred per the description; tracking next to book: the intrinsics guide covers only hand-written ops; the cuda-intrinsics-gen catalog workflow is undocumented #808 so the family does not stay undocumented.

@nihalpasham
nihalpasham merged commit 709ce9e into NVIDIA:main Aug 19, 2026
50 of 94 checks passed
nihalpasham pushed a commit that referenced this pull request Aug 20, 2026
…s own test (#1052)

`mlir-dialects.md` anchors its op counts to a catalog stamp and says how to
tell when they have rotted:

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

Every generated file now stamps `26a9cc13`, so that condition is true. Six
numbers and one description are stale, all of them from the last batch of
merges:

| claim | page | tree |
|---|--:|--:|
| dialect total | 560 | **570** |
| hand-written ops | 19 | **21** |
| hand-written `wgmma` row | 7 | **9** |
| generated ops | 541 | **549** |
| catalog entries | 1002 | **1010** |
| generated "Warp-level" row | 31 | **39** |

The two deltas are traceable: #1021 and #1025 added two hand-written `wgmma`
ops (19 -> 21), and #1032 added the eight `redux.sync` f32 variants
(541 -> 549, 1002 -> 1010, and the Warp-level row that owns `redux`).

The `wgmma` row's description moved with its count rather than just the
number. It read "the m64n64k16 bf16 shapes", but #1025 added
`WgmmaMmaM64N64K16F32F16Op` and `WgmmaMmaGroupValuesM64N64K16F32F16Op`, so the
module now holds f16 shapes too.

Module counts did not change: 7 hand-written plus 35 generated is still 42.

Verified against the tree rather than against the merge descriptions:
`^pub struct \w+Op;` counts 21 under `src/ops/` and 549 under
`src/ops/generated/`, 570 together; `intrinsics/catalog.json` holds 1010
entries; and all 35 generated files carry the one stamp `26a9cc13`. Both
tables sum to their new totals (7 rows to 21, 11 rows to 549) and each still
lists every module on disk with nothing that is not one. Book builds clean
under `sphinx-build -W`.

Signed-off-by: Vyncint Ng <[email protected]>
nihalpasham added a commit that referenced this pull request Aug 20, 2026
…ist (#1053)

* docs(book): the warp chapter says the f32 redux.sync form does not exist

`warp-level-programming.md` closes its `redux.sync` section with:

    - **Integers only.** There is no `f32`/`f64` form before `sm_100`, so float
      reductions keep the butterfly.

#1032 shipped that form. `cuda-device` now exports eight `f32` entry points
that the chapter mentions nowhere:

    redux_sync_min_f32       redux_sync_max_f32
    redux_sync_min_abs_f32   redux_sync_max_abs_f32
    redux_sync_min_nan_f32   redux_sync_max_nan_f32
    redux_sync_min_abs_nan_f32  redux_sync_max_abs_nan_f32

A reader following this page today writes the shuffle butterfly for an `f32`
min/max reduction that the hardware can do in one instruction, because the
book told them the instruction does not exist.

Add a subsection for the family and correct the bullet. `f64` still has no
`redux.sync` form, so that half of the claim stands and is kept.

Three things the new subsection is careful about:

- **It is not one function per operation.** The integer family is, and the
  page says so. For `f32`, `.abs` and `.NaN` are independent instruction
  modifiers, so each of the four combinations is its own entry point.

- **The `.NaN` distinction is stated in the catalog's own terms.** The plain
  and `.abs` forms ignore NaN inputs; the `.NaN` forms propagate NaN when any
  lane contributes one. That is the difference that decides which to call.

- **The floor is narrower than "sm_100+".** The catalog records PTX 8.6 with a
  target union of `sm_100a|sm_100f|sm_103a|sm_103f`, so the intrinsic is not
  selected on `sm_110a` or `sm_120a` -- consumer Blackwell included. Saying
  "Blackwell" without that would send RTX-50 users down a path that cannot
  lower.

No performance claim is made. The integer section's 4.74x is a measurement on
an A10G; the `f32` family needs a B200/GB200, `redux_f32` is in
`SM100_COMPILE_EXAMPLES` so CI checks its emitted PTX rather than running it,
and its `main` skips unless the device reports exactly `sm_100`. The
subsection says that instead of implying a number.

Verified: all eight names exist as `pub fn` in `crates/cuda-device/src/warp.rs`;
the arch union, PTX version and NaN/abs semantics come from
`intrinsics/catalog.json`, not from the merge description. Every one of the
eight is written module-qualified, so `check-book-api-names.sh` now covers all
of them -- it checks 39 qualified names where it checked 35, and renaming one
to `redux_sync_max_abs_nan_f64` makes it fail. Book builds clean under
`sphinx-build -W`.

Signed-off-by: Vyncint Ng <[email protected]>

* docs(book): plain-language pass on the redux f32 section

---------

Signed-off-by: Vyncint Ng <[email protected]>
Co-authored-by: nihalpasham <[email protected]>
nihalpasham added a commit that referenced this pull request Aug 20, 2026
…ls FP8 Planned (#1054)

* docs(book): the feature appendix has no row for tensor cores, and calls FP8 Planned

The page opens by promising "every compiler capability, runtime API, and
hardware feature along with its current support status." Three gaps against
that promise, in increasing order of size.

**FP8 is listed as not implemented.** Under "Not Yet Implemented":

    | FP8 / MX Data Types | **Planned** | Roadmap item for Blackwell.
                                          No architectural limitation. |

The catalog holds 158 entries for these formats -- 12 conversions and 146
matrix ops -- surfacing as `pub unsafe fn` in `cuda_device::convert`,
`cuda_device::wmma` and `cuda_device::tcgen05`, and the `mma_mxf8f6f4` example
compiles them. By the page's own legend that is **Partial**, not Planned.

The gap is real and worth naming rather than dropping the row: there is *no
arithmetic* on these formats. Grouping the 158 by kind gives 12 `cvt` and 146
`mma`, and nothing matching add/mul/sub/fma/min/max/abs. So a value is carried
as a packed bit pattern and converted before use, unlike `f16`/`bf16`, which
have their own scalar and packed arithmetic modules. That is what the new row
says.

**The Warp section has no `redux.sync` row**, although `cuda_device::warp`
exports sixteen of them. The section lists shuffle, vote and lane/warp ID. The
new row carries both halves and their different floors: integers on sm_80+,
and `f32` min/max with optional `.abs`/`.NaN` on
`sm_100a`/`sm_100f`/`sm_103a`/`sm_103f` (#1032). `f64` has no form, which the
row also says.

**There is no matrix or tensor-core section at all.** `grep -i` for "tensor
core", "wgmma", "tcgen05", "wmma", "mma" or "TMEM" across the whole appendix
returns nothing -- no row for warp-level `mma.sync`, sparse MMA, Hopper
warpgroup MMA, Blackwell tcgen05/TMEM, or the accumulator fragment algebra, in
the feature matrix of a compiler whose headline example is a Blackwell GEMM.
Add a section for it, and move the FP8 row there, since the matrix path is
where those formats are actually used.

Statuses are calibrated against the existing TMA section, which is the other
Hopper+ hardware feature and marks compile-only-in-CI capabilities **Full**
with the architecture stated in the description. These rows follow that.

Every row is sourced from the tree, not from memory: module summaries come
from each module's own `//!` header (`wgmma` states Hopper `sm_90a`, `tcgen05`
Blackwell sm_100+), sparse MMA is confirmed by the `mma.sp.sync.aligned.*`
strings in `generated/sparse_mma.rs`, and the redux names are checked against
`pub fn` declarations in `warp.rs`. Book builds clean under `sphinx-build -W`
and `check-book-api-names.sh` passes.

Signed-off-by: Vyncint Ng <[email protected]>

* docs(book): correct the wgmma row and plain-language touch-ups in the feature appendix

---------

Signed-off-by: Vyncint Ng <[email protected]>
Co-authored-by: nihalpasham <[email protected]>
nihalpasham added a commit that referenced this pull request Aug 20, 2026
…ed in a day (#1055)

* ci: four tooling comments keep tree sizes by hand, and all four drifted in a day

#1032 added one example, `redux_f32`, and eight catalog entries. That single
merge falsified numbers in four places:

| site | said | now |
|---|--:|--:|
| `check-example-license-policy.sh` (x3) | 217 locks | 218 |
| `check-example-license-policy.sh` (x2) | 215 examples | 216 |
| `check-example-license-policy.sh` | 13871 packages, floor 2170 | 13934, 2180 |
| `cargo-deny.yml` | 31 runs instead of 217 | ... of 218 |
| `Justfile` | 986 catalog entries | 1010 |
| `examples-compile.yml` | 210 example crates | 216 |

Six of those transcriptions are mine, from #1043 and #1044, written the day
before. Refreshing them buys one day. The counts are not load-bearing in any
of the four -- each is there to make a structural point -- so state the
structure and let the code report the numbers:

- The license-policy guard already announced its representative count. It now
  announces the lock count beside it, so the grouping ratio is observable
  output rather than a comment to keep in step:

      Checking deny.toml over 31 representative example workspaces,
      grouped from 218 example lock files.

- Its scope comment and its enumeration cross-check now say "one lock per
  example directory, plus one per nested sub-workspace" instead of naming
  today's totals.

- The parsed-package floor is computed as ten per lock, so the comment says
  that rather than quoting the current product.

- `cargo-deny.yml` says one run per distinct dependency set instead of one per
  lock file, and points at the script's own output.

- The `Justfile` comment's point was that the generated path dominates, which
  35 generated op modules against 7 hand-written makes without an entry count.
  Module counts are structural and have not moved through any of these merges.

- `examples-compile.yml`'s number only justified a timeout, so "every example
  crate" does the same job.

One number is kept and re-labelled rather than removed: the `[a-m]*` glob
illustration in the cross-check comment now reads "measured once ... 137 of
the 217 locks then present", matching the timestamped-measurement idiom the
same file already uses two paragraphs above. The argument needs a concrete
ratio; making it explicitly historical stops it being a live claim.

Verified: the guard passes unchanged -- 31 representatives grouped from 218
lock files, `deny.toml holds over every example workspace outside
POLICY_EXEMPT_EXAMPLES`, exit 0. `bash -n` clean, `just --list` parses, all
eleven workflows parse, and dialect-nvvm really does hold 35 generated and 7
hand-written op modules.

Signed-off-by: Vyncint Ng <[email protected]>

* ci: correct the floor-margin claim and tighten the rewritten tooling comments

---------

Signed-off-by: Vyncint Ng <[email protected]>
Co-authored-by: nihalpasham <[email protected]>
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.

2 participants