Repository navigation
[ROCm] Support USE_ASAN=1 build - #188242
xinyazhang wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates PyTorch’s ROCm build and packaging CMake logic to support AddressSanitizer (ASAN) builds (notably with TheRock 7.14), bumps AOTriton to 0.12.1b, and adds tech-preview support for gfx1250 by adjusting dependency download/selection and toolchain integration.
Changes:
- Extend CMake logic to make ROCm ASAN builds more viable (sanitizer runtime probing/rpath, HIP linker-type mapping, rocSHMEM device bitcode handling).
- Improve OpenMP/oneDNN linkage detection/propagation for non-MKL OpenMP runtimes.
- Bump and reshape AOTriton package selection (0.12.1b, rocm7.14 entries, ASAN variants, gfx1250 images) and patch build issues on newer Clang for benchmark.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| cmake/public/mkldnn.cmake | Propagates OpenMP runtime linkage to oneDNN consumers via caffe2::mkldnn. |
| cmake/public/LoadHIP.cmake | Ensures HIP language enablement doesn’t fail when CMAKE_LINKER_TYPE is set. |
| cmake/Modules/FindSanitizer.cmake | Adds ASAN shared-runtime rpath support during probe and propagates it to targets. |
| cmake/Modules/FindOpenMP.cmake | Prefers Clang-reported libomp.so location to avoid selecting incompatible runtimes. |
| cmake/External/aotriton.cmake | Updates AOTriton version/sha lists, adds rocm7.14 and gfx1250, and supports ASAN variants. |
| cmake/EnvVarForwarding.cmake | Replaces unsafe environment re-parsing with a Python-driven environment reader and cache setter. |
| cmake/Dependencies.cmake | Adds Clang 23+ warning suppression for the benchmark subproject. |
| caffe2/CMakeLists.txt | Adds rocSHMEM device bitcode linking for ROCm ASAN SDKs. |
5fb12c9 to
bd34b92
Compare
bd34b92 to
a101cd3
Compare
|
|
|
@jeffdaily failures are due to inductor timeouts or MI300 runner times outs (>360 mins). |
jeffdaily
left a comment
There was a problem hiding this comment.
Let's split this into 2 PRs, one for AOTriton 0.12.1.b and one for broader ASAN build enhancements/fixes.
I'll keep this PR for ASAN and move it back to draft. Then I'll file a new PR for 0.12.1b+gfx1250. |
a101cd3 to
2fa2bbc
Compare
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Notable New Features:
* ROCm PyTorch now supports ASAN build with TheRock 7.14 SDK
+ Use clang from TheRock 7.14 as the host compiler
+ integration builds cleanly; tests unvalidated due to crashing during the early-initialization phase of the ROCm ASAN runtime.
+ Build of CK SDPA with ASAN is not tested
+ Select ASAN build of AOTriton for SDPA
Notable Bug Fixes:
* Rewrites env var parsers in `cmake/EnvVarForwarding.cmake` with python script
+ The old parser is error-prone and failed to handle complicated `PS1` env var like `${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$` (This is DEFAULT `PS1` from Ubuntu 24.04)
+ An outcome of this buggy parser is: `USE_ASAN` is never set if `PS1` contains `;` and occurs earlier than `USE_ASAN` in env vars.
+ **Breaking** the new parser now honors exported env vars over cmake command-line -D and/or CMakeCache.txt
* Other related ASAN build fixes on TheRock 7.14+Clang Environment
Pull Request resolved: pytorch#188242
Approved by: https://github.com/jeffdaily
Co-authored-by: Claude Opus 4.8 <[email protected]>
This PR adds initial ROCm support for gfx1250 (CDNA5). What this PR enables: - Gates gfx1250-specific behavior on ROCm 7.14+ (the support floor), applied consistently across CUDABlas.cpp, ScaledBlas.cpp, CUDAHooks.cpp, and the test helpers. - Adds gfx1250 to the hipBLASLt preferred/supported arch lists and the hipSparseLt support check (ROCm 7.14+). - Extends the scaled GEMM / MX-format paths (block-wise Float8_e8m0fnu, mxfp8, mxfp4) to gfx1250. - Sets the gfx1250 shared-memory limit to 320 KB (vs 160 KB on gfx950), matching on the suffix-stripped arch name. - Adds CDNA2/CDNA3/CDNA5 "or later" arch helpers and updates FP8 / MX GEMM test gating in common_cuda.py. - Builds Composable Kernel (CK) GEMM as a separate ck_gemm library with gfx1250 filtered out of HIP_ARCHITECTURES, so a multi-arch build that includes gfx1250 keeps CK GEMM for the other archs instead of failing to compile for gfx1250 (composable_kernel has no gfx1250 support yet). The filter is removed once CK supports gfx1250. - Extends the gfx942 nontemporal vectorized-load path in MemoryAccess.cuh to gfx1250. - Refactors duplicated arch-check logic in CUDABlas.cpp, ScaledBlas.cpp, and cuSPARSELtOps.cpp per review feedback. - Writes the CublasHandlePool workspace archs in full (gfx942/gfx950/gfx1250). Enabled via the main merge: - Flash attention and memory-efficient attention on gfx1250 via AOTriton 0.12.1b (from pytorch#188242), which this branch merges in. What is not enabled yet: - CK SDPA on gfx1250: composable_kernel has no gfx1250 support; the CK SDPA target auto-filters to gfx942/gfx950. - CK GEMM on gfx1250: filtered out (see above) until composable_kernel supports it. - FP8 grouped GEMM on gfx1250: MSLK builds only gfx942/gfx950. - int4 mm on gfx1250: the tinygemm MFMA kernel needs a WMMA port; the ops return a clear "not supported yet" error and the int4 unit tests skip gfx1250. CI note: - gfx1250 is not added to the ROCm 7.2 (rocm-n) docker image, whose HIP compiler cannot target gfx1250. gfx1250 CI belongs on the nightly ROCm image and is added in a follow-up. Co-authored-by: @glen-amd Pull Request resolved: pytorch#188597 Approved by: https://github.com/jeffdaily Co-authored-by: Prachi Gupta <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Co-authored-by: Jeff Daily <[email protected]>
This PR adds initial ROCm support for gfx1250 (CDNA5). What this PR enables: - Gates gfx1250-specific behavior on ROCm 7.14+ (the support floor), applied consistently across CUDABlas.cpp, ScaledBlas.cpp, CUDAHooks.cpp, and the test helpers. - Adds gfx1250 to the hipBLASLt preferred/supported arch lists and the hipSparseLt support check (ROCm 7.14+). - Extends the scaled GEMM / MX-format paths (block-wise Float8_e8m0fnu, mxfp8, mxfp4) to gfx1250. - Sets the gfx1250 shared-memory limit to 320 KB (vs 160 KB on gfx950), matching on the suffix-stripped arch name. - Adds CDNA2/CDNA3/CDNA5 "or later" arch helpers and updates FP8 / MX GEMM test gating in common_cuda.py. - Builds Composable Kernel (CK) GEMM as a separate ck_gemm library with gfx1250 filtered out of HIP_ARCHITECTURES, so a multi-arch build that includes gfx1250 keeps CK GEMM for the other archs instead of failing to compile for gfx1250 (composable_kernel has no gfx1250 support yet). The filter is removed once CK supports gfx1250. - Extends the gfx942 nontemporal vectorized-load path in MemoryAccess.cuh to gfx1250. - Refactors duplicated arch-check logic in CUDABlas.cpp, ScaledBlas.cpp, and cuSPARSELtOps.cpp per review feedback. - Writes the CublasHandlePool workspace archs in full (gfx942/gfx950/gfx1250). Enabled via the main merge: - Flash attention and memory-efficient attention on gfx1250 via AOTriton 0.12.1b (from pytorch#188242), which this branch merges in. What is not enabled yet: - CK SDPA on gfx1250: composable_kernel has no gfx1250 support; the CK SDPA target auto-filters to gfx942/gfx950. - CK GEMM on gfx1250: filtered out (see above) until composable_kernel supports it. - FP8 grouped GEMM on gfx1250: MSLK builds only gfx942/gfx950. - int4 mm on gfx1250: the tinygemm MFMA kernel needs a WMMA port; the ops return a clear "not supported yet" error and the int4 unit tests skip gfx1250. CI note: - gfx1250 is not added to the ROCm 7.2 (rocm-n) docker image, whose HIP compiler cannot target gfx1250. gfx1250 CI belongs on the nightly ROCm image and is added in a follow-up. Co-authored-by: @glen-amd Pull Request resolved: pytorch#188597 Approved by: https://github.com/jeffdaily, https://github.com/pruthvistony Co-authored-by: Prachi Gupta <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Co-authored-by: Jeff Daily <[email protected]>
This PR adds initial ROCm support for gfx1250 (CDNA5). What this PR enables: - Gates gfx1250-specific behavior on ROCm 7.14+ (the support floor), applied consistently across CUDABlas.cpp, ScaledBlas.cpp, CUDAHooks.cpp, and the test helpers. - Adds gfx1250 to the hipBLASLt preferred/supported arch lists and the hipSparseLt support check (ROCm 7.14+). - Extends the scaled GEMM / MX-format paths (block-wise Float8_e8m0fnu, mxfp8, mxfp4) to gfx1250. - Sets the gfx1250 shared-memory limit to 320 KB (vs 160 KB on gfx950), matching on the suffix-stripped arch name. - Adds CDNA2/CDNA3/CDNA5 "or later" arch helpers and updates FP8 / MX GEMM test gating in common_cuda.py. - Builds Composable Kernel (CK) GEMM as a separate ck_gemm library with gfx1250 filtered out of HIP_ARCHITECTURES, so a multi-arch build that includes gfx1250 keeps CK GEMM for the other archs instead of failing to compile for gfx1250 (composable_kernel has no gfx1250 support yet). The filter is removed once CK supports gfx1250. - Extends the gfx942 nontemporal vectorized-load path in MemoryAccess.cuh to gfx1250. - Refactors duplicated arch-check logic in CUDABlas.cpp, ScaledBlas.cpp, and cuSPARSELtOps.cpp per review feedback. - Writes the CublasHandlePool workspace archs in full (gfx942/gfx950/gfx1250). Enabled via the main merge: - Flash attention and memory-efficient attention on gfx1250 via AOTriton 0.12.1b (from pytorch#188242), which this branch merges in. What is not enabled yet: - CK SDPA on gfx1250: composable_kernel has no gfx1250 support; the CK SDPA target auto-filters to gfx942/gfx950. - CK GEMM on gfx1250: filtered out (see above) until composable_kernel supports it. - FP8 grouped GEMM on gfx1250: MSLK builds only gfx942/gfx950. - int4 mm on gfx1250: the tinygemm MFMA kernel needs a WMMA port; the ops return a clear "not supported yet" error and the int4 unit tests skip gfx1250. CI note: - gfx1250 is not added to the ROCm 7.2 (rocm-n) docker image, whose HIP compiler cannot target gfx1250. gfx1250 CI belongs on the nightly ROCm image and is added in a follow-up. Co-authored-by: @glen-amd Pull Request resolved: pytorch#188597 Approved by: https://github.com/jeffdaily, https://github.com/pruthvistony Co-authored-by: Prachi Gupta <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Co-authored-by: Jeff Daily <[email protected]>
Notable New Features:
* ROCm PyTorch now supports ASAN build with TheRock 7.14 SDK
+ Use clang from TheRock 7.14 as the host compiler
+ integration builds cleanly; tests unvalidated due to crashing during the early-initialization phase of the ROCm ASAN runtime.
+ Build of CK SDPA with ASAN is not tested
+ Select ASAN build of AOTriton for SDPA
Notable Bug Fixes:
* Rewrites env var parsers in `cmake/EnvVarForwarding.cmake` with python script
+ The old parser is error-prone and failed to handle complicated `PS1` env var like `${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$` (This is DEFAULT `PS1` from Ubuntu 24.04)
+ An outcome of this buggy parser is: `USE_ASAN` is never set if `PS1` contains `;` and occurs earlier than `USE_ASAN` in env vars.
+ **Breaking** the new parser now honors exported env vars over cmake command-line -D and/or CMakeCache.txt
* Other related ASAN build fixes on TheRock 7.14+Clang Environment
Pull Request resolved: pytorch#188242
Approved by: https://github.com/jeffdaily
Co-authored-by: Claude Opus 4.8 <[email protected]>
Notable New Features:
* ROCm PyTorch now supports ASAN build with TheRock 7.14 SDK
+ Use clang from TheRock 7.14 as the host compiler
+ integration builds cleanly; tests unvalidated due to crashing during the early-initialization phase of the ROCm ASAN runtime.
+ Build of CK SDPA with ASAN is not tested
+ Select ASAN build of AOTriton for SDPA
Notable Bug Fixes:
* Rewrites env var parsers in `cmake/EnvVarForwarding.cmake` with python script
+ The old parser is error-prone and failed to handle complicated `PS1` env var like `${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$` (This is DEFAULT `PS1` from Ubuntu 24.04)
+ An outcome of this buggy parser is: `USE_ASAN` is never set if `PS1` contains `;` and occurs earlier than `USE_ASAN` in env vars.
+ **Breaking** the new parser now honors exported env vars over cmake command-line -D and/or CMakeCache.txt
* Other related ASAN build fixes on TheRock 7.14+Clang Environment
Pull Request resolved: pytorch#188242
Approved by: https://github.com/jeffdaily
Co-authored-by: Claude Opus 4.8 <[email protected]>
This PR adds initial ROCm support for gfx1250 (CDNA5). What this PR enables: - Gates gfx1250-specific behavior on ROCm 7.14+ (the support floor), applied consistently across CUDABlas.cpp, ScaledBlas.cpp, CUDAHooks.cpp, and the test helpers. - Adds gfx1250 to the hipBLASLt preferred/supported arch lists and the hipSparseLt support check (ROCm 7.14+). - Extends the scaled GEMM / MX-format paths (block-wise Float8_e8m0fnu, mxfp8, mxfp4) to gfx1250. - Sets the gfx1250 shared-memory limit to 320 KB (vs 160 KB on gfx950), matching on the suffix-stripped arch name. - Adds CDNA2/CDNA3/CDNA5 "or later" arch helpers and updates FP8 / MX GEMM test gating in common_cuda.py. - Builds Composable Kernel (CK) GEMM as a separate ck_gemm library with gfx1250 filtered out of HIP_ARCHITECTURES, so a multi-arch build that includes gfx1250 keeps CK GEMM for the other archs instead of failing to compile for gfx1250 (composable_kernel has no gfx1250 support yet). The filter is removed once CK supports gfx1250. - Extends the gfx942 nontemporal vectorized-load path in MemoryAccess.cuh to gfx1250. - Refactors duplicated arch-check logic in CUDABlas.cpp, ScaledBlas.cpp, and cuSPARSELtOps.cpp per review feedback. - Writes the CublasHandlePool workspace archs in full (gfx942/gfx950/gfx1250). Enabled via the main merge: - Flash attention and memory-efficient attention on gfx1250 via AOTriton 0.12.1b (from pytorch#188242), which this branch merges in. What is not enabled yet: - CK SDPA on gfx1250: composable_kernel has no gfx1250 support; the CK SDPA target auto-filters to gfx942/gfx950. - CK GEMM on gfx1250: filtered out (see above) until composable_kernel supports it. - FP8 grouped GEMM on gfx1250: MSLK builds only gfx942/gfx950. - int4 mm on gfx1250: the tinygemm MFMA kernel needs a WMMA port; the ops return a clear "not supported yet" error and the int4 unit tests skip gfx1250. CI note: - gfx1250 is not added to the ROCm 7.2 (rocm-n) docker image, whose HIP compiler cannot target gfx1250. gfx1250 CI belongs on the nightly ROCm image and is added in a follow-up. Co-authored-by: @glen-amd Pull Request resolved: pytorch#188597 Approved by: https://github.com/jeffdaily Co-authored-by: Prachi Gupta <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Co-authored-by: Jeff Daily <[email protected]>
This PR adds initial ROCm support for gfx1250 (CDNA5). What this PR enables: - Gates gfx1250-specific behavior on ROCm 7.14+ (the support floor), applied consistently across CUDABlas.cpp, ScaledBlas.cpp, CUDAHooks.cpp, and the test helpers. - Adds gfx1250 to the hipBLASLt preferred/supported arch lists and the hipSparseLt support check (ROCm 7.14+). - Extends the scaled GEMM / MX-format paths (block-wise Float8_e8m0fnu, mxfp8, mxfp4) to gfx1250. - Sets the gfx1250 shared-memory limit to 320 KB (vs 160 KB on gfx950), matching on the suffix-stripped arch name. - Adds CDNA2/CDNA3/CDNA5 "or later" arch helpers and updates FP8 / MX GEMM test gating in common_cuda.py. - Builds Composable Kernel (CK) GEMM as a separate ck_gemm library with gfx1250 filtered out of HIP_ARCHITECTURES, so a multi-arch build that includes gfx1250 keeps CK GEMM for the other archs instead of failing to compile for gfx1250 (composable_kernel has no gfx1250 support yet). The filter is removed once CK supports gfx1250. - Extends the gfx942 nontemporal vectorized-load path in MemoryAccess.cuh to gfx1250. - Refactors duplicated arch-check logic in CUDABlas.cpp, ScaledBlas.cpp, and cuSPARSELtOps.cpp per review feedback. - Writes the CublasHandlePool workspace archs in full (gfx942/gfx950/gfx1250). Enabled via the main merge: - Flash attention and memory-efficient attention on gfx1250 via AOTriton 0.12.1b (from pytorch#188242), which this branch merges in. What is not enabled yet: - CK SDPA on gfx1250: composable_kernel has no gfx1250 support; the CK SDPA target auto-filters to gfx942/gfx950. - CK GEMM on gfx1250: filtered out (see above) until composable_kernel supports it. - FP8 grouped GEMM on gfx1250: MSLK builds only gfx942/gfx950. - int4 mm on gfx1250: the tinygemm MFMA kernel needs a WMMA port; the ops return a clear "not supported yet" error and the int4 unit tests skip gfx1250. CI note: - gfx1250 is not added to the ROCm 7.2 (rocm-n) docker image, whose HIP compiler cannot target gfx1250. gfx1250 CI belongs on the nightly ROCm image and is added in a follow-up. Co-authored-by: @glen-amd Pull Request resolved: pytorch#188597 Approved by: https://github.com/jeffdaily, https://github.com/pruthvistony Co-authored-by: Prachi Gupta <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Co-authored-by: Jeff Daily <[email protected]>
Notable New Features:
* ROCm PyTorch now supports ASAN build with TheRock 7.14 SDK
+ Use clang from TheRock 7.14 as the host compiler
+ integration builds cleanly; tests unvalidated due to crashing during the early-initialization phase of the ROCm ASAN runtime.
+ Build of CK SDPA with ASAN is not tested
+ Select ASAN build of AOTriton for SDPA
Notable Bug Fixes:
* Rewrites env var parsers in `cmake/EnvVarForwarding.cmake` with python script
+ The old parser is error-prone and failed to handle complicated `PS1` env var like `${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$` (This is DEFAULT `PS1` from Ubuntu 24.04)
+ An outcome of this buggy parser is: `USE_ASAN` is never set if `PS1` contains `;` and occurs earlier than `USE_ASAN` in env vars.
+ **Breaking** the new parser now honors exported env vars over cmake command-line -D and/or CMakeCache.txt
* Other related ASAN build fixes on TheRock 7.14+Clang Environment
Pull Request resolved: pytorch#188242
Approved by: https://github.com/jeffdaily
Co-authored-by: Claude Opus 4.8 <[email protected]>
#3421) Validation theRock Run: https://github.com/ROCm/TheRock/actions/runs/29045360944 Cherry-pick of upstream [pytorch#188597](pytorch#188597) onto `release/2.12` to add initial ROCm support for **gfx1250 (CDNA5)**. Co-authored-by: @glen-amd - Gates gfx1250-specific behavior on ROCm 7.14+ (the support floor), applied consistently across CUDABlas.cpp, ScaledBlas.cpp, CUDAHooks.cpp, and the test helpers. - Adds gfx1250 to the hipBLASLt preferred/supported arch lists and the hipSparseLt support check (ROCm 7.14+). - Extends the scaled GEMM / MX-format paths (block-wise Float8_e8m0fnu, mxfp8, mxfp4) to gfx1250. - Sets the gfx1250 shared-memory limit to 320 KB (vs 160 KB on gfx950), matching on the suffix-stripped arch name. - Adds CDNA2/CDNA3/CDNA5 "or later" arch helpers and updates FP8 / MX GEMM test gating in common_cuda.py. - Builds Composable Kernel (CK) GEMM as a separate ck_gemm library with gfx1250 filtered out of HIP_ARCHITECTURES, so a multi-arch build that includes gfx1250 keeps CK GEMM for the other archs instead of failing to compile for gfx1250 (composable_kernel has no gfx1250 support yet). The filter is removed once CK supports gfx1250. - Extends the gfx942 nontemporal vectorized-load path in MemoryAccess.cuh to gfx1250. - Refactors duplicated arch-check logic in CUDABlas.cpp, ScaledBlas.cpp, and cuSPARSELtOps.cpp per review feedback. - Writes the CublasHandlePool workspace archs in full (gfx942/gfx950/gfx1250). Enabled via the main merge: - Flash attention and memory-efficient attention on gfx1250 via AOTriton 0.12.1b (from pytorch#188242), which this branch merges in. What is not enabled yet: - CK SDPA on gfx1250: composable_kernel has no gfx1250 support; the CK SDPA target auto-filters to gfx942/gfx950. - CK GEMM on gfx1250: filtered out (see above) until composable_kernel supports it. - FP8 grouped GEMM on gfx1250: MSLK builds only gfx942/gfx950. - int4 mm on gfx1250: the tinygemm MFMA kernel needs a WMMA port; the ops return a clear "not supported yet" error and the int4 unit tests skip gfx1250. CI note: - gfx1250 is not added to the ROCm 7.2 (rocm-n) docker image, whose HIP compiler cannot target gfx1250. gfx1250 CI belongs on the nightly ROCm image and is added in a follow-up. Co-authored-by: @glen-amd - Upstream PR: pytorch#188597 - Related AOTriton bump: pytorch#188242 --------- Co-authored-by: Prachi Gupta <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Co-authored-by: Jeff Daily <[email protected]> (cherry picked from commit 13eab2b)
#3421) Validation theRock Run: https://github.com/ROCm/TheRock/actions/runs/29045360944 Cherry-pick of upstream [pytorch#188597](pytorch#188597) onto `release/2.12` to add initial ROCm support for **gfx1250 (CDNA5)**. Co-authored-by: @glen-amd - Gates gfx1250-specific behavior on ROCm 7.14+ (the support floor), applied consistently across CUDABlas.cpp, ScaledBlas.cpp, CUDAHooks.cpp, and the test helpers. - Adds gfx1250 to the hipBLASLt preferred/supported arch lists and the hipSparseLt support check (ROCm 7.14+). - Extends the scaled GEMM / MX-format paths (block-wise Float8_e8m0fnu, mxfp8, mxfp4) to gfx1250. - Sets the gfx1250 shared-memory limit to 320 KB (vs 160 KB on gfx950), matching on the suffix-stripped arch name. - Adds CDNA2/CDNA3/CDNA5 "or later" arch helpers and updates FP8 / MX GEMM test gating in common_cuda.py. - Builds Composable Kernel (CK) GEMM as a separate ck_gemm library with gfx1250 filtered out of HIP_ARCHITECTURES, so a multi-arch build that includes gfx1250 keeps CK GEMM for the other archs instead of failing to compile for gfx1250 (composable_kernel has no gfx1250 support yet). The filter is removed once CK supports gfx1250. - Extends the gfx942 nontemporal vectorized-load path in MemoryAccess.cuh to gfx1250. - Refactors duplicated arch-check logic in CUDABlas.cpp, ScaledBlas.cpp, and cuSPARSELtOps.cpp per review feedback. - Writes the CublasHandlePool workspace archs in full (gfx942/gfx950/gfx1250). Enabled via the main merge: - Flash attention and memory-efficient attention on gfx1250 via AOTriton 0.12.1b (from pytorch#188242), which this branch merges in. What is not enabled yet: - CK SDPA on gfx1250: composable_kernel has no gfx1250 support; the CK SDPA target auto-filters to gfx942/gfx950. - CK GEMM on gfx1250: filtered out (see above) until composable_kernel supports it. - FP8 grouped GEMM on gfx1250: MSLK builds only gfx942/gfx950. - int4 mm on gfx1250: the tinygemm MFMA kernel needs a WMMA port; the ops return a clear "not supported yet" error and the int4 unit tests skip gfx1250. CI note: - gfx1250 is not added to the ROCm 7.2 (rocm-n) docker image, whose HIP compiler cannot target gfx1250. gfx1250 CI belongs on the nightly ROCm image and is added in a follow-up. Co-authored-by: @glen-amd - Upstream PR: pytorch#188597 - Related AOTriton bump: pytorch#188242 --------- Co-authored-by: Prachi Gupta <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Co-authored-by: Jeff Daily <[email protected]> (cherry picked from commit 13eab2b)
Notable New Features:
* ROCm PyTorch now supports ASAN build with TheRock 7.14 SDK
+ Use clang from TheRock 7.14 as the host compiler
+ integration builds cleanly; tests unvalidated due to crashing during the early-initialization phase of the ROCm ASAN runtime.
+ Build of CK SDPA with ASAN is not tested
+ Select ASAN build of AOTriton for SDPA
Notable Bug Fixes:
* Rewrites env var parsers in `cmake/EnvVarForwarding.cmake` with python script
+ The old parser is error-prone and failed to handle complicated `PS1` env var like `${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$` (This is DEFAULT `PS1` from Ubuntu 24.04)
+ An outcome of this buggy parser is: `USE_ASAN` is never set if `PS1` contains `;` and occurs earlier than `USE_ASAN` in env vars.
+ **Breaking** the new parser now honors exported env vars over cmake command-line -D and/or CMakeCache.txt
* Other related ASAN build fixes on TheRock 7.14+Clang Environment
Pull Request resolved: pytorch#188242
Approved by: https://github.com/jeffdaily
Co-authored-by: Claude Opus 4.8 <[email protected]>
…-vars section Three points from janeyx99's review of the reference section. The forwarding mechanism was described in shorthand -- "forwarded by prefix", "passthrough", "read from env", "CMake-native" -- without saying what those mean. They are now defined once, framed as what to check when a variable appears not to take effect, which is the only reason a reader needs the distinction. Whether every variable can be set inline on the build command needed answering, and the answer has a wrinkle worth stating. All of them can except the CMake-only options, but what happens on the *next* build differs: prefix-forwarded names are re-applied every configure and override the cache, while alias and passthrough names only seed an entry that does not exist yet, so changing them later has no effect until the cache is edited or deleted. Both are sticky if simply dropped from the command line, since only variables actually present in the environment are forwarded at all. That asymmetry is called out as provisional rather than documented as design. It is anomaly (a) in the build-config precedence draft, whose proposal is to bring both classes under one rule, and this section will change when that lands. The review question is itself evidence the current split is confusing. The "Removed with setup.py" section is gone. Listing variables that no longer do anything does not belong in a reference of current options. What was still useful moved: USE_NINJA's replacement is now a CMAKE_GENERATOR entry under everyday knobs, which also fills a real gap -- CMAKE_GENERATOR=Ninja appears in the BUILD_CONFIG alias a few paragraphs earlier but was documented nowhere -- and CMAKE_FRESH's advice is folded into the cache discussion. CMAKE_ONLY is dropped. One paragraph outside the moved text changed too. The existing "options passed for the first time will persist" claim predates pytorch#188242 and is now wrong for the prefix-forwarded majority; it would have sat three paragraphs above the section contradicting it, so it now points at the new subsection instead. README.md carries a similar stale claim, left alone here to keep this a documentation move. This commit was authored with the assistance of an AI coding assistant. Test Plan: Documentation-only change. The override-versus-seed split was read out of cmake/EnvVarForwarding.cmake rather than assumed: prefix-forwarded names go through `_envfwd_apply`, which does `set(... CACHE STRING ... FORCE)` when the cached value differs, while the `_ENV_ALIASES` and `_ENV_PASSTHROUGH` loops are guarded by `NOT DEFINED ${_var}`. The enumeration emits assignments only for names present in `os.environ`, which is why omitting a variable leaves the cached value in both cases. Anchors, including the two new table-of-contents entries and the two new cross-references, all resolve: ``` python3 - <<'PY' import re s = open('CONTRIBUTING.md').read() def anchor(t): t = re.sub(r'`', '', t.strip().lower()) return re.sub(r'\s', '-', re.sub(r'[^\w\s-]', '', t)) have = {anchor(t) for _, t in re.findall(r'^(#{2,4}) (.+)$', s, re.M)} print([a for a in re.findall(r'\]\(#([^)]+)\)', s) if a not in have] or 'no broken anchors') PY ``` Lint: ``` lintrunner --paths-cmd='git diff --name-only origin/viable/strict' ```
cmake/EnvVarForwarding.cmake forwarded its variables with two different semantics. Names matched by prefix (BUILD_*, USE_*, CMAKE_*) have overridden the cache on every configure since pytorch#188242, so changing USE_CUDA in the environment takes effect on the next build. The names in the passthrough and alias lists (BLAS, TORCH_CUDA_ARCH_LIST, CUDNN_*, MKL_THREADING, ...) still used the original seed-only loop, guarded by NOT DEFINED, so they were written once and then ignored: changing BLAS in the environment did nothing to an existing build directory, and -D beat the environment for these names while losing to it for the prefixed ones. This change routes the passthrough names and all aliases through the same _envfwd_apply the prefix names use, so one rule holds for every knob: environment variables win over -D / cmake.define, those win over pyproject.toml, and all three win over what the build directory remembers. For developers this means a BLAS, MKL_THREADING or CUDNN_* value exported in the shell now re-applies on every build, overwriting a ccmake edit of that entry, exactly as USE_* and BUILD_* already did. The _ENV_ALIASES and _LOW_PRIORITY_ALIASES lists collapse into one, with a single semantics: an alias applies only when its canonical name is not itself in the environment, and where several aliases name the same variable the first listed one wins. Among the aliases, the only observable difference is that a canonical name now beats its alias when both are set (CUDNN_LIBRARY over CUDNN_LIB_DIR); no CI job sets both. As a consequence of going through _envfwd_apply, the passthrough and alias names are now also recorded in env_forwarded.txt, so the native-AOT stage-2 drift check covers them, as its docstring already claimed. The alternative, restoring flags-over-environment for the prefixed names instead, was rejected: scikit-build-core resolves its own and every declared config-setting as environment > -C > default, and a project cannot invert that, so flags-over-environment could not have been delivered uniformly. pytorch#200651 binds torch.blas and torch.cuda-arch-list to these names and documents that the bound environment variable takes precedence over the setting; that sentence is only true under this rule, so that PR rebases on this one. The README "Adjust Build Options" and CONTRIBUTING "subsequent builds" paragraphs stated the old seed-only behavior and now state the rule; the EnvVarForwarding header carries it too. Test Plan tools/test/test_env_var_forwarding.py configures a NONE-language CMake project that includes the module and asserts the four tiers for a prefix name and for BLAS (environment over -D, environment over cache, cache kept when the environment is silent, -D over cache), plus canonical-over-alias, alias-over-cache, first-listed-alias-wins and the drift-file recording. Against the unmodified module four of the eight tests fail, exactly the BLAS and alias cases. ``` python -m pytest tools/test/test_env_var_forwarding.py -q lintrunner -a cmake/EnvVarForwarding.cmake tools/test/test_env_var_forwarding.py tools/native_aot/build_stage2.py README.md CONTRIBUTING.md ``` Every commit that touched the module since its introduction was traced to its PR and checked against the new semantics; each CMake-side write to a forwarded variable is either a non-FORCE default or a normal-variable shadow, both of which behave the same under either semantics. Authored with an AI assistant; the diff was reviewed by hand. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Go through the following checklist - [x] Passes lint (`spin fixlint`) - [x] Added/updated tests - [x] Updated documentation (if applicable) - [ ] Included benchmark results (for PRs impacting perf) --- ## Linked issue or supporting maintainer Part of #201664 ## BC-breaking? No. One behavior change for existing build directories: a `BLAS`, `MKL_THREADING` or `CUDNN_*` value exported in the shell now re-applies on every build and overwrites a ccmake edit of that entry, as `USE_*` and `BUILD_*` already did since #188242. ## Summary (human written only) This PR homogenizes the treatment of configure options for the Pytorch build. It is part of #201664, implementing most of the necessary changes that are not covered in other PRs or dependent on future changes. ## Agent details (if applicable) Drafted with Claude Code; diff and commit message reviewed by hand. The commit message follows. cmake/EnvVarForwarding.cmake forwarded its variables with two different semantics. Names matched by prefix (BUILD_*, USE_*, CMAKE_*) have overridden the cache on every configure since #188242, so changing USE_CUDA in the environment takes effect on the next build. The names in the passthrough and alias lists (BLAS, TORCH_CUDA_ARCH_LIST, CUDNN_*, MKL_THREADING, ...) still used the original seed-only loop, guarded by NOT DEFINED, so they were written once and then ignored: changing BLAS in the environment did nothing to an existing build directory, and -D beat the environment for these names while losing to it for the prefixed ones. This change routes the passthrough names and all aliases through the same _envfwd_apply the prefix names use, so one rule holds for every knob: environment variables win over -D / cmake.define, those win over pyproject.toml, and all three win over what the build directory remembers. For developers this means a BLAS, MKL_THREADING or CUDNN_* value exported in the shell now re-applies on every build, overwriting a ccmake edit of that entry, exactly as USE_* and BUILD_* already did. The _ENV_ALIASES and _LOW_PRIORITY_ALIASES lists collapse into one, with a single semantics: an alias applies only when its canonical name is not itself in the environment, and where several aliases name the same variable the first listed one wins. Among the aliases, the only observable difference is that a canonical name now beats its alias when both are set (CUDNN_LIBRARY over CUDNN_LIB_DIR); no CI job sets both. As a consequence of going through _envfwd_apply, the passthrough and alias names are now also recorded in env_forwarded.txt, so the native-AOT stage-2 drift check covers them, as its docstring already claimed. The alternative, restoring flags-over-environment for the prefixed names instead, was rejected: scikit-build-core resolves its own and every declared config-setting as environment > -C > default, and a project cannot invert that, so flags-over-environment could not have been delivered uniformly. #200651 binds torch.blas and torch.cuda-arch-list to these names and documents that the bound environment variable takes precedence over the setting; that sentence is only true under this rule, so that PR rebases on this one. The README "Adjust Build Options" and CONTRIBUTING "subsequent builds" paragraphs stated the old seed-only behavior and now state the rule; the EnvVarForwarding header carries it too. Test Plan tools/test/test_env_var_forwarding.py configures a NONE-language CMake project that includes the module and asserts the four tiers for a prefix name and for BLAS (environment over -D, environment over cache, cache kept when the environment is silent, -D over cache), plus canonical-over-alias, alias-over-cache, first-listed-alias-wins and the drift-file recording. Against the unmodified module four of the eight tests fail, exactly the BLAS and alias cases. ``` python -m pytest tools/test/test_env_var_forwarding.py -q lintrunner -a cmake/EnvVarForwarding.cmake tools/test/test_env_var_forwarding.py tools/native_aot/build_stage2.py README.md CONTRIBUTING.md ``` Every commit that touched the module since its introduction was traced to its PR and checked against the new semantics; each CMake-side write to a forwarded variable is either a non-FORCE default or a normal-variable shadow, both of which behave the same under either semantics. Authored with an AI assistant; the diff was reviewed by hand. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Pull Request resolved: #201666 Approved by: https://github.com/atalman
…-vars section Three points from janeyx99's review of the reference section. The forwarding mechanism was described in shorthand -- "forwarded by prefix", "passthrough", "read from env", "CMake-native" -- without saying what those mean. They are now defined once, framed as what to check when a variable appears not to take effect, which is the only reason a reader needs the distinction. Whether every variable can be set inline on the build command needed answering, and the answer has a wrinkle worth stating. All of them can except the CMake-only options, but what happens on the *next* build differs: prefix-forwarded names are re-applied every configure and override the cache, while alias and passthrough names only seed an entry that does not exist yet, so changing them later has no effect until the cache is edited or deleted. Both are sticky if simply dropped from the command line, since only variables actually present in the environment are forwarded at all. That asymmetry is called out as provisional rather than documented as design. It is anomaly (a) in the build-config precedence draft, whose proposal is to bring both classes under one rule, and this section will change when that lands. The review question is itself evidence the current split is confusing. The "Removed with setup.py" section is gone. Listing variables that no longer do anything does not belong in a reference of current options. What was still useful moved: USE_NINJA's replacement is now a CMAKE_GENERATOR entry under everyday knobs, which also fills a real gap -- CMAKE_GENERATOR=Ninja appears in the BUILD_CONFIG alias a few paragraphs earlier but was documented nowhere -- and CMAKE_FRESH's advice is folded into the cache discussion. CMAKE_ONLY is dropped. One paragraph outside the moved text changed too. The existing "options passed for the first time will persist" claim predates pytorch#188242 and is now wrong for the prefix-forwarded majority; it would have sat three paragraphs above the section contradicting it, so it now points at the new subsection instead. README.md carries a similar stale claim, left alone here to keep this a documentation move. This commit was authored with the assistance of an AI coding assistant. Test Plan: Documentation-only change. The override-versus-seed split was read out of cmake/EnvVarForwarding.cmake rather than assumed: prefix-forwarded names go through `_envfwd_apply`, which does `set(... CACHE STRING ... FORCE)` when the cached value differs, while the `_ENV_ALIASES` and `_ENV_PASSTHROUGH` loops are guarded by `NOT DEFINED ${_var}`. The enumeration emits assignments only for names present in `os.environ`, which is why omitting a variable leaves the cached value in both cases. Anchors, including the two new table-of-contents entries and the two new cross-references, all resolve: ``` python3 - <<'PY' import re s = open('CONTRIBUTING.md').read() def anchor(t): t = re.sub(r'`', '', t.strip().lower()) return re.sub(r'\s', '-', re.sub(r'[^\w\s-]', '', t)) have = {anchor(t) for _, t in re.findall(r'^(#{2,4}) (.+)$', s, re.M)} print([a for a in re.findall(r'\]\(#([^)]+)\)', s) if a not in have] or 'no broken anchors') PY ``` Lint: ``` lintrunner --paths-cmd='git diff --name-only origin/viable/strict' ```
…-vars section Three points from janeyx99's review of the reference section. The forwarding mechanism was described in shorthand -- "forwarded by prefix", "passthrough", "read from env", "CMake-native" -- without saying what those mean. They are now defined once, framed as what to check when a variable appears not to take effect, which is the only reason a reader needs the distinction. Whether every variable can be set inline on the build command needed answering, and the answer has a wrinkle worth stating. All of them can except the CMake-only options, but what happens on the *next* build differs: prefix-forwarded names are re-applied every configure and override the cache, while alias and passthrough names only seed an entry that does not exist yet, so changing them later has no effect until the cache is edited or deleted. Both are sticky if simply dropped from the command line, since only variables actually present in the environment are forwarded at all. That asymmetry is called out as provisional rather than documented as design. It is anomaly (a) in the build-config precedence draft, whose proposal is to bring both classes under one rule, and this section will change when that lands. The review question is itself evidence the current split is confusing. The "Removed with setup.py" section is gone. Listing variables that no longer do anything does not belong in a reference of current options. What was still useful moved: USE_NINJA's replacement is now a CMAKE_GENERATOR entry under everyday knobs, which also fills a real gap -- CMAKE_GENERATOR=Ninja appears in the BUILD_CONFIG alias a few paragraphs earlier but was documented nowhere -- and CMAKE_FRESH's advice is folded into the cache discussion. CMAKE_ONLY is dropped. One paragraph outside the moved text changed too. The existing "options passed for the first time will persist" claim predates pytorch#188242 and is now wrong for the prefix-forwarded majority; it would have sat three paragraphs above the section contradicting it, so it now points at the new subsection instead. README.md carries a similar stale claim, left alone here to keep this a documentation move. This commit was authored with the assistance of an AI coding assistant. Test Plan: Documentation-only change. The override-versus-seed split was read out of cmake/EnvVarForwarding.cmake rather than assumed: prefix-forwarded names go through `_envfwd_apply`, which does `set(... CACHE STRING ... FORCE)` when the cached value differs, while the `_ENV_ALIASES` and `_ENV_PASSTHROUGH` loops are guarded by `NOT DEFINED ${_var}`. The enumeration emits assignments only for names present in `os.environ`, which is why omitting a variable leaves the cached value in both cases. Anchors, including the two new table-of-contents entries and the two new cross-references, all resolve: ``` python3 - <<'PY' import re s = open('CONTRIBUTING.md').read() def anchor(t): t = re.sub(r'`', '', t.strip().lower()) return re.sub(r'\s', '-', re.sub(r'[^\w\s-]', '', t)) have = {anchor(t) for _, t in re.findall(r'^(#{2,4}) (.+)$', s, re.M)} print([a for a in re.findall(r'\]\(#([^)]+)\)', s) if a not in have] or 'no broken anchors') PY ``` Lint: ``` lintrunner --paths-cmd='git diff --name-only origin/viable/strict' ```
Notable New Features:
Notable Bug Fixes:
cmake/EnvVarForwarding.cmakewith python scriptPS1env var like${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$(This is DEFAULTPS1from Ubuntu 24.04)USE_ASANis never set ifPS1contains;and occurs earlier thanUSE_ASANin env vars.cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil