[hardware] feat: add ROCm/HIP platform backend (PlatformROCm) - #2
Open
xiaohong42 wants to merge 1 commit into
Open
[hardware] feat: add ROCm/HIP platform backend (PlatformROCm)#2xiaohong42 wants to merge 1 commit into
xiaohong42 wants to merge 1 commit into
Conversation
xiaohong42
force-pushed
the
feat/rocm-platform-abstraction
branch
from
June 12, 2026 02:33
998b6f0 to
9613903
Compare
Add a dedicated PlatformROCm backend so ROCm is a first-class platform instead of silently falling back to PlatformCUDA. ROCm is largely CUDA-compatible (PyTorch reuses torch.cuda.* via hipify), so PlatformROCm subclasses PlatformCUDA and only overrides what differs, extending the parent via super(). - platform_rocm.py (new): PlatformROCm(PlatformCUDA). vendor_name="amd" (device_name stays "cuda"); is_platform_available gated on torch.version.hip and mirrors the parent's smi-check structure using rocm-smi (with /opt/rocm/bin lookup); rollout_env_vars adds a user-overridable SGLANG_USE_AITER; ray_noset_envvars adds HIP/ROCR NOSET vars so Ray does not clear them. - platform_cuda.py: is_platform_available returns False when torch.version.hip is not None, so auto-detection picks ROCm on AMD. - platform_manager.py: register PlatformROCm. - tests/special_sanity/check_device_api_usage.py: whitelist platform_rocm.py (reuses torch.cuda via hipify). Validated on AMD ROCm (ROCm 7.0, 8x gfx942 / MI3xx): get_platform() resolves to PlatformROCm, env vars and Ray NOSET vars are correct, and end-to-end GRPO smoke training runs with 8-GPU RCCL. CI cannot cover this (requires ROCm hardware); validated manually. Co-authored-by: Cursor <cursoragent@cursor.com>
xiaohong42
force-pushed
the
feat/rocm-platform-abstraction
branch
from
June 12, 2026 02:53
9613903 to
8a5a9b7
Compare
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.
What does this PR do?
Add a dedicated
PlatformROCmbackend so ROCm is a first-class platform instead of falling back toPlatformCUDA. ROCm is largely CUDA-compatible (PyTorch reusestorch.cuda.*via hipify), soPlatformROCmsubclassesPlatformCUDAand only overrides what differs, extending the parent viasuper().Checklist Before Starting
[hardware] feat: add ROCm/HIP platform backend (PlatformROCm)— not a breaking change.Test
Validated on AMD ROCm (ROCm 7.0, 8x gfx942 / MI3xx):
get_platform()resolves toPlatformROCm(notPlatformCUDA);PlatformCUDA.is_platform_available()returnsFalseon ROCm.vendor_name='amd',device_name='cuda',is_platform_available(use_smi_check=True)=True.rollout_env_vars()={'NCCL_CUMEM_ENABLE': '0', 'SGLANG_USE_AITER': '1'}; withSGLANG_USE_AITER=0exported it becomes'0'(override honored).ray_noset_envvars()includes CUDA + HIP + ROCR NOSET vars.CI cannot cover this (requires ROCm hardware); validated manually.
API and Usage Example
No API change. ROCm is auto-detected; AITER can be disabled by the user:
Design & Code Changes
verl/plugin/platform/platform_rocm.py(new) —PlatformROCm(PlatformCUDA):vendor_name="amd"(device_namestays"cuda"); inheritsis_availablefromPlatformCUDA; overridesis_platform_available(gated ontorch.version.hip, mirroring the parent's smi-check structure but usingrocm-smi);rollout_env_varsaddsSGLANG_USE_AITER(user-overridable);ray_noset_envvarsadds HIP/ROCR NOSET vars.platform_cuda.py—is_platform_availablereturnsFalsewhentorch.version.hip is not None, so auto-detection picks ROCm on AMD.platform_manager.py— registerPlatformROCm.tests/special_sanity/check_device_api_usage.py— whitelistplatform_rocm.py(reusestorch.cudavia hipify).Notes on specific decisions:
is_platform_availablemirrorsPlatformCUDA— kept structurally aligned with the parent (HIP build check, then optional smi probe, thentorch.cuda.is_available()fallback), only swappingnvidia-smiforrocm-smi(with a/opt/rocm/binlookup). The leadingtorch.version.hipgate is what distinguishes ROCm from NVIDIA during auto-detection.SGLANG_USE_AITERinrollout_env_vars— defaults to"1"but readsos.environ.get(...)so users can override.visible_devices_envvarstaysCUDA_VISIBLE_DEVICES— verl drives visibility viaCUDA_VISIBLE_DEVICESand keepsHIP_VISIBLE_DEVICESunset; the HIP side is handled byray_noset_envvars(preventing Ray from clearing it). Switching the primary variable to HIP would flip many read/write sites and conflict with Ray's GPU assignment.Checklist Before Submitting
ci-requestchannel when ready for CI.recipesubmodule.