mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
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#139
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/93
Author: @0xDELUXA
Created: 8/4/2026
Status: ✅ Merged
Merged: 8/4/2026
Merged by: @comfyanonymous
Base:
main← Head:amd/hip-swiglu-rotdim📝 Commits (1)
b07fb07HIP port of #88: swiglu input_act and partial-rotary rot_dim📊 Changes
6 files changed (+319 additions, -56 deletions)
View changed files
📝
comfy_kitchen/backends/hip/__init__.py(+34 -28)📝
comfy_kitchen/backends/hip/dlpack_bindings.cpp(+27 -15)📝
comfy_kitchen/backends/hip/hadamard.h(+25 -7)📝
comfy_kitchen/backends/hip/ops/quantize_int8.hip(+6 -1)📝
comfy_kitchen/backends/hip/ops/rms_rope.hip(+24 -4)📝
tests/test_hip_wmma.py(+203 -1)📄 Description
Ports #88 to the HIP backend.
#88 added
swigluas aninput_actand arot_dimprefix forrms_rope_split_half, fusing both into the CUDA kernels. HIP took them as eager fallbacks, so results were already correct. This is a performance port, not a correctness fix.Partial rotary
rot_dimrms_rope.hiprotates the firstrot_dimdims in split-half pairs(p, p + rot_dim/2)and adds a norm-only tail for the rest. The RMS reduction still spans the fullhead_dim. The tail's store performs the single rounding eager'srms_normapplies, so no extra rounding step is needed there.require_rope_shapesnow validates the freqs table againstrot_diminstead ofhead_dim. It is shared withapply_rope, which passeshead_dimand is unchanged.rot_dim = 0keeps rotating everything.The eager bail-outs in
rms_rope_split_half/rms_rope_split_half_are gone. The GQA path, where q and k have different head counts and route through single-tensor calls, carriesrot_dimthrough as well.SwiGLU
input_actThe ConvRot int8 quantizer gains act code 2, reading a
[gate | up]row twice as wide as the K it stages and writes. Only the activated row is staged in LDS, so the per-device K budget is unchanged.int8_linearnow tracks the activated widthk_actseparately from the raw input width, so the% 16check, the group-divisibility check and the LDS budget all see the width actually being quantized rather than the doubled input. Routesthe fused quantizer cannot serve (no convrot, K over the LDS cap) still apply the activation eagerly, matching the CUDA backend.
Architecture coverage
rms_rope.hiphas no WMMA dependency, so partial rotary works on RDNA2 through RDNA4.rms_rope_split_halfis not in_WMMA_ONLY_OPS, so it still dispatches to HIP on RDNA2.The swiglu kernel also compiles everywhere, but on RDNA2
int8_linearis dropped from the constraints (no matrix cores), so the fused path is unreachable there and the op routes to triton/eager. Same situation as the existinggelu_tanhfusion.Compile-verified on gfx1030 (RDNA2), gfx1100 (RDNA3), gfx1151 (RDNA3.5) and gfx1200 (RDNA4). Run-verified on RDNA4 only - the test machine has a single gfx1200, which cannot execute gfx11 or gfx10 code.
Tests
14 new cases in
tests/test_hip_wmma.py:rot_dimand dtyperot_dim == head_dimbit-identical to omitting itvproven untouchedrot_dimrejectedsilu(gate) * upfirst#88's tests parametrize over
["cuda", "triton", "eager"]only, so HIP coverage has to live in the HIP suite.One existing line changed:
test_rms_rope_rejects_a_short_weightcalls the raw_C.rms_ropebinding positionally and needed the new argument.Results
test_hip_wmma.py,test_hip_dispatch.py,test_int8_input_act.pyandtest_int8.py: 335 passed, 64 skipped.Full suite on gfx1200 (ROCm 7.15, torch 2.12): the failure set is identical with and without this change, verified by stashing and re-running. Those failures are pre-existing NVFP4/MXFP8 and triton-tolerance cases unrelated to the HIP backend.
Measured on gfx1200 at MiniMax shapes (56 x 128 heads,
rot_dim96, ffn 14336), against the eager fallback this replaces:rms_rope_split_half_int8_linear(fc2)Across 50 DiT blocks that is roughly 0.9 s per denoise step. MiniMax (
comfy/ldm/minimax/model.py) is currently the only ComfyUI model requesting either feature, so this is a no-op elsewhere.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.