Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ behaviour change, and a version check cannot see a tree that never bumped.

---

## `0.58.6` — Added: the `m16n8k8` tf32 MMA atom (`MmaAtom::nvidia_m16n8k8_tf32_f32`) and the `MmaAtom::with_tf32_inputs` rounding flag (U57)

Not breaking (a new constructor and a `#[serde(default)]` flag; no variant or public struct literal changes). PM ruling Q5 (B): no tf32 `ElementKind`; the operands are `F32` fragments and the **compute rule** rounds `A` and `B` to tf32 (10 explicit mantissa bits, ties away from zero, `cvt.rna.tf32.f32`) before the products, which stay exact in `f64` and sum in ascending `k` from `C`, rounded once to `F32`. Fragment layouts (PTX ISA 9.5 9.7.16.5.7, Figures 75, 78, 80, read as text; `gid = lane / 4`, `tig = lane % 4`): `A` value `i` is row `gid + 8 * (i % 2)`, column `tig + 4 * (i / 2)`; `B` value `i` is row `tig + 4 * i`, column `gid`; `C`/`D` as every `m16n8` atom. CUTLASS `SM80_16x8x8_F32TF32TF32F32_TN` (`mma_traits_sm80.hpp`, BSD-3, facts only) gives the same maps (different source and method). `unpopped-cpu-c` spells the rounding in C. Tests: `tests/kernel_mma.rs` (fragments placed by the PTX formulas, an independent exact-scaling tf32 reference, and a control that the unrounded result differs), `unpopped-cpu-c/tests/kernel_mma_emit_agrees.rs` (oracle and C agree on operands whose dropped mantissa bits matter). Closes the CUTLASS union row 76 (tf32 as an MMA operand) as ruled.

---

## `0.58.5` — Added: `unpopped::fixtures` (feature `fixtures`): one checker-valid kernel or module per `Stmt` variant, for emitter decline tests (U60)

Non-breaking, additive, behind the `fixtures` cargo feature (normal builds do not carry it). `unpopped::fixtures::fixtures()` returns one small kernel, or one module with its entry index, for each of the 46 `Stmt` variants, so an emitter's decline test can assert the emitter's own refusal text while the checker passes; `fixture(name)` looks one up and `needs(name)` says what it needs. `variant_name` is an exhaustive `match` with no wildcard arm and `ALL` is generated from the same list, so a new `Stmt` variant fails the build under the feature until it has a fixture. Unit tests assert that every variant has exactly one fixture, that every fixture passes `check_kernel` or `check_module`, and that each fixture really contains a statement of its own variant. `CollectiveTuple`, `Call`, `CallTuple` and `ExternCall` are modules; `MulticastLoadReduce` needs a two-device launch; `Tcgen05Mma`, `Tcgen05Ld`, `Tcgen05Alloc` and `Tcgen05Dealloc` use tensor memory; `Wgmma` and `Tcgen05Mma` use the oracle-only row-major operand layouts.
Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ categories = ["compilers", "development-tools", "science"]

