Repository navigation
Conversation
Replace FindHIP.cmake's hip_add_library/hip_add_executable with CMake's
native enable_language(HIP) and standard add_library/add_executable.
This enables proper HIP device compilation on Windows where FindHIP's
bash-based linker helper doesn't work.
Key changes:
- LoadHIP.cmake: enable_language(HIP) with Windows workarounds for
MSVC/GNU frontend mixing (forced compiler detection, GNU-style
compile/link rules, MSVC runtime library mapping)
- Dependencies.cmake: migrate HIP_HIPCC_FLAGS to CMAKE_HIP_FLAGS,
replace hip_include_directories with target_include_directories,
use hip::host instead of hip::amdhip64
- All CMakeLists: replace hip_add_library with add_library, replace
HIP_SOURCE_PROPERTY_FORMAT with LANGUAGE HIP, set LINKER_LANGUAGE CXX
on shared HIP libraries for proper Windows linking
- Fix -mllvm flag deduplication by using -mllvm=<arg> form
- Add HAVE_AVX{2,512}_CPU_DEFINITION to CMAKE_HIP_FLAGS for
DispatchStub ABI compatibility between torch_cpu and torch_hip
- Fix unconditional ck_group_gemm reference when USE_ROCM_CK_GEMM=OFF
- Third-party (gloo, fbgemm): dual-path support for native/legacy HIP
Authored with Claude Code.
Co-Authored-By: Claude Opus 4.6 (1M context)
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/180485
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Unrelated FailureAs of commit 059210c with merge base b127675 ( NEW FAILURE - The following job has failed:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Hey @GZGavinZhao, I was inspired by your #172775 and got enable_language(HIP) working on TheRock Windows build. I'd appreciate your review here. Thanks. |
| message(STATUS "HIP language enabled with compiler: ${CMAKE_HIP_COMPILER}") | ||
| message(STATUS "HIP architectures: ${CMAKE_HIP_ARCHITECTURES}") | ||
|
|
||
| if(WIN32) |
There was a problem hiding this comment.
I don't have a Windows machine to test, but can you try CMake v4.3.0 and above and see if this section is still necessary? v4.3.0 and above contains my upstreamed fix. Be sure you're using clang-cl.exe for this.
There was a problem hiding this comment.
Thanks for the pointer. Two reasons to keep this block as-is for now:
- PyTorch's
cmake_minimum_required(VERSION 3.27)(top of the rootCMakeLists.txt) sets the supported floor well below the 4.3.0 that contains your upstream fix. Even if the workaround becomes a no-op on 4.3.0+, it's still required for any user on a 3.27 ≤ CMake < 4.3.0 toolchain — and gating the override behindif(CMAKE_VERSION VERSION_LESS 4.3.0)adds a conditional path I'd rather not maintain until the floor moves up. - On
clang-cl.exe: I haven't taken that path. The PR is currently set up withclang++.exe(the GNU-frontend driver), which is what got the TheRock Windows build working end-to-end. Tryingclang-cl.exewould be a separate exercise — and given (1), it wouldn't remove the workaround from the supported version range anyway.
Happy to revisit once the cmake floor moves, or to take a follow-up PR that tries clang-cl.exe if there's a concrete reason to prefer it.
There was a problem hiding this comment.
Thanks @GZGavinZhao. Tested on Windows with CMake 4.3.2 (which contains your fix). Two scenarios:
-
clang-cl.exefor both C/CXX and HIP, no Windows workarounds: Configure succeeds, the generated HIP compile rule uses MSVC-style syntax that clang-cl accepts, andSleep.hipcompiles cleanly. Two minor warnings about-std=c++20and-fclang-abi-compat=17being ignored by clang-cl — those flags inDependencies.cmake'sCMAKE_HIP_FLAGSwould need MSVC-driver equivalents (/std:c++20and-Xclang -fclang-abi-compat=17). -
clang-cl.exefor C/CXX +clang++.exefor HIP (current PR), no Windows workarounds:enable_language(HIP)fails because the HIP compiler ABI test compiles with C/CXX-inherited flags (/DWIN32 /Ob0 /Od /RTC1 --cuda-host-only) which clang++ (GNU frontend) rejects. Even after skipping ABI detection (CMAKE_HIP_COMPILER_FORCED=TRUE), the generated compile rule still uses MSVC-style syntax (/nologo /Fo /Fd -clang:-MD -imsvc) which clang++ rejects.
So the if(WIN32) blocks are necessary if we keep clang++.exe as the HIP compiler. They become unnecessary if we switch to clang-cl.exe for HIP, as your fix supports. Switching has the appeal of dropping ~50 lines of platform-specific overrides; the tradeoff is reworking the Dependencies.cmake CMAKE_HIP_FLAGS from GNU-style to MSVC-driver-style. Happy to do that as a follow-up if preferred — let me know.
There was a problem hiding this comment.
Looks fine from a quick scan. Building this is a bit time-consuming so I won't be able to test this properly until this weekend. Just left a comment about the possibility of dropping if (WIN32) section in LoadHIP.cmake.
I'd also suggest explicitly testing the build with both fbgemm and gloo enabled. Legacy HIP builds use find_package(HIP) which is known to have a conflict with enable_language(HIP) (see discussion here). I believe gloo has migrated away from that in pytorch/gloo#478 but fbgemm still has this line. If this conflict is not fixed yet, theoretically we would have a problem when building fbgemm_gpu together with PyTorch.
When using CMake native HIP language support, marking .cpp files as LANGUAGE HIP causes clang to emit a per-TU __hip_cuid_<hash> symbol. sccache invokes the compiler with preprocessed input, which leaves clang's driver with no unique path to hash — every .cpp.o ends up with the same __hip_cuid_ symbol and torch_hip fails to link with "multiple definition" errors. Local builds without sccache weren't affected because each TU got a unique CUID from its real source path. Filter Caffe2_HIP_SRCS so only .cu/.hip files get LANGUAGE HIP (matching the legacy hip_add_library behavior); .cpp files compile as CXX and never emit __hip_cuid_. Also drop the redundant LANGUAGE HIP on GENERATED_CXX_TORCH_CUDA (c_shim_cuda.cpp). While here, clean up c10/hip/CMakeLists.txt: the old block marking .cc files as HIP was dead code from 2018 (c10/cuda has no .cu files, HIPIFY renames .cu->.hip anyway) and referenced the long-removed hcc compiler. c10/hip is host-only, so all sources compile as CXX. Authored-by: Claude Opus 4.7 (1M context)
|
@claude Please do a deep review focused on subtle correctness bugs and regressions that are easy for human reviewers to miss. Prioritize findings over summary. I dont care about anything that isnt a real bug drop all the noise but that, if you there isnt anything to report just say so with a small comment |
|
Claude finished @drisspg's task in 6m 9s —— View job I did a thorough review of all 10 changed files looking specifically for subtle correctness bugs and regressions. I didn't find any real bugs. The key behavioral changes are all intentional and correct:
Nothing to flag. |
# Conflicts: # c10/hip/CMakeLists.txt # caffe2/CMakeLists.txt
|
@drisspg would you be able to finish your review? |
|
Did we resolve the fbgemm_gpu issue? |
|
@drisspg Did some experiments to back up the answer. Short answer: PyTorch's main CMake never invokes The dep that is invoked from PyTorch's tree on the ROCm path is Experiments run locally on this PR branch (merged with current
The PR does not bump the gloo submodule pin — keeping the current scope minimal. Happy to add a gloo bump in a follow-up PR if reviewers prefer the cleaner story. |
PR pytorch#180485 ([ROCm] Use CMake native HIP language support) replaced FindHIP's hip_add_library and global HIP_CLANG_FLAGS arch filtering with native enable_language(HIP) and per-target HIP_ARCHITECTURES. Re-express the ck_sdpa gfx9 denylist (gfx900, gfx906, gfx90c) using the new HIP_ARCHITECTURES target property, mirroring the mslk allowlist pattern that pytorch#180485 already established in the same file. Same behavior, just expressed in the new build system. Authored with Claude Code.
On ROCm builds with USE_ROCM_CK_GEMM=OFF, GroupedBlas.cpp still included ck_group_gemm.h and emitted a source-level reference to at::hip::detail::group_gemm_ck(...) inside an always-false `if (use_fast_path)` branch. The Linux/legacy-CMake build path tolerated this (dead-code-elimination hid the unresolved symbol), but the Windows build under enable_language(HIP) in pytorch#180485 surfaces it as a linker failure. Gate the include and the call site uniformly on USE_ROCM_CK_GEMM and replace the bool indirection with explicit `#if defined(USE_ROCM_CK_GEMM)` / `#else`, so the fallback path is the only thing the compiler sees when CK is disabled. Split out from pytorch#180485 per @malfet review. Authored with Claude Code. Pull Request resolved: pytorch#182615 Approved by: https://github.com/malfet
…ytorch#180485) Replace FindHIP.cmake's hip_add_library/hip_add_executable with CMake's native enable_language(HIP) and standard add_library/add_executable. This enables proper HIP device compilation on Windows where FindHIP's bash-based linker helper doesn't work. Key changes: - LoadHIP.cmake: enable_language(HIP) with Windows workarounds for MSVC/GNU frontend mixing (forced compiler detection, GNU-style compile/link rules, MSVC runtime library mapping) - Dependencies.cmake: migrate HIP_HIPCC_FLAGS to CMAKE_HIP_FLAGS, replace hip_include_directories with target_include_directories, use hip::host instead of hip::amdhip64 - All CMakeLists: replace hip_add_library with add_library, replace HIP_SOURCE_PROPERTY_FORMAT with LANGUAGE HIP, set LINKER_LANGUAGE CXX on shared HIP libraries for proper Windows linking - Fix -mllvm flag deduplication by using -mllvm=<arg> form - Add HAVE_AVX{2,512}_CPU_DEFINITION to CMAKE_HIP_FLAGS for DispatchStub ABI compatibility between torch_cpu and torch_hip - Fix unconditional ck_group_gemm reference when USE_ROCM_CK_GEMM=OFF Authored with Claude Code. Co-Authored-By: Claude Opus 4.6 (1M context) Pull Request resolved: pytorch#180485 Approved by: https://github.com/drisspg, https://github.com/malfet
PR pytorch#180485 migrated the Windows HIP build from hip_add_library/hipcc to CMake's native HIP language with clang++ direct. The custom CMAKE_HIP_COMPILE_OBJECT rule installed in cmake/public/LoadHIP.cmake expands <FLAGS>, but the per-config CMAKE_HIP_FLAGS_RELEASE values do not reliably reach <FLAGS> for the HIP language, so HIP code silently fell back to clang++'s -O0 default. Every kernel in torch_hip.dll ended up unoptimized: 100% scratch spillage in the ISA, and the AMD runtime emits scratch ranges on every dispatch (palvirtual.hpp: scratch = ptr:[...] size:[90177536]). Result: ~99% conv2d FP16 perf regression on gfx1150 (2715 -> 16 GFLOP/s, bisected and validated at ROCm/TheRock#5157). Fix: inject -O3 directly into the compile rule template so it is guaranteed regardless of how <FLAGS> expands. Validation on gfx1150 / Radeon 890M (validate_torch_vroom.py): 5/5 nightly (pre-pytorch#180485): 2715 GFLOP/s 5/9 nightly (regressed): 16 GFLOP/s 5/9 + this patch: 2515 GFLOP/s The compile-rule location was identified and validated by @astrelsky on ROCm/TheRock#5157. Authored with assistance from Claude.
…_FLAGS PR pytorch#180485 migrated the Windows HIP build to native enable_language(HIP). PR pytorch#183365 stripped MSVC-style defaults (/DWIN32 /D_WINDOWS /O2 /Ob2 /DNDEBUG) out of CMAKE_HIP_FLAGS{,_<CONFIG>} so clang++ would stop warn-ignoring them, and tried to reinstate GNU equivalents by appending to CMAKE_HIP_FLAGS_RELEASE, CMAKE_HIP_FLAGS_DEBUG, etc. The reinstatement step does not work on this code path. The generated HIP compile rule expands <FLAGS> from CMAKE_HIP_FLAGS, but the per-config CMAKE_HIP_FLAGS_<CONFIG> variables do not reach <FLAGS> (verified by inspecting build.ninja: CMAKE_HIP_FLAGS contents like --offload-compress and --offload-arch appear, but the -O3 -DNDEBUG appended to CMAKE_HIP_FLAGS_RELEASE does not). That is the actual cause of the "silent -O0 fallback" reported in TheRock#5157 / pytorch#183853: with the MSVC /O2 stripped and the GNU -O3 unreachable, HIP code was effectively compiled at -O0. The previous version of this PR hardcoded -O3 in the CMAKE_HIP_COMPILE_OBJECT rule template. That restores Release perf but the -O3 sits outside the per-config plumbing, so it also leaks into Debug, RelWithDebInfo, and MinSizeRel builds. Inject the per-config optimization flags into CMAKE_HIP_FLAGS instead, gated on CMAKE_BUILD_TYPE. CMAKE_HIP_FLAGS does reach <FLAGS> in the generated rule, so this lands -O3/-O2/-O0/-Os (matching the build type) on the compile line for single-config generators (Ninja, Makefiles) without contaminating other configs. Drop the now-dead string(APPEND CMAKE_HIP_FLAGS_<CONFIG>) lines and the -O3 hack in the compile rule. Validation on gfx1151 / Radeon AI MAX 395 with CMake 4.3.2: Release shows -O3 -DNDEBUG in build.ninja FLAGS and Sleep.hip compiles cleanly with optimized ISA; Debug shows -O0 -g. Co-investigated with @astrelsky and @adityas-amd on TheRock#5157. Authored with assistance from Claude.
…_FLAGS (#183856) ## Issue Fixes ROCm/TheRock#5157. Fixes #183853. Windows ROCm HIP code was effectively compiled at `-O0` after #180485 + #183365 landed, causing a ~99% conv2d FP16 perf regression on gfx1150 (bisected and validated by @astrelsky and @adityas-amd at ROCm/TheRock#5157). ## Diagnosis After #183365 stripped the MSVC-style `/O2 /Ob2 /DNDEBUG` out of `CMAKE_HIP_FLAGS_RELEASE` and re-appended GNU `-O3 -DNDEBUG`, the actual build command still came up unoptimized. Inspecting the generated `build.ninja` shows why: - `CMAKE_HIP_FLAGS` contents (e.g. `--offload-compress -std=c++20 --offload-arch=...`) **do** reach the `$FLAGS` ninja variable used by every HIP compile. - `CMAKE_HIP_FLAGS_<CONFIG>` contents (e.g. `-O3 -DNDEBUG`) **do not**. That's the actual cause of the `-O0` fallback — `CMAKE_HIP_FLAGS_RELEASE` is dead code on the Windows HIP compile path. ## Fix - Drop the dead `string(APPEND CMAKE_HIP_FLAGS_<CONFIG> ...)` lines. - Inject the appropriate `-O{3,2,0,s}` plus `-DNDEBUG`/`-g` directly into `CMAKE_HIP_FLAGS`, gated on `CMAKE_BUILD_TYPE`. This works for single-config generators (Ninja, Makefiles), which is what the Windows ROCm build uses. - Drop the `-O3` from the compile rule template so non-Release configs aren't tainted. Pull Request resolved: #183856 Approved by: https://github.com/jeffdaily, https://github.com/astrelsky Co-authored-by: Jeff Daily <[email protected]>
On ROCm builds with USE_ROCM_CK_GEMM=OFF, GroupedBlas.cpp still included ck_group_gemm.h and emitted a source-level reference to at::hip::detail::group_gemm_ck(...) inside an always-false `if (use_fast_path)` branch. The Linux/legacy-CMake build path tolerated this (dead-code-elimination hid the unresolved symbol), but the Windows build under enable_language(HIP) in pytorch#180485 surfaces it as a linker failure. Gate the include and the call site uniformly on USE_ROCM_CK_GEMM and replace the bool indirection with explicit `#if defined(USE_ROCM_CK_GEMM)` / `#else`, so the fallback path is the only thing the compiler sees when CK is disabled. Split out from pytorch#180485 per @malfet review. Authored with Claude Code. Pull Request resolved: pytorch#182615 Approved by: https://github.com/malfet
…ytorch#180485) Replace FindHIP.cmake's hip_add_library/hip_add_executable with CMake's native enable_language(HIP) and standard add_library/add_executable. This enables proper HIP device compilation on Windows where FindHIP's bash-based linker helper doesn't work. Key changes: - LoadHIP.cmake: enable_language(HIP) with Windows workarounds for MSVC/GNU frontend mixing (forced compiler detection, GNU-style compile/link rules, MSVC runtime library mapping) - Dependencies.cmake: migrate HIP_HIPCC_FLAGS to CMAKE_HIP_FLAGS, replace hip_include_directories with target_include_directories, use hip::host instead of hip::amdhip64 - All CMakeLists: replace hip_add_library with add_library, replace HIP_SOURCE_PROPERTY_FORMAT with LANGUAGE HIP, set LINKER_LANGUAGE CXX on shared HIP libraries for proper Windows linking - Fix -mllvm flag deduplication by using -mllvm=<arg> form - Add HAVE_AVX{2,512}_CPU_DEFINITION to CMAKE_HIP_FLAGS for DispatchStub ABI compatibility between torch_cpu and torch_hip - Fix unconditional ck_group_gemm reference when USE_ROCM_CK_GEMM=OFF Authored with Claude Code. Co-Authored-By: Claude Opus 4.6 (1M context) Pull Request resolved: pytorch#180485 Approved by: https://github.com/drisspg, https://github.com/malfet
On ROCm builds with USE_ROCM_CK_GEMM=OFF, GroupedBlas.cpp still included ck_group_gemm.h and emitted a source-level reference to at::hip::detail::group_gemm_ck(...) inside an always-false `if (use_fast_path)` branch. The Linux/legacy-CMake build path tolerated this (dead-code-elimination hid the unresolved symbol), but the Windows build under enable_language(HIP) in pytorch#180485 surfaces it as a linker failure. Gate the include and the call site uniformly on USE_ROCM_CK_GEMM and replace the bool indirection with explicit `#if defined(USE_ROCM_CK_GEMM)` / `#else`, so the fallback path is the only thing the compiler sees when CK is disabled. Split out from pytorch#180485 per @malfet review. Authored with Claude Code. Pull Request resolved: pytorch#182615 Approved by: https://github.com/malfet
…ytorch#180485) Replace FindHIP.cmake's hip_add_library/hip_add_executable with CMake's native enable_language(HIP) and standard add_library/add_executable. This enables proper HIP device compilation on Windows where FindHIP's bash-based linker helper doesn't work. Key changes: - LoadHIP.cmake: enable_language(HIP) with Windows workarounds for MSVC/GNU frontend mixing (forced compiler detection, GNU-style compile/link rules, MSVC runtime library mapping) - Dependencies.cmake: migrate HIP_HIPCC_FLAGS to CMAKE_HIP_FLAGS, replace hip_include_directories with target_include_directories, use hip::host instead of hip::amdhip64 - All CMakeLists: replace hip_add_library with add_library, replace HIP_SOURCE_PROPERTY_FORMAT with LANGUAGE HIP, set LINKER_LANGUAGE CXX on shared HIP libraries for proper Windows linking - Fix -mllvm flag deduplication by using -mllvm=<arg> form - Add HAVE_AVX{2,512}_CPU_DEFINITION to CMAKE_HIP_FLAGS for DispatchStub ABI compatibility between torch_cpu and torch_hip - Fix unconditional ck_group_gemm reference when USE_ROCM_CK_GEMM=OFF Authored with Claude Code. Co-Authored-By: Claude Opus 4.6 (1M context) Pull Request resolved: pytorch#180485 Approved by: https://github.com/drisspg, https://github.com/malfet
…_FLAGS (pytorch#183856) ## Issue Fixes ROCm/TheRock#5157. Fixes pytorch#183853. Windows ROCm HIP code was effectively compiled at `-O0` after pytorch#180485 + pytorch#183365 landed, causing a ~99% conv2d FP16 perf regression on gfx1150 (bisected and validated by @astrelsky and @adityas-amd at ROCm/TheRock#5157). ## Diagnosis After pytorch#183365 stripped the MSVC-style `/O2 /Ob2 /DNDEBUG` out of `CMAKE_HIP_FLAGS_RELEASE` and re-appended GNU `-O3 -DNDEBUG`, the actual build command still came up unoptimized. Inspecting the generated `build.ninja` shows why: - `CMAKE_HIP_FLAGS` contents (e.g. `--offload-compress -std=c++20 --offload-arch=...`) **do** reach the `$FLAGS` ninja variable used by every HIP compile. - `CMAKE_HIP_FLAGS_<CONFIG>` contents (e.g. `-O3 -DNDEBUG`) **do not**. That's the actual cause of the `-O0` fallback — `CMAKE_HIP_FLAGS_RELEASE` is dead code on the Windows HIP compile path. ## Fix - Drop the dead `string(APPEND CMAKE_HIP_FLAGS_<CONFIG> ...)` lines. - Inject the appropriate `-O{3,2,0,s}` plus `-DNDEBUG`/`-g` directly into `CMAKE_HIP_FLAGS`, gated on `CMAKE_BUILD_TYPE`. This works for single-config generators (Ninja, Makefiles), which is what the Windows ROCm build uses. - Drop the `-O3` from the compile rule template so non-Release configs aren't tainted. Pull Request resolved: pytorch#183856 Approved by: https://github.com/jeffdaily, https://github.com/astrelsky Co-authored-by: Jeff Daily <[email protected]>
On ROCm builds with USE_ROCM_CK_GEMM=OFF, GroupedBlas.cpp still included ck_group_gemm.h and emitted a source-level reference to at::hip::detail::group_gemm_ck(...) inside an always-false `if (use_fast_path)` branch. The Linux/legacy-CMake build path tolerated this (dead-code-elimination hid the unresolved symbol), but the Windows build under enable_language(HIP) in pytorch#180485 surfaces it as a linker failure. Gate the include and the call site uniformly on USE_ROCM_CK_GEMM and replace the bool indirection with explicit `#if defined(USE_ROCM_CK_GEMM)` / `#else`, so the fallback path is the only thing the compiler sees when CK is disabled. Split out from pytorch#180485 per @malfet review. Authored with Claude Code. Pull Request resolved: pytorch#182615 Approved by: https://github.com/malfet
…ytorch#180485) Replace FindHIP.cmake's hip_add_library/hip_add_executable with CMake's native enable_language(HIP) and standard add_library/add_executable. This enables proper HIP device compilation on Windows where FindHIP's bash-based linker helper doesn't work. Key changes: - LoadHIP.cmake: enable_language(HIP) with Windows workarounds for MSVC/GNU frontend mixing (forced compiler detection, GNU-style compile/link rules, MSVC runtime library mapping) - Dependencies.cmake: migrate HIP_HIPCC_FLAGS to CMAKE_HIP_FLAGS, replace hip_include_directories with target_include_directories, use hip::host instead of hip::amdhip64 - All CMakeLists: replace hip_add_library with add_library, replace HIP_SOURCE_PROPERTY_FORMAT with LANGUAGE HIP, set LINKER_LANGUAGE CXX on shared HIP libraries for proper Windows linking - Fix -mllvm flag deduplication by using -mllvm=<arg> form - Add HAVE_AVX{2,512}_CPU_DEFINITION to CMAKE_HIP_FLAGS for DispatchStub ABI compatibility between torch_cpu and torch_hip - Fix unconditional ck_group_gemm reference when USE_ROCM_CK_GEMM=OFF Authored with Claude Code. Co-Authored-By: Claude Opus 4.6 (1M context) Pull Request resolved: pytorch#180485 Approved by: https://github.com/drisspg, https://github.com/malfet
…_FLAGS (pytorch#183856) ## Issue Fixes ROCm/TheRock#5157. Fixes pytorch#183853. Windows ROCm HIP code was effectively compiled at `-O0` after pytorch#180485 + pytorch#183365 landed, causing a ~99% conv2d FP16 perf regression on gfx1150 (bisected and validated by @astrelsky and @adityas-amd at ROCm/TheRock#5157). ## Diagnosis After pytorch#183365 stripped the MSVC-style `/O2 /Ob2 /DNDEBUG` out of `CMAKE_HIP_FLAGS_RELEASE` and re-appended GNU `-O3 -DNDEBUG`, the actual build command still came up unoptimized. Inspecting the generated `build.ninja` shows why: - `CMAKE_HIP_FLAGS` contents (e.g. `--offload-compress -std=c++20 --offload-arch=...`) **do** reach the `$FLAGS` ninja variable used by every HIP compile. - `CMAKE_HIP_FLAGS_<CONFIG>` contents (e.g. `-O3 -DNDEBUG`) **do not**. That's the actual cause of the `-O0` fallback — `CMAKE_HIP_FLAGS_RELEASE` is dead code on the Windows HIP compile path. ## Fix - Drop the dead `string(APPEND CMAKE_HIP_FLAGS_<CONFIG> ...)` lines. - Inject the appropriate `-O{3,2,0,s}` plus `-DNDEBUG`/`-g` directly into `CMAKE_HIP_FLAGS`, gated on `CMAKE_BUILD_TYPE`. This works for single-config generators (Ninja, Makefiles), which is what the Windows ROCm build uses. - Drop the `-O3` from the compile rule template so non-Release configs aren't tainted. Pull Request resolved: pytorch#183856 Approved by: https://github.com/jeffdaily, https://github.com/astrelsky Co-authored-by: Jeff Daily <[email protected]>
Replace FindHIP.cmake's hip_add_library/hip_add_executable with CMake's native enable_language(HIP) and standard add_library/add_executable. This enables proper HIP device compilation on Windows where FindHIP's bash-based linker helper doesn't work.
Key changes:
Authored with Claude Code.
Co-Authored-By: Claude Opus 4.6 (1M context)
cc @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang