-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
AttributeError: Can't get attribute 'SiLUActivation' on <module 'transformers.activations' #28177
Comments
Hi @Lokesh-Jatangi, thanks for raising this issue! Is there a reason you're using |
The checkpoint stores a pruned model whose structure and weights are different and hence I couldnot use |
@Lokesh-Jatangi Have you solved your problem? |
@Lokesh-Jatangi We can't guarantee backwards compatibility for a checkpoint which isn't a transformers architecture and isn't loaded through the officially supported API. In order to be able to maintain the repo, there will be objects which we'll move, rename and delete and so pickling in this way may cause issues. I'd suggest loading the model on the most recent compatible version of transformers. Updating the model to use torch's silu activation implementation and then resave the model out. I think this should resolve the issue and allow you to load in the model in more recent transformers versions again. |
I add this to "site-packages/transformers/activations.py" ,it works |
System Info
System info -
transformers
version: 4.36.2I am using a custom script which loads LLAMA checkpoint through torch.
model_orig = torch.load(checkpoint_path)
While unpickling checkpoints in torch "SiLUActivation" class is missing from activations.py.
This PR #27136 removed the SiLUActivation class mentioning it was reduntant.
P.S :- With transformers version 4.35.0 , loading a checkpoint through torch containing SiLU activation layer was succesful.
Find the below trace :-
line 65, in load_model_from_checkpoint model_orig = torch.load(checkpoint_path) File "/opt/conda/envs/adapt/lib/python3.10/site-packages/torch/serialization.py", line 1014, in load return _load(opened_zipfile, File "/opt/conda/envs/adapt/lib/python3.10/site-packages/torch/serialization.py", line 1422, in _load result = unpickler.load() File "/opt/conda/envs/adapt/lib/python3.10/site-packages/torch/serialization.py", line 1415, in find_class return super().find_class(mod_name, name) AttributeError: Can't get attribute 'SiLUActivation' on <module 'transformers.activations' from '/opt/conda/envs/adapt/lib/python3.10/site-packages/transformers/activations.py'>
I would happy to add it the SiLU class back to activations.py file and submit it here. Please let me know if i can proceed .
Who can help?
@amyeroberts
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
Any model which has SILU activation function and loaded through "torch.load()" will face this issue.
Expected behavior
After adding reverting back the changes , the torch should be able identify SiLU activation class.
The text was updated successfully, but these errors were encountered: