Skip to content

rocm/gfx1151: K-unroll WMMA GEMM lever — measured, regresses, kept as reference - #357

Merged
gstoner merged 2 commits into
mainfrom
rocm-gfx1151-gemm-kunroll
Jul 10, 2026
Merged

gstoner merged 2 commits into
mainfrom
rocm-gfx1151-gemm-kunroll

Conversation

@gstoner

@gstoner gstoner commented Jul 10, 2026

Copy link
Copy Markdown
Owner

The occupancy/dual-issue follow-up from PR #356's inventory §9. I rigorously swept the two remaining WMMA GEMM levers on-device — both are negative, which closes the lever with data (and saves future effort chasing it).

What I measured (gfx1151, kernel-only, best-of-N)

1. Every untested asymmetric macro-tile (2×3, 3×3, 4×2, 2×5, 5×2, 5×3, 3×5, 2×6, 6×2, 2×7, 2×8, 3×6) at 1024–4096³:
No untested tile beats the current 2×4/3×4 adaptive. 3×4 is the confirmed sweet spot 1024–3072³; 4×3 edges it by only ~3% at 4096³ (a wash at 3072³). The 12-tile register-budget sweet spot holds.

2. K-unrolling (new kKernelTemplateKU — KU 16-wide K-panels/step → more MLP, then KU·MT·NT WMMAs):

tile KU1 KU2 KU4
2×4 8.5–10.8 −3% … +2% (4096) −63…−71%
3×4 8.5–12.7 −54…−66% −55…−67%
4×3 7.1–13.0 −43…−49% −52…−69%

Regresses. The KU× a/b load buffers blow the VGPR budget → occupancy collapse — the same cliff as 4×4. Only 2×4-KU2 at 4096³ is +2%, still far below 3×4-KU1.

Synthesis

Every lever that adds register pressure (bigger tiles, K-unroll, register prefetch) hits the same occupancy cliff; every memory-hierarchy lever (LDS, pipelined LDS) is a wash on unified LPDDR5x (Stage F). And the named dual-issue lever doesn't apply — the inner loop is WMMA-issue-bound (12 back-to-back WMMAs/step) and RDNA3 VOPD pairs VALU ops, not WMMA. The production register kernel is at the practical ceiling for this design on Strix Halo (~13 TFLOP/s ≈ 22% of the ~59 f16 WMMA peak). Past here needs a fundamentally lower-register-footprint design, or a datacenter arch where global bandwidth is the bottleneck and the kept LDS/pipe/KU rungs pay off.

What's kept

The KU variant + ..._bench_ku / ..._ku C-ABI entries are retained as a correctness-verified reference rung (like the existing LDS/pipe rungs), NOT promoted — production stays the size-adaptive 2×4/3×4 register kernel. test_rocm_gemm_ku_reference.py locks correctness across shapes (incl. ragged-K tail + KU=2/4). STRIX_HALO Stage H documents the full sweep + synthesis.

Verification

ruff + mypy clean; 50-test sweep green (KU reference, f32 gemm, perf ratchet, WMMA runtime symbol).

🤖 Generated with Claude Code

… reference

The occupancy/dual-issue follow-up. Rigorously swept the two remaining WMMA GEMM
levers on-device; both are negative, closing the lever.

- Asymmetric-tile sweep (2x3,3x3,4x2,2x5,5x2,5x3,3x5,2x6,6x2,2x7,2x8,3x6 at
  1024-4096³): no untested tile beats the 2x4/3x4 adaptive. 3x4 is the confirmed
  sweet spot; 4x3 edges it ~3% at 4096³ only. The 12-tile register-budget sweet
  spot holds.
- K-unroll (new kKernelTemplateKU: KU 16-wide K-panels/step then KU*MT*NT WMMAs;
  ..._bench_ku / ..._ku C-ABI + timedKernelLaunches/runDeviceGemm paths):
  REGRESSES. KU2 -54..-66% on 3x4, -43..-49% on 4x3; KU4 collapses -60..-71%. The
  KUx a/b load buffers blow the VGPR budget → occupancy collapse (same cliff as
  4x4). Only 2x4-KU2 at 4096³ is +2%, still far below 3x4-KU1.

Verified correct (test_rocm_gemm_ku_reference.py, incl. ragged-K tail + KU=2/4);
kept as a correctness-verified REFERENCE rung (like the LDS/pipe rungs) for a
lower-register design or a datacenter arch — NOT promoted (production stays the
size-adaptive 2x4/3x4 register kernel). STRIX_HALO Stage H documents the sweep +
the synthesis: every register-pressure lever hits the occupancy cliff, every
memory-hierarchy lever is a wash on this unified-memory APU, and dual-issue does
not apply to a WMMA-issue-bound loop (VOPD pairs VALU, not WMMA). The kernel is
at the practical ceiling (~13 TFLOP/s ≈ 22% peak) for this design on Strix Halo.

Verified: ruff + mypy clean; 50-test sweep green.

Co-Authored-By: Claude Opus 4.8 (1M context) <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: 6bbeb31857

ℹ️ 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 src/compiler/codegen/Tessera_ROCM_Backend/runtime/hip/tessera_rocm_gemm.cpp Outdated
…CI/review)

- CI drift: the new tessera_rocm_wmma_gemm_f16_{bench_ku,ku} C-ABI symbols are
  scanned into runtime_abi.csv; regenerate runtime_abi + compiler_progress.
- Review (P2): runGemmKU validated only M/N/K, so a nonpositive tile reached
  gridFor (mt/nt==0 → div-by-zero) or the kernel (ku==0 → K-loop increments by 0
  → GPU hang). Reject mt/nt/ku <= 0 before compile/launch (mirrors benchVariantKU)
  + reject tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gstoner
gstoner enabled auto-merge July 10, 2026 21:34
@gstoner
gstoner merged commit 80bb52c into main Jul 10, 2026
17 checks passed
@gstoner
gstoner deleted the rocm-gfx1151-gemm-kunroll branch July 11, 2026 13:00
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