[workspace.dependencies]
# Unpopped's own crates — path + version so they can be published independently.
unpopped-vocab = { path = "crates/unpopped-vocab", version = "0.58.5" }
unpopped = { path = "crates/unpopped", version = "0.58.5" }
unpopped-vocab = { path = "crates/unpopped-vocab", version = "0.58.6" }
unpopped = { path = "crates/unpopped", version = "0.58.6" }
# The reference emitters. Each depends on `unpopped`, never the reverse — the
# core holds the standard and the traits; a target holds its own spelling.
unpopped-cpu-c = { path = "crates/unpopped-cpu-c", version = "0.58.5" }
unpopped-cpu-c = { path = "crates/unpopped-cpu-c", version = "0.58.6" }
# The tree-sitter walkers that lift C-family source into the IR (the former `convert` feature of `unpopped`).
unpopped-convert = { path = "crates/unpopped-convert", version = "0.58.5" }
unpopped-convert = { path = "crates/unpopped-convert", version = "0.58.6" }
# Dtype primitives. Versions match the Baracuda workspace the vocabulary was
# carved from, so the extracted crate resolves identically on either side of the
# split until it is published.
Expand Down
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ CireSnave, 2026-10-24: *"I want the IR to cover the full union of the capabiliti
| U54 | Autodiff as a scheduled source-to-source transformation crate over the kernel layer (PM Q13, ruled A, lowest priority, behind every READY row). Union row Slang 49 | none yet | scheduled, last |
| U55 | Non-semantic scheduling hints (PM Q14, ruled A): `schedule_barrier`-style hints carried with no semantics, as the `Unroll` hint is; one field batched with the next breaking release. Union row Mojo 17 | none yet | **READY**, batches with U13/U18/U36 |
| U56 | `Fp8FastAccum` (PM 2026-11-25): the hold was one sentence of the PM's own, 2026-11-09, in `docs/accum-policies.md` ("no hardware model is documented, so none is built"); it was **not** a CireSnave board ruling (the earlier citation of boards 443/444 was wrong, corrected here). Under the standing rule that a gap is a row it is READY: model it as an `AccumSpec` policy by its software-documented parameters (the promotion interval and the count of imprecise accumulations that CUTLASS's and Triton's fast-accumulate kernels expose) with a declared bound, stated as a policy and not as a claim about the hardware. Union row CUTLASS 72 | none yet | **READY** |
| U57 | tf32 as an operand (PM Q5, ruled B): keep `AccumSpec::Tf32` (F32 operands rounded) and add no `ElementKind`; the row counts once a `wmma` tf32 conformance kernel runs it. Union row CUTLASS 76 | none yet | **READY**: one conformance kernel |
| U57 | tf32 as an operand (PM Q5, ruled B): keep `AccumSpec::Tf32` (F32 operands rounded) and add no `ElementKind`; the row counts once a `wmma` tf32 conformance kernel runs it. Union row CUTLASS 76 | `lane/u57-tf32-atom` | **built**: the `m16n8k8` tf32 atom and `MmaAtom::with_tf32_inputs`, run by oracle and cpu-c tests |
| U58 | The index-operand dtype of gather and scatter (U1's remainder): index leaves of `I8`/`I16`/`U8`/`U16`/`U32`/`U64` beyond the `I32`/`I64` the checker admits, with the oracle and cpu-c to match. It was waiting for the 2026-10-28 seam hold, **superseded (PM 2026-11-25)**. Union row Mojo 49 | none yet | **READY** |
| U59 | Measured exactness for **kernel-layer** kernels (`docs/design-kernel-fidelity.md`): `unpopped::exactness` already records measurements (device stamp, kernel hash, `Exact`/`Flushes`, coverage; `Flushes` dominates; unmeasured claims nothing) but keys them by a plan-layer `ScalarExpr` body, so a `lower_kernel` kernel (vulkane's Metal f32/bf16 flush, f16 preserves) cannot be recorded or asked. Proposed, additive: `kernel_key(&KernelFn, dtype)`, `ExactnessRecord::for_kernel`, `ExactnessLedger::{find,lookup,admit}_kernel` over one shared implementation, and shared IR probe recipes (the oracle is the reference); no new field on `GeneratedKernel` (the first draft of this row proposed a `KernelFidelity` type there, which duplicated the ledger and is withdrawn). KISS has no value admitting flush (6.17-0002); if CireSnave later wants one it is a wire change, filed then | vulkane via pm-kernels, 2026-11-26 | **design** (docs only), ruled A (local extension now; pm-kernels 2026-11-26). Slice 1: key, record and ledger entry points, tests. Owner Unpopped (key, entry points, recipes) + each emitter lane's harness (its records), size M |
| U60 | Shared kernel fixtures for emitter decline tests: `unpopped::fixtures`, one checker-valid `KernelFn` (or `Module`, for `Call`/`CallTuple`/`ExternCall`) per `Stmt` variant an emitter refuses by name, so a decline test can assert the **emitter's** refusal text (the checker passes) and a decline-removed mutant can fail it; five emitter repos would otherwise each hand-build the same fixtures. Plan: a published table `(variant name, Fixture)`, proven valid by `check_kernel`/`check_module` in unpopped's own suite, plus a completeness test driven by an exhaustive `match` over `Stmt` (a new variant breaks the build until it has a fixture or a stated reason); the layout-heavy ones (`Wgmma`, `Tcgen05*`, `Mma`, `MatrixLoad`/`MatrixStore`, `MulticastLoadReduce`) reuse the layouts of unpopped's own tests. Additive | vulkane (ROADMAP 9h audit), 2026-11-26 | **READY** (priority asked of pm-kernels; gates vulkane 9h, not a release). Owner Unpopped, size M-L |
Expand Down
2 changes: 1 addition & 1 deletion crates/unpopped-conformance/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "unpopped-conformance"
version = "0.58.5"
version = "0.58.6"
description = "Cross-emitter conformance evidence for Unpopped: tests that are about the STANDARD rather than about any one backend, and so cannot live in a backend's crate."
edition.workspace = true
rust-version.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/unpopped-convert/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "unpopped-convert"
version = "0.58.5"
version = "0.58.6"
description = "The shared tree-sitter walkers that lift C-family kernel source into Unpopped's neutral IR: a `Frontend` value carries what a language contributes (kernel marker, residue list, buffer naming, a `parse` function) and `lift_elementwise`, `lift_reduction`, `lift_scan` and `lift` do the one CST walk for every language. No grammar is bundled: CUDA's parser is `baracuda-cuda-parse`, Slang's is `vulkane-slang-parse`. Split out of `unpopped` (its former `convert` feature) so the stable core no longer names the parser technology."
readme = "README.md"
edition.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/unpopped-cpu-c/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "unpopped-cpu-c"
version = "0.58.5"
version = "0.58.6"
description = "The portable-C99 reference emitter for Unpopped: lowers a neutral `KernelPlan` to C source that compiles on any C compiler, with no vendor intrinsic, no conditional compilation, and no device. Ships the software codecs the narrow dtypes need (FP8 E4M3/E5M2, sub-byte i4/u4/b1, and a struct complex ABI), so `f8e4m3fn` and `c128` lower without naming anyone's toolchain. This is the normative reference emitter a new target is read against, and the one every differential test runs through."
readme = "README.md"
edition.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/unpopped-cpu-c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ It is the normative reference emitter a new target is read against, and the one
Depend on the exact version of `unpopped` it was released with (pre-1.0; pin exact versions):

```toml
unpopped = "=0.58.5"
unpopped-cpu-c = "=0.58.5"
unpopped = "=0.58.6"
unpopped-cpu-c = "=0.58.6"
```

See the `unpopped` crate documentation for the plan and kernel IR this crate consumes.
Expand Down
14 changes: 14 additions & 0 deletions crates/unpopped-cpu-c/src/mma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ impl Emitter<'_> {
(Some(bk), Some(wa), Some(wb)) => Some((bk as usize, wa, wb)),
_ => None,
};
if atom.tf32_inputs() {
// the tf32 atoms round A and B to tf32 (ties away from zero, `cvt.rna.tf32.f32`) before the products
let (m, n, k) = atom.mnk();
self.mma_round_tf32(a_name, (m * k) as usize);
self.mma_round_tf32("mb", (k * n) as usize);
}
self.mma_product(atom, wide, a_name, block);
let vd = atom.values(2);
let stored = format!("({td})md[mi{id}o2[l * {vd} + v]]");
Expand Down Expand Up @@ -205,6 +211,14 @@ impl Emitter<'_> {
self.line("}");
}

