Comfy-Org / Comfy-Org/ComfyUI

IndexError: list index out of range in model_management.py during model loading

Open
#13,903 1 comment 1 reaction 0 assignees View on GitHub
Potential Bug
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 7h
Merged PRs (30d)
158

Description

### Custom Node Testing

- [ ] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)

### Expected Behavior

Not sure if this is actually a bug or just a one-off corrupted state, but i will just put it here in case it helps debugging.

Setup:
```sh
Found comfy_kitchen backend cuda: {'available': True, 'disabled': False, 'unavailable_reason': None, 'capabilities': ['apply_rope', 'apply_rope1', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8', 'scaled_mm_nvfp4']}
Found comfy_kitchen backend eager: {'available': True, 'disabled': False, 'unavailable_reason': None, 'capabilities': ['apply_rope', 'apply_rope1', 'dequantize_mxfp8', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8', 'scaled_mm_mxfp8', 'scaled_mm_nvfp4']}
Found comfy_kitchen backend triton: {'available': True, 'disabled': True, 'unavailable_reason': None, 'capabilities': ['apply_rope', 'apply_rope1', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8']}
Checkpoint files will always be loaded safely.
Total VRAM 8192 MB, total RAM 49078 MB
pytorch version: 2.10.0+cu130
Enabled fp16 accumulation.
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA GeForce RTX 3070 : cudaMallocAsync
Using async weight offloading with 2 streams
Enabled pinned memory 19631.0
working around nvidia conv3d memory bug.
Using pytorch attention
aimdo: src-win/cuda-detour.c:38:INFO:aimdo_setup_hooks: installing 6 hooks
aimdo: src-win/cuda-detour.c:28:DEBUG:install_hook_entries: hooks successfully installed
aimdo: src-win/shmem-detect.c:80:INFO:comfy-aimdo WDDM adapter match: NVIDIA GeForce RTX 3070 runtime_luid=00000000:0000e404 dxgi_luid=00000000:0000e404
aimdo: src/control.c:152:INFO:comfy-aimdo inited for GPU: NVIDIA GeForce RTX 3070 (VRAM: 8191 MB)
DynamicVRAM support detected and enabled
Python version: 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)]
ComfyUI version: 0.21.0
comfy-aimdo version: 0.3.0
comfy-kitchen version: 0.2.8
```

This happened only once so far while running this workflow, and rerunning the workflow immediately worked fine.

So I currently don’t have a reliable reproducer. Just reporting it in case this traceback is useful or somehow related to model loading/offloading changes.

### Actual Behavior

.

### Steps to Reproduce

.

### Debug Logs

