mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[PR #122] [MERGED] Occupancy-aware HIP WMMA GEMM tile selection and vectorized fp8 elementwise kernels #160
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/comfy-kitchen#160
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Comfy-Org/comfy-kitchen/pull/122
Author: @0xDELUXA
Created: 8/18/2026
Status: ✅ Merged
Merged: 8/25/2026
Merged by: @comfyanonymous
Base:
main← Head:amd/hip-gemm-tile-selection📝 Commits (2)
897aabaOccupancy-aware HIP WMMA GEMM tile selection and vectorized fp8 elementwise kernels9192c77Vectorize the stochastic-rounding fp8 quantize kernel📊 Changes
8 files changed (+379 additions, -88 deletions)
View changed files
📝
comfy_kitchen/backends/hip/fp8_utils.h(+16 -0)📝
comfy_kitchen/backends/hip/gemm_wmma.h(+78 -0)📝
comfy_kitchen/backends/hip/ops/gemm_fp8.hip(+1 -20)📝
comfy_kitchen/backends/hip/ops/gemm_int8.hip(+1 -16)📝
comfy_kitchen/backends/hip/ops/per_tensor_fp8.hip(+120 -12)📝
comfy_kitchen/backends/hip/ops/stochastic_round_fp8.hip(+80 -37)📝
tests/test_hip_wmma.py(+28 -2)📝
tests/test_qdq.py(+55 -1)📄 Description
This PR is a continuation of #94 by @crashingalexsan and carries two commits. The first cherry picks the author's commits with their permission, squashed into one commit that keeps their authorship, rebased onto current
main. The second extends the same vectorization tostochastic_round_fp8, the one fp8 elementwise kernel #94 left scalar.Performance-only change: no public API or numerics are changed, and all paths remain bit-identical.
GEMM tile selection
Replaces the previous
M/N/Kthreshold-based WMMA tile selection with a sharedlaunch_gemm_wmma()ingemm_wmma.h, used by both fp8 and int8 launchers. Selection now considers grid coverage, K depth, and warp grid.Shapes selecting the same config stay within +/- 4%. Outputs are bit-identical.
Elementwise kernels
per_tensor_fp8now has a 16-elements/thread path using 16-byte loads/stores when both pointers are aligned, with the original scalar path retained for misaligned views.At 64M elements:
Stochastic rounding
stochastic_round_fp8receives the same vectorized path, reaching 297 GB/s at 64M elements vs 142 GB/s previously.The per-element logic is shared through
stochastic_round_one()to guarantee identical rounding between paths. Vectorization helpers are shared throughfp8_utils.h.Scalar/vectorized paths were verified bit-identical across
float32/float16/bfloat16, bothe4m3fnande5m2, multiple sizes, and edge cases including NaNs, infinities, +/- 0, +/- 448, 57344 and subnormals.RDNA coverage
256x128 BKB=64tile, is removed.Testing
gfx1200:
main: 416 passed, 16 failed, 4 skippedThe same 16 NVFP4 failures occur on both revisions and originate from comfy-kitchen's Triton backend on AMD, unrelated to this PR.
The 56 additional passing tests cover deep-K/skinny GEMMs and misaligned-view elementwise cases.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.