我使用QWen3.5 文本生成报错,最新版本的
Custom Node Testing
- [ ] I have tried disabling custom nodes and the issue persists (see how to disable custom nodes if you need help)
Expected Behavior
/opt/ComfyUI/models/text_encoders/qwen3.5_4b_bf16.safetensors
Actual Behavior
/opt/ComfyUI/models/text_encoders/qwen3.5_4b_bf16.safetensors
Steps to Reproduce
/opt/ComfyUI/models/text_encoders/qwen3.5_4b_bf16.safetensors
Debug Logs
comfyui-1 | [INFO] Comfy model compiler graph breaks: 0, rogues: 11
comfyui-1 | [ERROR] !!! Exception during processing !!! Unsupported Flash Attention tensor strides
comfyui-1 | [ERROR] Traceback (most recent call last):
comfyui-1 | File "/opt/ComfyUI/execution.py", line 556, in execute
comfyui-1 | output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, v3_data=v3_data)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/opt/ComfyUI/execution.py", line 353, in get_output_data
comfyui-1 | return_values = await _async_map_node_over_list(prompt_id, unique_id, obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, v3_data=v3_data)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/opt/ComfyUI/execution.py", line 327, in _async_map_node_over_list
comfyui-1 | await process_inputs(input_dict, i)
comfyui-1 | File "/opt/ComfyUI/execution.py", line 315, in process_inputs
comfyui-1 | result = f(**inputs)
comfyui-1 | ^^^^^^^^^^^
comfyui-1 | File "/opt/ComfyUI/comfy_api/internal/__init__.py", line 149, in wrapped_func
comfyui-1 | return method(locked_class, **inputs)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/opt/ComfyUI/comfy_api/latest/_io.py", line 2219, in EXECUTE_NORMALIZED
comfyui-1 | to_return = cls.execute(*args, **kwargs)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/opt/ComfyUI/comfy_extras/nodes_textgen.py", line 74, in execute
comfyui-1 | generated_ids = clip.generate(
comfyui-1 | ^^^^^^^^^^^^^^
comfyui-1 | File "/opt/ComfyUI/comfy/sd.py", line 493, in generate
comfyui-1 | return self.cond_stage_model.generate(tokens, do_sample=do_sample, max_length=max_length, temperature=temperature, top_k=top_k, top_p=top_p, min_p=min_p, repetition_penalty=repetition_penalty, seed=seed, presence_penalty=presence_penalty, mtp=mtp)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/opt/ComfyUI/comfy/sd1_clip.py", line 755, in generate
comfyui-1 | return getattr(self, self.clip).generate(tokens, do_sample=do_sample, max_length=max_length, temperature=temperature, top_k=top_k, top_p=top_p, min_p=min_p, repetition_penalty=repetition_penalty, seed=seed, presence_penalty=presence_penalty, mtp=mtp)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/opt/ComfyUI/comfy/text_encoders/qwen35.py", line 1316, in generate
comfyui-1 | return self.transformer.generate(embeds, do_sample, max_length, temperature, top_k, top_p, min_p, repetition_penalty, seed,
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/opt/ComfyUI/comfy/text_encoders/qwen35.py", line 919, in generate
comfyui-1 | return self._generate_mtp(embeds, max_length, stop_tokens, mtp, sampling=sampling, position_ids=kwargs.get("position_ids"),
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/opt/ComfyUI/comfy/text_encoders/qwen35.py", line 1150, in _generate_mtp
comfyui-1 | commit, ranks = step()
comfyui-1 | ^^^^^^
comfyui-1 | File "/opt/ComfyUI/comfy/text_encoders/qwen35.py", line 1074, in step
comfyui-1 | dk, top, hid_in = draft(verify_tokens[:, k:k + 1], hid_in, pos + k)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/opt/ComfyUI/comfy/text_encoders/qwen35.py", line 1041, in draft
comfyui-1 | comfy.model_prefetch.prefetch_queue_pop(queue, device, head, dt, core=core,
comfyui-1 | File "/opt/ComfyUI/comfy/model_prefetch.py", line 333, in prefetch_queue_pop
comfyui-1 | core()
comfyui-1 | File "/opt/ComfyUI/comfy/text_encoders/qwen35.py", line 1027, in core
comfyui-1 | n1, r1 = self.mtp(draft_emb, draft_hidden, draft_freqs, mtp_kv)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
comfyui-1 | return self._call_impl(*args, **kwargs)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
comfyui-1 | return forward_call(*args, **kwargs)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/opt/ComfyUI/comfy/text_encoders/qwen35.py", line 854, in forward
comfyui-1 | x, _ = self.layers[0](x, attention_mask=None, freqs_cis=freqs_cis, optimized_attention=attention, past_key_value=past_key_value)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
comfyui-1 | return self._call_impl(*args, **kwargs)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
comfyui-1 | return forward_call(*args, **kwargs)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/opt/ComfyUI/comfy/text_encoders/qwen35.py", line 565, in forward
comfyui-1 | h, present_key_value = self.self_attn(self.input_layernorm(x), attention_mask=attention_mask, freqs_cis=freqs_cis, optimized_attention=optimized_attention, past_key_value=past_key_value)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
comfyui-1 | return self._call_impl(*args, **kwargs)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
comfyui-1 | return forward_call(*args, **kwargs)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/opt/ComfyUI/comfy/text_encoders/qwen35.py", line 529, in forward
comfyui-1 | output = past_key_value.attend(xq, xk, xv)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/opt/ComfyUI/comfy/text_encoders/llama.py", line 99, in attend
comfyui-1 | return comfy_kitchen.flash_attention_decode_gqa(xq, self.key, self.value, self.seqlen)
comfyui-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
comfyui-1 | File "/usr/local/lib/python3.12/dist-packages/comfy_kitchen/flash_attention.py", line 217, in flash_attention_decode_gqa
comfyui-1 | _cuda_backend._C.flash_attention_decode_gqa(
comfyui-1 | RuntimeError: Unsupported Flash Attention tensor strides
comfyui-1 |
comfyui-1 | [INFO] Prompt executed in 3.62 seconds
Other
No response
I traced the reported Unsupported Flash Attention tensor strides exception to the comfy-kitchen native GQA flash-decode binding (source Git blob c692d1942392484051e98ac497e359ee4f590413). Its stride guard requires K/V outer strides 0–2 to match, Q/K/V head-dimension stride to equal 1, and tightly packed output strides (final=1, row=heads256, batch=sequenceheads*256). This guard is separate from the earlier shape and BF16 checks.
I ran an isolated metadata-only classifier against that source contract: 15/15 unit tests PASS, 12/12 synthetic stride cases classified as expected. No actual Qwen3.5 execution or GPU repair is claimed, and the traceback enters the CUDA native extension; there is no basis yet to call this an AMD/ROCm bug.
To identify the failing tensor rather than guess: could you capture shape, stride() and dtype for q/k/v/output immediately before _cuda_backend._C.flash_attention_decode_gqa, plus GPU model, torch/CUDA version, installed comfy-kitchen version/build, ComfyUI commit and whether Qwen3.5 MTP/speculative decode is enabled? That would distinguish an upstream tensor-view/layout problem from a wheel/runtime mismatch. Blindly copying a large KV cache with .contiguous() before identifying the mismatch is not an evidenced fix.
If those metadata are available, I can evaluate the precise failing guard and derive a targeted regression test.
— Nigel Hutchinson, NH Applied | https://nhapplied.co.uk | [email protected]
我使用了下面的代码做了打印: def attend(self, xq, xk, xv): tree = self.tracker["tree"] print("==== FA DECODE GQA INPUT DEBUG ====") print(f"q: shape={xq.shape}, stride={xq.stride()}, dtype={xq.dtype}") print(f"k: shape={xk.shape}, stride={xk.stride()}, dtype={xk.dtype}") print(f"v: shape={xv.shape}, stride={xv.stride()}, dtype={xv.dtype}") print("===================================") if tree is not None: # every row attends the committed prefix, then its ancestors and itself through the log-sum-exp out, lse = comfy_kitchen.flash_attention_decode_gqa(xq, self.key, self.value, self.seqlen, return_lse=True, causal=False) return comfy_kitchen.flash_attention_decode_tree_merge(out, lse, xq, xk, xv, tree.mask, torch.empty_like(out)) return comfy_kitchen.flash_attention_decode_gqa(xq, self.key, self.value, self.seqlen) 打印日志如下: comfyui-1 | ==== FA DECODE GQA INPUT DEBUG ==== comfyui-1 | q: shape=torch.Size([1, 16, 1, 256]), stride=(4096, 256, 256, 1), dtype=torch.bfloat16 comfyui-1 | k: shape=torch.Size([1, 4, 1, 256]), stride=(1024, 256, 256, 1), dtype=torch.bfloat16 comfyui-1 | v: shape=torch.Size([1, 4, 1, 256]), stride=(1024, 256, 1024, 1), dtype=torch.bfloat16 comfyui-1 | =================================== 版本信息如下 Comfyui:version = "0.45.0" GPU: NVIDIA GeForce RTX 4090 D comfy-kitchen:0.2.41 MTP: auto or off 都是报错,其他没有做测试 torch version: 2.8.0+cu128 torch cuda runtime: 12.8
我重新配置了系统环境的版本,使用torch2.13&cu130,已经可以正常运行了