Comfy-Org / Comfy-Org/ComfyUI

After updating the CN functionality of z-image, the following error occurred: UnboundLocalError: local variable 'model' referenced before assignment

Open
#11,099 15 comments 0 reactions 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

Official test nodes

### Actual Behavior

Image

### Steps to Reproduce

[z-image-cn.json](https://github.com/user-attachments/files/23927278/z-image-cn.json)

### Debug Logs

```powershell
got prompt
Using xformers attention in VAE
Using xformers attention in VAE
VAE load device: cuda:0, offload device: cpu, dtype: torch.bfloat16
[QwenVL] Node on nvidia_gpu
Returning existing local_dir `F:\AIGC\ComfyUI-aki-1.5pro\models\LLM\Qwen-VL\Qwen3-VL-2B-Instruct` as remote repo cannot be accessed in `snapshot_download` (Cannot reach https://huggingface.co/api/models/Qwen/Qwen3-VL-2B-Instruct/revision/main: offline mode is enabled. To disable it, please unset the `HF_HUB_OFFLINE` environment variable.).
Returning existing local_dir `F:\AIGC\ComfyUI-aki-1.5pro\models\LLM\Qwen-VL\Qwen3-VL-2B-Instruct` as remote repo cannot be accessed in `snapshot_download` (Cannot reach https://huggingface.co/api/models/Qwen/Qwen3-VL-2B-Instruct/revision/main: offline mode is enabled. To disable it, please unset the `HF_HUB_OFFLINE` environment variable.).
[QwenVL] Loading Qwen3-VL-2B-Instruct (None (FP16), attn=flash_attention_2)
# 😺dzNodes: LayerStyle -> ImageScaleByAspectRatio V2 Processed 1 image(s).
CLIP/text encoder model load device: cuda:0, offload device: cpu, current: cpu, dtype: torch.float16
Requested to load ZImageTEModel_
loaded completely; 17325.21 MB usable, 7672.25 MB loaded, full load: True
!!! Exception during processing !!! local variable 'model' referenced before assignment
Traceback (most recent call last):
File "F:\AIGC\ComfyUI-aki-1.5pro\execution.py", line 510, 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 "F:\AIGC\ComfyUI-aki-1.5pro\execution.py", line 324, 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 "F:\AIGC\ComfyUI-aki-1.5pro\execution.py", line 298, in _async_map_node_over_list
await process_inputs(input_dict, i)
File "F:\AIGC\ComfyUI-aki-1.5pro\execution.py", line 286, in process_inputs
result = f(**inputs)
File "F:\AIGC\ComfyUI-aki-1.5pro\comfy_extras\nodes_model_patch.py", line 215, in load_model_patch
model.load_state_dict(sd)
UnboundLocalError: local variable 'model' referenced before assignment

comfyui lumi batcher overwrite task done
Prompt executed in 45.23 seconds
```

### 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.