Port libtorchaudio GPU extensions to build under ROCm/HIP#16
Conversation
The torch CUDAExtension HIPIFY path only rewrites source files, not headers, so CUDA symbols used in headers survived un-hipified and broke the ROCm build (e.g. "cuda_runtime_api.h file not found", and the rnnt/forced_align GPU kernels were entirely gated behind #ifdef USE_CUDA). - Add cuda_compat.h mapping the CUDA runtime names used in headers (cudaStream_t, cudaError_t, cudaSuccess, cudaGetErrorString, cudaGetLastError) to their HIP equivalents under USE_ROCM. HIP natively supports the <<<>>> launch syntax and warp shuffle intrinsics already guarded in the kernels. - Extend the #ifdef USE_CUDA guards in the rnnt GPU headers, macros.h, options.h, and cuctc headers to also cover USE_ROCM, including HIP fp16/runtime headers.
Temporarily points torchaudio at the ROCm/audio#16 HIP-port commit (ethanwee1/audio fork) so TheRock can build/validate it. Repoint to the merged ROCm/audio release/2.11.0.1 commit once ROCm/audio#16 lands.
|
TheRock test build (Windows gfx110X-all) exercising this HIP port via ROCm/pytorch#3382: |
- cuda_compat.h: alias the CUDA runtime functions/enums used by the sources (cudaSetDevice, cudaMemcpy*, cudaMemset*, cudaStreamSynchronize, cudaGetErrorName, cudaMemcpy kinds) to HIP under USE_ROCM. - Route cub through hipcub (namespace cub = hipcub) under USE_ROCM in forced_align and cuctc kernels. - Enable Options::stream_ for USE_ROCM. - ctc_prefix_decoder.cpp includes cuda_compat.h instead of cuda_runtime.h.
|
Build with hipcub + runtime shim + Options::stream_ (via ROCm/pytorch#3382): Fixes this round: cuda_compat.h now aliases the CUDA runtime funcs used by the sources (cudaSetDevice/cudaMemcpy*/cudaMemset*/cudaStreamSynchronize/cudaGetErrorName), cub routed through hipcub, and Options::stream_ enabled for USE_ROCM. |
https://amd-hub.atlassian.net/browse/ROCM-24803?focusedCommentId=500051 Interim unblock: pins torchaudio to the stable release/2.11 (2.11.0), which already builds and publishes on Windows, replacing the floating pytorch/audio main (2.11.0a0) pin. The torchaudio 2.11.0.1 ROCm GPU port is tracked separately in #3382 and ROCm/audio#16.
|
Superseded by the HIPIFY-based approach (mirrors torchvision's setup.py) instead of a hand-written CUDA->HIP compat shim. |
…io#16) Revert the temporary HIPIFY-based pin (ROCm/audio#17) back to the compat-shim port commit that passed TheRock Windows validation (28529085509). The HIPIFY setup.py approach still leaves CUDA headers unconverted; the cuda_compat.h port in ROCm/audio#16 is the validated path. The Windows cross-drive HIPIFY fix remains in torch/utils/cpp_extension.py (this PR); it is unrelated to the audio-side port strategy.
|
Reopened — this is the validated port path. ROCm/pytorch#3382 pin repointed back here ( Validated TheRock Windows build: https://github.com/ROCm/TheRock/actions/runs/28529085509 |
https://amd-hub.atlassian.net/browse/ROCM-24803?focusedCommentId=500051