You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the scripts in the examples/ folder of Accelerate or an officially supported no_trainer script in the examples folder of the transformers repo (such as run_no_trainer_glue.py)
My own task or dataset (give details below)
Reproduction
When using the HunyuanVideo model via diffusers framework with the following script:
Traceback (most recent call last):
File "/workspaces/huvideo_diffusers_repro.py", line 21, in <module>
_ = pipe(
^^^^^
File "/workspaces/.venv_py311/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/diffusers/src/diffusers/pipelines/hunyuan_video/pipeline_hunyuan_video.py", line 689, in __call__
self.maybe_free_model_hooks()
File "/workspaces/diffusers/src/diffusers/pipelines/pipeline_utils.py", line 1119, in maybe_free_model_hooks
self.enable_model_cpu_offload(device=getattr(self, "_offload_device", "cuda"))
File "/workspaces/diffusers/src/diffusers/pipelines/pipeline_utils.py", line 1050, in enable_model_cpu_offload
self.remove_all_hooks()
File "/workspaces/diffusers/src/diffusers/pipelines/pipeline_utils.py", line 1017, in remove_all_hooks
accelerate.hooks.remove_hook_from_module(model, recurse=True)
File "/workspaces/accelerate/src/accelerate/hooks.py", line 203, in remove_hook_from_module
delattr(module, "_hf_hook")
File "/workspaces/.venv_py311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 2043, in __delattr__
super().__delattr__(name)
AttributeError: 'OptimizedModule' object has no attribute '_hf_hook'
When wrapping these two lines with try ... except, the run succeeds.
Error: AttributeError – 'OptimizedModule' object has no attribute '_hf_hook'
Error: AttributeError – 'OptimizedModule' object has no attribute '_old_forward'
This indicates that there seems to be a logical error when using the following coding pattern:
if hasattr(object, attr):
delattr(object, attr)
Suggesting that even though hasattr returns True, there is no guarantee delattr will work as intended.
Expected behavior
Successful run without errors.
The text was updated successfully, but these errors were encountered:
System Info
Information
Tasks
no_trainer
script in theexamples
folder of thetransformers
repo (such asrun_no_trainer_glue.py
)Reproduction
When using the HunyuanVideo model via diffusers framework with the following script:
Following error arises:
When wrapping these two lines with
try ... except
, the run succeeds.https://github.com/huggingface/accelerate/blob/main/src/accelerate/hooks.py#L203
https://github.com/huggingface/accelerate/blob/main/src/accelerate/hooks.py#L212
If we still log the exceptions, they produce:
This indicates that there seems to be a logical error when using the following coding pattern:
Suggesting that even though
hasattr
returns True, there is no guaranteedelattr
will work as intended.Expected behavior
Successful run without errors.
The text was updated successfully, but these errors were encountered: