mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[PR #279] Accept DLPack-normalized size-1 strides in flash decode GQA #279
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#279
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/279
Author: @potoior
Created: 10/26/2026
Status: 🔄 Open
Base:
main← Head:dlpack-size1-stride-flash-decode📝 Commits (1)
c41c5d5Accept DLPack-normalized size-1 strides in flash decode GQA📊 Changes
3 files changed (+47 additions, -2 deletions)
View changed files
📝
comfy_kitchen/backends/cuda/dlpack_bindings.cpp(+8 -1)📝
comfy_kitchen/backends/hip/dlpack_bindings.cpp(+7 -1)📝
tests/test_flash_attention.py(+32 -0)📄 Description
Fixes #274
Problem
flash_attention_decode_gqarejects the first decode step of a single-token generate: PyTorch 2.9-era DLPack exports (observed on the NGC 25.09 container, GB10) normalize the strides of size-1 dimensions to 1, so the output[B, 1, H*D]reaches the binding with strides(1, 1, 1)and the binding's exact stride assertions throwUnsupported Flash Attention tensor strides(#274). The wrapper allocates that output itself, so nothing on the Python side can work around it.Change
Size-1 strides never participate in addressing (the index is always 0), so the binding now only constrains the strides of non-singleton dimensions, in both the CUDA and HIP bindings. The kernel keeps receiving whatever stride the export produced: for every dimension the assertions previously guarded, either the dimension is larger than 1 and the stride is still checked, or the dimension is 1 and the stride value is irrelevant to addressing.
Tests
test_flash_attention_decode_gqa_accepts_dlpack_normalized_size1_stridesdrives the CUDA binding directly with anas_stridedoutput whose strides mirror the normalized export — rejected before this change, accepted and numerically correct (against the softmax reference) after it. The test does not depend on the exporter's behavior, so it reproduces the #274 conditions on any torch.Verified on an NVIDIA Thor (sm_110, torch 2.11.0+cu130, whose DLPack export still preserves size-1 strides): the new test plus the full
test_flash_attention.pysuite pass (155 passed, 20 HIP-only skips). The HIP binding change mirrors the CUDA one line for line but could not be exercised without AMD hardware.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.