/// Round the `count` logical values of `name` to tf32: the `f32` bits plus `0x1000`, the low 13 mantissa bits cleared
/// (a carry into the exponent is the overflow to infinity; a non-finite value is left as it is).
fn mma_round_tf32(&mut self, name: &str, count: usize) {
self.line(&format!(
"for (int i = 0; i < {count}; ++i) {{ union {{ float f; unsigned int u; }} t; t.f = (float){name}[i]; if ((t.u & 0x7f800000u) != 0x7f800000u) t.u = (t.u + 0x1000u) & 0xFFFFE000u; {name}[i] = t.f; }}"
));
}

/// `D = A.B + C` over the logical matrices: from `C`, ascending `k`; `(block, sfa, sfb)` scales each factor.
fn mma_product(
&mut self,
Expand Down
30 changes: 30 additions & 0 deletions crates/unpopped-cpu-c/tests/kernel_mma_emit_agrees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,33 @@ fn the_narrow_float_atoms_agree_with_the_oracle() {
agree_launch(tag, &k, args(&atom));
}
}

/// The tf32 atom: A and B are rounded to tf32 (ties away) before the products, in the oracle and in the generated C.
/// Inputs are `1 + j * 2^-13`, so the dropped mantissa bits change the answer (a plain `0.125` multiple would not).
#[test]
fn the_tf32_atom_agrees_with_the_oracle() {
let atom = MmaAtom::nvidia_m16n8k8_tf32_f32();
let tf = |seed: u32, len: u32| {
let bytes: Vec<u8> = (0..len)
.flat_map(|i| {
let j = (seed * 7 + i * 5 + 3) % 16;
let v = 1.0 + j as f32 * f32::powi(2.0, -13);
(if (seed + i) % 3 == 0 { -v } else { v }).to_le_bytes()
})
.collect();
KernelArg::Buffer(TypedBuffer::new(
ElementKind::F32,
vec![i64::from(len)],
vec![1],
bytes,
))
};
let n = |w| 32 * atom.values(w);
let args = vec![
tf(1, n(0)),
tf(2, n(1)),
KernelArg::Buffer(buffer(ElementKind::F32, 3, n(2))),
KernelArg::Buffer(buffer(ElementKind::F32, 0, n(2))),
];
agree_launch("mma_tf32", &kernel(&atom), args);
}
2 changes: 1 addition & 1 deletion crates/unpopped-vocab/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "unpopped-vocab"
version = "0.58.5"
version = "0.58.6"
description = "The driver-free classifier vocabulary for kernel generation: pure-data dispatch tags (ElementKind, ArchSku, OpCategory, layout / op-family tags), the StructureKey / OperandDesc classifier key and its `structure_key` derivation, the dispatch-table types, the PlanPreference / PrecisionGuarantee descriptors, and the DeviceRepr memory-layout marker. Vendor-neutral and device-free: it depends on no backend, no driver, and no vendor crate, so generators, selectors and runtimes can share one vocabulary without inheriting anyone's device stack. Extracted from the Baracuda workspace, where it was developed as baracuda-kernel-vocab."
edition.workspace = true
rust-version.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/unpopped/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "unpopped"
version = "0.58.5"
version = "0.58.6"
description = "A vendor-neutral kernel generator: the backend-agnostic IR, plan, transform pipeline, contracts and dispatch artifacts, plus the `Backend` and `Compiler` traits a target implements. Ships a portable-C99 reference backend and a CPU oracle, so it builds and self-tests with no device, no driver, and no vendor dependency. Device backends live under their own vendor identity and depend on this crate — the CUDA emitter, its NVRTC compiler and the Fuel synthesizer live in `baracuda-cuda-emit`. Pre-1.0 and moving; pin exact versions."
edition.workspace = true
rust-version.workspace = true
Expand Down
61 changes: 58 additions & 3 deletions crates/unpopped/src/mma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@
//! shipped: their metadata and scale-factor lane tables have not been checked against a source other than the atom's
//! own author, so the flags are exercised by atoms built in the tests.
//!
//! Shipped: the PTX `mma.sync.aligned` atoms `m16n8k16` (f16 and bf16 into f32) and `m16n8k32` (s8 into s32). The
//! `m16n8k8` tf32 atom waits for a tf32 operand notion: there is no tf32 `ElementKind`, and "the operands are
//! rounded to tf32 first" belongs to the compute rule, not to the layout.
//! - [`MmaAtom::with_tf32_inputs`]: the `F32` operands are rounded to tf32 before the products (the compute rule of the
//! tf32 atoms; there is no tf32 `ElementKind`, PM ruling Q5).
//!
//! Shipped: the PTX `mma.sync.aligned` atoms `m16n8k16` (f16 and bf16 into f32), `m16n8k32` (s8 into s32) and `m16n8k8`
//! (tf32 into f32, [`MmaAtom::nvidia_m16n8k8_tf32_f32`]).

