Repository navigation
[release/2.11][ROCm] Reland: Enable expandable segments (#173330) (#177974) - #3106
Merged
Merged
Conversation
…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
force-pushed
the
pg-expandable-segments-2.11
branch
from
March 26, 2026 22:07
f9cef24 to
34e107f
Compare
|
Jenkins build for 34e107f4157ae600bcb7e86132214e46aec35ff8 commit finished as FAILURE |
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.
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Original pull request: pytorch#173330 Fixes pytorch#168737. Fixes pytorch#168736.
The original diff enabled expandable segments for ROCm by adding
#ifdef USE_ROCMguards 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), notrequestedHandleTypes(plural) as in CUDA. Additionally,hipMemHandleTypeFabricdoes not exist in HIP, so theCU_MEM_HANDLE_TYPE_FABRICassignment must be skipped on ROCm.Fix applied on top of the original diff (from D96652342):
prop.requestedHandleType = hipMemHandleTypePosixFileDescriptorunder#ifdef USE_ROCM(singular field name, HIP constant)prop.requestedHandleTypes = CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTORfor CUDA (plural field name, CUDA constant)CU_MEM_HANDLE_TYPE_FABRICassignment entirely on ROCm under#ifndef USE_ROCM, ashipMemHandleTypeFabricdoes not exist in HIPCo-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:
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