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 docs/audit/backend/apple/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -2659,3 +2659,9 @@ Runtime dispatch contract changed. A compiled-ROCm **failure** (tessera-opt ran
Measured before the fix: a deliberately broken pass pipeline returned `ok=True, compiler_path="rocm_compiled", execution_kind="native_gpu"` with correct numbers. Strict-mode suite results are identical before and after (18 fail both ways, all pre-existing), so this adds no new failures.

**Outcome: parity validated — no change required.** Apple already routes failure-class dispatch through `_note_dispatch_fallback`; those sites are among the 18 pre-existing strict-mode failures measured on main (`tessera.matmul: MPS matmul symbol unavailable for dtype float32`). That is the funnel working as designed on this backend, and it is the precedent this change follows rather than a parallel mechanism (Decision #31).

## Cross-backend sync `ROCM-PIPELINE-TILE-LOWERING-2026-08-04` — the compiled pipeline can lower `tile.mma`

Both ROCm compiled pipelines (plain and canonical) now run `lower-tile-to-rocm{arch=<chip>}` after `generate-wmma-gemm-kernel`. Verified byte-identical hsaco with and without the pass on the default path, so the production lane is unchanged.

**Outcome: not applicable — architecture-specific reason.** No `!tile.fragment` or `tile.mma` consumers on this backend (`TILE-FRAGMENT-TYPE-PARAM-2026-08-03`), and no ROCm pipeline is involved.
6 changes: 6 additions & 0 deletions docs/audit/backend/nvidia/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -2238,3 +2238,9 @@ Measured before the fix: a deliberately broken pass pipeline returned `ok=True,
**Outcome: not applicable — architecture-specific reason.** The changed sites are all `_RocmCompiledUnavailable` raise points inside ROCm compiled-lane hsaco builders. NVIDIA's compiled lanes do not raise that exception and are untouched.

**Follow-up worth recording, not created here:** NVIDIA has no equivalent failure/envelope split on its own compiled paths, so the same masking may exist there. Establishing that needs an sm_120 host, which this box is not — asserting it either way from here would be the guesswork this thread has been eliminating.

## Cross-backend sync `ROCM-PIPELINE-TILE-LOWERING-2026-08-04` — the compiled pipeline can lower `tile.mma`

Both ROCm compiled pipelines (plain and canonical) now run `lower-tile-to-rocm{arch=<chip>}` after `generate-wmma-gemm-kernel`. Verified byte-identical hsaco with and without the pass on the default path, so the production lane is unchanged.

**Outcome: follow-up required — recorded, not fixed here.** The equivalent NVIDIA seam is worse, not merely missing: `NVWGMMALoweringPass` lowered a `tile.mma` carrying an accumulator to a two-operand call and dropped it (`NVWGMMA-ACCUMULATOR-GUARD-2026-08-03`). That is guarded to fail closed; threading it for real is W1.1 step 2b on this backend and needs an sm_120 host for the numeric gate that ROCm just got.
14 changes: 14 additions & 0 deletions docs/audit/backend/rocm/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -2348,3 +2348,17 @@ Measured before the fix: a deliberately broken pass pipeline returned `ok=True,
18 failure-class raise sites across the gemm, canonical gemm, flash_attn fwd/bwd, linear_attn, softmax and norm fwd/bwd lanes now go through `_rocm_compiled_failed`. Two were missed on the first pass because the conversion matched MESSAGE TEXT; the structural gate `test_every_non_elf_check_routes_through_the_funnel` now enumerates by the `!= b"\x7fELF"` guard instead, so wording cannot hide one again.

**Why it mattered here specifically:** W1.1 step 2b is gated on gfx1151 numerics, and that gate could not distinguish a working lowering from a silent fallback. With it fixed, the 2b measurement ran and inverted the plan (see `W1_1_TYPING_DESIGN.md` §4.3).

## Cross-backend sync `ROCM-PIPELINE-TILE-LOWERING-2026-08-04` — the compiled pipeline can lower `tile.mma`

Both ROCm compiled pipelines (plain and canonical) now run `lower-tile-to-rocm{arch=<chip>}` after `generate-wmma-gemm-kernel`. Verified byte-identical hsaco with and without the pass on the default path, so the production lane is unchanged.

**Outcome: follow-up required — this backend owns the change.**

`GenerateWMMAGemmKernel{via-tile=true}` emits `tile.mma %a, %b, %acc`, but no runtime pipeline lowered it: the op reached LLVM translation and died on *"missing LLVMTranslationDialectInterface registration ... for op: tile.mma"*. W1.1's Tile-IR seam was therefore unreachable from the lane that actually executes.

With the pass in place, via-tile compiles and runs **bit-identical** to the production `tessera_rocm.wmma` lane on gfx1151 at 64^3, 256^3 and 128x96x64 — so the accumulator survives the round trip. Gated by `test_rocm_pipeline_tile_lowering.py`: a structural count (every wmma-gemm lane must have a lowering) plus a hardware numeric comparison carrying the bogus-option control.

`arch=` is mandatory and gated separately: the pass defaults to a CDNA part and emits `llvm.amdgcn.mfma.contract`, an MFMA intrinsic wrong for RDNA 3.5 that does not resolve.

**Remaining:** `TileToROCM`'s TYPED fragment branch still requires a `FragmentZeroOp` accumulator, so the typed form cannot yet do what the untyped one now demonstrably does.
6 changes: 6 additions & 0 deletions docs/audit/backend/x86/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,9 @@ Runtime dispatch contract changed. A compiled-ROCm **failure** (tessera-opt ran
Measured before the fix: a deliberately broken pass pipeline returned `ok=True, compiler_path="rocm_compiled", execution_kind="native_gpu"` with correct numbers. Strict-mode suite results are identical before and after (18 fail both ways, all pre-existing), so this adds no new failures.

**Outcome: not applicable — architecture-specific reason.** x86 elementwise lanes raise `_RocmCompiledUnavailable` only for `lib is None` / missing-symbol conditions — envelope limits by construction, since there is no compile step whose output could be malformed. No x86 site was reclassified.

## Cross-backend sync `ROCM-PIPELINE-TILE-LOWERING-2026-08-04` — the compiled pipeline can lower `tile.mma`

Both ROCm compiled pipelines (plain and canonical) now run `lower-tile-to-rocm{arch=<chip>}` after `generate-wmma-gemm-kernel`. Verified byte-identical hsaco with and without the pass on the default path, so the production lane is unchanged.

**Outcome: not applicable — architecture-specific reason.** x86 carries `!tessera_x86.tile` and has no cooperative-matrix `tile.mma` path; its pipelines are untouched.
107 changes: 107 additions & 0 deletions docs/audit/compiler/W1_1_TYPING_DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,113 @@ see §4.1; each producer still needs its own fixture and at least one needs a
backend lowering fixture. Do not start at 5 (inventory: "Do not start at (4)" —
same rule, renumbered).

### 4.5 Step 3 is not a migration — no producer is fragment-shaped

Measured 2026-08-04, on starting step 3. The inventory (§6) warned to "expect
per-producer surprises"; the surprise is not per-producer, it is all of them.

`FragmentPackOp::verify` requires **exactly one `!tile.tile` input**. What the
five construction sites actually pass to `tile.mma`:

| site | operands |
|---|---|
| `TileIRLoweringPass` ×2 | `tile.async_copy` results — **tensors** (`st.addTypes({src.getType(), …})`) |
| `GenerateWMMAGemmKernel` | lane-level **vectors** (`toFrag` → `vector::BitCastOp`) |
| `GenerateWMMALinearAttnKernel` | same shape |
| `GenerateWMMAFlashAttnKernel` | same shape |

**Zero producers pass a `!tile.tile` or a `tile.view` result.** No operand can be
wrapped in `fragment_pack`: the typed contract expects
`tile.view → fragment_pack → tile.mma`, and every producer supplies either a
tensor or a vector whose lane math it has already done.

That is a **division-of-labour mismatch**, not a syntax gap. The typed form
assumes the COMPILER performs the lane mapping (`materializeFragmentPack`); the
hand-written generators perform it themselves and hand over finished vectors.
Both are coherent; they are different models.

**Consequences the plan's wording does not survive:**

* Step 3 ("migrate the 5 construction sites, one per PR") is not a migration. It
is a rewrite of working, numerically-verified generators — including the
production ROCm GEMM lane — to emit logical tile views and surrender their
lane math.
* Step 5 ("delete `MMAOp::verify()`'s permissive branch") is **unreachable as
written**: deleting it breaks every existing producer.

**Three options; this is an architectural choice, not a task:**

a. **Restructure the producers** to `tile.view → fragment_pack`. Rewrites
proven kernels for no measured performance benefit.
b. **Widen `fragment_pack`** to accept tensors/vectors. Cheap, and it discards
most of what the typed contract buys — §3's whole point was that the type
states what makes two fragments interchangeable.
c. **Scope the typed form to synthesized kernels** (the Decision #28 lane) and
treat the permissive branch as the documented boundary between two
legitimate models rather than debt awaiting deletion.

**Recommendation: (c).** The typed contract earns its keep where the compiler
owns the lane mapping — exactly the synthesizer's job. The hand-written
generators are a separate working lane whose operands are physical by design.
Under (c) step 5 becomes "the permissive branch is a declared compatibility
envelope, and any path where the compiler owns lane mapping must use the typed
form" — a Decision #32-style declared boundary rather than an open TODO.

This also closes W1.1 honestly: steps 1, 2 and 2b's guard are real contract
improvements that landed and are gated; steps 3–5 as written were premised on a
producer shape that does not exist.

---

### 4.4 Gap 2 is not independently actionable — it is coupled to step 3

§4.3 listed two remaining ROCm gaps. The first (the pipeline could not lower
`tile.mma`) is closed. The second — `TileToROCM`'s TYPED branch requiring a
`FragmentZeroOp` accumulator — **should not be fixed yet**, and the reason is
worth stating so it is not picked up as ready work.

**The typed branch has no producer and no test.** Measured 2026-08-04:

| question | answer |
|---|---|
| C++ passes emitting `fragment_pack` / `fragment_zero` | **none** (only the two consumers and the verifier mention them) |
| Python emitters producing them for ROCm | **none** — `runtime.py` has 0 occurrences |
| lit fixtures pairing a typed fragment with a ROCm lowering | **none** |
| tests asserting its `"typed ROCm lowering requires ..."` diagnostic | **none** |
| other users of `materializeFragmentPack` | none — it is local to `TileToROCM.cpp` |

**And the fix is not the obvious one.** Relaxing the `FragmentZeroOp` check
alone would reproduce the NVIDIA defect exactly: the typed branch synthesises
its own accumulator —

```cpp
Value zero = arith::ConstantOp::create(builder, loc, accTy,
builder.getZeroAttr(accTy));
state.addOperands({*a, *b, zero}); // typed branch — accumulator DISCARDED
state.addOperands({mmaData[0], mmaData[1], acc}); // untyped branch — threaded
```

— so accepting a non-zero accumulator without threading it would silently drop
it. Threading requires materialising the incoming accumulator fragment into the
physical `accTy` vector, the accumulator-side counterpart of
`materializeFragmentPack`, which A and B already have and the accumulator does
not.

That is real work, and it is **unverifiable today**: with no producer, there is
no program to run and therefore no numeric gate. Building it now would repeat
the mistake §4.3 corrected — infrastructure for a path nothing executes, sized
by reasoning rather than measurement.

**So gap 2 is a step-3 obligation, not a predecessor of it.** When a producer
migrates to emit typed fragments for ROCm, that migration must carry the
accumulator materialisation with it, and its numeric gate covers both. Until
then the branch is unexercised code whose contract cannot be checked.

The untyped path — which production uses via `via-tile` — already threads the
accumulator correctly and is proven bit-identical on gfx1151 (§4.3).

---

### 4.3 Measured 2026-08-04 — 2b for ROCm is NOT a region-signature conversion

§4.2 concluded that threading the accumulator means converting the `scf.for`
Expand Down
2 changes: 1 addition & 1 deletion docs/audit/generated/test_coverage.csv
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ map,0,0,0,0,1,,structural_only,category default for 'control_flow'
masked_categorical,10,0,0,10,0,,directly_tested,10 direct test references
masked_fill,11,4,0,15,0,fp16 fp32 fp4_e2m1 fp6_e3m2 fp8_e4m3 fp8_e5m2 nvfp4,directly_tested,15 direct test references
masked_scatter,14,0,1,14,0,fp16,directly_tested,14 direct test references
matmul,460,247,21,707,0,bf16 f16 f32 f64 fp16 fp32 fp4_e2m1 fp64 fp6_e2m3 fp6_e3m2 fp8_e4m3 fp8_e5m2 int32 int64 int8 nvfp4,directly_tested,707 direct test references
matmul,461,247,21,708,0,bf16 f16 f32 f64 fp16 fp32 fp4_e2m1 fp64 fp6_e2m3 fp6_e3m2 fp8_e4m3 fp8_e5m2 int32 int64 int8 nvfp4,directly_tested,708 direct test references
max,7,0,2,7,0,bf16 f16 f32 fp16 fp32 int32 int64,directly_tested,7 direct test references
max_pool,6,0,0,6,0,,directly_tested,6 direct test references
maximum,10,0,2,10,0,bf16 f32 fp16 fp32,directly_tested,10 direct test references
Expand Down
4 changes: 2 additions & 2 deletions docs/audit/generated/test_coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Generated from `python/tessera/compiler/test_coverage_audit.py`. Don't edit by
## Headline

- **482** ops in `primitive_coverage` registry.
- **4677** total Python-test references, **1147** total lit-fixture references.
- **4678** total Python-test references, **1147** total lit-fixture references.
- **83** ops have **zero** references in either test surface.
- **119** ops have ≤1 reference ("thinly tested").
- **159** ops have ≥10 references ("well tested").
Expand All @@ -17,7 +17,7 @@ Generated from `python/tessera/compiler/test_coverage_audit.py`. Don't edit by

| Op | py refs | lit refs | total | neg | dtypes |
|----|--------:|---------:|------:|----:|--------|
| `matmul` | 460 | 247 | 707 | 21 | `bf16`, `f16`, `f32`, `f64` … |
| `matmul` | 461 | 247 | 708 | 21 | `bf16`, `f16`, `f32`, `f64` … |
| `flash_attn` | 126 | 72 | 198 | 9 | `bf16`, `f16`, `f32`, `f64` … |
| `softmax` | 144 | 44 | 188 | 31 | `bf16`, `f16`, `f32`, `f64` … |
| `add` | 119 | 32 | 151 | 10 | `bf16`, `f16`, `f32`, `f64` … |
Expand Down
30 changes: 30 additions & 0 deletions python/tessera/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -5756,6 +5756,21 @@ def _build_compiled_gemm_hsaco(
pipeline = (
"builtin.module("
"generate-wmma-gemm-kernel,"
# W1.1 — lower any tile.mma the generator emitted.
#
# `generate-wmma-gemm-kernel{via-tile=true}` emits
# `tile.mma %a, %b, %acc` at the Tile-IR seam instead of
# `tessera_rocm.wmma`. Without this pass that op survives to LLVM
# translation and the build dies with "missing
# LLVMTranslationDialectInterface registration ... for op:
# tile.mma", so via-tile was unreachable in production.
#
# A no-op when via-tile is off: verified byte-identical hsaco
# with and without the pass on the default path. The arch is
# mandatory -- lower-tile-to-rocm defaults to a CDNA part and
# would emit `llvm.amdgcn.mfma.contract`, an MFMA intrinsic that
# is wrong for RDNA 3.5 and does not resolve.
f"lower-tile-to-rocm{{arch={chip}}},"
"lower-tessera-target-to-rocdl,"
"gpu.module(convert-scf-to-cf,convert-gpu-to-rocdl,"
"reconcile-unrealized-casts),"
Expand Down Expand Up @@ -5838,6 +5853,21 @@ def _build_canonical_gemm_hsaco(
"rocm-wave-lds-pipeline,"
"rocm-wave-lds-legality,"
f"generate-wmma-gemm-kernel{{canonical-staging={staging}}},"
# W1.1 — lower any tile.mma the generator emitted.
#
# `generate-wmma-gemm-kernel{via-tile=true}` emits
# `tile.mma %a, %b, %acc` at the Tile-IR seam instead of
# `tessera_rocm.wmma`. Without this pass that op survives to LLVM
# translation and the build dies with "missing
# LLVMTranslationDialectInterface registration ... for op:
# tile.mma", so via-tile was unreachable in production.
#
# A no-op when via-tile is off: verified byte-identical hsaco
# with and without the pass on the default path. The arch is
# mandatory -- lower-tile-to-rocm defaults to a CDNA part and
# would emit `llvm.amdgcn.mfma.contract`, an MFMA intrinsic that
# is wrong for RDNA 3.5 and does not resolve.
f"lower-tile-to-rocm{{arch={chip}}},"
"lower-tessera-target-to-rocdl,"
"gpu.module(convert-scf-to-cf,convert-gpu-to-rocdl,"
"reconcile-unrealized-casts),"
Expand Down
Loading
Loading