Update torch AMP autocast syntax for CUDA compatibility#6267
Update torch AMP autocast syntax for CUDA compatibility#6267KanTakahiro wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request correctly updates the deprecated torch.cuda.amp.autocast syntax to torch.amp.autocast('cuda', ...) in espnet2/enh/encoder/stft_encoder.py and espnet2/enh/layers/uses2_swin.py. The changes address a FutureWarning and are consistent with PyTorch's current API.
While the changes made are correct, a similar instance of the deprecated syntax was missed in espnet2/enh/layers/uses2_swin.py on line 147. To ensure all deprecation warnings of this type are resolved, I recommend updating that line as well:
# espnet2/enh/layers/uses2_swin.py:147
- with torch.cuda.amp.autocast(enabled=False):
+ with torch.amp.autocast('cuda', enabled=False):By including this change, the pull request will be more complete. No other issues were found.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6267 +/- ##
===========================================
+ Coverage 56.24% 69.39% +13.14%
===========================================
Files 897 759 -138
Lines 84917 69849 -15068
===========================================
+ Hits 47765 48473 +708
+ Misses 37152 21376 -15776
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
for more information, see https://pre-commit.ci
|
Thanks a lot. I also found several other potential issues with using @Emrys365, what do you think? |
Sorry for missing the discussion. I agree that we should update the deprecated |
|
This PR is stale because it has been open for 90 days with no activity. |
What did you change?
I modified
espnet2/enh/encoder/stft_encoder.pyandespnet2/enh/layers/uses2_swin.py:Why did you make this change?
There is a FutureWarning when I use espnet2:
~/.pyenv/myenv12/lib/python3.12/site-packages/espnet2/enh/encoder/stft_encoder.py:79: FutureWarning:
torch.cuda.amp.autocast(args...)is deprecated. Please usetorch.amp.autocast('cuda', args...)instead.@torch.cuda.amp.autocast(enabled=False)
~/.pyenv/myenv12/lib/python3.12/site-packages/espnet2/enh/layers/uses2_swin.py:329: FutureWarning:
torch.cuda.amp.autocast(args...)is deprecated. Please usetorch.amp.autocast('cuda', args...)instead.Is your PR small enough?
Yes
Additional Context