Repository navigation
[ROCm] Use native HIP support from CMake - #172775
GZGavinZhao wants to merge 3 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/172775
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Unrelated FailureAs of commit cbbb86f with merge base ef0353f ( 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. |
|
The label |
8058b31 to
0fc6d2d
Compare
|
@pytorchbot label "topic: not user facing" |
|
Back in the day I intended to create a PR for the HIP language support in PyTorch, however it turned out that there is no support for HIP Language in CMake on Windows. Has that been fixed recently? |
@ScottTodd can you comment here? |
8a29231 to
285f0d9
Compare
…#172799) The HasSameArgTypes test references `at::native::modern::detail::has_same_arg_types`, which was defined in `aten/src/ATen/native/cuda/ROCmLoops.cuh`. This file was deleted in c11bd72 (#120101) when ROCm switched to using the hipified version of `CUDALoops.cuh` instead. My understanding is that this test should be removed since it's a legacy compile-time check for a code path that no longer exists. Causes failure in #172775 in [this run](https://github.com/pytorch/pytorch/actions/runs/21153824053/job/60835278003?pr=172775). Pull Request resolved: #172799 Approved by: https://github.com/m-gallus, https://github.com/jeffdaily
|
@GZGavinZhao we have another PR that needs to set Aside: would be nice if we had a ROCm Windows build as part of CI. |
|
I'll investigate it once again today and see if I can figure out a way to make If this doesn't work, I'll restore the |
285f0d9 to
69f224b
Compare
|
Some good progress! The current version went pass Details |
I suspect this is ROCm/TheRock#3042. ROCm nightly releases starting after Edit: I just put that information at the top of that issue. |
|
Thanks! I'll test again tonight with newer releases, hopefully this time everything will just work. |
|
Not ready yet, trying to figure out why it's not building after rebase. |
You might encounter ROCm/TheRock#3283 (another build break for Windows ROCm we detected last night) |
e2411e2 to
345068d
Compare
|
Found a solution to ROCm/TheRock#3283. After rebasing changes in this PR on top of that, this PR now builds on Windows as well. |
d075acb to
c8c4e4f
Compare
| message("HIP_VERSION_MINOR: ${HIP_VERSION_MINOR}") | ||
| message("TORCH_HIP_VERSION: ${TORCH_HIP_VERSION}") | ||
|
|
||
| # Backup variables before searching to workaround FindHIP.cmake overriding HIP variables. |
There was a problem hiding this comment.
@GZGavinZhao do we absolutely need find_package(HIP), or can we rely solely on enable_language(HIP) instead?
There was a problem hiding this comment.
We don't need find_package(HIP) and just having enable_language(HIP) is enough. The comment here though is talking about a dependency (rocRAND) using find_package(HIP) which is out of our control.
There was a problem hiding this comment.
Understood. I agree then with your approach. You'll need to make backward-compatible changes that can work with dependencies that do the wrong thing today, but will be fixed similarly in the future. CC @ScottTodd
|
|
||
| if(NOT BUILD_LIBTORCHLESS) | ||
| torch_cuda_based_add_library(c10_cuda ${C10_CUDA_SRCS} ${C10_CUDA_HEADERS}) | ||
| add_library(c10_cuda ${C10_CUDA_SRCS} ${C10_CUDA_HEADERS}) |
There was a problem hiding this comment.
Be careful making changes to code paths that are shared with CUDA.
There was a problem hiding this comment.
I've checked to make sure no code uses torch_cuda_based_add_library. Can you run the CI again?
There was a problem hiding this comment.
Also, the rationale for removing torch_cuda_based_add_library is that it should be superceded by add_library since we don't use hip_add_library anymore:
macro(torch_cuda_based_add_library cuda_target)
if(USE_ROCM)
hip_add_library(${cuda_target} ${ARGN})
elseif(USE_CUDA)
add_library(${cuda_target} ${ARGN})
else()
endif()
endmacro()So replacing torch_cuda_based_add_library with add_library is guaranteed to have no effect on CUDA code paths.
|
Gentle ping requesting a new CI run <3 |
bfd1479 to
7d7c31c
Compare
|
New CI run please, some |
7d7c31c to
cbbb86f
Compare
) enable_language(HIP) doesn't work on Windows yet Context: * ROCm/TheRock#3172 * pytorch#172679 * pytorch#172775 Pull Request resolved: pytorch#174233 Approved by: https://github.com/jeffdaily, https://github.com/ScottTodd Co-authored-by: Jeff Daily <[email protected]>
) enable_language(HIP) doesn't work on Windows yet Context: * ROCm/TheRock#3172 * pytorch#172679 * pytorch#172775 Pull Request resolved: pytorch#174233 Approved by: https://github.com/jeffdaily, https://github.com/ScottTodd Co-authored-by: Jeff Daily <[email protected]>
|
Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as |
Rationale for using native HIP CMake support:
It allows easy separation of the C++ compiler and HIP compiler. This is often desirable for distributions because we want to provide both CPU optimized and GPU optimized PyTorch in one package, and oftentimes this means we don't want to use the specific LLVM verison/configuration that ROCm's LLVM uses. Even without this use case, in general I don't think it's good to tie the C++ compiler to the HIP compiler whenever one needs to compile with ROCm support.
Note that technically it's possible to disentangle C++ and HIP compilers, but it is undocumented and requires some CMake modifications. When using CMake's native HIP support, it's as easy as setting
CMAKE_HIP_COMPILER.It's the officially recommended way to use HIP: https://rocm.docs.amd.com/en/latest/conceptual/cmake-packages.html#using-hip-in-cmake
It's the same method that CUDA uses, so this makes the use of two languages consistent.
I haven't been able to test it on Windows yet.Tested on Windows too (this is not part of the CI).cc @EikanWang @jgong5 @wenzhe-nrv @sanchitintel @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang