-
Notifications
You must be signed in to change notification settings - Fork 27.4k
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
(False?) warning about weight_g/weight_v missing on WeightNorm on PyTorch #26796
Comments
Hey @sterlind - sorry for the delay in getting back to you! You are indeed correct in that the warning shouldn't be triggered. The state dict is copied correctly with the PyTorch weight norm refactoring, but the warning thrown in |
I see similar warning when importing Wav2Vec2.0:
In the end it works correctly and I should just ignore the warning, right? |
Just to follow up on this, it may be related. When trying to convert a wav2vec2-conformer from the Traceback (most recent call last):
File "MY_UTILITIES_PATH/convert_wav2vec2_conformer_original_pytorch_checkpoint_to_pytorch.py", line 308, in <module>
convert_wav2vec2_conformer_checkpoint(
File "MY_ENV_PATH//lib/python3.9/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "MY_UTILITIES_PATH/convert_wav2vec2_conformer_original_pytorch_checkpoint_to_pytorch.py", line 293, in convert_wav2vec2_conformer_checkpoint
recursively_load_weights(model, hf_wav2vec, not is_finetuned)
File "MY_UTILITIES_PATH/convert_wav2vec2_conformer_original_pytorch_checkpoint_to_pytorch.py", line 167, in recursively_load_weights
set_recursively(hf_model, mapped_key, value, name, weight_type)
File "MY_UTILITIES_PATH/convert_wav2vec2_conformer_original_pytorch_checkpoint_to_pytorch.py", line 87, in set_recursively
hf_shape = getattr(hf_pointer, weight_type).shape
File "MY_ENV_PATH//lib/python3.9/site-packages/torch/nn/modules/module.py", line 1695, in __getattr__
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
AttributeError: 'ParametrizedConv1d' object has no attribute 'weight_g' |
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. |
cc @sanchit-gandhi we can close this now that the PR was merged no? |
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. |
Is this been fixed? It still pops the same error when loading using model = HubertModel.from_pretrained("facebook/hubert-base-ls960")
|
Reopening as I can confirm this is still an issue on main cc @sanchit-gandhi @kamilakesbi |
cc @ylacombe |
Hi. I can confirm this is a fake warning. torch.version -> '1.13.1+cu117'
no warning torch.version -> '2.4.1+cu121'
As previously highlighted, the warning mentions these two apparently non-initialized layers:
However, loading the state_dict directly on torch and checking for the equivalent variables, we can verify they were correctly loaded.
I almost had a heart attack when I discovered this issue one day after the ICASSP deadline! x) |
The issue should disappear with #33275, feel free to re-open the discussion or another issue if you're facing a similar issue! |
If I understand correctly this naming change in PyTorch weight norm, from weight_v, weight_g to original1, original0 which causes this fake warning, is what also causes the fairseq to HF conversion script to crash as mentioned by @MorenoLaQuatra . I also faced the same issue trying to convert models from fairseq. @ylacombe - should I create a PR to fix this? Should be quite easy by adding a special case in the conversion mapping here transformers/src/transformers/models/hubert/convert_hubert_original_pytorch_checkpoint_to_pytorch.py Line 111 in 53fad64
|
From my end, the bug still exists, the warning disappeared in the new version but the state is not currently loaded which will print as all zeros for weight_v and weight_g |
Hey @Windval, could you share a reproducer ? |
System Info
transformers
version: 4.34.0Who can help?
@sanchit-gandhi
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
Simply running:
Produces the following warning:
What I gather from the PyTorch documentation
and updated code is that the PyTorch folks decided to migrate the
weight_v
andweight_g
params of WeightNorm tooriginal0
andoriginal1
.Initially I thought the model was simply broken by this breaking change in PyTorch, however I was confused since I saw discussions that it should have been fixed by this PR in transformers, as discussed here: #24692
So I attached my debugger to
_weight_norm_compat_hook
, and sure enough it activated and seems to have migrated the state:(during debug)
(after model load, in Jupyter):
So I'm pretty sure the warning is a false alarm, but I'm also confused since the migration happens before the warning is traced, so I wanted to check.
Expected behavior
No warning should have appeared.
The text was updated successfully, but these errors were encountered: