mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[PR #134] [CLOSED] HIP: accelerate AWQ W4A16 with WMMA #168
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#168
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/134
Author: @tangzzycc
Created: 8/24/2026
Status: ❌ Closed
Base:
main← Head:opt/hip-awq-w4a16-mma📝 Commits (4)
031236dHIP: accelerate AWQ W4A16 with WMMAdbe90f4fix(hip): keep mixed-dtype AWQ inputs on scalar path2d55d1bfix(hip): refine AWQ W4A16 dispatcha50e241fix(hip): refine AWQ W4A16 large-M fallback📊 Changes
5 files changed (+313 additions, -20 deletions)
View changed files
📝
comfy_kitchen/backends/hip/__init__.py(+54 -8)📝
comfy_kitchen/backends/hip/dlpack_bindings.cpp(+3 -3)📝
comfy_kitchen/backends/hip/ops/gemv_awq.hip(+125 -3)📝
tests/test_hip_dispatch.py(+8 -0)📝
tests/test_hip_wmma.py(+123 -6)📄 Description
Summary
This PR improves the HIP implementation of
gemv_awq_w4a16with size-based dispatch:The tiered design follows the existing CUDA backend: GEMV for small M, fused MMA for medium M, and dequantization followed by PyTorch matmul for very large M. The HIP implementation uses the project's existing RDNA WMMA policies.
M <= 8.M > 2048.The public API, packed weight layout, output layout, and bias behavior remain unchanged.
Implementation
The fused kernel uses a
16 x 128 x 64tile. Each workgroup stages one activation tile and one dequantized weight tile in LDS. The dequantized weights are shared across 16 activation rows and accumulated with the existingMmaF16orMmaBf16policy.The WMMA path requires group size 64, matching activation/scale/output dtypes, and a 16-byte-aligned activation pointer. Other inputs continue to use the original kernel. For very large M, materializing the dequantized weight is amortized by the tuned PyTorch matrix multiplication path.
Performance
Measured on an AMD Radeon 8060S (
gfx1151) with ROCm 7.2.BF16,
N=K=4096, medium-M comparison against the previous HIP kernel:BF16,
N=K=4096, routing comparison:The crossover near the dispatch limit varies with dtype and projection shape, so the fallback is intentionally limited to very large M.
Architecture verification
The extension was successfully compiled for every currently supported gfx11/gfx12 target
Code-object inspection confirmed FP16 and BF16 WMMA instructions on every target. The optimized kernels use 20,736 bytes of LDS and have no private-memory, VGPR, or SGPR spills. Runtime performance was measured on gfx1151; the remaining targets were validated through compilation and code-object inspection.
Validation
Test result:
The AWQ tests cover FP16/BF16 execution, small and non-tile-aligned shapes, scalar fallback, misaligned contiguous inputs, bias, and large-M routing.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.