Skip to content

[release/2.11][ROCm] Reland: Enable expandable segments (#173330) (#177974) - #3106

Merged
pragupta merged 1 commit into
ROCm:release/2.11from
pragupta:pg-expandable-segments-2.11
Mar 27, 2026
Merged

pragupta merged 1 commit into
ROCm:release/2.11from
pragupta:pg-expandable-segments-2.11

Conversation

@pragupta

Copy link
Copy Markdown
Collaborator

Summary:
Original pull request: pytorch#173330 Fixes pytorch#168737. Fixes pytorch#168736.

The original diff enabled expandable segments for ROCm by adding #ifdef USE_ROCM guards throughout CUDACachingAllocator.cpp to use HIP APIs (hipMemAddressReserve, hipMemCreate, hipMemMap, etc.) instead of CUDA driver APIs when building for ROCm.

Root cause: In HIP/ROCm 6.2.1, the field name for memory allocation properties is requestedHandleType (singular), not requestedHandleTypes (plural) as in CUDA. Additionally, hipMemHandleTypeFabric does not exist in HIP, so the CU_MEM_HANDLE_TYPE_FABRIC assignment must be skipped on ROCm.

Fix applied on top of the original diff (from D96652342):

  • Use prop.requestedHandleType = hipMemHandleTypePosixFileDescriptor under #ifdef USE_ROCM (singular field name, HIP constant)
  • Use prop.requestedHandleTypes = CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR for CUDA (plural field name, CUDA constant)
  • Skip the CU_MEM_HANDLE_TYPE_FABRIC assignment entirely on ROCm under #ifndef USE_ROCM, as hipMemHandleTypeFabric does not exist in HIP

Co-authored-by: Prachi Gupta [email protected]
Co-authored-by: Jeff Daily [email protected]
Co-authored-by: moonshadow-25 [email protected]
Co-authored-by: Vighanesh Sharma [email protected]

Test Plan:

fbpkg build //aps_models/ads/ecosystem/eval/cogwheel_tests/amd:cogwheel_aps_ads_icvr_kd_eval_amd_test_harness --build-remote

https://www.internalfb.com/sandcastle/workflow/1049338713192153464

Differential Revision: D97211385

Pull Request resolved: pytorch#177974
Approved by: https://github.com/jeffdaily, https://github.com/echen4096

(cherry picked from commit 5792701)

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

…77974)

Summary:
Original pull request: pytorch#173330
Fixes pytorch#168737.
Fixes pytorch#168736.

The original diff enabled expandable segments for ROCm by adding `#ifdef USE_ROCM`
guards throughout CUDACachingAllocator.cpp to use HIP APIs (hipMemAddressReserve,
hipMemCreate, hipMemMap, etc.) instead of CUDA driver APIs when building for ROCm.

Root cause: In HIP/ROCm 6.2.1, the field name for memory allocation properties is
`requestedHandleType` (singular), not `requestedHandleTypes` (plural) as in CUDA.
Additionally, `hipMemHandleTypeFabric` does not exist in HIP, so the
`CU_MEM_HANDLE_TYPE_FABRIC` assignment must be skipped on ROCm.

Fix applied on top of the original diff (from D96652342):
- Use `prop.requestedHandleType = hipMemHandleTypePosixFileDescriptor` under
  `#ifdef USE_ROCM` (singular field name, HIP constant)
- Use `prop.requestedHandleTypes = CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR` for
  CUDA (plural field name, CUDA constant)
- Skip the `CU_MEM_HANDLE_TYPE_FABRIC` assignment entirely on ROCm under
  `#ifndef USE_ROCM`, as `hipMemHandleTypeFabric` does not exist in HIP

Co-authored-by: Prachi Gupta [email protected]
Co-authored-by: Jeff Daily [email protected]
Co-authored-by: moonshadow-25 [email protected]
Co-authored-by: Vighanesh Sharma [email protected]

Test Plan:
```
fbpkg build //aps_models/ads/ecosystem/eval/cogwheel_tests/amd:cogwheel_aps_ads_icvr_kd_eval_amd_test_harness --build-remote
```

https://www.internalfb.com/sandcastle/workflow/1049338713192153464

Differential Revision: D97211385

Pull Request resolved: pytorch#177974
Approved by: https://github.com/jeffdaily, https://github.com/echen4096

(cherry picked from commit 5792701)
@pragupta
pragupta force-pushed the pg-expandable-segments-2.11 branch from f9cef24 to 34e107f Compare March 26, 2026 22:07
@pragupta
pragupta requested a review from jeffdaily March 26, 2026 22:07
@rocm-repo-management-api

rocm-repo-management-api Bot commented Mar 26, 2026 •

Copy link
Copy Markdown

Jenkins build for 34e107f4157ae600bcb7e86132214e46aec35ff8 commit finished as FAILURE
Links: Pipeline Overview / Build artifacts / Test Results

@pragupta
pragupta merged commit 2fea146 into ROCm:release/2.11 Mar 27, 2026
1 check failed
@pragupta pragupta changed the title [ROCm] Reland: Enable expandable segments (#173330) (#177974) [release/2.11][ROCm] Reland: Enable expandable segments (#173330) (#177974) Mar 27, 2026
darren-amd added a commit to ROCm/TheRock that referenced this pull request Apr 15, 2026
## Motivation
Fixes #4524

`test_mempool_expandable` was recently enabled for ROCm for torch 2.11
with ROCm/pytorch#3106 and requires building
`dummy_allocator` (which require the rocm[devel] packages). This test
was previously skipped for ROCm and is currently skipped for torch 2.12:
https://github.com/ROCm/TheRock/blob/3faaafaf8b72c1e500ff99be0616773ecdb64a52/external-builds/pytorch/skip_tests/pytorch_2.12.py#L17
Adding to skip list for torch 2.11, this is not present in 2.8-2.10, so
I didn't want to add it to the generic skip list.
<!-- Explain the purpose of this PR and the goals it aims to achieve.
-->

## Technical Details

- Added `test_mempool_expandable` to
`external-builds/pytorch/skip_tests/pytorch_2.11.py` to skip the test
<!-- Explain the changes along with any relevant GitHub links. -->

## Test Plan

- Verify that the tests are unblocked
<!-- Explain any relevant testing done to verify this PR. -->

## Test Result
- Tests are unblocked:
https://github.com/ROCm/TheRock/actions/runs/24415633738/job/71323862312
- The remaining failures are not related to this test and are reported
in other issues
<!-- Briefly summarize test outcomes. -->

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
@pragupta

Copy link
Copy Markdown
Collaborator Author

!cherry-pick --onto release/2.10 release/2.9

pragupta added a commit that referenced this pull request Apr 25, 2026
…77974) (#3106) (#3178)

Summary:
Original pull request: pytorch#173330
Fixes pytorch#168737. Fixes
pytorch#168736.

The original diff enabled expandable segments for ROCm by adding `#ifdef
USE_ROCM` guards throughout CUDACachingAllocator.cpp to use HIP APIs
(hipMemAddressReserve, hipMemCreate, hipMemMap, etc.) instead of CUDA
driver APIs when building for ROCm.

Root cause: In HIP/ROCm 6.2.1, the field name for memory allocation
properties is `requestedHandleType` (singular), not
`requestedHandleTypes` (plural) as in CUDA. Additionally,
`hipMemHandleTypeFabric` does not exist in HIP, so the
`CU_MEM_HANDLE_TYPE_FABRIC` assignment must be skipped on ROCm.

Fix applied on top of the original diff (from D96652342):
- Use `prop.requestedHandleType = hipMemHandleTypePosixFileDescriptor`
under `#ifdef USE_ROCM` (singular field name, HIP constant)
- Use `prop.requestedHandleTypes =
CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR` for CUDA (plural field name,
CUDA constant)
- Skip the `CU_MEM_HANDLE_TYPE_FABRIC` assignment entirely on ROCm under
`#ifndef USE_ROCM`, as `hipMemHandleTypeFabric` does not exist in HIP

Co-authored-by: Prachi Gupta [email protected]
Co-authored-by: Jeff Daily [email protected]
Co-authored-by: moonshadow-25 [email protected]
Co-authored-by: Vighanesh Sharma [email protected]

Test Plan:
```
fbpkg build //aps_models/ads/ecosystem/eval/cogwheel_tests/amd:cogwheel_aps_ads_icvr_kd_eval_amd_test_harness --build-remote
```

https://www.internalfb.com/sandcastle/workflow/1049338713192153464

Differential Revision: D97211385

Pull Request resolved: pytorch#177974
Approved by: https://github.com/jeffdaily, https://github.com/echen4096

(cherry picked from commit 5792701)

<!-- Explain the purpose of this PR and the goals it aims to achieve.
-->

<!-- Explain the changes along with any relevant GitHub links. -->

<!-- Explain any relevant testing done to verify this PR. -->

<!-- Briefly summarize test outcomes. -->

- [ ] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.


(cherry picked from commit 2fea146)

## Motivation

<!-- Explain the purpose of this PR and the goals it aims to achieve.
-->

## Technical Details

<!-- Explain the changes along with any relevant GitHub links. -->

## Test Plan

<!-- Explain any relevant testing done to verify this PR. -->

## Test Result

<!-- Briefly summarize test outcomes. -->

## Submission Checklist

- [ ] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.

---------

Co-authored-by: Haoyu Zhang <[email protected]>
pragupta added a commit that referenced this pull request Apr 25, 2026
…77974) (#3106) (#3179)

Summary:
Original pull request: pytorch#173330
Fixes pytorch#168737. Fixes
pytorch#168736.

The original diff enabled expandable segments for ROCm by adding `#ifdef
USE_ROCM` guards throughout CUDACachingAllocator.cpp to use HIP APIs
(hipMemAddressReserve, hipMemCreate, hipMemMap, etc.) instead of CUDA
driver APIs when building for ROCm.

Root cause: In HIP/ROCm 6.2.1, the field name for memory allocation
properties is `requestedHandleType` (singular), not
`requestedHandleTypes` (plural) as in CUDA. Additionally,
`hipMemHandleTypeFabric` does not exist in HIP, so the
`CU_MEM_HANDLE_TYPE_FABRIC` assignment must be skipped on ROCm.

Fix applied on top of the original diff (from D96652342):
- Use `prop.requestedHandleType = hipMemHandleTypePosixFileDescriptor`
under `#ifdef USE_ROCM` (singular field name, HIP constant)
- Use `prop.requestedHandleTypes =
CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR` for CUDA (plural field name,
CUDA constant)
- Skip the `CU_MEM_HANDLE_TYPE_FABRIC` assignment entirely on ROCm under
`#ifndef USE_ROCM`, as `hipMemHandleTypeFabric` does not exist in HIP

Co-authored-by: Prachi Gupta [email protected]
Co-authored-by: Jeff Daily [email protected]
Co-authored-by: moonshadow-25 [email protected]
Co-authored-by: Vighanesh Sharma [email protected]

Test Plan:
```
fbpkg build //aps_models/ads/ecosystem/eval/cogwheel_tests/amd:cogwheel_aps_ads_icvr_kd_eval_amd_test_harness --build-remote
```

https://www.internalfb.com/sandcastle/workflow/1049338713192153464

Differential Revision: D97211385

Pull Request resolved: pytorch#177974
Approved by: https://github.com/jeffdaily, https://github.com/echen4096

(cherry picked from commit 5792701)

## Motivation

<!-- Explain the purpose of this PR and the goals it aims to achieve.
-->

## Technical Details

<!-- Explain the changes along with any relevant GitHub links. -->

## Test Plan

<!-- Explain any relevant testing done to verify this PR. -->

## Test Result

<!-- Briefly summarize test outcomes. -->

## Submission Checklist

- [ ] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.


(cherry picked from commit 2fea146)

## Motivation

<!-- Explain the purpose of this PR and the goals it aims to achieve.
-->

## Technical Details

<!-- Explain the changes along with any relevant GitHub links. -->

## Test Plan

<!-- Explain any relevant testing done to verify this PR. -->

## Test Result

<!-- Briefly summarize test outcomes. -->

## Submission Checklist

- [ ] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.

Co-authored-by: Haoyu Zhang <[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.

2 participants