Conversation
torch.nn.utils.weight_norm is deprecated in favor of torch.nn.utils.parametrizations.weight_norm, which uses the modern parametrization API. The new API is state_dict-compatible with the old one. Update the three source files that call it directly (CNN.py, HifiGAN.py, beats.py).
Author
|
Gentle ping on this one — it's been quiet for 11 days since the last activity, so I wanted to check whether there's anything else you'd like me to adjust or add before this can move forward. Happy to make changes if so. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3074
What & why
torch.nn.utils.weight_normis deprecated in favor oftorch.nn.utils.parametrizations.weight_norm, which uses the modernparametrization API. The old API emits a
FutureWarningat import/use timeand is scheduled for removal.
SpeechBrain called the deprecated API directly in three source files:
speechbrain/nnet/CNN.py—Conv1d/Conv2d/ConvTranspose1dspeechbrain/lobes/models/HifiGAN.py—DiscriminatorSspeechbrain/lobes/models/beats.py— positional convspeechbrain/lobes/models/discrete/dac.pyalready uses the new API via itstry/exceptimport, so it needs no change.Fix
Replace
nn.utils.weight_norm(...)withnn.utils.parametrizations.weight_norm(...)in the three files above. The newAPI is documented as state_dict-compatible with the old one, so no checkpoint
migration is required.
remove_weight_norm()calls are left untouched — incurrent PyTorch it transparently handles parametrized modules.
Verification
nn.utils.weight_norm(remains inspeechbrain/source (excl. recipes/tests).(
name/dimargs in beats.py are preserved).environment), so behaviour was not exercised end-to-end here; CI is expected
to validate forward/backward and checkpoint loading.
Note
This is a deprecation-warning fix rather than a crash — it does not alter
current runtime behaviour, but prevents breakage once the old API is removed.