[PyTorch] Fix autocast deprecation warnings
Description
Fix autocast deprecation warnings.
Starting from PyTorch 2.4, use
torch.get_autocast_dtype("cuda")
torch.amp.autocast("cuda")
instead of device-specific APIs.
Closes https://github.com/NVIDIA/TransformerEngine/pull/1167.
Type of change
- [ ] Documentation change (change only to the documentation, either a fix or a new content)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Infra/Build change
- [ ] Code refractor
Checklist:
- [ ] I have read and followed the contributing guidelines
- [ ] The functionality is complete
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
/te-ci pytorch
/te-ci pytorch
/te-ci pytorch
/te-ci pytorch
@ksivaman Can you review again?
Does this look good to you? @ksivaman
/te-ci pytorch
/te-ci pytorch
/te-ci pytorch
/te-ci pytorch