```powershell
got prompt
Requested to load SDXL
0 models unloaded.
Model SDXL prepared for dynamic VRAM loading. 4897MB Staged. 788 patches attached.
100%|████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:16<00:00, 4.23s/it]
Requested to load AutoencoderKL
0 models unloaded.
Model AutoencoderKL prepared for dynamic VRAM loading. 159MB Staged. 0 patches attached.
Prompt executed in 41.62 seconds
got prompt
Requested to load AutoencodingEngine
0 models unloaded.
Model AutoencodingEngine prepared for dynamic VRAM loading. 159MB Staged. 0 patches attached.
Model Lumina2 prepared for dynamic VRAM loading. 11739MB Staged. 166 patches attached.
100%|████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:31<00:00, 3.53s/it]
0 models unloaded.
Model AutoencodingEngine prepared for dynamic VRAM loading. 159MB Staged. 0 patches attached.
Requested to load SAM3
Model SAM3 prepared for dynamic VRAM loading. 990MB Staged. 0 patches attached.
0 models unloaded.
Model AutoencodingEngine prepared for dynamic VRAM loading. 159MB Staged. 0 patches attached.
0 models unloaded.
Model AutoencodingEngine prepared for dynamic VRAM loading. 159MB Staged. 0 patches attached.
Requested to load Lumina2
Model Lumina2 prepared for dynamic VRAM loading. 11739MB Staged. 166 patches attached.
100%|████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:14<00:00, 2.90s/it]
0 models unloaded.
Model AutoencodingEngine prepared for dynamic VRAM loading. 159MB Staged. 0 patches attached.
Model SAM3 prepared for dynamic VRAM loading. 990MB Staged. 0 patches attached.
Found quantization metadata version 1
Detected mixed precision quantization
Using mixed precision operations
model weight dtype torch.bfloat16, manual cast: torch.bfloat16
model_type FLUX
Using sage attention mode: auto
[ComfyUI-Upscaler-Tensorrt|INFO] - Loading TensorRT engine: F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\models\tensorrt\upscaler\4x_foolhardy_Remacri_fp16_1x3x256x256_1x3x512x512_1x3x1280x1280_10.12.0.36.trt
[ComfyUI-Upscaler-Tensorrt|INFO] - Loading TensorRT engine: F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\models\tensorrt\upscaler\1x-ITF-SkinDiffDetail-Lite-v1_fp16_1x3x256x256_1x3x512x512_1x3x1280x1280_10.12.0.36.trt
DrawMaskOnImage batch: 100%|█████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 64.34it/s]
Requested to load WanVAE
0 models unloaded.
Model WanVAE prepared for dynamic VRAM loading. 242MB Staged. 0 patches attached. Force pre-loaded 52 weights: 28 KB.
0 models unloaded.
Model WanVAE prepared for dynamic VRAM loading. 242MB Staged. 0 patches attached. Force pre-loaded 52 weights: 28 KB.
model weight dtype torch.float8_e5m2, manual cast: torch.float16
model_type FLOW
Using sage attention mode: auto
Requested to load WAN21
!!! Exception during processing !!! list index out of range
Traceback (most recent call last):
File "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\execution.py", line 535, 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 "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\execution.py", line 335, 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 "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\execution.py", line 309, in _async_map_node_over_list
await process_inputs(input_dict, i)
File "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\execution.py", line 297, in process_inputs
result = f(**inputs)
^^^^^^^^^^^
File "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\nodes.py", line 1572, in sample
return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\nodes.py", line 1537, in common_ksampler
samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\comfy\sample.py", line 66, in sample
samples = sampler.sample(noise, positive, negative, cfg=cfg, latent_image=latent_image, start_step=start_step, last_step=last_step, force_full_denoise=force_full_denoise, denoise_mask=noise_mask, sigmas=sigmas, callback=callback, disable_pbar=disable_pbar, seed=seed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\comfy\samplers.py", line 1180, in sample
return sample(self.model, noise, positive, negative, cfg, self.device, sampler, sigmas, self.model_options, latent_image=latent_image, denoise_mask=denoise_mask, callback=callback, disable_pbar=disable_pbar, seed=seed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\comfy\samplers.py", line 1070, in sample
return cfg_guider.sample(noise, latent_image, sampler, sigmas, denoise_mask, callback, disable_pbar, seed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\comfy\samplers.py", line 1052, in sample
output = executor.execute(noise, latent_image, sampler, sigmas, denoise_mask, callback, disable_pbar, seed, latent_shapes=latent_shapes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\comfy\patcher_extension.py", line 112, in execute
return self.original(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\comfy\samplers.py", line 985, in outer_sample
self.inner_model, self.conds, self.loaded_models = comfy.sampler_helpers.prepare_sampling(self.model_patcher, noise.shape, self.conds, self.model_options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\comfy\sampler_helpers.py", line 143, in prepare_sampling
return executor.execute(model, noise_shape, conds, model_options=model_options, force_full_load=force_full_load, force_offload=force_offload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\comfy\patcher_extension.py", line 112, in execute
return self.original(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\comfy\sampler_helpers.py", line 157, in _prepare_sampling
comfy.model_management.load_models_gpu([model] + models, memory_required=memory_required, minimum_memory_required=minimum_memory_required, force_full_load=force_full_load)
File "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\comfy\model_management.py", line 783, in load_models_gpu
free_memory(total_memory_required[device] * 1.1 + extra_mem,
File "F:\AI\ComfyUI-Nightly-AlwaysUpToDate\ComfyUI\comfy\model_management.py", line 680, in free_memory
if current_loaded_models[i].model.is_dynamic() and for_dynamic:
~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Prompt executed in 70.62 seconds
got prompt
Requested to load WAN21
Model WAN21 prepared for dynamic VRAM loading. 13626MB Staged. 1053 patches attached.
100%|████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:21<00:00, 5.46s/it]
0 models unloaded.
Model WanVAE prepared for dynamic VRAM loading. 242MB Staged. 0 patches attached. Force pre-loaded 52 weights: 28 KB.
Requested to load WanVAE
0 models unloaded.
Model WanVAE prepared for dynamic VRAM loading. 242MB Staged. 0 patches attached. Force pre-loaded 52 weights: 28 KB.
0 models unloaded.
Model WanVAE prepared for dynamic VRAM loading. 242MB Staged. 0 patches attached. Force pre-loaded 52 weights: 28 KB.
```

### Other

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.