pytorch/test/cpp_extensions
KarhouTam 13413b3b07 [AMP][Refactor] Autocast dtype handling to simplify device-specific c… (#165221)
This PR refactors the autocast context manager in autocast_mode.py to simplify and centralize the logic for checking supported dtypes for each device. The previous implementation repeated similar checks for multiple device types. Now, a single mapping device_supported_dtypes is used to associate device types with their supported dtypes, and the validation logic is unified.

**The former PR #163446 was merged but reverted due to failed CI test on `openreg` related tests.**

This RR additionally slightly modified some test assertions for passing the CI tests. CI failed due to assertion for the exactly same error message. For example:
```
File "/var/lib/jenkins/workspace/test/cpp_extensions/open_registration_extension/torch_openreg/tests/test_autocast.py", line 9, in test_autocast_with_unsupported_type
    with self.assertWarnsRegex(
        AssertionError: "In openreg autocast, but the target dtype torch.float32 is not supported." does not match "In openreg autocast, but the target dtype is not supported. Disabling autocast."
```

Sorry for the inconvenience again.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/165221
Approved by: https://github.com/albanD
2025-10-28 06:21:29 +00:00
..
libtorch_agnostic_extension Revert "Widen ops support to take in IntHOArrayRef vs only std::vec (#165152)" 2025-10-20 17:26:42 +00:00
no_python_abi_suffix_test
open_registration_extension/torch_openreg [AMP][Refactor] Autocast dtype handling to simplify device-specific c… (#165221) 2025-10-28 06:21:29 +00:00
python_agnostic_extension Replace setup.py bdist_wheel with python -m build --wheel (#156712) 2025-09-29 21:51:32 +00:00
self_compiler_include_dirs_test
torch_stable_test_extension Error when TORCH_STABLE_ONLY is defined in TensorBase.h (#161658) 2025-08-28 04:36:31 +00:00
torch_test_cpp_extension
cpp_c10d_extension.cpp
cpp_c10d_extension.hpp
cpp_frontend_extension.cpp
cublas_extension.cpp
cuda_dlink_extension_add.cu
cuda_dlink_extension_add.cuh
cuda_dlink_extension_kernel.cu
cuda_dlink_extension.cpp
cuda_extension_kernel.cu
cuda_extension_kernel2.cu
cuda_extension.cpp
cuda_extension.cu
cudnn_extension.cpp
cusolver_extension.cpp
dangling_impl_extension.cpp
doubler.h
extension.cpp
identity.cpp
jit_extension.cpp
jit_extension2.cpp
maia_extension.cpp
mps_extension.mm [MPSHooks] Release pending command encoder (#164093) 2025-09-29 17:50:12 +00:00
mtia_extension.cpp
open_registration_extension.cpp [OpenReg][1/N] Migrate cpp_extensions_open_device_registration to OpenReg (#156588) 2025-06-26 03:59:50 +00:00
rng_extension.cpp
setup.py
torch_library.cu
xpu_extension.sycl