[Core] Add explicit HWR registration bypass and progress logs

Signed-off-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
Hongsheng Liu committed 2026-09-06 17:06:41 +08:00
1 parent 039808e0d9
commit 729ccd7f11
14 files changed
+144 -5

No files matched your search

+6
View File
@@ -73,12 +73,15 @@ class OffloadConfig:
# Optional per-worker ceiling for registering an HWR mmap. Zero means no
# additional ceiling; pin_cpu_memory controls whether registration is tried.
dlo_host_registration_limit_gib: float = 0.0
dlo_host_registration_mode: str = "auto"
# ``None`` preserves the model's legacy plan-driven component topology;
# a frozenset is an explicit compact-API selection.
components: frozenset[str] | None = None
dlo_transfers: dict[str, DLOTransfer] | None = None
def __post_init__(self) -> None:
if self.dlo_host_registration_mode not in ("auto", "disabled"):
raise ValueError("dlo_host_registration_mode must be auto or disabled")
if self.components is not None:
self.components = parse_offload_components(self.components)
if self.dlo_transfers is None:
@@ -174,7 +177,9 @@ class OffloadConfig:
dlo_transfers = dict(resolved.transfers)
dlo_resident_layers = resolved.resident_layers
dit_uses_allgather = resolved.uses_allgather(DIT_COMPONENT)
registration_mode = getattr(od_config, "dlo_host_registration_mode", "auto")
dlo_host_registration_limit_gib = validate_dlo_host_registration_options(
mode=registration_mode,
limit_gib=getattr(od_config, "dlo_host_registration_limit_gib", 0.0),
enable_dlo=enable_distributed_layerwise_offload,
use_allgather=dit_uses_allgather,
@@ -210,6 +215,7 @@ class OffloadConfig:
dlo_use_allgather=dit_uses_allgather,
dlo_resident_layers=dlo_resident_layers,
dlo_host_registration_limit_gib=dlo_host_registration_limit_gib,
dlo_host_registration_mode=registration_mode,
components=components,
dlo_transfers=dlo_transfers,
)
@@ -6,12 +6,14 @@ from __future__ import annotations
import ctypes
import mmap
import time
from collections import defaultdict
from collections.abc import Sequence
from dataclasses import dataclass
from typing import Protocol
import torch
from vllm.logger import init_logger
from vllm_omni.host_weight_runtime import MappedHostRegion
@@ -21,6 +23,8 @@ from .host_registration import (
HostRegistrationError,
)
logger = init_logger(__name__)
_CUDA_HOST_REGISTER_READ_ONLY = 0x08
_CUDA_DEVICE_ATTRIBUTE_HOST_REGISTER_READ_ONLY_SUPPORTED = 113
@@ -187,7 +191,9 @@ class CudaHostRegistration:
registered: list[_AddressRange] = []
try:
for region in mapped:
for index, region in enumerate(mapped, start=1):
logger.info("Registering HWR host range %d/%d: %d bytes", index, len(mapped), region.size)
started = time.perf_counter()
error = runtime.cudaHostRegister(region.start, region.size, _CUDA_HOST_REGISTER_READ_ONLY)
if int(error) != 0:
raise HostRegistrationError(
@@ -195,6 +201,9 @@ class CudaHostRegistration:
f"[{region.start:#x}, {region.end:#x}): {_handled_error_message(runtime, error)}"
)
registered.append(region)
logger.info(
"Registered HWR host range %d/%d in %.3f s", index, len(mapped), time.perf_counter() - started
)
except Exception as exc:
rollback_errors: list[str] = []
rollback_failed: list[_AddressRange] = []
@@ -1080,6 +1080,9 @@ class DistributedLayerwiseOffloadBackend(OffloadBackend):
lease = self._host_weight_lease
if lease is None:
return False
if self.config.dlo_host_registration_mode == "disabled":
logger.info("HWR mmap registration disabled by transport policy; using bounded host staging")
return False
if not self.config.pin_cpu_memory:
logger.info("HWR mmap registration disabled by pin_cpu_memory=False; using bounded host staging")
return False
@@ -1089,6 +1092,12 @@ class DistributedLayerwiseOffloadBackend(OffloadBackend):
limit_gib = self.config.dlo_host_registration_limit_gib
max_bytes = int(limit_gib * 1024**3) if limit_gib > 0 else None
logger.info(
"Starting HWR mmap registration on %s: %d source range(s), budget_bytes=%s",
self.device,
len(lease.mapped_regions),
max_bytes,
)
started = time.perf_counter()
try:
registration = register_host_mappings(