[PR #130] Tune gfx1151 INT8 deep-K tile selection #164

Open
opened 2026-10-26 22:21:02 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-kitchen/pull/130
Author: @Yasei-no-otoko
Created: 8/22/2026
Status: 🔄 Open

Base: main ← Head: codex/optimize-int8-convrot-gfx1151


📝 Commits (1)

  • 0a2b1f4 Tune gfx1151 INT8 deep-K tile selection

📊 Changes

3 files changed (+107 additions, -14 deletions)

View changed files

📝 comfy_kitchen/backends/hip/gemm_wmma.h (+44 -14)
📝 comfy_kitchen/backends/hip/ops/gemm_int8.hip (+17 -0)
📝 tests/test_hip_wmma.py (+46 -0)

📄 Description

Summary

  • Build directly on current main, including #122's shared occupancy-aware WMMA selector.
  • Add a 256x128x128 INT8 specialization only for the measured gfx1151 target when M >= 512, N >= 128, K >= 14336, the grid covers the device, and either K >= 2N or the grid divides evenly across WGPs.
  • Derive the gfx target and WGP count from the GEMM allocation in the shared WMMA helper, so the specialized and fallback selectors cannot inspect different process-current devices.
  • Keep unmeasured gfx110x/gfx115x targets and RDNA 4 on #122's selector.
  • Keep benchmark tooling only on the separate operational branch; this PR changes the shared WMMA device probe, the INT8 launcher, and its tests.

Why this predicate

The original K >= 2N predicate was re-tested. It preserves the H3 contraction but is too broad without a depth floor: representative smaller-K shapes regressed by 0.5% to 20.8% on gfx1151. A plain K >= 14336 gate also selected the 256-row tile on some wide-N grids where the shared selector was faster. K = 14336 is the MiniMax-H3 mlp_down contraction depth.

The final predicate retains the H3/deep-K case and adds the 256-row tile only for complete WGP rounds. Compared with the previous K >= 14336 gate (HIP events, alternating fresh processes, median of run medians):

Shape (M,N,K) Previous Final Change
(512,8192,14336) 3.6192 ms 3.1618 ms -12.6%
(512,9216,14336) 3.7262 ms 3.6161 ms -3.0%
(1024,8192,14336) 6.5110 ms 6.3050 ms -3.2%
H3 (3802,5376,14336) same tile 15.1003 ms neutral

The current allocation-derived shared probe recheck measured H3 mlp_down at 15.1154 ms on gfx1151, within the prior run spread. Tested HIP outputs are bit-identical between selectors.

E2E on gfx1151

MiniMax-H3, same models/prompt/seed/settings, 124 frames at 24 fps, 20 steps:

  • Full 1344x768 fresh-process comparison after rebasing: current main 2119 s; #130 2093 s (-1.23%).
  • Fast selector iteration at 416x224, H.264 High + AAC-LC:
Selector E2E
Previous K >= 14336 gate 145.34 s
Original K >= 2N candidate 144.21 s
Final WGP + K >= 2N gate 145.35 s

The spread is below 0.8% and within fresh-process noise; the H3 shape selects the same tile in all three. Every file decodes to exactly 124 frames at 416x224/24 fps plus 5.167 s stereo AAC, with identical decoded video and audio SHA-256 hashes. The final review change only narrows other architectures and centralizes the device probe; it does not change gfx1151 tile selection or kernel math.

Architecture policy

  • RDNA 3 (gfx110x): #122 selector retained; compile validated, not performance-measured locally.
  • RDNA 3.5: specialization enabled only on measured gfx1151; gfx1150, gfx1152, and gfx1153 retain #122.
  • RDNA 4 (gfx12xx): #122 selector retained; compile and contributor runtime validated for gfx1200.

Validation

  • 32-thread HIP build for gfx1100, gfx1151, gfx1200, and gfx1201
  • Targeted H3/deep-K plus shared FP8 paths: 30 passed
  • test_hip_wmma.py, test_int8.py, and test_int8_input_act.py on gfx1151: 474 passed, 62 skipped
  • ruff check and git diff --check
  • gfx1151 H3 mlp_down HIP-event sanity check on final head: 15.1154 ms

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/comfy-kitchen/pull/130 **Author:** [@Yasei-no-otoko](https://github.com/Yasei-no-otoko) **Created:** 8/22/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `codex/optimize-int8-convrot-gfx1151` --- ### 📝 Commits (1) - [`0a2b1f4`](https://github.com/Comfy-Org/comfy-kitchen/commit/0a2b1f49951648f887f0b1ac597ec36ae0d93b25) Tune gfx1151 INT8 deep-K tile selection ### 📊 Changes **3 files changed** (+107 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `comfy_kitchen/backends/hip/gemm_wmma.h` (+44 -14) 📝 `comfy_kitchen/backends/hip/ops/gemm_int8.hip` (+17 -0) 📝 `tests/test_hip_wmma.py` (+46 -0) </details> ### 📄 Description ## Summary - Build directly on current `main`, including #122's shared occupancy-aware WMMA selector. - Add a `256x128x128` INT8 specialization only for the measured `gfx1151` target when `M >= 512`, `N >= 128`, `K >= 14336`, the grid covers the device, and either `K >= 2N` or the grid divides evenly across WGPs. - Derive the gfx target and WGP count from the GEMM allocation in the shared WMMA helper, so the specialized and fallback selectors cannot inspect different process-current devices. - Keep unmeasured gfx110x/gfx115x targets and RDNA 4 on #122's selector. - Keep benchmark tooling only on the separate [operational branch](https://github.com/Yasei-no-otoko/comfy-kitchen/tree/codex/ops-int8-pr130-pr127-pr129-gfx1151); this PR changes the shared WMMA device probe, the INT8 launcher, and its tests. ## Why this predicate The original `K >= 2N` predicate was re-tested. It preserves the H3 contraction but is too broad without a depth floor: representative smaller-K shapes regressed by 0.5% to 20.8% on gfx1151. A plain `K >= 14336` gate also selected the 256-row tile on some wide-N grids where the shared selector was faster. `K = 14336` is the MiniMax-H3 `mlp_down` contraction depth. The final predicate retains the H3/deep-K case and adds the 256-row tile only for complete WGP rounds. Compared with the previous `K >= 14336` gate (HIP events, alternating fresh processes, median of run medians): | Shape `(M,N,K)` | Previous | Final | Change | |---|---:|---:|---:| | `(512,8192,14336)` | 3.6192 ms | 3.1618 ms | -12.6% | | `(512,9216,14336)` | 3.7262 ms | 3.6161 ms | -3.0% | | `(1024,8192,14336)` | 6.5110 ms | 6.3050 ms | -3.2% | | H3 `(3802,5376,14336)` | same tile | 15.1003 ms | neutral | The current allocation-derived shared probe recheck measured H3 `mlp_down` at 15.1154 ms on gfx1151, within the prior run spread. Tested HIP outputs are bit-identical between selectors. ## E2E on gfx1151 MiniMax-H3, same models/prompt/seed/settings, 124 frames at 24 fps, 20 steps: - Full 1344x768 fresh-process comparison after rebasing: current `main` 2119 s; #130 2093 s (-1.23%). - Fast selector iteration at 416x224, H.264 High + AAC-LC: | Selector | E2E | |---|---:| | Previous `K >= 14336` gate | 145.34 s | | Original `K >= 2N` candidate | 144.21 s | | Final WGP + `K >= 2N` gate | 145.35 s | The spread is below 0.8% and within fresh-process noise; the H3 shape selects the same tile in all three. Every file decodes to exactly 124 frames at 416x224/24 fps plus 5.167 s stereo AAC, with identical decoded video and audio SHA-256 hashes. The final review change only narrows other architectures and centralizes the device probe; it does not change gfx1151 tile selection or kernel math. ## Architecture policy - RDNA 3 (`gfx110x`): #122 selector retained; compile validated, not performance-measured locally. - RDNA 3.5: specialization enabled only on measured `gfx1151`; `gfx1150`, `gfx1152`, and `gfx1153` retain #122. - RDNA 4 (`gfx12xx`): #122 selector retained; compile and contributor runtime validated for gfx1200. ## Validation - [x] 32-thread HIP build for gfx1100, gfx1151, gfx1200, and gfx1201 - [x] Targeted H3/deep-K plus shared FP8 paths: 30 passed - [x] `test_hip_wmma.py`, `test_int8.py`, and `test_int8_input_act.py` on gfx1151: 474 passed, 62 skipped - [x] `ruff check` and `git diff --check` - [x] gfx1151 H3 `mlp_down` HIP-event sanity check on final head: 15.1154 ms --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/comfy-kitchen#164
No description provided.