kijai / ComfyUI-CogVideoXWrapper

990 stars 60 forks source link

local variable 'control_start' referenced before assignment #141

Closed Lumilie closed 1 month ago

Lumilie commented 1 month ago

Hey :)

I get this error from the CogVideoSampler when using your workflow: cogvideox_5b_example_01.json

'local variable 'control_start' referenced before assignment' in /workspace/ComfyUI/custom_nodes/ComfyUI-CogVideoXWrapper/pipeline_cogvideox.py

If i check out the commit a2200c4 -> works there.

mwoody450 commented 1 month ago

Same issue, and it's interesting because Comfy can't run after it; I have to restart the engine before it can even start another generation.

kijai commented 1 month ago

Thanks for the report, should be fixed now.

mwoody450 commented 1 month ago

Thank you, but I updated via Comfy manager, restarted, and the tried workflow again, but it produces the same error. Reproduced below; I'm realizing it's slightly different than the one in the subject of this issue despite referencing the same variable; I can open a new issue if that's useful.

Requested to load SD3ClipModel_
Loading 1 new model
Temporal tiling and context schedule disabled
  0%|                                                                                           | 0/45 [00:00<?, ?it/s]
!!! Exception during processing !!! cannot access local variable 'control_start' where it is not associated with a value
Traceback (most recent call last):
  File "G:\AI\ComfyUI_windows_portable\ComfyUI\execution.py", line 323, in execute
    output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:\AI\ComfyUI_windows_portable\ComfyUI\execution.py", line 198, in get_output_data
    return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:\AI\ComfyUI_windows_portable\ComfyUI\execution.py", line 169, in _map_node_over_list
    process_inputs(input_dict, i)
  File "G:\AI\ComfyUI_windows_portable\ComfyUI\execution.py", line 158, in process_inputs
    results.append(getattr(obj, func)(**inputs))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:\AI\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-CogVideoXWrapper\nodes.py", line 953, in process
    latents = pipeline["pipe"](
              ^^^^^^^^^^^^^^^^^
  File "G:\AI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\utils\_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "G:\AI\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-CogVideoXWrapper\pipeline_cogvideox.py", line 798, in __call__
    latents = latents.to(prompt_embeds.dtype)
        ^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'control_start' where it is not associated with a value
mwoody450 commented 1 month ago

Hunh... on a hunch and in response to a warning buried in the logs, I uninstalled the LayerStyle plugin. It wasn't used in the workflow in question, but that still seems to have fixed it: it's generating now, though it'll take some time to finish. Not going to argue with success!

kijai commented 1 month ago

Hunh... on a hunch and in response to a warning buried in the logs, I uninstalled the LayerStyle plugin. It wasn't used in the workflow in question, but that still seems to have fixed it: it's generating now, though it'll take some time to finish. Not going to argue with success!

Sounds more like it didn't restart properly or something didn't refresh on the first try, the problem was just my mistake when adding support for controlnet.

Lumilie commented 1 month ago

Thanks for fixing it so quick <3

bolin919 commented 1 month ago

Hey :)

I get another error from the CogVideoSampler when using all offical workflow after updating the ComfyUI-CogVideoXWrapper.

ComfyUI Error Report

Error Details

kijai commented 1 month ago

Hey :)

I get another error from the CogVideoSampler when using all offical workflow after updating the ComfyUI-CogVideoXWrapper.

ComfyUI Error Report

Error Details

  • Node Type: CogVideoSampler
  • Exception Type: UnboundLocalError
  • Exception Message: cannot access local variable 'o' where it is not associated with a value

Stack Trace

  File "/home/rum/ComfyUI/execution.py", line 323, in execute
    output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/rum/ComfyUI/execution.py", line 198, in get_output_data
    return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/rum/ComfyUI/execution.py", line 169, in _map_node_over_list
    process_inputs(input_dict, i)

  File "/home/rum/ComfyUI/execution.py", line 158, in process_inputs
    results.append(getattr(obj, func)(**inputs))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/rum/ComfyUI/custom_nodes/ComfyUI-CogVideoXWrapper/nodes.py", line 953, in process
    latents = pipeline["pipe"](
              ^^^^^^^^^^^^^^^^^

  File "/home/rum/anaconda3/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^

  File "/home/rum/ComfyUI/custom_nodes/ComfyUI-CogVideoXWrapper/pipeline_cogvideox.py", line 835, in __call__
    noise_pred = self.transformer(
                 ^^^^^^^^^^^^^^^^^

  File "/home/rum/anaconda3/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/rum/anaconda3/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/rum/ComfyUI/custom_nodes/ComfyUI-CogVideoXWrapper/custom_cogvideox_transformer_3d.py", line 615, in forward
    hidden_states, encoder_hidden_states = block(
                                           ^^^^^^

  File "/home/rum/anaconda3/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/rum/anaconda3/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/rum/ComfyUI/custom_nodes/ComfyUI-CogVideoXWrapper/custom_cogvideox_transformer_3d.py", line 288, in forward
    attn_hidden_states, attn_encoder_hidden_states = self.attn1(
                                                     ^^^^^^^^^^^

  File "/home/rum/anaconda3/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/rum/anaconda3/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/rum/anaconda3/lib/python3.12/site-packages/diffusers/models/attention_processor.py", line 490, in forward
    return self.processor(
           ^^^^^^^^^^^^^^^

  File "/home/rum/ComfyUI/custom_nodes/ComfyUI-CogVideoXWrapper/custom_cogvideox_transformer_3d.py", line 100, in __call__
    hidden_states = sageattn(query, key, value, is_causal=False)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/rum/anaconda3/lib/python3.12/site-packages/sageattention/core.py", line 87, in sageattn
    return o

This was a change in sageattn code that caused this, it's fixed now in sageattn 1.0.2:

pip install sageattention==1.0.2 -i https://pypi.org/simple/