# ComfyUI Error Report ## Error Details - **Node ID:** 90 - **Node Type:** WanVideoSampler - **Exception Type:** UnboundLocalError - **Exception Message:** cannot access local variable 'callback_latent' where it is not associated with a value ## Stack Trace ``` File "G:\comfyui\ComfyUI\execution.py", line 496, 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, hidden_inputs=hidden_inputs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\comfyui\ComfyUI\execution.py", line 315, 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, hidden_inputs=hidden_inputs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\comfyui\ComfyUI\execution.py", line 289, in _async_map_node_over_list await process_inputs(input_dict, i) File "G:\comfyui\ComfyUI\execution.py", line 277, in process_inputs result = f(**inputs) ^^^^^^^^^^^ File "G:\comfyui\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\nodes.py", line 3988, in process "samples": callback_latent.unsqueeze(0).cpu() if callback is not None else None, ^^^^^^^^^^^^^^^ ``` ## System Information - **ComfyUI Version:** 0.3.56 - **Arguments:** main.py --auto-launch - **OS:** nt - **Python Version:** 3.12.10 (tags/v3.12.10:0cc8128, Apr 8 2025, 12:21:36) [MSC v.1943 64 bit (AMD64)] - **Embedded Python:** false - **PyTorch Version:** 2.7.1+cu128 ## Devices - **Name:** cuda:0 NVIDIA GeForce RTX 4070 Ti SUPER : cudaMallocAsync - **Type:** cuda - **VRAM Total:** 17170956288 - **VRAM Free:** 15821963264 - **Torch VRAM Total:** 0 - **Torch VRAM Free:** 0 ## Logs ``` 2025-09-01T14:58:56.860057 - 0.9 seconds: G:\comfyui\ComfyUI\custom_nodes\comfyui-mixlab-nodes 2025-09-01T14:58:56.860057 - 1.1 seconds: G:\comfyui\ComfyUI\custom_nodes\ComfyUI_Custom_Nodes_AlekPet 2025-09-01T14:58:56.861054 - 1.7 seconds: G:\comfyui\ComfyUI\custom_nodes\ComfyUI-nunchaku 2025-09-01T14:58:56.861054 - 2.4 seconds: G:\comfyui\ComfyUI\custom_nodes\ComfyUI-Easy-Use 2025-09-01T14:58:56.861054 - 2025-09-01T14:58:57.088527 - Context impl SQLiteImpl. 2025-09-01T14:58:57.088527 - Will assume non-transactional DDL. 2025-09-01T14:58:57.089524 - No target revision found. 2025-09-01T14:58:57.111451 - Starting server 2025-09-01T14:58:57.112447 - To see the GUI go to: http://127.0.0.1:8188 2025-09-01T14:58:58.110145 - G:\comfyui\ComfyUI\custom_nodes\comfyui-mixlab-nodes\webApp\lib/photoswipe-lightbox.esm.min.js2025-09-01T14:58:58.110145 - 2025-09-01T14:58:58.154639 - G:\comfyui\ComfyUI\custom_nodes\comfyui-mixlab-nodes\webApp\lib/photoswipe.min.css2025-09-01T14:58:58.154639 - 2025-09-01T14:58:58.155636 - G:\comfyui\ComfyUI\custom_nodes\comfyui-mixlab-nodes\webApp\lib/pickr.min.js2025-09-01T14:58:58.155636 - 2025-09-01T14:58:58.192513 - G:\comfyui\ComfyUI\custom_nodes\comfyui-mixlab-nodes\webApp\lib/classic.min.css2025-09-01T14:58:58.192513 - 2025-09-01T14:58:58.193509 - G:\comfyui\ComfyUI\custom_nodes\comfyui-mixlab-nodes\webApp\lib/model-viewer.min.js2025-09-01T14:58:58.193509 - 2025-09-01T14:58:58.197497 - G:\comfyui\ComfyUI\custom_nodes\comfyui-mixlab-nodes\webApp\lib/juxtapose.css2025-09-01T14:58:58.198493 - 2025-09-01T14:58:58.209456 - G:\comfyui\ComfyUI\custom_nodes\comfyui-mixlab-nodes\webApp\lib/juxtapose.min.js2025-09-01T14:58:58.209456 - 2025-09-01T14:58:58.799579 - [36;20m[G:\comfyui\ComfyUI\custom_nodes\comfy_mtb] | INFO -> Found multiple match, we will pick the last D:\AI-sd\sd-webui-aki-v4\models\SwinIR ['G:\\comfyui\\ComfyUI\\models\\upscale_models', 'D:\\AI-sd\\sd-webui-aki-v4\\models\\ESRGAN', 'D:\\AI-sd\\sd-webui-aki-v4\\models\\RealESRGAN', 'D:\\AI-sd\\sd-webui-aki-v4\\models\\SwinIR'][0m 2025-09-01T14:58:58.807556 - []2025-09-01T14:58:58.807556 - 2025-09-01T14:58:58.807556 - []2025-09-01T14:58:58.807556 - 2025-09-01T14:59:00.532965 - got prompt 2025-09-01T14:59:00.569842 - Using xformers attention in VAE 2025-09-01T14:59:00.570844 - Using xformers attention in VAE 2025-09-01T14:59:00.726582 - VAE load device: cuda:0, offload device: cpu, dtype: torch.bfloat16 2025-09-01T14:59:00.882662 - Requested to load FluxClipModel_ 2025-09-01T14:59:00.889639 - loaded completely 9.5367431640625e+25 4777.53759765625 True 2025-09-01T14:59:00.998583 - CLIP/text encoder model load device: cuda:0, offload device: cpu, current: cuda:0, dtype: torch.float16 2025-09-01T14:59:01.063367 - clip missing: ['text_projection.weight'] 2025-09-01T14:59:01.722971 - FETCH ComfyRegistry Data: 5/962025-09-01T14:59:01.722971 - 2025-09-01T14:59:03.042519 - model weight dtype torch.float8_e4m3fn, manual cast: torch.bfloat16 2025-09-01T14:59:03.043516 - model_type FLUX 2025-09-01T14:59:11.471386 - FETCH ComfyRegistry Data: 10/962025-09-01T14:59:11.473376 - 2025-09-01T14:59:11.998346 - Requested to load Flux 2025-09-01T14:59:18.503848 - loaded completely 0.0 11350.067443847656 True 2025-09-01T14:59:18.514805 - Patching comfy attention to use sageattn2025-09-01T14:59:18.514805 - 2025-09-01T14:59:18.688225 - 0%| | 0/20 [00:00<?, ?it/s]2025-09-01T14:59:20.150041 - FETCH ComfyRegistry Data: 15/962025-09-01T14:59:20.150041 - 2025-09-01T14:59:28.628200 - 40%|█████████████████████████████████▏ | 8/20 [00:09<00:14, 1.17s/it]2025-09-01T14:59:29.656666 - FETCH ComfyRegistry Data: 20/962025-09-01T14:59:29.657170 - 2025-09-01T14:59:37.969589 - 80%|█████████████████████████████████████████████████████████████████▌ | 16/20 [00:19<00:04, 1.16s/it]2025-09-01T14:59:38.276116 - FETCH ComfyRegistry Data: 25/962025-09-01T14:59:38.276619 - 2025-09-01T14:59:42.606388 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:23<00:00, 1.16s/it]2025-09-01T14:59:42.609378 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:23<00:00, 1.20s/it]2025-09-01T14:59:42.610375 - 2025-09-01T14:59:42.612369 - Restoring initial comfy attention2025-09-01T14:59:42.613364 - 2025-09-01T14:59:43.566091 - Requested to load AutoencodingEngine 2025-09-01T14:59:44.164328 - loaded completely 0.0 159.87335777282715 True 2025-09-01T14:59:44.683600 - comfyui lumi batcher overwrite task done2025-09-01T14:59:44.684596 - 2025-09-01T14:59:44.695560 - Prompt executed in 44.16 seconds 2025-09-01T14:59:47.355547 - FETCH ComfyRegistry Data: 30/962025-09-01T14:59:47.355547 - 2025-09-01T14:59:50.013416 - got prompt 2025-09-01T14:59:50.431031 - loaded completely 0.0 11350.067443847656 True 2025-09-01T14:59:50.435018 - Patching comfy attention to use sageattn2025-09-01T14:59:50.435018 - 2025-09-01T14:59:55.538670 - 25%|████████████████████▊ | 5/20 [00:05<00:16, 1.11s/it]2025-09-01T14:59:56.060186 - FETCH ComfyRegistry Data: 35/962025-09-01T14:59:56.060689 - 2025-09-01T15:00:03.927199 - 60%|█████████████████████████████████████████████████▏ | 12/20 [00:13<00:09, 1.19s/it]2025-09-01T15:00:04.665127 - FETCH ComfyRegistry Data: 40/962025-09-01T15:00:04.666123 - 2025-09-01T15:00:13.251827 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.14s/it]2025-09-01T15:00:13.252823 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.14s/it]2025-09-01T15:00:13.252823 - 2025-09-01T15:00:13.253821 - Restoring initial comfy attention2025-09-01T15:00:13.253821 - 2025-09-01T15:00:13.397095 - FETCH ComfyRegistry Data: 45/962025-09-01T15:00:13.397604 - 2025-09-01T15:00:14.837381 - loaded completely 0.0 159.87335777282715 True 2025-09-01T15:00:15.176809 - comfyui lumi batcher overwrite task done2025-09-01T15:00:15.177805 - 2025-09-01T15:00:15.179799 - Prompt executed in 25.16 seconds 2025-09-01T15:00:22.087367 - FETCH ComfyRegistry Data: 50/962025-09-01T15:00:22.088368 - 2025-09-01T15:00:26.342724 - got prompt 2025-09-01T15:00:27.137497 - loaded completely 0.0 11350.067443847656 True 2025-09-01T15:00:27.148464 - Patching comfy attention to use sageattn2025-09-01T15:00:27.148464 - 2025-09-01T15:00:29.963897 - 15%|████████████▍ | 3/20 [00:02<00:17, 1.03s/it]2025-09-01T15:00:30.838878 - FETCH ComfyRegistry Data: 55/962025-09-01T15:00:30.839380 - 2025-09-01T15:00:39.316242 - 55%|█████████████████████████████████████████████ | 11/20 [00:12<00:10, 1.17s/it]2025-09-01T15:00:39.731658 - FETCH ComfyRegistry Data: 60/962025-09-01T15:00:39.737147 - 2025-09-01T15:00:47.708181 - 90%|█████████████████████████████████████████████████████████████████████████▊ | 18/20 [00:20<00:02, 1.20s/it]2025-09-01T15:00:48.592029 - FETCH ComfyRegistry Data: 65/962025-09-01T15:00:48.592029 - 2025-09-01T15:00:50.028377 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.18s/it]2025-09-01T15:00:50.029376 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.14s/it]2025-09-01T15:00:50.029376 - 2025-09-01T15:00:50.030370 - Restoring initial comfy attention2025-09-01T15:00:50.030370 - 2025-09-01T15:00:51.666354 - loaded completely 0.0 159.87335777282715 True 2025-09-01T15:00:52.027193 - comfyui lumi batcher overwrite task done2025-09-01T15:00:52.027193 - 2025-09-01T15:00:52.033721 - Prompt executed in 25.69 seconds 2025-09-01T15:00:57.732591 - FETCH ComfyRegistry Data: 70/962025-09-01T15:00:57.732591 - 2025-09-01T15:01:02.463536 - got prompt 2025-09-01T15:01:03.089034 - loaded completely 0.0 11350.067443847656 True 2025-09-01T15:01:03.098004 - Patching comfy attention to use sageattn2025-09-01T15:01:03.098004 - 2025-09-01T15:01:05.773837 - 15%|████████████▍ | 3/20 [00:02<00:17, 1.01s/it]2025-09-01T15:01:06.618083 - FETCH ComfyRegistry Data: 75/962025-09-01T15:01:06.618083 - 2025-09-01T15:01:15.225214 - 55%|█████████████████████████████████████████████ | 11/20 [00:12<00:10, 1.17s/it]2025-09-01T15:01:15.559178 - FETCH ComfyRegistry Data: 80/962025-09-01T15:01:15.559178 - 2025-09-01T15:01:23.462415 - 90%|█████████████████████████████████████████████████████████████████████████▊ | 18/20 [00:20<00:02, 1.18s/it]2025-09-01T15:01:24.532134 - FETCH ComfyRegistry Data: 85/962025-09-01T15:01:24.532134 - 2025-09-01T15:01:25.823332 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.18s/it]2025-09-01T15:01:25.824332 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.14s/it]2025-09-01T15:01:25.824332 - 2025-09-01T15:01:25.824332 - Restoring initial comfy attention2025-09-01T15:01:25.825360 - 2025-09-01T15:01:27.465611 - loaded completely 0.0 159.87335777282715 True 2025-09-01T15:01:27.822201 - comfyui lumi batcher overwrite task done2025-09-01T15:01:27.822201 - 2025-09-01T15:01:27.825191 - Prompt executed in 25.36 seconds 2025-09-01T15:01:33.620743 - FETCH ComfyRegistry Data: 90/962025-09-01T15:01:33.620743 - 2025-09-01T15:01:43.439162 - FETCH ComfyRegistry Data: 95/962025-09-01T15:01:43.439162 - 2025-09-01T15:01:45.474384 - FETCH ComfyRegistry Data [DONE]2025-09-01T15:01:45.474384 - 2025-09-01T15:01:45.625519 - [ComfyUI-Manager] default cache updated: https://api.comfy.org/nodes 2025-09-01T15:01:45.715218 - FETCH DATA from: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json2025-09-01T15:01:45.715218 - 2025-09-01T15:01:47.345156 - got prompt 2025-09-01T15:01:47.361993 - Requested to load Flux 2025-09-01T15:01:47.516137 - [DONE]2025-09-01T15:01:47.516137 - 2025-09-01T15:01:47.591887 - [ComfyUI-Manager] All startup tasks have been completed. 2025-09-01T15:01:48.028249 - loaded completely 0.0 11350.067443847656 True 2025-09-01T15:02:12.473821 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:24<00:00, 1.26s/it]2025-09-01T15:02:12.474817 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:24<00:00, 1.22s/it]2025-09-01T15:02:12.474817 - 2025-09-01T15:02:14.322793 - loaded completely 0.0 159.87335777282715 True 2025-09-01T15:02:14.683971 - comfyui lumi batcher overwrite task done2025-09-01T15:02:14.683971 - 2025-09-01T15:02:14.685964 - Prompt executed in 27.34 seconds 2025-09-01T15:02:19.663561 - got prompt 2025-09-01T15:02:20.178226 - loaded completely 0.0 11350.067443847656 True 2025-09-01T15:02:44.645309 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:24<00:00, 1.25s/it]2025-09-01T15:02:44.646305 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:24<00:00, 1.22s/it]2025-09-01T15:02:44.646305 - 2025-09-01T15:02:46.461739 - loaded completely 0.0 159.87335777282715 True 2025-09-01T15:02:46.818816 - comfyui lumi batcher overwrite task done2025-09-01T15:02:46.818816 - 2025-09-01T15:02:46.820813 - Prompt executed in 27.16 seconds 2025-09-01T15:02:53.822858 - got prompt 2025-09-01T15:02:53.845781 - Requested to load Flux 2025-09-01T15:02:54.625791 - loaded completely 0.0 11350.067443847656 True 2025-09-01T15:02:54.635757 - Patching comfy attention to use sageattn2025-09-01T15:02:54.635757 - 2025-09-01T15:03:17.948689 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:23<00:00, 1.19s/it]2025-09-01T15:03:17.950687 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:23<00:00, 1.17s/it]2025-09-01T15:03:17.951683 - 2025-09-01T15:03:17.953675 - Restoring initial comfy attention2025-09-01T15:03:17.953675 - 2025-09-01T15:03:19.664335 - loaded completely 0.0 159.87335777282715 True 2025-09-01T15:03:20.021412 - comfyui lumi batcher overwrite task done2025-09-01T15:03:20.021412 - 2025-09-01T15:03:20.027392 - Prompt executed in 26.20 seconds 2025-09-01T15:03:29.398450 - got prompt 2025-09-01T15:03:30.062602 - loaded completely 0.0 11350.067443847656 True 2025-09-01T15:03:30.071572 - Patching comfy attention to use sageattn2025-09-01T15:03:30.071572 - 2025-09-01T15:03:52.914438 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.17s/it]2025-09-01T15:03:52.915434 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.14s/it]2025-09-01T15:03:52.915434 - 2025-09-01T15:03:52.916431 - Restoring initial comfy attention2025-09-01T15:03:52.916431 - 2025-09-01T15:03:54.593879 - loaded completely 0.0 159.87335777282715 True 2025-09-01T15:03:54.936053 - comfyui lumi batcher overwrite task done2025-09-01T15:03:54.937051 - 2025-09-01T15:03:54.938046 - Prompt executed in 25.54 seconds 2025-09-01T15:05:17.191259 - got prompt 2025-09-01T15:05:17.823083 - loaded completely 0.0 11350.067443847656 True 2025-09-01T15:05:17.832052 - Patching comfy attention to use sageattn2025-09-01T15:05:17.833050 - 2025-09-01T15:05:40.406129 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.16s/it]2025-09-01T15:05:40.406129 - 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:22<00:00, 1.13s/it]2025-09-01T15:05:40.406999 - 2025-09-01T15:05:40.407512 - Restoring initial comfy attention2025-09-01T15:05:40.407512 - 2025-09-01T15:05:42.007023 - loaded completely 0.0 159.87335777282715 True 2025-09-01T15:05:42.368928 - comfyui lumi batcher overwrite task done2025-09-01T15:05:42.368928 - 2025-09-01T15:05:42.370921 - Prompt executed in 25.18 seconds 2025-09-01T15:18:47.644508 - got prompt 2025-09-01T15:18:59.759942 - T5Encoder: 29%|███████████████████████████████████████████████████████▏ | 7/24 [00:00<00:00, 69.54it/s]2025-09-01T15:18:59.794825 - T5Encoder: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 24/24 [00:00<00:00, 177.06it/s]2025-09-01T15:18:59.795821 - 2025-09-01T15:19:00.091094 - T5Encoder: 0%| | 0/24 [00:00<?, ?it/s]2025-09-01T15:19:00.139935 - T5Encoder: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 24/24 [00:00<00:00, 501.63it/s]2025-09-01T15:19:00.140927 - 2025-09-01T15:19:16.616558 - CUDA Compute Capability: 8.9 2025-09-01T15:19:16.616558 - Detected model in_channels: 16 2025-09-01T15:19:16.617551 - Model cross attention type: t2v, num_heads: 40, num_layers: 40 2025-09-01T15:19:16.618547 - Model variant detected: 14B 2025-09-01T15:19:17.079385 - model_type FLOW 2025-09-01T15:19:17.592839 - Loading LoRA: Wan2.2加速\Wan21_T2V_14B_lightx2v_cfg_step_distill_lora_rank32 with strength: 3.0 2025-09-01T15:19:17.807323 - Using accelerate to load and assign model weights to device... 2025-09-01T15:19:24.630193 - Loading transformer parameters to cuda:0: 83%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 906/1095 [00:06<00:00, 966.70it/s]2025-09-01T15:19:24.655110 - Loading transformer parameters to cuda:0: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1095/1095 [00:06<00:00, 159.93it/s]2025-09-01T15:19:24.656107 - 2025-09-01T15:19:24.657103 - Using 1052 LoRA weight patches for WanVideo model 2025-09-01T15:19:25.598506 - sigmas: tensor([1.0000, 0.9600, 0.8889, 0.7272, 0.0000]) 2025-09-01T15:19:25.599502 - timesteps: tensor([999, 959, 888, 727], device='cuda:0') 2025-09-01T15:19:25.599502 - Using per-step cfg list: [2.0, 1.0, 1.0, 1.0] 2025-09-01T15:19:25.973765 - Input sequence length: 31050 2025-09-01T15:19:25.973765 - Sampling 89 frames at 720x480 with 4 steps 2025-09-01T15:21:45.420019 - 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [02:19<00:00, 26.10s/it]2025-09-01T15:21:45.421016 - 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [02:19<00:00, 34.77s/it]2025-09-01T15:21:45.421016 - 2025-09-01T15:21:47.906432 - Allocated memory: memory=0.097 GB 2025-09-01T15:21:47.906432 - Max allocated memory: max_memory=12.714 GB 2025-09-01T15:21:47.907430 - Max reserved memory: max_reserved=12.938 GB 2025-09-01T15:21:48.211045 - CUDA Compute Capability: 8.9 2025-09-01T15:21:48.211045 - Detected model in_channels: 16 2025-09-01T15:21:48.212042 - Model cross attention type: t2v, num_heads: 40, num_layers: 40 2025-09-01T15:21:48.213039 - Model variant detected: 14B 2025-09-01T15:21:48.689720 - model_type FLOW 2025-09-01T15:21:49.195154 - Loading LoRA: Wan2.2加速\Wan21_T2V_14B_lightx2v_cfg_step_distill_lora_rank32 with strength: 1.0 2025-09-01T15:21:49.294817 - Using accelerate to load and assign model weights to device... 2025-09-01T15:21:58.279127 - Loading transformer parameters to cuda:0: 51%|█████████████████████████████████████████████████████████████████████████████▊ | 553/1095 [00:08<00:18, 29.40it/s]2025-09-01T15:21:58.373810 - Loading transformer parameters to cuda:0: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1095/1095 [00:09<00:00, 120.63it/s]2025-09-01T15:21:58.373810 - 2025-09-01T15:21:58.386767 - Using 1052 LoRA weight patches for WanVideo model 2025-09-01T15:21:58.555691 - sigmas: tensor([0.]) 2025-09-01T15:21:58.556688 - timesteps: tensor([], device='cuda:0', dtype=torch.int64) 2025-09-01T15:22:00.877498 - Input sequence length: 31050 2025-09-01T15:22:00.878495 - Sampling 89 frames at 720x480 with 0 steps 2025-09-01T15:22:01.295938 - 0it [00:00, ?it/s]2025-09-01T15:22:01.297932 - 0it [00:00, ?it/s]2025-09-01T15:22:01.297932 - 2025-09-01T15:22:01.847336 - Allocated memory: memory=0.053 GB 2025-09-01T15:22:01.847336 - Max allocated memory: max_memory=7.034 GB 2025-09-01T15:22:01.847336 - Max reserved memory: max_reserved=7.094 GB 2025-09-01T15:22:02.003449 - !!! Exception during processing !!! cannot access local variable 'callback_latent' where it is not associated with a value 2025-09-01T15:22:02.009429 - Traceback (most recent call last): File "G:\comfyui\ComfyUI\execution.py", line 496, 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, hidden_inputs=hidden_inputs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\comfyui\ComfyUI\execution.py", line 315, 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, hidden_inputs=hidden_inputs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\comfyui\ComfyUI\execution.py", line 289, in _async_map_node_over_list await process_inputs(input_dict, i) File "G:\comfyui\ComfyUI\execution.py", line 277, in process_inputs result = f(**inputs) ^^^^^^^^^^^ File "G:\comfyui\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\nodes.py", line 3988, in process "samples": callback_latent.unsqueeze(0).cpu() if callback is not None else None, ^^^^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'callback_latent' where it is not associated with a value 2025-09-01T15:22:02.017402 - comfyui lumi batcher overwrite task done2025-09-01T15:22:02.017402 - 2025-09-01T15:22:02.024379 - Prompt executed in 194.37 seconds 2025-09-01T15:26:18.533291 - got prompt 2025-09-01T15:26:18.565355 - Using accelerate to load and assign model weights to device... 2025-09-01T15:26:25.545938 - Loading transformer parameters to cuda:0: 64%|█████████████████████████████████████████████████████████████████████████████████████████████████▌ | 698/1095 [00:06<00:00, 569.60it/s]2025-09-01T15:26:25.588794 - Loading transformer parameters to cuda:0: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1095/1095 [00:07<00:00, 155.95it/s]2025-09-01T15:26:25.588794 - 2025-09-01T15:26:25.589791 - Using 1052 LoRA weight patches for WanVideo model 2025-09-01T15:26:25.652581 - sigmas: tensor([1.0000, 0.9600, 0.8889, 0.7272, 0.0000]) 2025-09-01T15:26:25.652581 - timesteps: tensor([999, 959, 888, 727], device='cuda:0') 2025-09-01T15:26:25.654574 - Using per-step cfg list: [2.0, 1.0, 1.0, 1.0] 2025-09-01T15:26:26.099813 - Input sequence length: 31050 2025-09-01T15:26:26.099813 - Sampling 89 frames at 720x480 with 4 steps 2025-09-01T15:28:34.761959 - 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [02:08<00:00, 24.73s/it]2025-09-01T15:28:34.763951 - 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [02:08<00:00, 32.06s/it]2025-09-01T15:28:34.764948 - 2025-09-01T15:28:37.388334 - Allocated memory: memory=0.097 GB 2025-09-01T15:28:37.389330 - Max allocated memory: max_memory=11.671 GB 2025-09-01T15:28:37.390934 - Max reserved memory: max_reserved=12.312 GB 2025-09-01T15:28:37.402353 - Using accelerate to load and assign model weights to device... 2025-09-01T15:28:42.447834 - Loading transformer parameters to cuda:0: 47%|████████████████████████████████████████████████████████████████████████▍ | 518/1095 [00:05<00:02, 266.27it/s]2025-09-01T15:28:42.541592 - Loading transformer parameters to cuda:0: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1095/1095 [00:05<00:00, 213.15it/s]2025-09-01T15:28:42.541592 - 2025-09-01T15:28:42.542513 - Using 1052 LoRA weight patches for WanVideo model 2025-09-01T15:28:42.585369 - sigmas: tensor([0.]) 2025-09-01T15:28:42.585369 - timesteps: tensor([], device='cuda:0', dtype=torch.int64) 2025-09-01T15:28:42.834138 - Input sequence length: 31050 2025-09-01T15:28:42.835132 - Sampling 89 frames at 720x480 with 0 steps 2025-09-01T15:28:43.084302 - 0it [00:00, ?it/s]2025-09-01T15:28:43.089282 - 0it [00:00, ?it/s]2025-09-01T15:28:43.089282 - 2025-09-01T15:28:43.383958 - Allocated memory: memory=0.053 GB 2025-09-01T15:28:43.383958 - Max allocated memory: max_memory=7.034 GB 2025-09-01T15:28:43.384950 - Max reserved memory: max_reserved=7.094 GB 2025-09-01T15:28:43.414091 - !!! Exception during processing !!! cannot access local variable 'callback_latent' where it is not associated with a value 2025-09-01T15:28:43.418074 - Traceback (most recent call last): File "G:\comfyui\ComfyUI\execution.py", line 496, 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, hidden_inputs=hidden_inputs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\comfyui\ComfyUI\execution.py", line 315, 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, hidden_inputs=hidden_inputs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\comfyui\ComfyUI\execution.py", line 289, in _async_map_node_over_list await process_inputs(input_dict, i) File "G:\comfyui\ComfyUI\execution.py", line 277, in process_inputs result = f(**inputs) ^^^^^^^^^^^ File "G:\comfyui\ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper\nodes.py", line 3988, in process "samples": callback_latent.unsqueeze(0).cpu() if callback is not None else None, ^^^^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'callback_latent' where it is not associated with a value 2025-09-01T15:28:43.423058 - comfyui lumi batcher overwrite task done2025-09-01T15:28:43.423058 - 2025-09-01T15:28:43.428044 - Prompt executed in 144.88 seconds ``` ## Attached Workflow Please make sure that workflow does not contain any sensitive information such as API keys or passwords. ``` Workflow too large. Please manually upload the workflow from local file system. ``` ## Additional Context (Please add any additional context or steps to reproduce the error here) 报错的原因,怎么解决
时间: 2025-09-01 07:52:46 AIGC 浏览: 67
<think>
我们正在处理ComfyUI 0.3.56版本中WanVideoSampler节点出现的特定错误:`UnboundLocalError: cannot access local variable 'callback_latent' where it is not associated with a value`。根据错误信息,问题在于在某个代码路径中,局部变量`callback_latent`在未被赋值的情况下被访问。
根据引用[2]的解释,这个错误通常是由于在访问一个局部变量之前,该变量没有被赋予任何值。在引用[3]中,我们看到一个类似的错误,并通过确保变量在访问前被正确初始化来解决。
因此,我们需要检查WanVideoSampler节点的相关代码,特别是涉及`callback_latent`变量的部分。可能的原因和解决方案包括:
### 原因分析
1. **条件分支未覆盖所有情况**:在定义`callback_latent`的代码中,可能存在某些条件分支(如if语句)未能覆盖所有执行路径。当某些条件不满足时,`callback_latent`没有被赋值,但在后续代码中又被访问。
2. **异步回调问题**:如果`callback_latent`是在回调函数中赋值的,可能在回调完成之前就访问了该变量。
3. **作用域问题**:变量可能在嵌套函数中定义,但未正确使用`nonlocal`或`global`声明。
### 解决方案
1. **初始化变量**:在变量定义的位置,给它一个初始值(例如`None`),确保在任何代码路径下该变量都有值。
2. **检查所有条件分支**:确保在所有可能的分支(包括`else`分支)中变量都被正确赋值。
3. **确保回调完成**:如果变量在回调中赋值,需要确保在访问变量之前回调已经执行完毕。
### 具体步骤(假设我们能查看源码)
由于我们无法直接查看WanVideoSampler节点的源码,我们可以根据经验给出一般性修改建议。假设在代码中有类似以下的结构:
```python
def sample_function():
if some_condition:
callback_latent = some_value
# 其他代码...
use(callback_latent) # 当some_condition为False时,callback_latent未定义
```
修正为:
```python
def sample_function():
callback_latent = None # 初始化为None或其他合适的默认值
if some_condition:
callback_latent = some_value
# 其他代码...
use(callback_latent) # 此时callback_latent总是有值
```
### 实际案例参考
在引用[3]的示例中,通过将临时变量`layer`改为使用`self.layer`(即实例变量)来保证变量在后续访问时已被正确关联。但我们的错误是局部变量未初始化,所以初始化为默认值更合适。
### 针对ComfyUI WanVideoSampler节点的建议
由于这是ComfyUI的一个节点,我们可能需要检查该节点的执行流程。特别是视频采样可能涉及多帧处理,可能在某些帧处理失败时导致变量未赋值。因此,在节点的关键函数中,查找`callback_latent`变量,并确保它在所有路径下都有初始值。
### 总结
要解决此错误,我们需要:
1. 定位到使用`callback_latent`的函数。
2. 检查该函数中所有代码路径,确保`callback_latent`在任何情况下都被初始化。
3. 在函数开头初始化`callback_latent`(例如设为`None`),然后根据不同条件赋值。
如果问题仍然存在,可能需要进一步检查代码逻辑,确保异步操作完成后再访问变量。
§§相关问题§§
1. 在Python中,如何避免局部变量未初始化引发的UnboundLocalError?
2. ComfyUI中自定义节点的开发有哪些常见错误?
3. 如何处理异步回调中的变量赋值问题?
</think>
### ComfyUI 0.3.56 WanVideoSampler节点UnboundLocalError异常分析与解决
#### 问题原因分析
在ComfyUI 0.3.56的WanVideoSampler节点中,`UnboundLocalError: cannot access local variable 'callback_latent' where it is not associated with a value`错误的根本原因是**变量初始化不完整**。具体来说:
1. **条件分支未覆盖**:`callback_latent`变量在某些执行路径中被定义,但存在未覆盖的分支导致变量未初始化就被访问[^2]
2. **异步操作时序问题**:节点涉及视频采样和潜在空间操作,可能在异步回调完成前尝试访问`callback_latent`变量[^4]
3. **作用域边界问题**:嵌套函数或回调链中变量作用域管理不当,导致局部变量访问时机错误[^3]
#### 解决方案
##### 核心修复方法
在变量使用前显式初始化:
```python
# 在定义callback_latent的地方添加默认值
class WanVideoSampler:
def process_frames(self):
# 初始化保证所有分支可用
callback_latent = None
if video_source_ready:
callback_latent = self.decode_frames()
else:
callback_latent = self.load_default_latent()
# 安全使用
return self.apply_sampling(callback_latent)
```
##### 进阶修复方案
1. **异步操作保护机制**:
```python
def video_callback(data):
nonlocal callback_latent # 明确作用域声明
callback_latent = process_video_data(data)
def execute_sampling():
callback_latent = None # 关键初始化
start_video_processing(video_callback) # 异步操作
# 添加等待机制
while callback_latent is None:
time.sleep(0.01) # 非阻塞等待
return post_process(callback_latent)
```
2. **分支完整性检查**:
```python
def generate_latent():
latent = None
if conditionA:
latent = methodA()
elif conditionB:
latent = methodB()
else: # 必须添加兜底分支
latent = default_latent()
assert latent is not None # 防御性检查
return latent
```
#### 调试建议
1. 在ComfyUI中启用`--verbose`模式定位具体出错位置
2. 在节点代码中临时添加日志:
```python
print(f"Callback latent state: {locals().get('callback_latent', 'UNDEFINED')}")
```
3. 检查视频加载逻辑,确保所有异常路径都有默认值返回
#### 预防措施
1. 使用类型检查和默认值工具:
```python
from typing import Optional
def process_frame() -> Optional[LatentTensor]:
...
```
2. 安装静态分析工具检测未初始化变量:
```bash
pip install pylint
pylint your_custom_nodes.py
```
阅读全文
相关推荐



















