Skip to content

[ROCm] Support USE_ASAN=1 build - #188242

Closed
xinyazhang wants to merge 7 commits into
pytorch:mainfrom
xinyazhang:xinyazhang/aotriton-mainline-asan
Closed

xinyazhang wants to merge 7 commits into
pytorch:mainfrom
xinyazhang:xinyazhang/aotriton-mainline-asan

Conversation

@xinyazhang

@xinyazhang xinyazhang commented Jun 26, 2026 •

Copy link
Copy Markdown
Collaborator

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

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil

@pytorch-bot

pytorch-bot Bot commented Jun 26, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/188242

Note: Links to docs will display an error until the docs builds have been completed.

❌ 18 Cancelled Jobs, 1 Unclassified Failure

As of commit 362be1e with merge base ed8fd16 (image):

UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added the module: rocm AMD GPU support for Pytorch label Jun 26, 2026
@xinyazhang xinyazhang changed the title (WIP) [ROCM] Address Sanitizer support for ROCM 7.14 + Clang compiler [ROCM] Enable Address Sanitizer support with AOTriton 0.12.1b Jun 30, 2026
@xinyazhang xinyazhang changed the title [ROCM] Enable Address Sanitizer support with AOTriton 0.12.1b [ROCM] Enable Address Sanitizer and gfx1250 SDPA with AOTriton 0.12.1b Jun 30, 2026
@xinyazhang
xinyazhang requested a review from Copilot June 30, 2026 06:34
@xinyazhang xinyazhang added the topic: not user facing topic category label Jun 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread cmake/Modules/FindSanitizer.cmake Resolved
Comment thread cmake/Dependencies.cmake Resolved
@xinyazhang xinyazhang changed the title [ROCM] Enable Address Sanitizer and gfx1250 SDPA with AOTriton 0.12.1b [ROCm] Enable Address Sanitizer and gfx1250 SDPA with AOTriton 0.12.1b Jun 30, 2026
@xinyazhang
xinyazhang force-pushed the xinyazhang/aotriton-mainline-asan branch from 5fb12c9 to bd34b92 Compare June 30, 2026 06:48
@xinyazhang xinyazhang added ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/trunk Trigger trunk jobs on your pull request labels Jun 30, 2026
@xinyazhang
xinyazhang force-pushed the xinyazhang/aotriton-mainline-asan branch from bd34b92 to a101cd3 Compare June 30, 2026 15:59
@pytorch-bot

pytorch-bot Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

glen-amd added a commit to glen-amd/pytorch that referenced this pull request Jun 30, 2026
@xinyazhang xinyazhang removed the ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 label Jun 30, 2026
@xinyazhang
xinyazhang marked this pull request as ready for review June 30, 2026 21:16
@xinyazhang

Copy link
Copy Markdown
Collaborator Author

@jeffdaily failures are due to inductor timeouts or MI300 runner times outs (>360 mins).
However we probably want to wait reviews from @malfet and/or @atalman since this changes how the build system parses the env vars.

@xinyazhang
xinyazhang requested review from jeffdaily and malfet June 30, 2026 21:20
@xinyazhang xinyazhang assigned atalman and unassigned atalman Jun 30, 2026
@xinyazhang
xinyazhang requested a review from atalman June 30, 2026 21:23

@jeffdaily jeffdaily left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's split this into 2 PRs, one for AOTriton 0.12.1.b and one for broader ASAN build enhancements/fixes.

@xinyazhang

Copy link
Copy Markdown
Collaborator Author

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.

@xinyazhang
xinyazhang marked this pull request as draft June 30, 2026 22:03
@xinyazhang xinyazhang removed the ciflow/trunk Trigger trunk jobs on your pull request label Jun 30, 2026
@xinyazhang
xinyazhang force-pushed the xinyazhang/aotriton-mainline-asan branch from a101cd3 to 2fa2bbc Compare July 1, 2026 07:59
@xinyazhang

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

zjliu-amd pushed a commit to zjliu-amd/pytorch that referenced this pull request Jul 21, 2026
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]>
DamJanusz pushed a commit to DamJanusz/pytorch that referenced this pull request Jul 21, 2026
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]>
DamJanusz pushed a commit to DamJanusz/pytorch that referenced this pull request Jul 21, 2026
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]>
youlituao pushed a commit to youlituao/pytorch that referenced this pull request Jul 28, 2026
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]>
youlituao pushed a commit to youlituao/pytorch that referenced this pull request Jul 28, 2026
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]>
youlituao pushed a commit to youlituao/pytorch that referenced this pull request Jul 28, 2026
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]>
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
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]>
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
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]>
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
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]>
jithunnair-amd pushed a commit to ROCm/pytorch that referenced this pull request Jul 31, 2026
#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)
jithunnair-amd pushed a commit to ROCm/pytorch that referenced this pull request Jul 31, 2026
#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)
MelindaTan pushed a commit to MelindaTan/pytorch that referenced this pull request Jul 31, 2026
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]>
zklaus added a commit to zklaus/pytorch that referenced this pull request Aug 27, 2026
…-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'
```
zklaus added a commit to zklaus/pytorch that referenced this pull request Nov 9, 2026
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)
pytorchmergebot pushed a commit that referenced this pull request Nov 9, 2026
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
zklaus added a commit to zklaus/pytorch that referenced this pull request Nov 11, 2026
…-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'
```
zklaus added a commit to zklaus/pytorch that referenced this pull request Nov 12, 2026
…-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'
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/trunk Trigger trunk jobs on your pull request Merged module: rocm AMD GPU support for Pytorch open source topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants