[ROCm] Enable the cuMem CUDA-graph pool offload on ROCm (#59523)

Signed-off-by: aoshen02 <aoshen@inferact.ai>
Signed-off-by: indianspeedster <cspandey016@gmail.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: indianspeedster <cspandey016@gmail.com>
This commit is contained in:
aoshen02
2026-10-09 08:29:55 +00:00
committed by GitHub
co-authored by Claude Fable 5.1 indianspeedster
parent bacbbe1878
commit a6f43e57d6
9 changed files with 84 additions and 38 deletions
+4 -2
View File
@@ -1167,7 +1167,8 @@ def _rocm_aiter_fused_allreduce_rmsnorm_quant_per_group_impl(
w=weight,
eps=epsilon,
group_size=group_size,
registered=torch.cuda.is_current_stream_capturing(),
registered=torch.cuda.is_current_stream_capturing()
and ca.enable_register_for_capturing,
use_1stage=use_1stage,
)
assert result is not None
@@ -1219,7 +1220,8 @@ def _rocm_aiter_fused_allreduce_rmsnorm_quant_per_group_with_bf16_norm_impl(
w=weight,
eps=epsilon,
group_size=group_size,
registered=torch.cuda.is_current_stream_capturing(),
registered=torch.cuda.is_current_stream_capturing()
and ca.enable_register_for_capturing,
use_1stage=use_1stage,
emit_bf16=True,
)
+1 -1
View File
@@ -702,7 +702,7 @@ class VllmConfig:
and model_config.enable_sleep_mode
and model_config.sleep_mode_backend == "cumem"
and self.compilation_config.cudagraph_mode != CUDAGraphMode.NONE
and current_platform.is_cuda()
and current_platform.is_cuda_alike()
)
@property
+6 -2
View File
@@ -98,7 +98,7 @@ class CuMemAllocator:
offloaded to CPU memory, and the rest of the tensors will be discarded.
When we call `wake_up`, all tensors that are previously offloaded
will be loaded back to GPU memory, and the rest of the tensors will
have empty memory.
have empty memory (zeroed on ROCm).
Why it needs to be a singleton?
When allocated tensors are garbage collected, PyTorch will call
@@ -331,7 +331,7 @@ class CuMemAllocator:
def wake_up(self, tags: list[str] | None = None) -> None:
"""Wake up the allocator from sleep mode.
All data that is previously offloaded will be loaded back to GPU
memory, and the rest of the data will have empty memory.
memory, and the rest will have empty memory (zeroed on ROCm).
Args:
tags: The deferrable tags (weights, kv_cache) to load back to GPU
@@ -358,6 +358,10 @@ class CuMemAllocator:
cpu_ptr = cpu_backup_tensor.data_ptr()
libcudart.cudaMemcpy(ptr, cpu_ptr, size_in_bytes)
data.cpu_backup_tensor = None
elif current_platform.is_rocm():
# amdgpu <6.14 may return stale VRAM (#44972); drop with its support
libcudart.cudaMemset(ptr, 0, handle[1])
torch.accelerator.synchronize()
@contextmanager
def use_memory_pool(self, tag: str | None = None):
@@ -30,6 +30,8 @@ class AiterCustomAllreduce:
group: ProcessGroup,
device: int | str | torch.device,
max_size: int | None = None,
*,
register_graph_buffers: bool = True,
):
from aiter.dist.device_communicators.custom_all_reduce import (
CustomAllreduce as _AiterCustomAllreduce,
@@ -38,7 +40,10 @@ class AiterCustomAllreduce:
if max_size is None:
max_size = self.MAX_SIZE
self._impl = _AiterCustomAllreduce(group, device, max_size=max_size)
kwargs = {}
if not register_graph_buffers:
kwargs["enable_register_for_capturing"] = False
self._impl = _AiterCustomAllreduce(group, device, max_size=max_size, **kwargs)
@property
def aiter_ca(self):
@@ -151,6 +151,7 @@ class CudaCommunicator(DeviceCommunicatorBase):
self.aiter_ar_comm = AiterCustomAllreduce(
group=self.cpu_group,
device=self.device,
register_graph_buffers=register,
)
if use_custom_allreduce and self.aiter_ar_comm is None and self.world_size > 1:
@@ -174,6 +175,7 @@ class CudaCommunicator(DeviceCommunicatorBase):
self.aiter_ar_comm = AiterCustomAllreduce(
group=self.cpu_group,
device=self.device,
register_graph_buffers=register,
)
if self.aiter_ar_comm.disabled:
self.aiter_ar_comm = None