ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

Fix model_patcher.py by adding safety check for 'pinned'

Open Buumcode opened this issue 5 days ago • 1 comments

After update to v0.6.0 got this error in Nunchaku LoRA Loader:

!!! Exception during processing !!! 'NoneType' object is not callable
Traceback (most recent call last):
  File "c:\ComfyUI\execution.py", line 516, 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 "c:\ComfyUI\execution.py", line 330, 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 "c:\ComfyUI\execution.py", line 304, in _async_map_node_over_list
    await process_inputs(input_dict, i)
  File "c:\ComfyUI\execution.py", line 292, in process_inputs
    result = f(**inputs)
             ^^^^^^^^^^^
  File "C:\ComfyUI\custom_nodes\ComfyUI-nunchaku\nodes\lora\flux.py", line 117, in load_lora
    ret_model = copy.deepcopy(model)  # copy everything except the model
                ^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\miniconda3\Lib\copy.py", line 162, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\miniconda3\Lib\copy.py", line 259, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\miniconda3\Lib\copy.py", line 136, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "C:\ProgramData\miniconda3\Lib\copy.py", line 221, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\miniconda3\Lib\copy.py", line 162, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\miniconda3\Lib\copy.py", line 259, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\miniconda3\Lib\copy.py", line 136, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "C:\ProgramData\miniconda3\Lib\copy.py", line 221, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\miniconda3\Lib\copy.py", line 162, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\miniconda3\Lib\copy.py", line 261, in _reconstruct
    y.__setstate__(state)
TypeError: 'NoneType' object is not callable

Prompt executed in 48.54 seconds
Exception ignored in: <function ModelPatcher.__del__ at 0x000002386C4B67A0>
Traceback (most recent call last):
  File "c:\ComfyUI\comfy\model_patcher.py", line 1357, in __del__
    self.unpin_all_weights()
  File "c:\ComfyUI\comfy\model_patcher.py", line 654, in unpin_all_weights
    for key in list(self.pinned):
                    ^^^^^^^^^^^
AttributeError: 'ModelPatcher' object has no attribute 'pinned'

This fix AttributeError in ModelPatcher.del by adding safety check for 'pinned'. ***With pull request in ComfyUI-nunchaku - https://github.com/nunchaku-tech/ComfyUI-nunchaku/pull/737

Buumcode avatar Dec 25 '25 18:12 Buumcode

What happens with just your nunchaku change? It looks like the real fix.

rattus128 avatar Dec 25 '25 22:12 rattus128

Damn, something wrong with this - Nunchaku Flux Kontext start to generate "blurry" images with that. I've roll back ComfyUI to v0.3.76 - it's work perfect for Nunchaku Flux Kontext (but Z-image controlnet not work - model_patcher.py not allowed).

Buumcode avatar Dec 27 '25 07:12 Buumcode

everyone is using nunchaku with zimage and qwens , comfy devs should be more careful to not break nunchaku nodes by new fundamental changes , now we are stuck with 4.0

trollver9000 avatar Dec 28 '25 02:12 trollver9000