Skip to content

ROCm: the compiled pipeline can lower tile.mma (via-tile reachable) - #508

Merged
gstoner merged 1 commit into
mainfrom
agent/rocm-pipeline-tile-lowering
Aug 4, 2026
Merged

gstoner merged 1 commit into
mainfrom
agent/rocm-pipeline-tile-lowering

Conversation

@gstoner

@gstoner gstoner commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Closes the first of the two gaps W1_1_TYPING_DESIGN.md §4.3 identified.

The gap

GenerateWMMAGemmKernel{via-tile=true} emits tile.mma %a, %b, %acc, and its own comment says the op "flows through rocm-wave-lds-pipeline + lower-tile-to-rocm". Neither runtime pipeline contained that pass. tile.mma survived to LLVM translation:

cannot be converted to LLVM IR: missing `LLVMTranslationDialectInterface`
registration for dialect for op: tile.mma

So W1.1's Tile-IR seam was unreachable from the lane that actually executes — including the canonical pipeline, which already runs tessera-tile-ir-lowering and rocm-wave-lds-pipeline and still had no tile→ROCm lowering after the generator.

Verified in both directions

Default path unchanged. With via-tile off there's no tile.mma to lower, and the emitted hsaco is byte-identical with and without the pass — diffed at the tessera-opt level before making the change, since adding a pass to a working production lane needs evidence rather than an assumption.

via-tile now reachable. Injecting only via-tile=true (no hand-added lowering) compiles and runs bit-identical to the production lane on gfx1151:

shape |base − via-tile| |via-tile − numpy|
64×64×64 0 1.8e-06
256×256×256 0 1.3e-05
128×96×64 0 2.2e-06

Every measurement carried the bogus-option control (inject an invalid pass option, require ok=False) — an earlier run of this experiment reported bit-identical output while the injection silently never applied.

arch= is mandatory, and gated

lower-tile-to-rocm defaults to a CDNA part and emits llvm.amdgcn.mfma.contract — an MFMA intrinsic wrong for RDNA 3.5 that doesn't resolve. The pipeline string stays syntactically valid, so this fails at link time rather than parse time. Hence a gate, not a comment.

Gates

test_rocm_pipeline_tile_lowering.py counts lowerings against generators (a third lane added without one fails here), forbids the arch-less spelling, and compares numerics on hardware. Teeth verified by deleting one pipeline's pass — structural and hardware tests both fail.

Remaining from §4.3

TileToROCM's typed branch still requires a FragmentZeroOp accumulator, so the typed form can't yet do what the untyped one now demonstrably does. That's next.

14442 unit, mypy 0, ruff clean, docs in sync.

🤖 Generated with Claude Code

Closes the first of the two gaps W1_1_TYPING_DESIGN.md §4.3 identified.

`GenerateWMMAGemmKernel{via-tile=true}` emits `tile.mma %a, %b, %acc` at the
Tile-IR seam, and its own comment says the op "flows through
rocm-wave-lds-pipeline + lower-tile-to-rocm". Neither runtime pipeline contained
that pass. `tile.mma` therefore survived to LLVM translation and the build died
with

    cannot be converted to LLVM IR: missing `LLVMTranslationDialectInterface`
    registration for dialect for op: tile.mma

so W1.1's Tile-IR seam was unreachable from the lane that actually executes --
including the canonical pipeline, which already runs `tessera-tile-ir-lowering`
and `rocm-wave-lds-pipeline` and still had no tile -> ROCm lowering after the
generator.

Both pipelines now run `lower-tile-to-rocm{arch=<chip>}` after
`generate-wmma-gemm-kernel`.

── Verified, in both directions ──

Default path unchanged: with via-tile off there is no `tile.mma` to lower and
the emitted hsaco is BYTE-IDENTICAL with and without the pass (diffed at the
tessera-opt level before making the change, since adding a pass to a working
production lane needs that evidence, not an assumption).

via-tile now reachable: injecting only `via-tile=true` -- no hand-added lowering
-- compiles and runs bit-identical to the production `tessera_rocm.wmma` lane on
gfx1151 at 64^3, 256^3 and 128x96x64, matching numpy to ~1e-05. The accumulator
survives the round trip.

Every measurement carried the bogus-option control (inject an invalid pass
option, require ok=False), because an earlier run of this experiment reported
bit-identical output while the injection silently never applied.

`arch=` is mandatory and separately gated: `lower-tile-to-rocm` defaults to a
CDNA part and emits `llvm.amdgcn.mfma.contract`, an MFMA intrinsic wrong for
RDNA 3.5 that does not resolve. The pipeline string stays syntactically valid,
so this fails at link time rather than parse time -- hence a gate, not a comment.

Gates: `test_rocm_pipeline_tile_lowering.py` counts lowerings against generators
(so a third lane added without one fails here), forbids the arch-less spelling,
and compares numerics on hardware. Teeth verified by deleting one pipeline's
pass: the structural and hardware tests both fail.

Remaining from §4.3: `TileToROCM`'s TYPED branch still requires a
`FragmentZeroOp` accumulator.

14442 unit, mypy 0, ruff clean, docs in sync.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9217eff66b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/unit/test_rocm_pipeline_tile_lowering.py
@gstoner
gstoner merged commit d8bd973 into main Aug 4, 2026
14 checks passed
gstoner added a commit that referenced this pull request Aug 4, 2026
PR #508 review: make the via-tile test fail if the compiled lane degrades
@gstoner
gstoner deleted the agent/rocm-pipeline-tile-lowering branch August 7, 2026 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant