Skip to content

[release/2.13] Fix hipify skipping sources under Windows subst drives (ROCM-29365) - #3561

Merged
jithunnair-amd merged 1 commit into
release/2.13from
garayp/rocm-29365-hipify-realpath
Aug 13, 2026
Merged

jithunnair-amd merged 1 commit into
release/2.13from
garayp/rocm-29365-hipify-realpath

Conversation

@pablo-garay

@pablo-garay pablo-garay commented Aug 12, 2026 •

Copy link
Copy Markdown

Summary

On Windows ROCm CI, the release/2.13 torchaudio wheel build fails compiling GPU sources with fatal error: 'cuda_runtime_api.h' file not found (ROCM-29365 / ROCm/TheRock#7266). Root cause is in CUDAExtension's hipify step, not in torchaudio.

CUDAExtension scopes hipify to os.getcwd() and filters with includes=[build_dir/*]. The Windows CI runs the build under a subst drive (CHECKOUT_ROOT: B:/src), but torchaudio computes its source directory with Path(...).resolve(), which follows the subst alias back to the real drive (C:\...). So build_dir (B:\...) and the source paths (C:\...) use different drive spellings, the includes filter matches nothing, and hipify silently skips the GPU sources — leaving the raw #include <cuda_runtime_api.h> (via cuda_utils.h) for hipcc.

This is the same B: vs C: mount split as ROCM-28908; that fix removed the earlier hard crash, which let the build progress far enough to expose this.

Fix

Normalize both sides with os.path.realpath so the build directory and the source paths share one canonical form (collapsing symlinks/junctions and subst drive aliases). With that, includes=[build_dir/*] matches again and the header-recursion that rewrites cuda_runtime_api.h → hip/hip_runtime_api.h runs.

build_dir = os.path.realpath(os.getcwd())
...
extra_files=[os.path.realpath(s) for s in sources],
...
s_abs = os.path.realpath(source)

Evidence / validation

  • Failing run 31459420855: hipcc compiles the original compute.cu (not .hip); torchaudio's CUDAExtension hipify passes report replaced kernel launches: 0; hip_utils.h/compute.hip never appear in the log.
  • Local repro of the exact CUDAExtension hipify call on the real torchaudio GPU sources:
    • cwd == source tree → cuda_utils.h → hip_utils.h, compute.cu → compute.hip, replaced kernel launches: 1.
    • cwd != source tree (mimics B: vs C:) → 0 conversions, no .hip — matches the failing CI.
  • realpath collapses the subst alias so both paths agree, restoring the working (cwd == source) behavior. No effect on Linux, where the paths already agree.

Test plan

  • Windows ROCm release/2.13 wheel pipeline builds torchaudio successfully across supported Python versions.
  • Linux ROCm extension builds unaffected (regression check).
  • ROCM-28908 relpath fix remains intact.

Refs: ROCM-29365, ROCm/TheRock#7266, ROCM-28908.

Successful Passing Test

Validated end-to-end with a full Windows ROCm multi-arch PyTorch wheel build on this branch (same TheRock workflow that fails on release/2.13, only pytorch_git_ref repointed to this branch).

Build job succeeded: Build Multi-Arch Windows PyTorch Wheels (dev, 3.12, garayp/rocm-29365-hipify-realpath) — torch, torchaudio, and torchvision all built on Windows ROCm with the fix.

This is definitive confirmation. The exact ROCM-29365 sources now hipify and compile (build log, lines 714709-714718):

cuda_utils.h                 -> hip_utils.h                  [ok]
rnnt/gpu/compute.cu          -> rnnt/gpu/compute.hip         [ok]
forced_align/gpu/compute.cu  -> forced_align/gpu/compute.hip [ok]
Total number of replaced kernel launches: 11
Total number of replaced kernel launches: 8

Before the fix (on release/2.13), these passes reported Total number of replaced kernel launches: 0 and the CUDA header was left unhipified, so hipcc failed with cuda_runtime_api.h not found. With the fix, hipcc compiles compute.hip and resolves hip_utils.h cleanly.

Note: the downstream GPU test jobs in that run failed at dependency install (No matching distribution found for rocm==10.1.0a20260810 from the dev-releases index) — an unrelated TheRock test-harness/package-index gap, not this change. The tests never ran any torchaudio code.

CUDAExtension scopes hipify to os.getcwd(), but torchaudio (and others) pass source paths that resolve through symlinks/junctions or Windows subst drive aliases. On Windows CI the build runs under a subst drive (B:) while sources resolve to the real drive (C:), so the includes=[build_dir/*] filter matches nothing and hipify silently skips the GPU sources, leaving raw CUDA headers (cuda_runtime_api.h) for hipcc.

Normalize build_dir and source paths with os.path.realpath so both sides share a canonical form.

Signed-off-by: pablo-garay <[email protected]>
@pablo-garay
pablo-garay force-pushed the garayp/rocm-29365-hipify-realpath branch from 36fbd2c to 31bd56e Compare August 13, 2026 03:09
@pablo-garay

Copy link
Copy Markdown
Author

Windows ROCm wheel build validation (ROCM-29365)

Kicked off a full Windows multi-arch PyTorch wheel build on this branch to validate the fix end-to-end.

Validation run: https://github.com/ROCm/TheRock/actions/runs/31665799901

This is the same TheRock workflow (multi_arch_build_windows_pytorch_wheels.yml) that fails on release/2.13, with identical inputs except pytorch_git_ref points at this branch:

  • amdgpu_families: gfx110X-all;gfx120X-all;gfx103X-all;gfx1151 (all 4 families, full repro)
  • python_version: 3.12, rocm_version: 10.1.0a20260810, release_type: dev
  • test_amdgpu_families: auto (runs the GPU wheel tests too)

This branch is rebased onto release/2.13 HEAD (4be323cf) — the exact commit the failing run built — so the only difference from the red build is this fix. It builds torch from this branch first, then builds torchaudio against that torch, so the patched cpp_extension.py hipify path is exercised for real. A green torchaudio build (hipify pass reporting kernel replacements > 0, with compute.hip / hip_utils.h produced) confirms the root cause.

Local validation already done

A subst-drive regression test drives the patched hipify path and asserts both directions:

  • old logic (os.getcwd() / os.path.abspath) -> sources SKIPPED (reproduces ROCM-29365)
  • fix (os.path.realpath) -> sources CONVERTED (cuda_utils.h -> hip_utils.h, compute.cu -> compute.hip)

Happy to promote that into the PyTorch test suite as a regression guard if useful.

@jithunnair-amd
jithunnair-amd merged commit 3a4c3a1 into release/2.13 Aug 13, 2026
3 checks passed
@jithunnair-amd
jithunnair-amd deleted the garayp/rocm-29365-hipify-realpath branch August 13, 2026 21:05
pablo-garay added a commit that referenced this pull request Aug 24, 2026
…3561)

## Summary

On Windows ROCm CI, the `release/2.13` torchaudio wheel build fails
compiling GPU sources with `fatal error: 'cuda_runtime_api.h' file not
found` (ROCM-29365 / ROCm/TheRock#7266). Root cause is in
`CUDAExtension`'s hipify step, not in torchaudio.

`CUDAExtension` scopes hipify to `os.getcwd()` and filters with
`includes=[build_dir/*]`. The Windows CI runs the build under a `subst`
drive (`CHECKOUT_ROOT: B:/src`), but torchaudio computes its source
directory with `Path(...).resolve()`, which follows the `subst` alias
back to the real drive (`C:\...`). So `build_dir` (`B:\...`) and the
source paths (`C:\...`) use different drive spellings, the `includes`
filter matches nothing, and hipify silently skips the GPU sources —
leaving the raw `#include <cuda_runtime_api.h>` (via `cuda_utils.h`) for
hipcc.

This is the same `B:` vs `C:` mount split as ROCM-28908; that fix
removed the earlier hard crash, which let the build progress far enough
to expose this.

## Fix

Normalize both sides with `os.path.realpath` so the build directory and
the source paths share one canonical form (collapsing symlinks/junctions
and `subst` drive aliases). With that, `includes=[build_dir/*]` matches
again and the header-recursion that rewrites `cuda_runtime_api.h` →
`hip/hip_runtime_api.h` runs.

```python
build_dir = os.path.realpath(os.getcwd())
...
extra_files=[os.path.realpath(s) for s in sources],
...
s_abs = os.path.realpath(source)
```

## Evidence / validation

- Failing run 31459420855: hipcc compiles the original `compute.cu` (not
`.hip`); torchaudio's `CUDAExtension` hipify passes report `replaced
kernel launches: 0`; `hip_utils.h`/`compute.hip` never appear in the
log.
- Local repro of the exact `CUDAExtension` hipify call on the real
torchaudio GPU sources:
- cwd == source tree → `cuda_utils.h → hip_utils.h`, `compute.cu →
compute.hip`, `replaced kernel launches: 1`.
- cwd != source tree (mimics `B:` vs `C:`) → 0 conversions, no `.hip` —
matches the failing CI.
- `realpath` collapses the `subst` alias so both paths agree, restoring
the working (cwd == source) behavior. No effect on Linux, where the
paths already agree.

## Test plan

- [x] Windows ROCm `release/2.13` wheel pipeline builds torchaudio
successfully across supported Python versions.
- [x] Linux ROCm extension builds unaffected (regression check).
- [x] ROCM-28908 relpath fix remains intact.

Refs: ROCM-29365, ROCm/TheRock#7266, ROCM-28908.

## Successful Passing Test

Validated end-to-end with a full Windows ROCm multi-arch PyTorch wheel
build on this branch (same TheRock workflow that fails on
`release/2.13`, only `pytorch_git_ref` repointed to this branch).

**Build job succeeded:** [Build Multi-Arch Windows PyTorch Wheels (dev,
3.12,
garayp/rocm-29365-hipify-realpath)](https://github.com/ROCm/TheRock/actions/runs/31667526330)
— torch, torchaudio, and torchvision all built on Windows ROCm with the
fix.

This is definitive confirmation. The exact ROCM-29365 sources now hipify
and compile (build log, lines 714709-714718):

```
cuda_utils.h                 -> hip_utils.h                  [ok]
rnnt/gpu/compute.cu          -> rnnt/gpu/compute.hip         [ok]
forced_align/gpu/compute.cu  -> forced_align/gpu/compute.hip [ok]
Total number of replaced kernel launches: 11
Total number of replaced kernel launches: 8
```

Before the fix (on `release/2.13`), these passes reported `Total number
of replaced kernel launches: 0` and the CUDA header was left unhipified,
so `hipcc` failed with `cuda_runtime_api.h` not found. With the fix,
`hipcc` compiles `compute.hip` and resolves `hip_utils.h` cleanly.

_Note: the downstream GPU test jobs in that run failed at dependency
install (`No matching distribution found for rocm==10.1.0a20260810` from
the dev-releases index) — an unrelated TheRock
test-harness/package-index gap, not this change. The tests never ran any
torchaudio code._

Signed-off-by: pablo-garay <[email protected]>
Co-authored-by: pablo-garay <[email protected]>
(cherry picked from commit 3a4c3a1)
jithunnair-amd pushed a commit that referenced this pull request Aug 25, 2026
…l) (#3594)

## Summary

Carry-forward of ROCm-specific commits from `release/2.13` onto
`release/2.14` ? the 2.14 analog of the 2.13 "IFU dedup" ([PR
#3503](#3503)).

Analyzes the full IFU delta from [PR
#3591](#3591) at `release/2.13`'s
tip (`6596a0d`): **81 commits** in `release/2.13` not in `release/2.14`,
each either dropped (already in 2.14, or 2.13-only) or cherry-picked
here.

## Method

Same rules as the [release/2.13 cherry-pick
process](https://amd.atlassian.net/wiki/spaces/MLSE/pages/1819593560):

- **Drop ? already in 2.14**: patch-id equivalence (`git cherry`),
upstream PR already present, or content already relocated/absorbed into
2.14 (verified during cherry-pick).
- **Drop ? 2.13-only**: version bump, `related_commits`,
dependency/requirements pins, release-line CD/build changes.
- **Carry-forward**: ROCm-specific fixes not present in 2.14 in any
form.

## Commits carried forward (13)

| Source | Notes |
|--------|-------|
| Fix reentrant deadlock in `torch.cuda._lazy_call` (#3496) | clean |
| Skip ROCm-failing tests in test_cuda/test_nn (#3504) | **conflict
resolved** ? kept 2.14's `test_graph_capture_error...` cleanup + took
`@skipIfRocm`; kept 2.14's `test_allocator_backend` (already fixes
LD_LIBRARY_PATH via `subprocess_env()`) |
| skip test_hip_device_count (rocprofiler-sdk) | clean |
| skip flaky test_Embedding_discontiguous_cuda | clean |
| Skip profiler check for foreach tests on ROCm (#3262) | clean |
| Skip test_is_pinned_no_context on python 3.14+ | clean |
| Skip flaky test_reentrant_parent_error_on_cpu | clean |
| Filter out CK gemms for gfx1250-only arch (#3545) | clean |
| Fix hipify skipping sources under Windows subst drives (ROCM-29365)
(#3561) | clean |
| Fixed gfx1250_preferred_backend test (#3546) | clean |
| [ROCm] Optimize AMD normalization backward kernel (pytorch#189405) | clean |
| [release/2.13] Build rocSHMEM for the requested gfx target (#3582) |
clean |
| fix PicklingError handling for Python 3.14 | clean |

## Removed from this PR (per team)

- [RELEASE_ONLY] skip test_autoheuristic in-code (pytorch#180927) ? not needed
on 2.14. Upstream
[pytorch#180927](pytorch#180927)
is `RELEASE_ONLY`, merged to upstream `release/2.12` only (never on
`main` or upstream `release/2.14`).

## Reviewed and excluded (team decision: not needed for 2.14)

| Commit | Reason |
|--------|--------|
| Update composable_kernel submodule with gfx1033 support (#3499) |
2.14's CK pin already includes gfx1033; carrying would move the
submodule pointer **backward**. |
| Revert "Skip cudagraphs for kernel-free inductor graphs" (pytorch#187347) |
2.14 already has the fixed upstream **re-land** on top of the revert;
carrying = regressing 2.14. |
| Revert "[Reland] Port index_add fast path" (pytorch#188196) | 2.14 already
has the newer **re-land (pytorch#189506)** on top of the revert; carrying =
regressing 2.14. |

## Dropped as already in 2.14 (verified during cherry-pick)

- rocm-smi deprecation (#3434) ? 2.14 already has zero `rocm_smi` refs.
- Enable linalg via hipSOLVER, remove Magma (#3455) ? all 6 upstream PRs
already in 2.14.
- Stabilize ROCm 7.14 testing (#3525) ? 2.14 already carries the guards
+ skip messages.
- Add gfx1250 support in GroupedBlas (#3532) ? already in 2.14 via
upstream pytorch#190703 (`ScaledBlasDeviceUtils`).
- Fix uninitialized embedding indices `test_embedding_meta_indices`
(pytorch#188002) ? upstream already in 2.14.
- Unskip ROCSHMEM triton UTs on rocm 7.14 (#3578) ? targets a 2.13-only
7.14 module skip that 2.14 never had; tests already run on 2.14.

Remaining commits drop as 2.13-only (version/pins/related_commits/CD) or
as already-in-2.14 by patch-id/upstream.

## Test plan

- [x] TheRock full-stack dev build (torch + torchaudio + torchvision +
triton) on gfx94X-dcgpu for Python 3.10-3.14, all **Build** jobs green
(ROCm `10.1.0a20260822`, on the `aws-linux-scale-rocm-prod` pool), after
bringing the branch up to its base so `related_commits` resolves
torchaudio/torchvision:
  - py3.10  https://github.com/ROCm/TheRock/actions/runs/32863299013
  - py3.11  https://github.com/ROCm/TheRock/actions/runs/32863305363
  - py3.12  https://github.com/ROCm/TheRock/actions/runs/32863311391
  - py3.13  https://github.com/ROCm/TheRock/actions/runs/32863318109
  - py3.14  https://github.com/ROCm/TheRock/actions/runs/32863325370
- [x] TheRock CI wheel build on gfx94X-dcgpu for Python 3.10-3.14 all
green (ROCm `10.1.0a20260822`, torch-only, on the
`aws-linux-scale-rocm-prod` pool, ~1h40m each):
  - py3.10  https://github.com/ROCm/TheRock/actions/runs/32818564344
  - py3.11  https://github.com/ROCm/TheRock/actions/runs/32818568751
  - py3.12  https://github.com/ROCm/TheRock/actions/runs/32818572249
  - py3.13  https://github.com/ROCm/TheRock/actions/runs/32818576288
  - py3.14  https://github.com/ROCm/TheRock/actions/runs/32818580229



## Processed Commits List
Spreasheet with each commit evaluated for cherry-pick & resolution
(drop/include) with reasoning:


[pr3594-commit-outcomes.xlsx](https://github.com/user-attachments/files/31390971/pr3594-commit-outcomes.xlsx)

---------

Signed-off-by: pablo-garay <[email protected]>
Co-authored-by: Iurii Paikov <[email protected]>
Co-authored-by: Chinmay Dattanand Kuchinad <[email protected]>
Co-authored-by: rocm-repo-management-api-6[bot] <212817015+rocm-repo-management-api-6[bot]@users.noreply.github.com>
Co-authored-by: Dmitry Nikolaev <[email protected]>
Co-authored-by: srinivamd <[email protected]>
Co-authored-by: Subramanian <[email protected]>
Co-authored-by: zjliu-amd <[email protected]>
Co-authored-by: Andres Lugo <[email protected]>
Co-authored-by: pablo-garay <[email protected]>
Co-authored-by: Bo Li <[email protected]>
Co-authored-by: Anatoliy Litvinenko <[email protected]>
Co-authored-by: Jeff Daily <[email protected]>
Co-authored-by: Luca Bruni <[email protected]>
Co-authored-by: albmalamd <[email protected]>
jithunnair-amd pushed a commit that referenced this pull request Aug 25, 2026
…3561)

## Summary

On Windows ROCm CI, the `release/2.13` torchaudio wheel build fails
compiling GPU sources with `fatal error: 'cuda_runtime_api.h' file not
found` (ROCM-29365 / ROCm/TheRock#7266). Root cause is in
`CUDAExtension`'s hipify step, not in torchaudio.

`CUDAExtension` scopes hipify to `os.getcwd()` and filters with
`includes=[build_dir/*]`. The Windows CI runs the build under a `subst`
drive (`CHECKOUT_ROOT: B:/src`), but torchaudio computes its source
directory with `Path(...).resolve()`, which follows the `subst` alias
back to the real drive (`C:\...`). So `build_dir` (`B:\...`) and the
source paths (`C:\...`) use different drive spellings, the `includes`
filter matches nothing, and hipify silently skips the GPU sources —
leaving the raw `#include <cuda_runtime_api.h>` (via `cuda_utils.h`) for
hipcc.

This is the same `B:` vs `C:` mount split as ROCM-28908; that fix
removed the earlier hard crash, which let the build progress far enough
to expose this.

## Fix

Normalize both sides with `os.path.realpath` so the build directory and
the source paths share one canonical form (collapsing symlinks/junctions
and `subst` drive aliases). With that, `includes=[build_dir/*]` matches
again and the header-recursion that rewrites `cuda_runtime_api.h` →
`hip/hip_runtime_api.h` runs.

```python
build_dir = os.path.realpath(os.getcwd())
...
extra_files=[os.path.realpath(s) for s in sources],
...
s_abs = os.path.realpath(source)
```

## Evidence / validation

- Failing run 31459420855: hipcc compiles the original `compute.cu` (not
`.hip`); torchaudio's `CUDAExtension` hipify passes report `replaced
kernel launches: 0`; `hip_utils.h`/`compute.hip` never appear in the
log.
- Local repro of the exact `CUDAExtension` hipify call on the real
torchaudio GPU sources:
- cwd == source tree → `cuda_utils.h → hip_utils.h`, `compute.cu →
compute.hip`, `replaced kernel launches: 1`.
- cwd != source tree (mimics `B:` vs `C:`) → 0 conversions, no `.hip` —
matches the failing CI.
- `realpath` collapses the `subst` alias so both paths agree, restoring
the working (cwd == source) behavior. No effect on Linux, where the
paths already agree.

## Test plan

- [x] Windows ROCm `release/2.13` wheel pipeline builds torchaudio
successfully across supported Python versions.
- [x] Linux ROCm extension builds unaffected (regression check).
- [x] ROCM-28908 relpath fix remains intact.

Refs: ROCM-29365, ROCm/TheRock#7266, ROCM-28908.

## Successful Passing Test

Validated end-to-end with a full Windows ROCm multi-arch PyTorch wheel
build on this branch (same TheRock workflow that fails on
`release/2.13`, only `pytorch_git_ref` repointed to this branch).

**Build job succeeded:** [Build Multi-Arch Windows PyTorch Wheels (dev,
3.12,
garayp/rocm-29365-hipify-realpath)](https://github.com/ROCm/TheRock/actions/runs/31667526330)
— torch, torchaudio, and torchvision all built on Windows ROCm with the
fix.

This is definitive confirmation. The exact ROCM-29365 sources now hipify
and compile (build log, lines 714709-714718):

```
cuda_utils.h                 -> hip_utils.h                  [ok]
rnnt/gpu/compute.cu          -> rnnt/gpu/compute.hip         [ok]
forced_align/gpu/compute.cu  -> forced_align/gpu/compute.hip [ok]
Total number of replaced kernel launches: 11
Total number of replaced kernel launches: 8
```

Before the fix (on `release/2.13`), these passes reported `Total number
of replaced kernel launches: 0` and the CUDA header was left unhipified,
so `hipcc` failed with `cuda_runtime_api.h` not found. With the fix,
`hipcc` compiles `compute.hip` and resolves `hip_utils.h` cleanly.

_Note: the downstream GPU test jobs in that run failed at dependency
install (`No matching distribution found for rocm==10.1.0a20260810` from
the dev-releases index) — an unrelated TheRock
test-harness/package-index gap, not this change. The tests never ran any
torchaudio code._

Signed-off-by: pablo-garay <[email protected]>
Co-authored-by: pablo-garay <[email protected]>
(cherry picked from commit 3a4c3a1)
@jithunnair-amd jithunnair-amd changed the title Fix hipify skipping sources under Windows subst drives (ROCM-29365) [release/2.13] Fix hipify skipping sources under Windows subst drives (ROCM-29365) Aug 25, 2026
jithunnair-amd pushed a commit that referenced this pull request Aug 27, 2026
…3561)

## Summary

On Windows ROCm CI, the `release/2.13` torchaudio wheel build fails
compiling GPU sources with `fatal error: 'cuda_runtime_api.h' file not
found` (ROCM-29365 / ROCm/TheRock#7266). Root cause is in
`CUDAExtension`'s hipify step, not in torchaudio.

`CUDAExtension` scopes hipify to `os.getcwd()` and filters with
`includes=[build_dir/*]`. The Windows CI runs the build under a `subst`
drive (`CHECKOUT_ROOT: B:/src`), but torchaudio computes its source
directory with `Path(...).resolve()`, which follows the `subst` alias
back to the real drive (`C:\...`). So `build_dir` (`B:\...`) and the
source paths (`C:\...`) use different drive spellings, the `includes`
filter matches nothing, and hipify silently skips the GPU sources —
leaving the raw `#include <cuda_runtime_api.h>` (via `cuda_utils.h`) for
hipcc.

This is the same `B:` vs `C:` mount split as ROCM-28908; that fix
removed the earlier hard crash, which let the build progress far enough
to expose this.

## Fix

Normalize both sides with `os.path.realpath` so the build directory and
the source paths share one canonical form (collapsing symlinks/junctions
and `subst` drive aliases). With that, `includes=[build_dir/*]` matches
again and the header-recursion that rewrites `cuda_runtime_api.h` →
`hip/hip_runtime_api.h` runs.

```python
build_dir = os.path.realpath(os.getcwd())
...
extra_files=[os.path.realpath(s) for s in sources],
...
s_abs = os.path.realpath(source)
```

## Evidence / validation

- Failing run 31459420855: hipcc compiles the original `compute.cu` (not
`.hip`); torchaudio's `CUDAExtension` hipify passes report `replaced
kernel launches: 0`; `hip_utils.h`/`compute.hip` never appear in the
log.
- Local repro of the exact `CUDAExtension` hipify call on the real
torchaudio GPU sources:
- cwd == source tree → `cuda_utils.h → hip_utils.h`, `compute.cu →
compute.hip`, `replaced kernel launches: 1`.
- cwd != source tree (mimics `B:` vs `C:`) → 0 conversions, no `.hip` —
matches the failing CI.
- `realpath` collapses the `subst` alias so both paths agree, restoring
the working (cwd == source) behavior. No effect on Linux, where the
paths already agree.

## Test plan

- [x] Windows ROCm `release/2.13` wheel pipeline builds torchaudio
successfully across supported Python versions.
- [x] Linux ROCm extension builds unaffected (regression check).
- [x] ROCM-28908 relpath fix remains intact.

Refs: ROCM-29365, ROCm/TheRock#7266, ROCM-28908.

## Successful Passing Test

Validated end-to-end with a full Windows ROCm multi-arch PyTorch wheel
build on this branch (same TheRock workflow that fails on
`release/2.13`, only `pytorch_git_ref` repointed to this branch).

**Build job succeeded:** [Build Multi-Arch Windows PyTorch Wheels (dev,
3.12,
garayp/rocm-29365-hipify-realpath)](https://github.com/ROCm/TheRock/actions/runs/31667526330)
— torch, torchaudio, and torchvision all built on Windows ROCm with the
fix.

This is definitive confirmation. The exact ROCM-29365 sources now hipify
and compile (build log, lines 714709-714718):

```
cuda_utils.h                 -> hip_utils.h                  [ok]
rnnt/gpu/compute.cu          -> rnnt/gpu/compute.hip         [ok]
forced_align/gpu/compute.cu  -> forced_align/gpu/compute.hip [ok]
Total number of replaced kernel launches: 11
Total number of replaced kernel launches: 8
```

Before the fix (on `release/2.13`), these passes reported `Total number
of replaced kernel launches: 0` and the CUDA header was left unhipified,
so `hipcc` failed with `cuda_runtime_api.h` not found. With the fix,
`hipcc` compiles `compute.hip` and resolves `hip_utils.h` cleanly.

_Note: the downstream GPU test jobs in that run failed at dependency
install (`No matching distribution found for rocm==10.1.0a20260810` from
the dev-releases index) — an unrelated TheRock
test-harness/package-index gap, not this change. The tests never ran any
torchaudio code._

Signed-off-by: pablo-garay <[email protected]>
Co-authored-by: pablo-garay <[email protected]>
(cherry picked from commit 3a4c3a1)
crystalwhale1024-meta pushed a commit to crystalwhale1024-meta/pytorch that referenced this pull request Oct 7, 2026
…s in CUDAExtension (pytorch#194641)

## Summary

`CUDAExtension` scopes hipify to `os.getcwd()` and filters sources with `includes=[build_dir/*]`, comparing against `os.path.abspath(...)` source paths. When a build passes source paths that resolve through symlinks/junctions or Windows `subst` drive aliases, the two sides end up with different spellings of the same location, the `includes` filter matches nothing, and hipify **silently skips** the GPU sources leaving raw CUDA headers (e.g. `cuda_runtime_api.h`) for `hipcc`, which then fails with `fatal error: 'cuda_runtime_api.h' file not found`.

This reproduces on Windows ROCm CI, where the build runs under a `subst` drive (e.g. `B:`) while a dependency such as torchaudio computes its source directory with `Path(...).resolve()` and lands on the real drive (e.g. `C:`). `build_dir` (`B:\...`) and the source paths (`C:\...`) then disagree.

## Fix

The root cause is in `torch/utils/hipify/hipify_python.py`: `hipify()` appended `extra_files` to `all_files` verbatim, while `preprocessor()` tests `_to_unix_path(filepath)` against `all_files`. On Windows the appended backslash spelling never equals the forward-slash form being tested, so the `extra_files` escape hatch was effectively dead and hipification depended entirely on the `includes=[build_dir/*]` directory walk - which the subst-drive mismatch defeats. `extra_files` entries are now normalized with `_to_unix_path` on append (and added to `all_files_set`), fixing the silent skip at the source in a platform-independent, unit-testable way.

In `CUDAExtension` (and the matching `load()` / `_jit_compile` path), each source is canonicalized only when its plain `os.path.abspath` isn't already under `build_dir`. This fixes the subst-drive case without `realpath`-ing sources that are legitimately symlinked *into* the build dir - doing so would relocate the generated `.hip` outside `build_dir` and break the "paths relative to the setup.py directory" invariant. The build directory itself is still `realpath`'d (a no-op on POSIX).

Finally, when a `.cu`/`.cuh` source comes back unhipified, we now log a warning so this failure mode is self-diagnosing instead of surfacing later as a missing `cuda_runtime_api.h`.

The only Linux-visible behavior change is the guarded source canonicalization; the build-dir `realpath` and the `extra_files` normalization are no-ops on POSIX.

## Test plan

- New unit test `test/test_utils.py::TestHipify::test_hipify_keeps_symlinked_source_under_build_dir` (runs on Linux, no ROCm hardware): a `.cu` symlinked into the build dir is hipified in place, with the generated `.hip` staying under the build dir and not following the symlink into the real source tree.
- Windows ROCm extension build (e.g. torchaudio) hipifies and compiles GPU sources: the hipify pass reports kernel replacements > 0 and produces `.hip` sources instead of leaving `.cu`.

## CI results

Run on the current head with `ciflow/trunk` + full MI300 coverage (`ciflow/rocm-mi300`, `ciflow/periodic-rocm-mi300`, `ciflow/inductor-rocm-mi300`) — see [HUD](https://hud.pytorch.org/pr/194641). 338 checks passed (all of trunk, lint, CUDA, ASAN, Windows, macOS, aarch64, dynamo, and the ROCm MI350 matrix); the new hipify unit test passed.

The only 4 failures are all on the `linux-noble-rocm-py3.12-mi300` matrix and are pre-existing ROCm flakes unrelated to this change (which only touches the extension build/hipify path, not these tests):

- `test (default, 1, 8)` and `test (distributed, 3, 5)` — TF32 numeric-tolerance mismatch in `test_nn.py` Transformer tests (`Tensor-likes are not close`, ~0.23 abs diff vs 0.08 allowed).
- `test (inductor, 1, 2)` and `test (inductor, 2, 2)` — the whole `Test` step hit the 270-minute wall-clock limit mid `test_torchinductor`/`test_aot_inductor` suite (no assertion failure).

Cherry-pick of ROCm#3561 (ROCM-29365), validated end-to-end there with a full Windows ROCm multi-arch wheel build (torch + torchaudio + torchvision).

Pull Request resolved: pytorch#194641
Approved by: https://github.com/jithunnair-amd, https://github.com/jeffdaily

Co-authored-by: Jeff Daily <[email protected]>
cyyever pushed a commit to BakeLab/pytorch that referenced this pull request Oct 11, 2026
…s in CUDAExtension (pytorch#194641)

## Summary

`CUDAExtension` scopes hipify to `os.getcwd()` and filters sources with `includes=[build_dir/*]`, comparing against `os.path.abspath(...)` source paths. When a build passes source paths that resolve through symlinks/junctions or Windows `subst` drive aliases, the two sides end up with different spellings of the same location, the `includes` filter matches nothing, and hipify **silently skips** the GPU sources leaving raw CUDA headers (e.g. `cuda_runtime_api.h`) for `hipcc`, which then fails with `fatal error: 'cuda_runtime_api.h' file not found`.

This reproduces on Windows ROCm CI, where the build runs under a `subst` drive (e.g. `B:`) while a dependency such as torchaudio computes its source directory with `Path(...).resolve()` and lands on the real drive (e.g. `C:`). `build_dir` (`B:\...`) and the source paths (`C:\...`) then disagree.

## Fix

The root cause is in `torch/utils/hipify/hipify_python.py`: `hipify()` appended `extra_files` to `all_files` verbatim, while `preprocessor()` tests `_to_unix_path(filepath)` against `all_files`. On Windows the appended backslash spelling never equals the forward-slash form being tested, so the `extra_files` escape hatch was effectively dead and hipification depended entirely on the `includes=[build_dir/*]` directory walk - which the subst-drive mismatch defeats. `extra_files` entries are now normalized with `_to_unix_path` on append (and added to `all_files_set`), fixing the silent skip at the source in a platform-independent, unit-testable way.

In `CUDAExtension` (and the matching `load()` / `_jit_compile` path), each source is canonicalized only when its plain `os.path.abspath` isn't already under `build_dir`. This fixes the subst-drive case without `realpath`-ing sources that are legitimately symlinked *into* the build dir - doing so would relocate the generated `.hip` outside `build_dir` and break the "paths relative to the setup.py directory" invariant. The build directory itself is still `realpath`'d (a no-op on POSIX).

Finally, when a `.cu`/`.cuh` source comes back unhipified, we now log a warning so this failure mode is self-diagnosing instead of surfacing later as a missing `cuda_runtime_api.h`.

The only Linux-visible behavior change is the guarded source canonicalization; the build-dir `realpath` and the `extra_files` normalization are no-ops on POSIX.

## Test plan

- New unit test `test/test_utils.py::TestHipify::test_hipify_keeps_symlinked_source_under_build_dir` (runs on Linux, no ROCm hardware): a `.cu` symlinked into the build dir is hipified in place, with the generated `.hip` staying under the build dir and not following the symlink into the real source tree.
- Windows ROCm extension build (e.g. torchaudio) hipifies and compiles GPU sources: the hipify pass reports kernel replacements > 0 and produces `.hip` sources instead of leaving `.cu`.

## CI results

Run on the current head with `ciflow/trunk` + full MI300 coverage (`ciflow/rocm-mi300`, `ciflow/periodic-rocm-mi300`, `ciflow/inductor-rocm-mi300`) — see [HUD](https://hud.pytorch.org/pr/194641). 338 checks passed (all of trunk, lint, CUDA, ASAN, Windows, macOS, aarch64, dynamo, and the ROCm MI350 matrix); the new hipify unit test passed.

The only 4 failures are all on the `linux-noble-rocm-py3.12-mi300` matrix and are pre-existing ROCm flakes unrelated to this change (which only touches the extension build/hipify path, not these tests):

- `test (default, 1, 8)` and `test (distributed, 3, 5)` — TF32 numeric-tolerance mismatch in `test_nn.py` Transformer tests (`Tensor-likes are not close`, ~0.23 abs diff vs 0.08 allowed).
- `test (inductor, 1, 2)` and `test (inductor, 2, 2)` — the whole `Test` step hit the 270-minute wall-clock limit mid `test_torchinductor`/`test_aot_inductor` suite (no assertion failure).

Cherry-pick of ROCm#3561 (ROCM-29365), validated end-to-end there with a full Windows ROCm multi-arch wheel build (torch + torchaudio + torchvision).

Pull Request resolved: pytorch#194641
Approved by: https://github.com/jithunnair-amd, https://github.com/jeffdaily

Co-authored-by: Jeff Daily <[email protected]>
pablo-garay added a commit that referenced this pull request Oct 16, 2026
…#3561)

Resolve the build directory and source paths with os.path.realpath in CUDAExtension so hipify matches sources when Windows CI builds under a subst drive (B: aliasing C:). Without this, torchaudio GPU sources are left unhipified and fail on cuda_runtime_api.h. Same fix as release/2.13 (#3561) and release/2.14 (f11950f); nightly has it via pytorch#194641.

(cherry picked from commit f11950f)
Signed-off-by: pablo-garay <[email protected]>
jithunnair-amd pushed a commit that referenced this pull request Oct 16, 2026
…#3561) (#3832)

## Summary

Cherry-pick the hipify `subst`-drive fix into `release/2.15`. It's the
same change as `release/2.13` (#3561) and `release/2.14` (f11950f);
upstream nightly has it via pytorch#194641.

Windows CI builds under a `subst` drive (`B:` aliasing `C:\scratch-b`),
so `CUDAExtension` compares `B:\...` with `C:\...` and hipify silently
skips torchaudio's GPU sources. Resolving both sides with
`os.path.realpath` fixes the match. No effect on Linux.

## Test plan

- Failing without this: Windows py3.12 build of `release/2.15` ([run
38716492477](https://github.com/ROCm/TheRock/actions/runs/38716492477))
fails in torchaudio `rnnt/gpu/compute.cu` and
`forced_align/gpu/compute.cu` with `'cuda_runtime_api.h' file not
found`.
- The diff is identical to the 2.14 fix, which builds torchaudio on
Windows.
- Re-running the Windows build on `pablo-garay/release-2.15-integration`
with this commit for ROCm/TheRock#9031.

Signed-off-by: pablo-garay <[email protected]>
ethanwee1 pushed a commit to ROCm/TheRock that referenced this pull request Oct 16, 2026
JIRA ID: AIPYTORCH-1326

## Motivation

PyTorch `release/2.15` exists in ROCm/pytorch but is absent from
TheRock's release matrices and source manifests, so nightly, prerelease
and dev release builds never pick it up. This follows the 2.14
enablement in #7525.

## Technical Details

- Add `release/2.15` to the Linux and Windows release matrices
(`RELEASE_STABLE_PYTORCH_REFS`), the unsupported AMDGPU family filters
(`gfx90c`, same as 2.13/2.14), `PYTORCH_PRIMARY_TEST_PYTHON_VERSIONS`
(`3.11`), the source manifest defaults, and the support table in
`external-builds/pytorch/README.md`. The README row points torchaudio at
ROCm/audio, since 2.15's `related_commits` pins ROCm/audio
`release/2.11.1`.
- CI defaults (`CI_PYTORCH_REFS`) are unchanged.
- Python 3.15 for 2.15 is left to #8394.

Merge order: these ROCm/pytorch `release/2.15` PRs should land first, so
scheduled builds of the branch pick them up:

- ROCm/pytorch#3816 (`related_commits`: apex `release/1.15.0`, vision
`release/0.29`, ROCm/audio `release/2.11.1`)
- ROCm/pytorch#3818 (requirements pins)
- ROCm/pytorch#3832 (Windows hipify fix for subst drives, backport of
ROCm/pytorch#3561 from `release/2.14`)

## Test Plan

- `python
build_tools/github_actions/tests/configure_pytorch_release_matrix_test.py`
- `python
build_tools/github_actions/tests/configure_multi_arch_ci_test.py`
- `python
build_tools/github_actions/tests/generate_pytorch_source_manifest_test.py`
- `git diff --check`
- Wheel builds of `pablo-garay/release-2.15-integration` (`release/2.15`
+ ROCm/pytorch#3816 + ROCm/pytorch#3818 + ROCm/pytorch#3832),
gfx94X-dcgpu on Linux, gfx1151 on Windows, ROCm 10.2.0a20261013.

## Test Result

- Unit tests: 10 passed; 152 passed, 1 skipped; 13 passed, 1 skipped.
`git diff --check` clean.
- Linux builds passed on Python
[3.11](https://github.com/ROCm/TheRock/actions/runs/38705512288),
[3.12](https://github.com/ROCm/TheRock/actions/runs/38705525582),
[3.13](https://github.com/ROCm/TheRock/actions/runs/38705535781) and
[3.14](https://github.com/ROCm/TheRock/actions/runs/38705545732).
- Windows Python 3.12 build passed: [run
38848244359](https://github.com/ROCm/TheRock/actions/runs/38848244359).
The earlier [run
38716492477](https://github.com/ROCm/TheRock/actions/runs/38716492477),
without ROCm/pytorch#3832, failed building torchaudio.

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/TheRock/blob/main/CONTRIBUTING.md.

---------

Signed-off-by: pablo-garay <[email protected]>
jithunnair-amd pushed a commit that referenced this pull request Nov 4, 2026
…#3561) (#3832)

## Summary

Cherry-pick the hipify `subst`-drive fix into `release/2.15`. It's the
same change as `release/2.13` (#3561) and `release/2.14` (f11950f);
upstream nightly has it via pytorch#194641.

Windows CI builds under a `subst` drive (`B:` aliasing `C:\scratch-b`),
so `CUDAExtension` compares `B:\...` with `C:\...` and hipify silently
skips torchaudio's GPU sources. Resolving both sides with
`os.path.realpath` fixes the match. No effect on Linux.

## Test plan

- Failing without this: Windows py3.12 build of `release/2.15` ([run
38716492477](https://github.com/ROCm/TheRock/actions/runs/38716492477))
fails in torchaudio `rnnt/gpu/compute.cu` and
`forced_align/gpu/compute.cu` with `'cuda_runtime_api.h' file not
found`.
- The diff is identical to the 2.14 fix, which builds torchaudio on
Windows.
- Re-running the Windows build on `pablo-garay/release-2.15-integration`
with this commit for ROCm/TheRock#9031.

Signed-off-by: pablo-garay <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants