Skip to content

Support ROCm memory efficient SageAttention - #730

Open
Yasei-no-otoko wants to merge 1 commit into
kijai:mainfrom
Yasei-no-otoko:fix/rocm-minimax-h3-mem-eff-sage
Open

Support ROCm memory efficient SageAttention#730
Yasei-no-otoko wants to merge 1 commit into
kijai:mainfrom
Yasei-no-otoko:fix/rocm-minimax-h3-mem-eff-sage

Conversation

@Yasei-no-otoko

Copy link
Copy Markdown

Summary

  • use SageAttention's public Triton backend on HIP instead of requiring NVIDIA smXX detection
  • keep the existing CUDA architecture-specific kernels unchanged
  • allow the MiniMax H3 and Wan memory-efficient SageAttention patches on ROCm

Validation

  • python -m py_compile nodes/ltxv_nodes.py
  • git diff --check
  • loaded all KJNodes and registered MiniMaxH3MemoryEfficientSageAttentionPatch
  • Radeon 8060S / gfx1151 / ROCm 7.15: BF16 NHD (1, 512, 4, 128) output was finite with matching shape/dtype; mean absolute difference vs SDPA 0.000681, cosine similarity 0.999924
  • verified MiniMax H3 patch installation on two transformer blocks

@Yasei-no-otoko
Yasei-no-otoko marked this pull request as ready for review August 12, 2026 07:23
Copilot AI lite review requested due to automatic review settings August 12, 2026 07:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the memory-efficient SageAttention patches to work on ROCm/HIP by falling back to SageAttention’s public Triton/HIP backend when CUDA-arch detection is unavailable, while keeping the existing CUDA architecture-specific kernels intact.

Changes:

  • Adds a HIP fallback import path for SageAttention when CUDA arch detection cannot be used.
  • Uses the HIP SageAttention call path inside _sageattn_int8_fp8_nhd when available.
  • Updates WanVideo and MiniMax H3 patch guards/error messages to allow ROCm/HIP usage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread nodes/ltxv_nodes.py
Comment on lines +1704 to +1713
_sageattn_hip = None
try:
from sageattention.core import per_thread_int8_triton, per_warp_int8_cuda, per_block_int8_triton, per_channel_fp8, get_cuda_arch_versions, attn_false
_cuda_archs = get_cuda_arch_versions()
except Exception:
pass
if torch.version.hip is not None:
try:
from sageattention import sageattn as _sageattn_hip
except ImportError:
pass
Comment thread nodes/ltxv_nodes.py
Comment on lines +1881 to +1883
if _sageattn_hip is not None:
return _sageattn_hip(q, k, v, tensor_layout="NHD", is_causal=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants