Skip to content
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
6b9d008
feat(rocke): add human-approachable tiling primitives layer (helpers/…
cgmillette Jul 29, 2026
35d0f90
feat(rocke/tiling): add layout-viz + LDS bank-conflict model layer
cgmillette Aug 20, 2026
6659f44
Add edge classifier and reorder-cost plan to transforms
cgmillette Sep 3, 2026
1f5d979
Add analysis layer: coalescing and vectorization modeling
cgmillette Sep 3, 2026
45275f9
Add ASM-gated coalescing probe orchestrator
cgmillette Sep 3, 2026
3d8f7c7
Add tiling recorder for kernel transactions and ops
cgmillette Sep 3, 2026
1901174
Render coalescing address-space view and reorder/flow panels
cgmillette Sep 3, 2026
934fc3e
Add interleaved and CRC free-dim demo kernels
cgmillette Sep 3, 2026
4f62c73
Add block-diagram and auto-pipeline render automation
cgmillette Sep 3, 2026
23ac84e
Document label flow and viz API; retire design proposal
cgmillette Sep 3, 2026
807ee6d
Add tiling agentic tooling under tiling/.claude
cgmillette Sep 3, 2026
258fde9
Redact absolute perf figures from c_transpose proposal
cgmillette Sep 3, 2026
22903bf
Remove every dangerous default from the LDS conflict model
cgmillette Sep 16, 2026
6295089
Add a simulate mode to the LDS bank-conflict analysis
cgmillette Sep 16, 2026
3b06538
Refuse a read probe whose output window cannot hold the read
cgmillette Sep 16, 2026
adbc83b
Verify the read-mode probe against a golden
cgmillette Sep 16, 2026
72aa9dd
Add n_reads to isolate one LDS read by slope
cgmillette Sep 16, 2026
0218071
Add the validated gfx90a LDS read-port model
cgmillette Sep 16, 2026
393b147
Correct the layout-viz claims about the verify gates
cgmillette Sep 16, 2026
6636eb0
Require bank-conflict configs to be derived from the recording
cgmillette Sep 16, 2026
cb83bd3
Restructure the tiling-API skill after review
cgmillette Sep 16, 2026
7012d5d
Close the read-model review findings: gates, claims, and coverage
cgmillette Sep 16, 2026
bc1af35
Gate the read footprint, and fix an import test that only passed here
cgmillette Sep 17, 2026
a19ecab
Restore the layout-style trade-offs and split an unrunnable prompt
cgmillette Sep 17, 2026
c100949
Fix LDS conflict and layout-viz reporting bugs
cgmillette Sep 18, 2026
0be6f13
Update tiling docs, tooling, and recorder
cgmillette Sep 21, 2026
3ae9cb9
Harden the interleaved-tiling design doc; scrub flip&zip
cgmillette Sep 21, 2026
644116f
Restructure the tiling API into audience-tiered, composable primitives
cgmillette Sep 23, 2026
7aa3b2f
Move the tiling verification gates and geometry into analysis/
cgmillette Sep 24, 2026
4b6cd60
Tighten the tiling operand gate, LDS-bridge seam, and wide-load guard
cgmillette Sep 24, 2026
d8a2ea0
Check operand soundness at plan build and surface observer result types
cgmillette Sep 24, 2026
a4a55c3
Drop the auto_pipeline gate re-export shim; point callers at analysis
cgmillette Sep 24, 2026
ed599a9
Add the dense-atom interleavability proof sweep
cgmillette Sep 24, 2026
2f0858a
State the interleaving scope as a rule, not a frozen census
cgmillette Sep 24, 2026
99299e1
Refresh the AGENTS.md tiling section to the shipped surface
cgmillette Sep 24, 2026
5a4c93a
Emit global stores as base + constant so they vectorize to dwordx4
cgmillette Sep 24, 2026
2b830ff
Report a replicated layout in the transform classifier instead of gue…
cgmillette Sep 25, 2026
3cfc8e4
Add a mac_prio s_setprio knob to the tiling MMA driver
cgmillette Sep 25, 2026
2945800
Add a sched_group_barrier scheduling helper to the tiling API
cgmillette Sep 25, 2026
f6742b9
Record the tiling scheduling levers as knobs in the MMA/Tiling experts
cgmillette Sep 25, 2026
971c5b8
Reframe the recorded global-store vw=1 as a recorder-vs-ISA gap
cgmillette Sep 28, 2026
8ddff32
Record the cooperative-load split-axis corollary in the interleaving doc
cgmillette Sep 28, 2026
f20444a
Point the no-target error at declared_arch/declared_wave_size and cov…
cgmillette Sep 30, 2026
39d20b5
fix(rocke): validate the MMA accumulator layout before issuing
cgmillette Oct 5, 2026
c23e5e2
docs(rocke): add the API design standard and wire the style guides to it
cgmillette Oct 5, 2026
27d65ca
refactor(rocke): make MMA public accessors style-faithful, drop dupli…
cgmillette Oct 5, 2026
cb27b55
docs(rocke): sync MMA expert + layout-viz skill with style-faithful a…
cgmillette Oct 5, 2026
8e4e5f6
style(rocke): apply black formatting to the tiling layer
cgmillette Oct 5, 2026
0ad46b6
style(rocke): black-format the interleaved and manual gemm demos
cgmillette Oct 5, 2026
e486c9b
style(rocke): strip trailing whitespace from tiling docs
cgmillette Oct 5, 2026
8f044d1
Merge branch 'develop' into users/cgmillette/rocke/tiling-primitives
cgmillette Oct 5, 2026
6e005a8
fix(rocke): harden tiling emit/clip surface and fix viz star-export
cgmillette Oct 6, 2026
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
43 changes: 43 additions & 0 deletions dnn-providers/hip-kernel-provider/rocke/platform/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,49 @@ python3 dsl_docs/optimization/utilities/tools/wavescope/capture_wavescope_trace.
unavailable, and ISA-only analysis, see
`dsl_docs/optimization/utilities/skills/capture-kernel-trace-rocke.md`.

## Tiling primitives (`helpers/tiling/`)

A human-approachable, ND tiling + MMA primitives layer (`import rocke.helpers.tiling`). Reach for
it on **tiling problems**: MMA/GEMM-shaped kernels, wave-tile subtiling, custom thread/register
distributions, ragged/partial tiles (clipping), interleaved vs canonical operand layouts, and
target-agnostic MMA authoring — where you'd otherwise hand-write raw `TileDistributionEncoding`
integers.

**Before writing tiling code, read the docs** (they are the source of truth for what exists and
how to drive it):
- `helpers/tiling/docs/tiling_api_surface.md` — the **how-to-use catalog**: every surface, its
default (MMA-driven) mode AND its manual override, a composability matrix, and runnable examples.
Read this first to decide whether the problem is solvable with what's built.
- `helpers/tiling/docs/tiling_api_contract.md` — the **contract / why**: the audience tiers
(front door / toolbox / machinery), the glass-box principles, and how a custom override is
validated identically to a derived one.
- `helpers/tiling/docs/tiling_interleaving_design.md` — the **interleaved-layout SOT**: the recipe,
which atoms interleave (every dense square atom; the proof sweep is the census), and the
`InterleavedStyle` API.

**Workflow for a tiling problem:**
1. Read the API surface + contract docs; map the problem onto the built surface (dense MMA GEMM,
wave-tile subtiling with `order`, clipping/bounds, canonical vs interleaved operand layout,
arbitrary distributions via `make_tile_desc`, RCR + other data layouts). If a needed feature is
only `RESERVED`/`PLANNED` in the composability matrix, say so rather than inventing it.
2. Author with the front door: `TileMma` resolves the intrinsic and **processes the whole wave tile
(owns the M×N×K subtile grid + iteration + `order`)**, taking an optional `style=` (default
`CanonicalStyle`; `InterleavedStyle` for the wide-coalesced interleaved layout);
`make_tensor_desc`/`make_window` give ptr-free memory + auto-clipping; `make_fragment` + the
b-first verbs `load_fragment` / `store_fragment` / `fill_fragment` move data; `make_tile_desc(...)`
authors any custom distribution as a quantity-major geometric table (no raw encoding integers).
3. **Turn knobs / customize freely:** atom selection (shape tuple or intrinsic name), wave-tile
size, subtile `order`, operand `style=`, dtypes, target, clip bounds, and fully custom
distributions — all are data, composable per the matrix. The recorder + the `analysis/` gates
(`verify_lds_roundtrip` / `verify_mma_soundness`) verify a recorded kernel; reflection
(`describe`, `render_forward_map`, `render_inverse_map`) shows what any default resolved to.
4. Verify against a numpy golden reference (the demos are the template; torch is not used).

Tests: `PYTHONPATH=platform/python <venv>/python -m pytest platform/python/rocke/tests/helpers/tiling/ -q`.
Demos live under `helpers/tiling/kernels/` (e.g. `tiling_gemm_interleaved_demo.py`,
`tiling_gemm_manual_demo.py`). Built + bit-exact on gfx90a today; interleaved layouts are BUILT for
dense square atoms (`InterleavedStyle`); `c_transpose`, sparse, and MX remain reserved/planned seams.

## helpers/ placement

**Default:** new kernel logic goes in `instances/`. Promote to `helpers/` only when
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# rocKE — gfx architecture support audit (AICK-1582)

An inventory of which gfx targets rocKE supports, per component, distinguishing
**common code paths** (`core`, `helpers`, `instances/common`, `examples/common`,
`tests`) from **arch-specific lanes** (`instances/gfx*`, `examples/gfx*`). Derived
from the code; **device names only**, no performance data.

**Out of scope** (tracked elsewhere): fixing the gaps below (follow-up stories) and the
silent gfx950 device-detection fallback (AICK-1541 / AICK-1546).

## Targets in scope

| Target | Catalog (`arch_specs.json`) | ISA backend class | `instances/` lane | `examples/` lane | MMA family (wave) |
|---|---|---|---|---|---|
| gfx908 | ✗ | `Gfx9MfmaBackend` (forward-declared) | ✗ | ✗ | MFMA (wave64) |
| gfx90a | ✓ | `Gfx9MfmaBackend` | ✗ | ✗ | MFMA (wave64) |
| gfx942 | ✓ | `Gfx9MfmaBackend` | ✓ | ✓ | MFMA (wave64) |
| gfx950 | ✓ | `Gfx950Backend` | ✓ | ✓ | MFMA (wave64) — **default/baseline** |
| gfx1151 | ✓ | `Gfx11RdnaBackend` | ✓ | ✓ | WMMA (wave32) |
| gfx1201 | ✓ | `Gfx12RdnaBackend` | ✓ | ✓ | WMMA (wave32) |
| gfx1250 | ✓ | `Gfx1250Backend` (extends `Gfx12RdnaBackend`) | ✓ | ✓ | WMMA (wave32) |
| gfx11-generic | ✓ (alias) | `Gfx11RdnaBackend` | n/a | n/a | WMMA (wave32) |

Source: `core/arch/data/arch_specs.json`, `core/isa/backend.py:602` (`BACKEND_REGISTRY`),
`instances/`, `examples/`.

## Per-component support

### Core — arch catalog (`core/arch/`)
All six targets (+ the `gfx11-generic` alias) are populated in `arch_specs.json` with
wave size, LDS capacity, `vmcnt` width, MMA-atom catalog, memory-capability bits, and
`isa_triple`. `known_arches()` / `arch_from_isa()` / `ArchTarget.from_gfx()` read this
SSOT. **gfx908 has no row** — it is registered as a backend but cannot be built.

### Core — ISA backends (`core/isa/backend.py`)
`backend_for(arch)` resolves the gfx string to a backend class; a registered-but-
unpopulated target (gfx908) raises a `KeyError` with a "forward-declared … no
arch_specs.json metadata" message (`backend.py:642`). Capability divergences:

| Capability | Gfx9Mfma (908/90a/942) | Gfx950 | Gfx11Rdna (1151, generic) | Gfx12Rdna (1201) | Gfx1250 |
|---|---|---|---|---|---|
| MMA emission | MFMA | MFMA | WMMA (`emit_wmma`) | WMMA | WMMA |
| `s_waitcnt` | legacy split | legacy split | gfx11 layout | gfx11 layout | split counters (no legacy) |
| buffer SRD word3 | CDNA | CDNA | RDNA | RDNA | RDNA |
| async-LDS counter | ✗ | ✗ | ✗ | ✗ | ✓ |

### Core — lowering (`core/lower_llvm.py`, `core/lower_hip.py`)
Substantially **arch-neutral**: CFG, loops, memory ops, and type mapping are target-
independent. All arch-specific codegen (MMA family, `s_waitcnt`, buffer SRD, transpose
LDS reads) is funnelled through the single `ISABackend` selected at lowering init. The
default arch when none is given is **gfx950** (`core/backend.py`).

### Building blocks — MMA atoms (`helpers/atoms.py`)
Availability is **data-driven** via `ArchTarget.mma.has_shape()`; there are no hardcoded
per-arch `if gfx…` atom guards in Python.

| Atom group | Targets |
|---|---|
| MFMA f16/bf16 `16x16x16`, `32x32x8`, `4x4x4` | gfx90a, gfx942, gfx950 |
| MFMA fp32, fp8/bf8 | gfx942, gfx950 |
| MFMA K-packed (`…x32` / `…x16`) | gfx950 |
| MFMA MX (fp4/fp6) | gfx950 |
| WMMA `16x16x16` f16/bf16 (+ iu8/iu4 on gfx1151) | gfx1151, gfx11-generic |
| WMMA gfx12 `16x16x16` opcode | gfx1201 |
| WMMA K-packed `16x16x32` (+ fp8/bf8 mixed) | gfx1250 |

### Building blocks — common code (`helpers/`, `instances/common/`)
Mostly **arch-agnostic**: `distribution`, `tensor_view`, `pipeline`, `reduction`,
`schedule`, and `epilogues` operate in the tile/atom domain (epilogues use the atom's
own lane→output map, so they work for MFMA and WMMA alike). Most `instances/common`
builders import `ArchTarget` **only for spec validation** (`is_valid_spec` →
`has_shape`), not for codegen branching. The one genuinely arch-polymorphic dispatch is
`instances/common/gemm_universal.py::_mma_family()`, which selects MFMA vs WMMA by wave
size — one kernel body, both ISAs.

### Op-family coverage
| Family | gfx90a | gfx942 | gfx950 | gfx1151 | gfx1201 | gfx1250 |
|---|---|---|---|---|---|---|
| GEMM (`gemm_universal`, `mfma_gemm`) | ✓ | ✓ | ✓ | ✓ (WMMA) | ✓ (WMMA) | ✓ (WMMA) |
| Convolution (direct / implicit-gemm) | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ |
| Attention (`mfma_attention`) | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ |
| MoE (fused / mega) | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ |
| block-scale / MX GEMM | fp8: gfx942+ · MX: gfx950 | — | — | ✗ | ✗ | ✗ |

RDNA (gfx1151/1201/1250) currently has **GEMM only**; conv, attention, and MoE are
MFMA-authored and have no WMMA path.

### Tests (`tests/`)
| Target | Multiarch (CPU lowering) | Golden IR | Numeric (GPU) |
|---|---|---|---|
| gfx90a | ✓ | ✓ | via CDNA gate (no independent numeric case) |
| gfx942 | ✓ | ✓ | ✓ |
| gfx950 | ✓ | ✓ (heaviest) | ✓ |
| gfx1151 | ✓ | ✓ | ✓ (WMMA subset) |
| gfx1201 | ✓ | ✓ | ✗ (no numeric gate) |
| gfx1250 | ✓ | ✓ (mostly GEMM) | ✗ (no numeric gate) |
| gfx11-generic | ✓ | ✓ (alias) | ✗ |

Source: `tests/instances/test_rocke_multiarch.py`, `tests/golden/rocke_representative_ir_sha256.json`,
`tests/instances/test_rocke_numeric.py`.

## Common vs arch-lane summary
- **Common / arch-polymorphic:** `core`, `helpers`, `instances/common`, `examples/common`,
and the multiarch CPU test suite carry all targets through the catalog + atom dispatch.
- **Arch lanes:** `instances/gfx*` and `examples/gfx*` hold tuning and proof-of-concept
kernels. Note `instances/gfx1151/wmma_gemm.py` is a POC now superseded by
`gemm_universal` (`build_universal_gemm(spec, arch="gfx1151")`).

## Known issues / workarounds
1. **gfx950 default + silent device-detection fallback** — out of scope here (AICK-1541 / AICK-1546).
2. **gfx908** — backend registered but no catalog row; `backend_for("gfx908")` raises. Not usable.
3. **gfx90a** — catalog + backend present, but no `instances/`/`examples/` lane and no independent numeric gate (folded into the CDNA gate). Lowering-only today.
4. **RDNA breadth** — gfx1151/1201/1250 support GEMM only; WMMA conv/attention/MoE are unimplemented.
5. **Numeric gaps** — gfx1201 and gfx1250 have no on-GPU numeric test gate; golden IR for gfx1250 is mostly GEMM.
6. **Arch registry and MMA traits key on DISJOINT namespaces** — a raw target string matches at most one, and there is no bridge between them. Same class as item 2, generalized: a target present in one registry and absent from the other.

Measured (`arch_specs.json` keys vs the union of `supported_targets` over `load_mma_traits()`):

| | targets |
|---|---|
| in both | `gfx1250`, `gfx90a`, `gfx942`, `gfx950` |
| arch registry only | `gfx11-generic`, `gfx1151`, `gfx1201` |
| traits table only | `gfx11`, `gfx12`, `gfx908` |

The arch registry holds **specific targets**; the traits table holds a mix of specifics and **family umbrellas** (`gfx11`, `gfx12`). Overlap is partial in **both** directions, so a lookup miss in one namespace must never be reported as "this target is unsupported".

**`target_family` does not bridge them.** It matches a traits key for exactly one target (`gfx950`), and only because that target's family string happens to be its own name — the other values (`gfx9_mfma`, `gfx11_rdna`, `gfx12_rdna`, `gfx12_cdna`) are lowering-path labels and match **zero** traits rows. Closing this needs a new ordered match-key set per target, resolved once and passed as an object; see `multi_arch_data_layout.md` → "Resolving a target against the MMA catalog".

Related: `MmaTraits.supports()` takes a raw `str` and tests exact membership, which is the signature that makes the mismatch reachable.
7. **A matrix capability flag is not sufficient to emit a primitive** — a registered target can report a matrix capability TRUE while the catalog offers zero usable rows for it. Authority for "can I emit this" is the row carrying the layout parameters, not the flag.

## Proposed gap-closure priority
Ordering for follow-up stories (to be confirmed with the team):

1. **P1 — numeric validation** for targets that already have lanes but no on-GPU gate: gfx1201, gfx1250, and an independent gfx90a case.
2. **P2 — RDNA building-block breadth**: WMMA conv / attention / MoE, if RDNA is a delivery target.
3. **P3 — gfx908**: decide to drop the forward declaration or add a catalog row.
4. **P4 — golden IR breadth** for under-covered targets (gfx1250 non-GEMM families).
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,69 @@ Those are kernel-authoring concerns. New arches are added by updating
hardware facts only; they do not need to enumerate every existing kernel
family's pipelines.

### Residency — the occupancy model, and the inputs it still needs

"Occupancy math" above means this model, and it belongs here rather than in
`lds_banks.md`: residency touches capacity and resource limits, never banks.

**Residency is an UPPER BOUND from a model, not a definition, and it is
arch-dependent:** `min(LDS bound, register bound, wave-cap bound)`.

- **UNKNOWN bounds are EXCLUDED from the minimum**, and the result is labelled
by which bounds it covers — "≤ 4 workgroups, wave-cap bound only; LDS and
register bounds UNKNOWN".
- **If no bound is sourced, residency reads UNKNOWN** — not zero, not
unbounded. That empty case is the common one on a target nobody owns, and
leaving it unstated produces a `0` or an `inf` in a ranking column.
- **Never say a bound *binds*.** With one bound sourced you may say "≤ N by the
wave cap"; you may not say "the wave cap binds", because something UNKNOWN
may bind tighter. Binding is a MEASURED property.
- **Lead with the ORDERING, which needs no arch constants at all** — LDS bytes
are monotone arithmetic, so candidates can be ranked against each other long
before any bound computes. Treat the absolute bounds as a bonus that
populates as constants get registered.

**Honest status.** Three fields the model needs are published hardware
constants that are simply not registered yet, which is why two of the three
bounds are permanently UNKNOWN today:

| missing field | blocks |
|---|---|
| LDS bytes per CU (distinct from per-workgroup) | the LDS bound |
| register allocation granularity | the register bound |
| max waves per SIMD / per CU | the register bound |

These are hardware facts, not kernel-authoring concerns, so they sit on the
carry side of the list above. Registering them makes all three bounds
computable from registered data. Note also that **"registers" is not one
number** — some targets carry a separate accumulator file and some do not
(measured: `agprs=256` on gfx90a, `agprs=0` on gfx1201), so the register bound
must read both.

Registering these does not retire the exclude-UNKNOWN rule: provenance
degrades permanently when designing for a target nobody owns, so
device-sourced facts stay UNKNOWN however complete the registry gets. The rule
becomes rare instead of universal.

### Resolving a target against the MMA catalog

`ArchTarget` is documented above as carrying the supported MMA/WMMA shapes, so
the arch↔catalog key relationship is this document's design question. Two
constraints on the fix:

- **Resolve ONCE into a target object that carries its match keys, and query
every registry with that object — never with a raw string.** A raw string
with exact membership cannot express a target that resolves under a family
umbrella.
- A **match-key set is arch vocabulary, not kernel-family vocabulary**, so it
belongs on the carry side and does not violate the "does not carry" list
above. (Worth stating, because the rule reads as forbidding it at a glance.)

The *measured* state of that relationship per target — which targets resolve in
which registry — is a status finding, not a plan, and is audited in
`gfx_support_audit.md` under Known issues. This document says what the layering
should be; that one records where it currently is not.

ROCm version is a separate axis. `_DATALAYOUT` in `lower_llvm.py` is keyed by
both gfx and ROCm release. The backend interface threads ROCm version
explicitly (see "ISA Backend").
Expand Down
Loading
Loading