[PR #175] [MERGED] HIP port of #167: MiniMax H3 VAE kernels #197

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

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-kitchen/pull/175
Author: @0xDELUXA
Created: 9/13/2026
Status: ✅ Merged
Merged: 9/14/2026
Merged by: @comfyanonymous

Base: main ← Head: amd/hip-minimax-h3-vae


📝 Commits (1)

📊 Changes

15 files changed (+1404 additions, -37 deletions)

View changed files

📝 comfy_kitchen/backends/hip/CMakeLists.txt (+7 -0)
📝 comfy_kitchen/backends/hip/__init__.py (+250 -4)
📝 comfy_kitchen/backends/hip/dlpack_bindings.cpp (+170 -4)
📝 comfy_kitchen/backends/hip/epilogue.h (+22 -0)
📝 comfy_kitchen/backends/hip/gemm_wmma.h (+40 -11)
📝 comfy_kitchen/backends/hip/hadamard.h (+93 -12)
📝 comfy_kitchen/backends/hip/mma.h (+17 -0)
➕ comfy_kitchen/backends/hip/ops/conv3d_fp16.hip (+86 -0)
➕ comfy_kitchen/backends/hip/ops/gemm_fp16.hip (+33 -0)
➕ comfy_kitchen/backends/hip/ops/group_norm_pad3d.hip (+263 -0)
📝 comfy_kitchen/backends/hip/ops/quantize_int8.hip (+12 -3)
📝 tests/test_hip_dispatch.py (+1 -1)
📝 tests/test_hip_wmma.py (+408 -0)
📝 tests/test_int8_input_act.py (+1 -1)
📝 tests/test_int8_residual.py (+1 -1)

📄 Description

Ports #167 to the HIP backend. A performance port, HIP already routed every new call through the eager fallbacks added by #167. Numbers are from gfx1200, fp16.

  • fp16_conv3d uses implicit GEMM on the existing WMMA tile core, gathering A rows directly from NDHWC (no im2col); bias + residual are fused in the epilogue. At C=128, 5x130x130: 1.4 ms vs 6.6 ms for torch channels_last_3d and 3.9 ms for torch NCDHW with MIOpen off. At 258x258: 5.3 vs 48.0 and 11.5 ms. Accumulation is fp32.

  • fp16_linear uses the same fp16 WMMA core. It only handles K > 4096, where it beats the eager path; smaller K falls back to torch. At the H3 w2 shape (1797x2048x8192), it is 1.13x faster than F.linear, or 1.15x with residual fused.

  • group_norm_silu_pad3d is ported from group_norm_pad3d.cu and registers on RDNA2. Statistics use fp32, with normalized values rounded via round_to. At C=128, 384x672: 2.9 ms vs 99.2 ms for the eager op.

  • int8_linear(input_act="rms_norm") folds RMS norm into the fused G=256 ConvRot quantizer; spill and G=16/64 paths remain eager. The quantizer is 1.23–1.35x faster, with int8_linear reaching 1.00–1.07x end to end on H3 decoder shapes.

  • The int8 residual epilogue was measured but not kept: 1.05–1.08x at N=6144/16384, but 0.93–0.98x at N=2048 where H3 uses it. No HIP bias-dtype changes are needed.

ComfyUI's H3 VAE currently keeps ROCm encoder paths in NCDHW (Comfy-Org/ComfyUI#16187), so only fp16_linear and the RMS-norm fold are reached today. The conv3d and group-norm kernels are ready when that path changes.

The tile core now supports gathered operands without changing the ISA of existing GEMMs on gfx1030/gfx1100/gfx1200. Compile-verified on gfx1030, gfx1100, gfx1151, and gfx1200 with no new scratch spills; the 17-target build links. Run-verified on gfx1200.


🔄 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/175 **Author:** [@0xDELUXA](https://github.com/0xDELUXA) **Created:** 9/13/2026 **Status:** ✅ Merged **Merged:** 9/14/2026 **Merged by:** [@comfyanonymous](https://github.com/comfyanonymous) **Base:** `main` ← **Head:** `amd/hip-minimax-h3-vae` --- ### 📝 Commits (1) - [`4983016`](https://github.com/Comfy-Org/comfy-kitchen/commit/49830166231f9ef2c463c6baaf106fa687d2109d) HIP port of #167: MiniMax H3 VAE kernels ### 📊 Changes **15 files changed** (+1404 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `comfy_kitchen/backends/hip/CMakeLists.txt` (+7 -0) 📝 `comfy_kitchen/backends/hip/__init__.py` (+250 -4) 📝 `comfy_kitchen/backends/hip/dlpack_bindings.cpp` (+170 -4) 📝 `comfy_kitchen/backends/hip/epilogue.h` (+22 -0) 📝 `comfy_kitchen/backends/hip/gemm_wmma.h` (+40 -11) 📝 `comfy_kitchen/backends/hip/hadamard.h` (+93 -12) 📝 `comfy_kitchen/backends/hip/mma.h` (+17 -0) ➕ `comfy_kitchen/backends/hip/ops/conv3d_fp16.hip` (+86 -0) ➕ `comfy_kitchen/backends/hip/ops/gemm_fp16.hip` (+33 -0) ➕ `comfy_kitchen/backends/hip/ops/group_norm_pad3d.hip` (+263 -0) 📝 `comfy_kitchen/backends/hip/ops/quantize_int8.hip` (+12 -3) 📝 `tests/test_hip_dispatch.py` (+1 -1) 📝 `tests/test_hip_wmma.py` (+408 -0) 📝 `tests/test_int8_input_act.py` (+1 -1) 📝 `tests/test_int8_residual.py` (+1 -1) </details> ### 📄 Description Ports #167 to the HIP backend. A performance port, HIP already routed every new call through the eager fallbacks added by #167. Numbers are from gfx1200, fp16. - `fp16_conv3d` uses implicit GEMM on the existing WMMA tile core, gathering A rows directly from NDHWC (no im2col); bias + residual are fused in the epilogue. At C=128, 5x130x130: 1.4 ms vs 6.6 ms for torch channels_last_3d and 3.9 ms for torch NCDHW with MIOpen off. At 258x258: 5.3 vs 48.0 and 11.5 ms. Accumulation is fp32. - `fp16_linear` uses the same fp16 WMMA core. It only handles K > 4096, where it beats the eager path; smaller K falls back to torch. At the H3 `w2` shape (1797x2048x8192), it is 1.13x faster than `F.linear`, or 1.15x with residual fused. - `group_norm_silu_pad3d` is ported from `group_norm_pad3d.cu` and registers on RDNA2. Statistics use fp32, with normalized values rounded via `round_to`. At C=128, 384x672: 2.9 ms vs 99.2 ms for the eager op. - `int8_linear(input_act="rms_norm")` folds RMS norm into the fused G=256 ConvRot quantizer; spill and G=16/64 paths remain eager. The quantizer is 1.23–1.35x faster, with `int8_linear` reaching 1.00–1.07x end to end on H3 decoder shapes. - The int8 residual epilogue was measured but not kept: 1.05–1.08x at N=6144/16384, but 0.93–0.98x at N=2048 where H3 uses it. No HIP bias-dtype changes are needed. ComfyUI's H3 VAE currently keeps ROCm encoder paths in NCDHW (Comfy-Org/ComfyUI#16187), so only `fp16_linear` and the RMS-norm fold are reached today. The conv3d and group-norm kernels are ready when that path changes. The tile core now supports gathered operands without changing the ISA of existing GEMMs on gfx1030/gfx1100/gfx1200. Compile-verified on gfx1030, gfx1100, gfx1151, and gfx1200 with no new scratch spills; the 17-target build links. Run-verified on gfx1200. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-26 22:21:29 +00:00
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#197
No description provided.