mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[PR #112] [MERGED] Fix int8 attention rejecting batch-one inputs on PyTorch 2.9 and older #153
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#153
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/112
Author: @0xDELUXA
Created: 8/12/2026
Status: ✅ Merged
Merged: 8/12/2026
Merged by: @comfyanonymous
Base:
main← Head:amd/hip-int8-attention-size-one-strides📝 Commits (1)
2d5bf49Exempt size-one extents from the int8 attention stride checks📊 Changes
5 files changed (+75 additions, -24 deletions)
View changed files
📝
comfy_kitchen/backends/cuda/sage_attention/quant_qk_int8.cu(+16 -8)📝
comfy_kitchen/backends/cuda/sage_attention/quant_v_int8.cu(+9 -4)📝
comfy_kitchen/backends/hip/sage_attention/quant_qk_int8.hip(+13 -7)📝
comfy_kitchen/backends/hip/sage_attention/quant_v_int8.hip(+9 -5)📝
tests/test_int8_attention.py(+28 -0)📄 Description
Correctness fix for the int8 attention host-side guards, in both the CUDA and the HIP backend. Reported in #110 on gfx1151 with
torch 2.9.1+rocm7.2.1, where every MiniMax H3 workflow fails at the first attention call withsage int8 attention: Q/K base pointers and B/H/N strides must preserve 4-element alignment. Updating PyTorch resolves the issue.Cause
PyTorch 2.9.1 normalizes DLPack strides for size-one dimensions to
1. MiniMax H3 passesqwith shape[1, 56, 372, 128]and strides(7168, 128, 7168, 1), but the DLPack capsule becomes(1, 128, 7168, 1). The guard seesstride_b = 1and incorrectly rejects it as misaligned.A size-one dimension is only indexed at zero, so its stride cannot affect addressing or alignment. This affects torch 2.9.x and older.
Change
The Q/K and V int8 quantization guards now skip stride-alignment checks for dimensions with extent
< 2. Alignment checks for real extents and base pointers remain unchanged.Verification
stride_b == 0remains supported.61 passed, 5 skipped(one new regression test).nvcc. The edited guards compile cleanly with-std=c++17 -Wall -Wextra, and standalone tests matched HIP behavior.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.