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
{{ message }}
Repository navigation
TypeError: UVit2DModel.forward.<locals>.layer_() got an unexpected keyword argument 'encoder_hidden_states' #11214
accelerate launch train_amused.py \ --output_dir <output path> \ --train_batch_size 16 \ --gradient_accumulation_steps 1 \ --learning_rate 8e-4 \ --use_lora \ --pretrained_model_name_or_path amused/amused-256 \ --instance_data_dataset 'm1guelpf/nouns' \ --image_key image \ --prompt_key text \ --resolution 256 \ --mixed_precision fp16 \ --lr_scheduler constant \ --validation_prompts \ 'a pixel art character with square red glasses, a baseball-shaped head and a orange-colored body on a dark background' \ 'a pixel art character with square orange glasses, a lips-shaped head and a red-colored body on a light background' \ 'a pixel art character with square blue glasses, a microwave-shaped head and a purple-colored body on a sunny background' \ 'a pixel art character with square red glasses, a baseball-shaped head and a blue-colored body on an orange background' \ 'a pixel art character with square red glasses' \ 'a pixel art character' \ 'square red glasses on a pixel art character' \ 'square red glasses on a pixel art character with a baseball-shaped head' \ --max_train_steps 10000 \ --checkpointing_steps 500 \ --validation_steps 250 \ --gradient_checkpointing
Error log full trace:
Exception has occurred: TypeError UVit2DModel.forward.<locals>.layer_() got an unexpected keyword argument 'encoder_hidden_states' File "/home/wesker/personal/diffusers/src/diffusers/models/unets/uvit_2d.py", line 189, in forward hidden_states = layer_( ^^^^^^^ File "/home/wesker/anaconda3/envs/diffusion/lib/python3.11/site-packages/torch/amp/autocast_mode.py", line 44, in decorate_autocast return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/home/wesker/anaconda3/envs/diffusion/lib/python3.11/site-packages/accelerate/utils/operations.py", line 807, in __call__ return convert_to_fp32(self.model_forward(*args, **kwargs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/wesker/anaconda3/envs/diffusion/lib/python3.11/site-packages/accelerate/utils/operations.py", line 819, in forward return model_forward(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/wesker/anaconda3/envs/diffusion/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1750, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/wesker/anaconda3/envs/diffusion/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1739, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/wesker/personal/diffusers/examples/amused/train_amused.py", line 826, in main model( File "/home/wesker/personal/diffusers/examples/amused/train_amused.py", line 975, in <module> main(parse_args()) TypeError: UVit2DModel.forward.<locals>.layer_() got an unexpected keyword argument 'encoder_hidden_states'
Interestingly, this error only occurs when building diffusers from source by: git clone https://github.com/huggingface/diffusers.git && cd diffusers && pip install -e ".[torch]"
. When installing the diffusers package directly from pip and using the same train_amused.py script, the error does not appear
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.
Please note that issues that do not follow the contributing guidelines are likely to be ignored.
Activity
bghira commentedon Apr 6, 2025
can you show the whole trace?
bghira commentedon Apr 6, 2025
BasicTransformerBlock has encoder_hidden_states
https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention.py#L473
and transformer_layers is a list of BasicTransformerBlock
https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/unets/uvit_2d.py#L108
down_block and up_block are both UViTBlock, which also has
https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/unets/uvit_2d.py#L383
so i'm not clear where this layer arg error is coming in, a full trace will be helpful.
RongKaiWeskerMA commentedon Apr 7, 2025
accelerate launch train_amused.py \ --output_dir <output path> \ --train_batch_size 16 \ --gradient_accumulation_steps 1 \ --learning_rate 8e-4 \ --use_lora \ --pretrained_model_name_or_path amused/amused-256 \ --instance_data_dataset 'm1guelpf/nouns' \ --image_key image \ --prompt_key text \ --resolution 256 \ --mixed_precision fp16 \ --lr_scheduler constant \ --validation_prompts \ 'a pixel art character with square red glasses, a baseball-shaped head and a orange-colored body on a dark background' \ 'a pixel art character with square orange glasses, a lips-shaped head and a red-colored body on a light background' \ 'a pixel art character with square blue glasses, a microwave-shaped head and a purple-colored body on a sunny background' \ 'a pixel art character with square red glasses, a baseball-shaped head and a blue-colored body on an orange background' \ 'a pixel art character with square red glasses' \ 'a pixel art character' \ 'square red glasses on a pixel art character' \ 'square red glasses on a pixel art character with a baseball-shaped head' \ --max_train_steps 10000 \ --checkpointing_steps 500 \ --validation_steps 250 \ --gradient_checkpointingError log full trace:
Exception has occurred: TypeError UVit2DModel.forward.<locals>.layer_() got an unexpected keyword argument 'encoder_hidden_states' File "/home/wesker/personal/diffusers/src/diffusers/models/unets/uvit_2d.py", line 189, in forward hidden_states = layer_( ^^^^^^^ File "/home/wesker/anaconda3/envs/diffusion/lib/python3.11/site-packages/torch/amp/autocast_mode.py", line 44, in decorate_autocast return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/home/wesker/anaconda3/envs/diffusion/lib/python3.11/site-packages/accelerate/utils/operations.py", line 807, in __call__ return convert_to_fp32(self.model_forward(*args, **kwargs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/wesker/anaconda3/envs/diffusion/lib/python3.11/site-packages/accelerate/utils/operations.py", line 819, in forward return model_forward(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/wesker/anaconda3/envs/diffusion/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1750, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/wesker/anaconda3/envs/diffusion/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1739, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/wesker/personal/diffusers/examples/amused/train_amused.py", line 826, in main model( File "/home/wesker/personal/diffusers/examples/amused/train_amused.py", line 975, in <module> main(parse_args()) TypeError: UVit2DModel.forward.<locals>.layer_() got an unexpected keyword argument 'encoder_hidden_states'RongKaiWeskerMA commentedon Apr 7, 2025
Interestingly, this error only occurs when building diffusers from source by:
git clone https://github.com/huggingface/diffusers.git && cd diffusers && pip install -e ".[torch]". When installing the diffusers package directly from pip and using the same
train_amused.pyscript, the error does not appeargithub-actions commentedon May 6, 2025
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.
Please note that issues that do not follow the contributing guidelines are likely to be ignored.