Qwen2.5-VL text encoder fails on Intel XPU: unique_consecutive on cu_window_seqlens (split_with_sizes ... got split_sizes=[])
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 158
Description
### Custom Node Testing
- [x] I have tried disabling custom nodes and the issue persists (the standalone reproduction below imports `comfy` directly and loads no custom nodes)
### Expected Behavior
`TextEncodeQwenImageEdit` / `TextEncodeQwenImageEditPlus` (and any Qwen-Image / Qwen-Image-Edit workflow, e.g. the bundled "Qwen-Image-Edit 2511" template) encodes the prompt on an Intel GPU, as it does on CUDA.
### Actual Behavior
Every prompt encode fails inside the Qwen2.5-VL vision transformer on Intel XPU (torch 2.14.0+xpu, Arc Pro B70 / Battlemage). The first submission raises
```
RuntimeError: split_with_sizes expects split_sizes to sum exactly to 784 (input tensor's size at dimension 2), but got split_sizes=[]
```
and a second submission of the same graph raises
```
RuntimeError: numel: integer multiplication overflow
```
from `torch.unique_consecutive`. Diffusion sampling itself is fine on this backend (FLUX.2 klein / dev run normally); the failure is specific to `comfy/text_encoders/qwen_vl.py`.
Cause: `Qwen2VLVisionTransformer.forward` builds `cu_window_seqlens` with `device=hidden_states.device` and runs `torch.unique_consecutive` on it. On this torch XPU build, `unique_consecutive` / `nonzero` / boolean-mask indexing on XPU tensors return wrong results (a 10-element `x[x % 2 == 0]` returns 2 elements instead of 5) or raise the overflow error. The tensor is only ever consumed through `lengths.tolist()` in `VisionAttention`, so it never needed to be on the device. Building it on the CPU fixes the encode; I have a one-line PR for it and will link it here.
### Steps to Reproduce
1. Intel XPU host with torch 2.14.0+xpu (`torch.xpu.is_available()` is True), ComfyUI master `54e03f5` (same line is in v0.34.5), `--use-pytorch-cross-attention`.
2. Run any Qwen-Image-Edit workflow with an input image, or the standalone script below (no server, no custom nodes) with the Comfy-Org repackaged `qwen_2.5_vl_7b.safetensors`:
```python
"""Minimal Qwen-Image-Edit prompt encode on current ComfyUI master, no custom nodes, XPU."""
import sys, os
sys.path.insert(0, sys.argv[1]); os.chdir(sys.argv[1])
import comfy.options; comfy.options.enable_args_parsing()
sys.argv = [sys.argv[0], "--oneapi-device-selector", "level_zero:gpu", "--disable-xformers", "--use-pytorch-cross-attention"]
import torch, comfy.sd, comfy.model_management as mm
print("ComfyUI", os.popen("git log --oneline -1").read().strip(), "| torch", torch.__version__, "| device", mm.get_torch_device())
clip = comfy.sd.load_clip(ckpt_paths=["/text_encoders/qwen_2.5_vl_7b.safetensors"], clip_type=comfy.sd.CLIPType.QWEN_IMAGE)
image = torch.rand(1, 384, 384, 3) # any image; the failure is in the vision encoder's bookkeeping
tokens = clip.tokenize("Picture 1: <|vision_start|><|image_pad|><|vision_end|>make the jacket yellow", images=[image])
cond = clip.encode_from_tokens_scheduled(tokens)
print("encoded", tuple(cond[0][0].shape))
```
`python repro.py /path/to/ComfyUI`
### Debug Logs
Standalone reproduction on master `54e03f5` (no custom nodes):
```
Downloaded comfyui-workflow-templates-json
Downloaded comfyui-embedded-docs
Downloaded comfyui-frontend-package
Downloaded comfy-kitchen
Downloaded comfyui-workflow-templates-media-assets-01
Installed 12 packages in 826ms
ComfyUI 54e03f5 Add new model blueprints and reorganize subgraph categories (#14785) | torch 2.14.0+xpu | device xpu:0
Traceback (most recent call last):
File "qwen/repro_master.py", line 11, in
cond = clip.encode_from_tokens_scheduled(tokens)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "upstream-master/comfy/sd.py", line 342, in encode_from_tokens_scheduled
pooled_dict = self.encode_from_tokens(tokens, return_pooled=return_pooled, return_dict=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "upstream-master/comfy/sd.py", line 411, in encode_from_tokens
o = self.cond_stage_model.encode_token_weights(tokens)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "upstream-master/comfy/text_encoders/qwen_image.py", line 62, in encode_token_weights
out, pooled, extra = super().encode_token_weights(token_weight_pairs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "upstream-master/comfy/sd1_clip.py", line 743, in encode_token_weights
out = getattr(self, self.clip).encode_token_weights(token_weight_pairs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "upstream-master/comfy/sd1_clip.py", line 45, in encode_token_weights
o = self.encode(to_encode)
^^^^^^^^^^^^^^^^^^^^^^
File "upstream-master/comfy/sd1_clip.py", line 306, in encode
return self(tokens)
^^^^^^^^^^^^
File "torch/nn/modules/module.py", line 1783, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "torch/nn/modules/module.py", line 1794, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "upstream-master/comfy/sd1_clip.py", line 266, in forward
embeds, attention_mask, num_tokens, embeds_info = self.process_tokens(tokens, device)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "upstream-master/comfy/sd1_clip.py", line 228, in process_tokens
emb, extra = self.transformer.preprocess_embed(emb, device=device)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "upstream-master/comfy/text_encoders/llama.py", line 1266, in preprocess_embed
return self.visual(image.to(device, dtype=torch.float32), grid), grid
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "torch/nn/modules/module.py", line 1783, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "torch/nn/modules/module.py", line 1794, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "upstream-master/comfy/text_encoders/qwen_vl.py", line 451, in forward
hidden_states = block(hidden_states, position_embeddings, cu_seqlens_now, optimized_attention=optimized_attention)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "torch/nn/modules/module.py", line 1783, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "torch/nn/modules/module.py", line 1794, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "upstream-master/comfy/text_encoders/qwen_vl.py", line 278, in forward
hidden_states = self.attn(hidden_states, position_embeddings, cu_seqlens, optimized_attention)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "torch/nn/modules/module.py", line 1783, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "torch/nn/modules/module.py", line 1794, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "upstream-master/comfy/text_encoders/qwen_vl.py", line 235, in forward
torch.split(tensor, lengths.tolist(), dim=2) for tensor in (query_states, key_states, value_states)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "torch/functional.py", line 172, in split
return tensor.split(split_size_or_sections, dim)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "torch/_tensor.py", line 1069, in split
return torch._VF.split_with_sizes(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: split_with_sizes expects split_sizes to sum exactly to 784 (input tensor's size at dimension 2), but got split_sizes=[]
```
Full server log from the same machine on v0.34.5 (startup through both tracebacks; custom nodes were loaded in this run but none is on the failing path)
```
[INFO] setup plugin alembic.autogenerate.schemas
[INFO] setup plugin alembic.autogenerate.tables
[INFO] setup plugin alembic.autogenerate.types
[INFO] setup plugin alembic.autogenerate.constraints
[INFO] setup plugin alembic.autogenerate.defaults
[INFO] setup plugin alembic.autogenerate.comments
[INFO] setup plugin alembic.autogenerate.checkconstraint_byname
[WARNING] Could not autodetect AIMDO implementation, assuming Nvidia
[INFO] Set oneapi device selector to: level_zero:gpu
[INFO] Adding extra search path diffusion_models /diffusion_models
[INFO] Adding extra search path text_encoders /text_encoders
[INFO] Adding extra search path vae /vae
[INFO] Adding extra search path loras /loras
[INFO] Adding extra search path upscale_models /upscale_models
[INFO] [ComfyUI-Manager] Using `uv` as Python module for pip operations.
[START] Security scan
[DONE] Security scan
## ComfyUI-Manager: installing dependencies done.
** ComfyUI startup time: 2026-09-08 20:17:37.825
** Platform: Linux
** Python version: 3.12.14 (main, Sep 1 2026, 14:16:52) [Clang 22.1.3 ]
** Python executable: .venv/bin/python3
** ComfyUI Path: ComfyUI
** ComfyUI Base Folder Path: ComfyUI
** User directory: ComfyUI/user
** ComfyUI-Manager config path: ComfyUI/user/__manager/config.ini
** Log path: ComfyUI/user/comfyui.log
[INFO]
Prestartup times for custom nodes:
[INFO] 0.3 seconds: ComfyUI/custom_nodes/ComfyUI-Manager
[INFO]
[INFO] Found comfy_kitchen backend hip: {'available': False, 'disabled': False, 'unavailable_reason': 'PyTorch ROCm/HIP runtime not available', 'capabilities': []}
[INFO] Found comfy_kitchen backend triton: {'available': True, 'disabled': True, 'unavailable_reason': None, 'capabilities': ['adaln', 'apply_rope', 'apply_rope1', 'apply_rope1_', 'apply_rope_', 'apply_rope_split_half', 'apply_rope_split_half1', 'apply_rope_split_half1_', 'apply_rope_split_half_', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'int8_linear', 'na3d', 'quantize_and_rotate_rowwise', 'quantize_int8_rowwise', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8', 'rms_adaln', 'rms_rope', 'rms_rope1', 'rms_rope1_', 'rms_rope_', 'rms_rope_split_half', 'rms_rope_split_half1', 'rms_rope_split_half1_', 'rms_rope_split_half_', 'w4a8_int8_linear']}
[INFO] Found comfy_kitchen backend cuda: {'available': False, 'disabled': True, 'unavailable_reason': 'CUDA not available on this system', 'capabilities': []}
[INFO] Found comfy_kitchen backend eager: {'available': True, 'disabled': False, 'unavailable_reason': None, 'capabilities': ['adaln', 'apply_rope', 'apply_rope1', 'apply_rope1_', 'apply_rope_', 'apply_rope_split_half', 'apply_rope_split_half1', 'apply_rope_split_half1_', 'apply_rope_split_half_', 'convrot_w4a4_linear', 'dequantize_convrot_w4a4_weight', 'dequantize_int8_convrot_weight', 'dequantize_int8_convrot_weight_dtype', 'dequantize_int8_embedding', 'dequantize_int8_simple', 'dequantize_int8_simple_dtype', 'dequantize_mxfp8', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'dequantize_w4a8_int8_weight', 'gemv_awq_w4a16', 'int8_linear', 'na3d', 'prepare_int4_weight_for_int8_linear', 'quantize_and_rotate_rowwise', 'quantize_convrot_w4a4_weight', 'quantize_int8_convrot_weight', 'quantize_int8_rowwise', 'quantize_int8_tensorwise', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8', 'quantize_svdquant_w4a4', 'quantize_w4a8_int8_weight', 'rms_adaln', 'rms_rope', 'rms_rope1', 'rms_rope1_', 'rms_rope_', 'rms_rope_split_half', 'rms_rope_split_half1', 'rms_rope_split_half1_', 'rms_rope_split_half_', 'rotate_int8_convrot_weight', 'scaled_mm_mxfp8', 'scaled_mm_nvfp4', 'scaled_mm_svdquant_w4a4', 'stochastic_rounding_fp8', 'w4a8_int8_linear']}
[INFO] Checkpoint files will always be loaded safely.
[INFO] Total VRAM 31023 MB, total RAM 63976 MB
[INFO] pytorch version: 2.14.0+xpu
[INFO] Set vram state to: NORMAL_VRAM
[INFO] Device: xpu:0 Intel(R) Graphics [0xe223]
[INFO] Device: xpu:1 Intel(R) Graphics [0xe223]
[INFO] Using pytorch attention
[INFO] Python version: 3.12.14 (main, Sep 1 2026, 14:16:52) [Clang 22.1.3 ]
[INFO] ComfyUI version: 0.34.5
[INFO] comfy-aimdo version: 0.4.15
[INFO] comfy-kitchen version: 0.2.31
[INFO] comfyui-frontend-package version: 1.49.6
[INFO] comfyui-workflow-templates version: 0.11.55
[INFO] comfyui-embedded-docs version: 0.5.10
[INFO] comfy-kitchen version: 0.2.31
[INFO] comfy-aimdo version: 0.4.15
[INFO] [Prompt Server] web root: .venv/lib/python3.12/site-packages/comfyui_frontend_package/static
[INFO] Asset seeder disabled
.venv/lib/python3.12/site-packages/torch/jit/_script.py:1491: FutureWarning: `torch.jit.script` is deprecated. Please switch to `torch.compile` or `torch.export`.
warnings.warn(
[INFO] No OpenGL_accelerate module loaded: No module named 'OpenGL_accelerate'
[INFO] ### Loading: ComfyUI-Manager (V3.41)
[INFO] [ComfyUI-Manager] network_mode: public
[INFO] [ComfyUI-Manager] ComfyUI per-queue preview override detected (PR #11261). Manager's preview method feature is disabled. Use ComfyUI's --preview-method CLI option or 'Settings > Execution > Live preview method'.
[INFO] ### ComfyUI Revision: 760 [7fd919f0] *DETACHED | Released on '2026-09-05'
[INFO] ### Loading: ComfyUI-Impact-Pack (V8.28.3)
[INFO] [ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/model-list.json
[INFO] [ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/alter-list.json
[INFO] [Impact Pack] Wildcard total size (0.00 MB) is within cache limit (50.00 MB). Using full cache mode.
[INFO] [Impact Pack] Wildcards loading done.
[INFO] [ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/github-stats.json
[INFO]
Import times for custom nodes:
[INFO] 0.0 seconds: ComfyUI/custom_nodes/websocket_image_save.py
[INFO] 0.0 seconds: ComfyUI/custom_nodes/ComfyUI-segment-anything-2
[INFO] 0.0 seconds: ComfyUI/custom_nodes/ComfyUI-Manager
[INFO] 0.1 seconds: ComfyUI/custom_nodes/ComfyUI-Impact-Pack
[INFO]
[INFO] Context impl SQLiteImpl.
[INFO] Will assume non-transactional DDL.
[INFO] [ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json
[INFO] [ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/extension-node-map.json
[INFO] Using RAM pressure cache.
[INFO] Starting server
[INFO] To see the GUI go to: http://127.0.0.1:8188
[... a flux2_klein_t2i run that succeeded is omitted here ...]
[INFO] got prompt
[INFO] Using pytorch attention in VAE
[INFO] Using pytorch attention in VAE
[INFO] VAE load device: xpu:0, offload device: cpu, dtype: torch.bfloat16
[INFO] Requested to load WanVAE
[INFO] loaded completely; 27623.20 MB usable, 242.03 MB loaded, full load: True
FETCH ComfyRegistry Data [DONE]
[INFO] [ComfyUI-Manager] default cache updated: https://api.comfy.org/nodes
FETCH DATA from: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json [DONE]
[INFO] [ComfyUI-Manager] All startup tasks have been completed.
[INFO] Requested to load QwenImageTEModel_
[INFO] loaded completely; 14776.55 MB loaded, full load: True
[INFO] CLIP/text encoder model load device: xpu:0, offload device: cpu, current: xpu:0, dtype: torch.float16
[INFO] Creating deepclone of QwenImageTEModel_ for xpu:1.
[INFO] Requested to load QwenImageTEModel_
[INFO] loaded completely; 14776.55 MB loaded, full load: True
[INFO] CLIP/text encoder model load device: xpu:0, offload device: cpu, current: xpu:0, dtype: torch.float16
[INFO] Potential memory leak detected with model QwenImageTEModel_, doing a full garbage collect, for maximum performance avoid circular references in the model code.
[WARNING] WARNING, memory leak with model QwenImageTEModel_. Please make sure it is not being referenced from somewhere.
[INFO] Requested to load WanVAE
[INFO] Potential memory leak detected with model QwenImageTEModel_, doing a full garbage collect, for maximum performance avoid circular references in the model code.
[WARNING] WARNING, memory leak with model QwenImageTEModel_. Please make sure it is not being referenced from somewhere.
[INFO] loaded completely; 12797.68 MB usable, 242.03 MB loaded, full load: True
[INFO] Potential memory leak detected with model QwenImageTEModel_, doing a full garbage collect, for maximum performance avoid circular references in the model code.
[WARNING] WARNING, memory leak with model QwenImageTEModel_. Please make sure it is not being referenced from somewhere.
[INFO] Requested to load QwenImageTEModel_
[INFO] Potential memory leak detected with model QwenImageTEModel_, doing a full garbage collect, for maximum performance avoid circular references in the model code.
[WARNING] WARNING, memory leak with model QwenImageTEModel_. Please make sure it is not being referenced from somewhere.
[INFO] loaded completely; 44580.55 MB usable, 14776.55 MB loaded, full load: True
[ERROR] !!! Exception during processing !!! split_with_sizes expects split_sizes to sum exactly to 784 (input tensor's size at dimension 2), but got split_sizes=[]
[ERROR] Traceback (most recent call last):
File "ComfyUI/execution.py", line 545, in execute
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)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/execution.py", line 344, in get_output_data
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)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/execution.py", line 318, in _async_map_node_over_list
await process_inputs(input_dict, i)
File "ComfyUI/execution.py", line 306, in process_inputs
result = f(**inputs)
^^^^^^^^^^^
File "ComfyUI/comfy_api/internal/__init__.py", line 149, in wrapped_func
return method(locked_class, **inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy_api/latest/_io.py", line 1990, in EXECUTE_NORMALIZED
to_return = cls.execute(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy_extras/nodes_qwen.py", line 103, in execute
conditioning = clip.encode_from_tokens_scheduled(tokens)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd.py", line 341, in encode_from_tokens_scheduled
pooled_dict = self.encode_from_tokens(tokens, return_pooled=return_pooled, return_dict=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd.py", line 410, in encode_from_tokens
o = self.cond_stage_model.encode_token_weights(tokens)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/text_encoders/qwen_image.py", line 62, in encode_token_weights
out, pooled, extra = super().encode_token_weights(token_weight_pairs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd1_clip.py", line 743, in encode_token_weights
out = getattr(self, self.clip).encode_token_weights(token_weight_pairs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd1_clip.py", line 45, in encode_token_weights
o = self.encode(to_encode)
^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd1_clip.py", line 306, in encode
return self(tokens)
^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1783, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1794, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd1_clip.py", line 266, in forward
embeds, attention_mask, num_tokens, embeds_info = self.process_tokens(tokens, device)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd1_clip.py", line 228, in process_tokens
emb, extra = self.transformer.preprocess_embed(emb, device=device)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/text_encoders/llama.py", line 1266, in preprocess_embed
return self.visual(image.to(device, dtype=torch.float32), grid), grid
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1783, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1794, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/text_encoders/qwen_vl.py", line 451, in forward
hidden_states = block(hidden_states, position_embeddings, cu_seqlens_now, optimized_attention=optimized_attention)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1783, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1794, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/text_encoders/qwen_vl.py", line 278, in forward
hidden_states = self.attn(hidden_states, position_embeddings, cu_seqlens, optimized_attention)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1783, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1794, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/text_encoders/qwen_vl.py", line 235, in forward
torch.split(tensor, lengths.tolist(), dim=2) for tensor in (query_states, key_states, value_states)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/functional.py", line 172, in split
return tensor.split(split_size_or_sections, dim)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/_tensor.py", line 1069, in split
return torch._VF.split_with_sizes(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: split_with_sizes expects split_sizes to sum exactly to 784 (input tensor's size at dimension 2), but got split_sizes=[]
[... the same graph submitted a second time ...]
[INFO] got prompt
[INFO] Potential memory leak detected with model QwenImageTEModel_, doing a full garbage collect, for maximum performance avoid circular references in the model code.
[WARNING] WARNING, memory leak with model QwenImageTEModel_. Please make sure it is not being referenced from somewhere.
[INFO] Potential memory leak detected with model QwenImageTEModel_, doing a full garbage collect, for maximum performance avoid circular references in the model code.
[WARNING] WARNING, memory leak with model QwenImageTEModel_. Please make sure it is not being referenced from somewhere.
[INFO] Potential memory leak detected with model QwenImageTEModel_, doing a full garbage collect, for maximum performance avoid circular references in the model code.
[WARNING] WARNING, memory leak with model QwenImageTEModel_. Please make sure it is not being referenced from somewhere.
[INFO] Potential memory leak detected with model QwenImageTEModel_, doing a full garbage collect, for maximum performance avoid circular references in the model code.
[WARNING] WARNING, memory leak with model QwenImageTEModel_. Please make sure it is not being referenced from somewhere.
[INFO] Potential memory leak detected with model QwenImageTEModel_, doing a full garbage collect, for maximum performance avoid circular references in the model code.
[WARNING] WARNING, memory leak with model QwenImageTEModel_. Please make sure it is not being referenced from somewhere.
[INFO] Potential memory leak detected with model QwenImageTEModel_, doing a full garbage collect, for maximum performance avoid circular references in the model code.
[WARNING] WARNING, memory leak with model QwenImageTEModel_. Please make sure it is not being referenced from somewhere.
[INFO] Potential memory leak detected with model QwenImageTEModel_, doing a full garbage collect, for maximum performance avoid circular references in the model code.
[WARNING] WARNING, memory leak with model QwenImageTEModel_. Please make sure it is not being referenced from somewhere.
[ERROR] !!! Exception during processing !!! numel: integer multiplication overflow
[ERROR] Traceback (most recent call last):
File "ComfyUI/execution.py", line 545, in execute
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)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/execution.py", line 344, in get_output_data
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)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/execution.py", line 318, in _async_map_node_over_list
await process_inputs(input_dict, i)
File "ComfyUI/execution.py", line 306, in process_inputs
result = f(**inputs)
^^^^^^^^^^^
File "ComfyUI/comfy_api/internal/__init__.py", line 149, in wrapped_func
return method(locked_class, **inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy_api/latest/_io.py", line 1990, in EXECUTE_NORMALIZED
to_return = cls.execute(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy_extras/nodes_qwen.py", line 103, in execute
conditioning = clip.encode_from_tokens_scheduled(tokens)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd.py", line 341, in encode_from_tokens_scheduled
pooled_dict = self.encode_from_tokens(tokens, return_pooled=return_pooled, return_dict=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd.py", line 410, in encode_from_tokens
o = self.cond_stage_model.encode_token_weights(tokens)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/text_encoders/qwen_image.py", line 62, in encode_token_weights
out, pooled, extra = super().encode_token_weights(token_weight_pairs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd1_clip.py", line 743, in encode_token_weights
out = getattr(self, self.clip).encode_token_weights(token_weight_pairs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd1_clip.py", line 45, in encode_token_weights
o = self.encode(to_encode)
^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd1_clip.py", line 306, in encode
return self(tokens)
^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1783, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1794, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd1_clip.py", line 266, in forward
embeds, attention_mask, num_tokens, embeds_info = self.process_tokens(tokens, device)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd1_clip.py", line 228, in process_tokens
emb, extra = self.transformer.preprocess_embed(emb, device=device)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/text_encoders/llama.py", line 1266, in preprocess_embed
return self.visual(image.to(device, dtype=torch.float32), grid), grid
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1783, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1794, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/text_encoders/qwen_vl.py", line 423, in forward
cu_window_seqlens = torch.unique_consecutive(cu_window_seqlens)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/_jit_internal.py", line 637, in fn
return if_false(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/_jit_internal.py", line 637, in fn
return if_false(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/functional.py", line 1206, in _consecutive_return_output
output, _, _ = _unique_consecutive_impl(input, return_inverse, return_counts, dim)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/torch/functional.py", line 1053, in _unique_consecutive_impl
output, inverse_indices, counts = _VF.unique_consecutive( # type: ignore[attr-defined]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: numel: integer multiplication overflow
```
### Other
- With the one-line change (`torch.tensor(cu_window_seqlens)` without `device=`) the same script encodes `(1, 215, 3584)` on master, and on v0.34.5 the encoder answers questions and describes images correctly when driven through `clip.generate`; Qwen-Image-Edit-2511 then follows prompts end to end on this GPU.
- The underlying defect is in torch-xpu-ops, not ComfyUI; minimal torch-only reproducer on this build: `x = torch.arange(10, device="xpu"); x[x % 2 == 0].tolist()` returns `[0, 1]`. ComfyUI's SAM3 nodes hit the same bug (`pred_boxes[keep]` in `nodes_sam3.py`), which is out of scope for the PR.
Contributor guide
Research direction
Read comfy/text_encoders/qwen_vl.py, especially Qwen2VLVisionTransformer.forward and VisionAttention, where cu_window_seqlens is built and consumed. Run the standalone reproduction from the issue on Intel XPU with the specified PyTorch setup. Done when Qwen image prompt encoding succeeds without the split-size or unique_consecutive error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- backend, machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100