use serde::{Deserialize, Serialize};
use unpopped_vocab::ElementKind;
Expand Down Expand Up @@ -128,6 +130,10 @@ pub struct MmaAtom {
/// The `k` block of the scale operands (0 when the atom is not block-scaled).
#[serde(default)]
block: u32,
/// `A` and `B` are rounded to tf32 (10 explicit mantissa bits, ties away from zero, as `cvt.rna.tf32.f32`) before
/// the products: the `m16n8k8` tf32 atom's compute rule (U57; PM ruling Q5, no `ElementKind`).
#[serde(default)]
tf32_inputs: bool,
}

impl MmaAtom {
Expand Down Expand Up @@ -164,6 +170,7 @@ impl MmaAtom {
layouts: layouts.map(Layout::flat_modes).to_vec(),
extras: Vec::new(),
block: 0,
tf32_inputs: false,
};
for (i, what) in ["A", "B", "C"].into_iter().enumerate() {
atom.check_bijection(i, what)?;
Expand Down Expand Up @@ -311,6 +318,30 @@ impl MmaAtom {
Ok(self)
}

/// Round `A` and `B` to tf32 before the products (the tf32 atoms: the operands are `F32` registers whose low 13
/// mantissa bits the hardware ignores, so the compute rule rounds them with `cvt.rna.tf32.f32` semantics).
///
/// # Errors
/// [`MmaAtomError`] if the atom already has the flag or its operands are not `F32`.
pub fn with_tf32_inputs(mut self) -> Result<Self, MmaAtomError> {
if self.tf32_inputs {
return Err(MmaAtomError::FlagTwice);
}
if self.a != ElementKind::F32 || self.b != ElementKind::F32 {
return Err(MmaAtomError::BadFlag(
"tf32 input rounding needs F32 operand fragments",
));
}
self.tf32_inputs = true;
Ok(self)
}

/// Whether `A` and `B` are rounded to tf32 before the products.
#[must_use]
pub const fn tf32_inputs(&self) -> bool {
self.tf32_inputs
}

fn push_extra(
&mut self,
role: ExtraRole,
Expand Down Expand Up @@ -458,6 +489,30 @@ impl MmaAtom {
.expect("the PTX m16n8k16 fragment layouts are bijections")
}

/// PTX `mma.sync.aligned.m16n8k8` with tf32 inputs and an f32 accumulator (U57). The operands are `F32` fragments
/// (`.b32` registers holding tf32 values) and the atom carries the tf32 rounding flag. Fragments (PTX ISA 9.5
/// 9.7.16.5.7, Figures 75, 78, 80, with `gid = lane / 4`, `tig = lane % 4`): `A` value `i` is row `gid + 8 * (i % 2)`,
/// column `tig + 4 * (i / 2)`; `B` value `i` is row `tig + 4 * i`, column `gid`; `C`/`D` as every `m16n8` atom. CUTLASS
/// `SM80_16x8x8_F32TF32TF32F32_TN` (`mma_traits_sm80.hpp`) gives the same maps (a different source and method).
#[must_use]
pub fn nvidia_m16n8k8_tf32_f32() -> Self {
let a = flat(&[(4, 16), (8, 1), (2, 8), (2, 64)]);
let b = flat(&[(4, 1), (8, 8), (2, 4)]);
Self::new(
AtomSpec {
name: "nvidia.mma.sync.m16n8k8.tf32.f32",
mnk: (16, 8, 8),
dtypes: (ElementKind::F32, ElementKind::F32, ElementKind::F32),
scope: Scope::Subgroup,
lanes: 32,
},
[&a, &b, &c_m16n8()],
)
.expect("the PTX m16n8k8 tf32 fragment layouts are bijections")
.with_tf32_inputs()
.expect("an F32 atom takes the tf32 flag")
}

/// PTX `mma.sync.aligned.m16n8k32` with s8 inputs and an s32 accumulator.
#[must_use]
pub fn nvidia_m16n8k32_s8_s32() -> Self {
Expand Down
Loading