[Bugfix][KV Transfer] Reject NixlConnector + expandable_segments:True (#41237)
This commit is contained in:
@@ -713,6 +713,48 @@ class VllmConfig:
|
||||
# This is the same for all backends
|
||||
self.kv_transfer_config.kv_role = "kv_both"
|
||||
|
||||
def _verify_kv_transfer_compat(self) -> None:
|
||||
"""Reject configurations that silently corrupt KV transfers."""
|
||||
if (
|
||||
self.kv_transfer_config is None
|
||||
or self.kv_transfer_config.kv_connector is None
|
||||
):
|
||||
return
|
||||
|
||||
# PyTorch's expandable_segments allocator uses CUDA VMM, which can
|
||||
# remap a virtual address range to different physical pages over the
|
||||
# engine's lifetime. KV connectors that pin KV cache memory (e.g.
|
||||
# NixlConnector via ibv_reg_mr, MooncakeConnector) end up with their
|
||||
# registrations pointing at stale physical pages after any remap,
|
||||
# producing RDMA failures like IBV_WC_REM_ACCESS_ERR /
|
||||
# NIXL_ERR_REMOTE_DISCONNECT at the first inter-node KV transfer.
|
||||
# We can't enumerate every in-tree and out-of-tree connector that
|
||||
# pins memory, so we conservatively reject the combination whenever
|
||||
# any KV connector is configured.
|
||||
#
|
||||
# Sleep mode is exempt: CuMemAllocator.use_memory_pool toggles
|
||||
# expandable_segments off around its pool (see #40812), so the KV
|
||||
# cache allocated within that context lands on stable physical pages
|
||||
# even when the env var is set.
|
||||
if "expandable_segments:True" not in os.environ.get(
|
||||
"PYTORCH_CUDA_ALLOC_CONF", ""
|
||||
):
|
||||
return
|
||||
if self.model_config is not None and self.model_config.enable_sleep_mode:
|
||||
return
|
||||
|
||||
raise ValueError(
|
||||
f"KV connector {self.kv_transfer_config.kv_connector} is "
|
||||
"incompatible with PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True "
|
||||
"unless enable_sleep_mode is also enabled. PyTorch's CUDA VMM "
|
||||
"allocator can remap KV cache virtual addresses to different "
|
||||
"physical pages, invalidating any pinned/registered KV memory "
|
||||
"(e.g. IB memory regions registered by NIXL or Mooncake). Either "
|
||||
"unset expandable_segments:True or enable sleep mode (which "
|
||||
"routes KV allocations through CuMemAllocator's pool, where "
|
||||
"expandable_segments is automatically disabled)."
|
||||
)
|
||||
|
||||
def __post_init__(self):
|
||||
"""Verify configs are valid & consistent with each other."""
|
||||
|
||||
@@ -1353,6 +1395,7 @@ class VllmConfig:
|
||||
|
||||
# Handle the KV connector configs
|
||||
self._post_init_kv_transfer_config()
|
||||
self._verify_kv_transfer_compat()
|
||||
|
||||
# Log the custom passes that are enabled
|
||||
self.compilation_config.pass_config.log_enabled_passes()
|
||||
|
||||
Reference in New Issue
Block a user