Repository navigation
fix(minimax_h3): use the portable Triton libdevice in the audio VAE kernel so it compiles on ROCm - #1771
Open
WhatGhost wants to merge 1 commit into
Open
fix(minimax_h3): use the portable Triton libdevice in the audio VAE kernel so it compiles on ROCm#1771WhatGhost wants to merge 1 commit into
WhatGhost wants to merge 1 commit into
Conversation
…ernel so it compiles on ROCm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lightx2v/models/audio_encoders/hf/minimax_h3/triton_ops.py(added in #1721) importstriton.language.extra.cuda.libdevice. On ROCm the kernel fails to compile:so every MiniMax-H3 request that decodes audio fails on AMD GPUs. This PR imports
triton.language.extra.libdevice(dispatched per backend) and replaceslibdevice.rcp_rn(x), which the HIP libdevice does not provide, withtl.math.div_rn(1.0, x)(the same correctly rounded reciprocal).Results
AMD Radeon AI PRO R9700 (gfx1201), ROCm 7.2.4, torch 2.10.0, triton 3.6.0: MiniMax-H3 t2av at 768x1344x124 fails in the audio decoder on main and completes with this patch (the output has a non-silent audio track without clipping).
The audio decoder now runs the fused kernels from #1721 on AMD as well. Compared with its PyTorch modules (the path before #1721; on ROCm LightX2V disables cuDNN/MIOpen, so the grouped transposed convolution runs one GEMM + col2im per batch item and channel group):
vae_cpu_offload: weights moved in and out)Decodes are medians of 5, alternating the two paths in one process; the output matches the PyTorch modules to 100 dB SNR (max abs diff 9e-5). Full requests:
fp8-tritonDiT, 4-step LoRA, one request per path after a warmup, back to back on the same GPU, with the PyTorch modules forced by patchingMiniMaxH3AudioActivation1d.forward.NVIDIA
No change. GeForce RTX 5090 (sm_120), torch 2.11.0+cu130, Triton 3.6.0: the H3 audio VAE decoder with the released checkpoint and random latents of 207 and 603 frames (124- and 362-frame videos), before and after this patch:
Why: compiled for sm_80, sm_90 and sm_120,
expandsinresolve to the same__nv_expf/__nv_sinf(triton.language.extra.libdevicedispatches to the CUDA libdevice on NVIDIA, since Triton 3.0; it is also what Inductor imports). The reciprocal changes fromrcp.rn.ftz.f32todiv.rn.f32; both are correctly rounded and differ only for subnormal values, while the input isexp(beta) + 1e-9(0.29-5.62 over the checkpoint). The main path gains one SASS instruction; the rest of the added code is the division's out-of-line slow path for special values.Notes
Other kernels import
triton.language.extra.cuda.libdevicetoo (common/ops/norm/l2_normalize.py,common/ops/mm/fused_gelu_linear.py,common/ops/attn/kernels/ulysses_layout.py,models/video_encoders/hf/minimax_h3_causal/rgb.py,common/kvcache/attn/kernels/sage_*.py); they are not on the H3 t2av path and are left for a follow-up.