Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when switch to workflow TorchCompileVAE #158

Open
15053285989 opened this issue Dec 18, 2024 · 1 comment
Open

error when switch to workflow TorchCompileVAE #158

15053285989 opened this issue Dec 18, 2024 · 1 comment

Comments

@15053285989
Copy link

hi, I tried run workflow A(with TorchCompileVAE) first,
then switch to workflow B(without TorchCompileVAE),
and then switch back to workflow A(with TorchCompileVAE),
I got error as follows:

07:38:46 - !!! Exception during processing !!! Failed to compile model
07:38:46 - Traceback (most recent call last):
  File "/mnt/app/custom_nodes/ComfyUI-KJNodes/nodes/model_optimization_nodes.py", line 346, in compile
    vae.first_stage_model.encoder = torch.compile(vae.first_stage_model.encoder, mode=mode, fullgraph=fullgraph, backend=backend)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1984, in __setattr__
    raise TypeError(
TypeError: cannot assign 'comfy.ldm.modules.diffusionmodules.model.Encoder.forward' as child module 'encoder' (torch.nn.Module or None expected)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/app/execution.py", line 328, 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 "/mnt/app/execution.py", line 203, 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 "/mnt/app/execution.py", line 174, in _map_node_over_list
    process_inputs(input_dict, i)
  File "/mnt/app/execution.py", line 163, in process_inputs
    results.append(getattr(obj, func)(**inputs))
  File "/mnt/app/custom_nodes/ComfyUI-KJNodes/nodes/model_optimization_nodes.py", line 349, in compile
    raise RuntimeError("Failed to compile model")
RuntimeError: Failed to compile model
@15053285989
Copy link
Author

the reason is that compile flag is in node instanc, and when node is recycled, vae will be compiled twice.

            if not self._compiled_encoder:
                try:
                    vae.first_stage_model.encoder = torch.compile(vae.first_stage_model.encoder, mode=mode, fullgraph=fullgraph, backend=backend)
                    self._compiled_encoder = True
                except Exception as e:
                    logging.exception(e)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant