[Qwen Image 2.1] Hard crash in prefetch/staging-buffer path on Windows multi-GPU (Fatal Python error: Aborted)
Summary
Qwen Image 2.1 image editing / img-to-img generation hard-crashes ComfyUI during model initialization / the first sampling step on Windows with a multi-GPU setup.
Clarification: my failing workflow is image editing / img-to-img with an input image. The original issue description incorrectly referred to it as text-to-image. I have not confirmed this crash with pure text-to-image generation.
This is not a normal recoverable Python exception. The process terminates with:
0%| ... | 0/25 [00:00<?, ?it/s, Model Initializing ...]
Fatal Python error: AbortedThe top of the crash stack points to the Qwen Image 2.1 prefetch path:
File "comfy/ldm/wan/model_animate2.py", line ??? in prefetch
File "comfy/ldm/wan/model_animate2.py", line 217 in take
File "comfy/ldm/qwen_image21/model.py", line 353 in _forward
File "comfy/patcher_extension.py", line 113 in execute
File "comfy/ldm/qwen_image21/model.py", line 301 in forward
...Expected Behavior
Qwen Image 2.1 image editing / img-to-img should start sampling normally. If a GPU allocation or transfer cannot be completed, ComfyUI should ideally raise a recoverable CUDA/PyTorch error rather than aborting the entire Python process.
Actual Behavior
The text encoder and diffusion model are staged successfully:
[INFO] Model QwenImage21TEModel_ prepared for dynamic VRAM loading. 6018MB Staged.
[INFO] 0 models unloaded.
[INFO] Model QwenImage21 prepared for dynamic VRAM loading. 6920MB Staged.
0%| ... | 0/25 [00:00<?, ?it/s, Model Initializing ...]
Fatal Python error: AbortedComfyUI then exits completely.
Steps to Reproduce
- Run ComfyUI on Windows with the multi-GPU setup below.
- Load a Qwen Image 2.1 image editing / img-to-img workflow with an input image.
- Queue a generation (the failing run used 25 sampling steps).
- The model is staged, then ComfyUI aborts at
0/25while showingModel Initializing ....
Environment
- OS: Windows 11
- Python: 3.12 (from the crash paths)
- GPU: 2 × NVIDIA GeForce RTX 5060 Ti 16 GB
- ComfyUI: git/source checkout
- Dynamic VRAM loading is active according to the log
- Exact ComfyUI commit, PyTorch version, NVIDIA driver and CUDA runtime were not captured in this crash log
Suspected Area (not confirmed)
A local agent analysis suggested this may involve GPU staging-buffer allocation/reuse and/or asynchronous transfers.
The current model_animate2.py::prefetch() implementation creates two persistent staging buffers per tensor shape on the target device and then performs a non-blocking cast/copy on the offload stream:
buf_key = (tuple(t.shape), cast_dtype if cast_dtype is not None else t.dtype)
if buf_key not in self._staging:
self._staging[buf_key] = [
torch.empty(t.shape, dtype=buf_key[1], device=device)
for _ in range(2)
]
r = self._staging[buf_key][i % 2]
self._pending[i] = (
comfy.model_management.cast_to(
t, cast_dtype, device,
non_blocking=True,
stream=stream,
r=r
),
stream,
)Because the crash stack terminates inside prefetch -> take -> qwen_image21._forward, it may be worth checking:
- allocation/reuse of the two GPU staging buffers;
- lifetime or overwrite hazards around reused staging buffers;
- offload-stream / current-stream synchronization;
- asynchronous host-to-device copies / pinned-memory behavior;
- whether a CUDA failure from the async transfer path is causing the native process abort before PyTorch can surface an exception.
This is only a hypothesis; I have not confirmed the root cause.
Possibly Related
This may be related to #15255 ("Dynamic VRAM streaming crashes all generations..."), which documents Windows multi-GPU failures around host/pinned memory and CUDA transfers.
However, the failure mode here is slightly different: Qwen Image 2.1 aborts the Python process directly during its prefetch path, without first printing an explicit CUDA OOM / HostBuffer.read_file_slice exception.
I have not yet verified whether --disable-pinned-memory or forcing a single GPU with --cuda-device 0 avoids this specific Qwen Image 2.1 crash.
Crash Stack
Fatal Python error: Aborted
Stack (most recent call first):
File "C:\\soft\\comfyui_bygit\\ComfyUI\\comfy\\ldm\\wan\\model_animate2.py", line ??? in prefetch
File "C:\\soft\\comfyui_bygit\\ComfyUI\\comfy\\ldm\\wan\\model_animate2.py", line 217 in take
File "C:\\soft\\comfyui_bygit\\ComfyUI\\comfy\\ldm\\qwen_image21\\model.py", line 353 in _forward
File "C:\\soft\\comfyui_bygit\\ComfyUI\\comfy\\patcher_extension.py", line 113 in execute
File "C:\\soft\\comfyui_bygit\\ComfyUI\\comfy\\ldm\\qwen_image21\\model.py", line 301 in forward
File "C:\\soft\\comfyui_bygit\\ComfyUI\\.venv\\Lib\\site-packages\\torch\\nn\\modules\\module.py", line 1790 in _call_impl
File "C:\\soft\\comfyui_bygit\\ComfyUI\\.venv\\Lib\\site-packages\\torch\\nn\\modules\\module.py", line 1779 in _wrapped_call_impl
File "C:\\soft\\comfyui_bygit\\ComfyUI\\comfy\\model_base.py", line 254 in _apply_model
File "C:\\soft\\comfyui_bygit\\ComfyUI\\comfy\\samplers.py", line 335 in _calc_cond_batch
...
File "C:\\soft\\comfyui_bygit\\ComfyUI\\main.py", line 362 in prompt_worker
File "C:\\Users\\jz\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\threading.py", line 1032 in _bootstrap
[ERROR] ComfyUI exited with an error.Source: Comfy-Org/ComfyUI