Shared symmetric-memory infrastructure for context-parallel attention.
_symm_mem_spans_group(group) cached
Probe whether the group has NVLS symmetric memory.
Source code in vllm/v1/attention/ops/cp_common.py
| @functools.cache
def _symm_mem_spans_group(group: GroupCoordinator) -> bool:
"""Probe whether the group has NVLS symmetric memory."""
if not symm_mem_available:
return False
try:
from torch._C._autograd import DeviceType
from torch._C._distributed_c10d import _SymmetricMemory
device = torch.device("cuda", torch.accelerator.current_device_index())
if not _SymmetricMemory.has_multicast_support(DeviceType.CUDA, device.index):
return False
probe = symm_mem.empty(8, dtype=torch.uint8, device=device)
probe.zero_()
torch.accelerator.synchronize()
handle = symm_mem.rendezvous(probe, group.device_group.group_name)
spans = handle is not None and handle.multicast_ptr != 0
except Exception as error:
logger.debug("Direct CP symmetric-memory probe failed: %s", error)
return False
logger.debug_once(
"Direct CP symmetric memory across %d ranks: %s",
group.world_size,
"available" if spans else "unavailable",
)
return spans
|