mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[GH-ISSUE #274] flash_attention_decode_gqa rejects single-token decode (S == 1): output stride check fails after DLPack normalizes size-1 strides #73
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#73
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?
Originally created by @ntsrigaud on GitHub (Oct 23, 2026).
Original GitHub issue: https://github.com/Comfy-Org/comfy-kitchen/issues/274
Environment
nvcr.io/nvidia/pytorch:25.09-py3), CUDA 13.0, Python 3.12.3.Symptom
The FLUX 3 Klein prompt upsampler (
qwen3.5_9b_flux3_prompt_upsampler_int8_convrot.safetensors, CLIPLoader typeflux3) fails in ComfyUI'sTextGenerateat the first decode step:Cause
flash_attention_decode_gqaallocatesoutput = torch.empty((batch, query_length, heads * head_dim)). For one-token decode with B=1, H=16, D=256, that is shape(1, 1, 4096)with torch strides(4096, 4096, 1)._wrap_for_dlpack, the CUDA binding sees strides(1, 1, 1), because PyTorch 2.9's DLPack export gives size-1 dimensions stride 1.output.stride(1) == heads * kHeadDimandoutput.stride(0) == query_length * heads * kHeadDim(dlpack_bindings.cpp,flash_attention_decode_gqa), which a size-1 dimension no longer satisfies. q is affected the same way,(4096, 256, 256, 1)becoming(1, 256, 1, 1), but its checks still pass.Other observations
--use-ck-attention: with this flag the cache becomesInt8FixedKVCache, and decode fails withUnsupported step merge strides, which looks like the same pattern.w4a8_codebook_mma_linear requires contiguous tensors. It may be related; cf. #248.torch.nn.functional.scaled_dot_product_attentiongives correct text, and matches_decode_gqa_torchto within 4.9e-4 (one token) and 4.8e-7 (three tokens).Steps to reproduce
Queue
CLIPLoader(the upsampler above, typeflux3) →TextGenerate(the officialflux3_klein_int8_t2i.jsonsystem prompt;max_length3584, sampling on, temperature 1, top_k 1, top_p 0.95, presence_penalty 1.5, seed 804; prompt "Appetizing bowl of rich Thailand tom yum soup on a plain white background") →PreviewAny. It fails at the first decode step.@potoior commented on GitHub (Oct 26, 2026):
I'd like to take this — planning to relax the binding's stride assertions for size-1 dimensions (whose strides are irrelevant to addressing), add a regression test driving the S == 1 decode path with synthetic tensors, and verify against the reference on real hardware.