mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[GH-ISSUE #230] [Bug] comfy kitchen attention (INT8) returns pure noise on AMD gfx1100 once text conditioning exceeds ~150 tokens (Qwen-Image 2.1 int8_convrot) #65
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#65
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 @snow930 on GitHub (Oct 1, 2026).
Original GitHub issue: https://github.com/Comfy-Org/comfy-kitchen/issues/230
[Bug]
comfy kitchen attention(INT8 attention) returns pure noise on AMD gfx1100 when the text conditioning exceeds ~60–200 tokens (Qwen-Image 2.1int8_convrot)Environment
v0.38.0-7-gfb2315f1, released 2026-09-30)gfx1100(RDNA3), 20 GBwin32), Python 3.13.15--reserve-vram 1.0 --enable-dynamic-vram --use-split-cross-attention --disable-xformers --auto-launch --port 8188Qwen-Image/qwen_image_2.1_int8_convrot.safetensorsQwen-Image/qwen3vl_8b_int8_convrot.safetensorsQwen-Image/qwen_image_2.1_vae_bf16.safetensorsSummary
With the attention backend set to
comfy kitchen attention(comfy_kitchen_int8), Qwen-Image 2.1int8_convrotsampling produces a pure彩色噪点 image, at normal speed and without any error or warning.The corruption depends only on the length of the text conditioning, with a sharp cutoff:
Length sweep (neutral repeated Chinese sentence, seed 123456789, 8 steps, cfg 1.0, euler/simple):
Switching back to the default attention backend (remove the
ModelAttentionBackendnode, soattention_splitis used) with the identical prompt, resolution, steps and seed produces a correct image.Minimal reproduction — official nodes only, no custom nodes
UNETLoader→qwen_image_2.1_int8_convrot.safetensors(weight_dtype: default)CLIPLoader→qwen3vl_8b_int8_convrot.safetensors(type: qwen_image)VAELoader→qwen_image_2.1_vae_bf16.safetensorsModelAttentionBackendwithbackend = comfy kitchen attention, inserted betweenUNETLoaderandKSamplerTextEncodeQwenImage21,resolution = 1024, prompt = the 232-token text below (or any prompt ≳ 200 tokens)EmptySD3LatentImage512×512KSampler:seed 123456789, steps 8, cfg 1.0, euler, simple, denoise 1.0VAEDecode→SaveImage→ pure noise in ~6–9 s, exit status
success, no warning.Now delete node 4 and reconnect
KSampler.modeltoUNETLoader(default split attention), rerun → correct image in ~9 s.Reproduction text (232 tokens, neutral content)
repeated 7 times (280 Chinese characters = 232 tokens).
Full API-format graph (the failing variant)
For the working control: delete
"4"and set"7".inputs.model = ["1", 0].Isolation matrix (all with the same checkpoint/VAE/sampler settings)
Ruled out
EmptySD3LatentImageproduced a byte-identical PNG (same sha256) — withdenoise=1.0the latent only supplies the noise shape.qwen3vl_8b_int8_convrotgives conditioning(1, 21, 4096)for the short prompt and(1, 435, 4096)for the long one; both are NaN-free and Inf-free, and neither carries anattention_mask(extraonly containspooled_output). The TE output looks healthy.Localization hints
attention_comfy_kitchen_int8(comfy/ldm/modules/attention.py) →comfy_kitchen.int8_attention(comfy_kitchen/sage_attention.py) →torch.ops.comfy_kitchen.int8_attention, i.e. the hip backend INT8 attention kernel, not AOTriton/SDPA.prefix_lengoes from ~21 to ~435 while the image side changes from 4096 to 1024 tokens — and it breaks in both directions._sage_buffers:padded_k = -(-kv_length // cta_k) * cta_k,_SAGE_CTA_K = 64) and the K "stabilization detector" anchor sampling (anchor_indices, one key index per batch/KV head read by the K quantizer), for inputs whose K length is dominated by a long prefix rather than by the padded image grid.status: success, and normal speed (2.4 s/it at 1024×1824 vs 55 s/it for split). This matches the "attention kernel returns wrong results without surfacing an error" pattern reported for other AMD attention paths (e.g. ROCm/aotriton#210).Impact
Qwen-Image 2.1
int8_convrot+comfy kitchen attentionis effectively unusable on AMD RDNA3 for prompt-enhancer workflows, whose enhanced prompts are typically 300–600 tokens. The only working alternative on this machine is the defaultattention_split, which is ~23× slower at 1024×1824.Note: the
pytorch attentionoption is not a workaround for this checkpoint either — it raisesRuntimeError: convrot global spill requires caller-provided workspace buffers.@0xDELUXA commented on GitHub (Oct 4, 2026):
This is the same bug as #214: comfy-kitchen 0.2.36 added a prepared dense-mask path to the HIP int8 attention kernel, and on gfx11 fast-math folded away the empty-tile guard, so fully masked key tiles produced NaN.
That also explains why only prompt length matters. In Qwen Image 2.1 the text tokens attend with a causal bool mask, while the image queries attend without any mask. A longer text segment sends that causal mask through the dense path and produces fully masked tiles; image resolution only changes the unmasked part, so it has no effect.
Fixed in
19ea55band released in comfy-kitchen 0.2.37, which current ComfyUI master requires. Could you update (pip install comfy-kitchen==0.2.37) and rerun the 232-token reproducer to confirm?