[Mooncake] Use all HCAs on multi-NIC hosts instead of GPU-indexed RNIC selection (#43799)
Signed-off-by: Dao Le <Dao007forever@gmail.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
01d8cd92dd
commit
c1d754d681
@@ -283,94 +283,6 @@ def test_get_configured_preferred_segment_rejects_empty_override():
|
|||||||
rdma_utils.get_configured_preferred_segment({"preferred_segment": " "})
|
rdma_utils.get_configured_preferred_segment({"preferred_segment": " "})
|
||||||
|
|
||||||
|
|
||||||
def test_get_configured_worker_rnic_prefers_explicit_device_name(monkeypatch):
|
|
||||||
store_config = worker.MooncakeStoreConfig(
|
|
||||||
metadata_server="",
|
|
||||||
local_buffer_size=1,
|
|
||||||
protocol="rdma",
|
|
||||||
device_name="rocep139s0",
|
|
||||||
master_server_address="",
|
|
||||||
)
|
|
||||||
|
|
||||||
assert (
|
|
||||||
rdma_utils.get_configured_worker_rnic(
|
|
||||||
protocol=store_config.protocol,
|
|
||||||
configured_device=store_config.device_name,
|
|
||||||
)
|
|
||||||
== "rocep139s0"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_configured_worker_rnic_selects_device_from_explicit_csv(monkeypatch):
|
|
||||||
monkeypatch.setattr(
|
|
||||||
rdma_utils,
|
|
||||||
"get_current_physical_gpu_index",
|
|
||||||
lambda: 1,
|
|
||||||
)
|
|
||||||
store_config = worker.MooncakeStoreConfig(
|
|
||||||
metadata_server="",
|
|
||||||
local_buffer_size=1,
|
|
||||||
protocol="rdma",
|
|
||||||
device_name="rocep139s0,rocep140s0",
|
|
||||||
master_server_address="",
|
|
||||||
)
|
|
||||||
|
|
||||||
assert (
|
|
||||||
rdma_utils.get_configured_worker_rnic(
|
|
||||||
protocol=store_config.protocol,
|
|
||||||
configured_device=store_config.device_name,
|
|
||||||
)
|
|
||||||
== "rocep140s0"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_configured_worker_rnic_warns_and_returns_empty_for_rdma_with_no_device(
|
|
||||||
caplog, monkeypatch
|
|
||||||
):
|
|
||||||
"""No device configured + protocol=rdma → emit a clear warning and return ""
|
|
||||||
so the C++ side handles auto-selection. There is no Python-side fallback."""
|
|
||||||
monkeypatch.setattr(logging.getLogger("vllm"), "propagate", True)
|
|
||||||
with caplog.at_level(logging.WARNING):
|
|
||||||
result = rdma_utils.get_configured_worker_rnic(
|
|
||||||
protocol="rdma",
|
|
||||||
configured_device="",
|
|
||||||
)
|
|
||||||
assert result == ""
|
|
||||||
warnings = [r for r in caplog.records if r.levelno == logging.WARNING]
|
|
||||||
assert any("No RDMA devices specified" in r.message for r in warnings), (
|
|
||||||
f"expected fallback warning, got {[r.message for r in warnings]}"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_configured_worker_rnic_silent_for_tcp_with_no_device(caplog, monkeypatch):
|
|
||||||
"""protocol=tcp + no device → return "" silently (no RDMA, no warning)."""
|
|
||||||
monkeypatch.setattr(logging.getLogger("vllm"), "propagate", True)
|
|
||||||
with caplog.at_level(logging.WARNING):
|
|
||||||
result = rdma_utils.get_configured_worker_rnic(
|
|
||||||
protocol="tcp",
|
|
||||||
configured_device="",
|
|
||||||
)
|
|
||||||
assert result == ""
|
|
||||||
warnings = [r for r in caplog.records if r.levelno == logging.WARNING]
|
|
||||||
assert not any("RDMA" in r.message for r in warnings), (
|
|
||||||
"did not expect RDMA warning for tcp protocol, got "
|
|
||||||
f"{[r.message for r in warnings]}"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_configured_worker_rnic_rejects_short_explicit_csv(monkeypatch):
|
|
||||||
monkeypatch.setattr(
|
|
||||||
rdma_utils,
|
|
||||||
"get_current_physical_gpu_index",
|
|
||||||
lambda: 2,
|
|
||||||
)
|
|
||||||
with pytest.raises(ValueError, match="does not cover local GPU 2"):
|
|
||||||
rdma_utils.get_configured_worker_rnic(
|
|
||||||
protocol="rdma",
|
|
||||||
configured_device="rocep139s0,rocep140s0",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class _ReplicaDesc:
|
class _ReplicaDesc:
|
||||||
def __init__(self, tier: str):
|
def __init__(self, tier: str):
|
||||||
self.tier = tier
|
self.tier = tier
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import torch
|
|
||||||
|
|
||||||
import vllm.envs as envs
|
import vllm.envs as envs
|
||||||
from vllm.logger import init_logger
|
from vllm.logger import init_logger
|
||||||
|
|
||||||
@@ -20,22 +18,6 @@ def normalize_string_override(value: Any) -> str | None:
|
|||||||
return normalized or None
|
return normalized or None
|
||||||
|
|
||||||
|
|
||||||
def get_current_physical_gpu_index() -> int | None:
|
|
||||||
try:
|
|
||||||
from vllm.platforms import current_platform
|
|
||||||
except ImportError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
try:
|
|
||||||
device_index = torch.accelerator.current_device_index()
|
|
||||||
physical_device_id = current_platform.device_id_to_physical_device_id(
|
|
||||||
device_index
|
|
||||||
)
|
|
||||||
return int(physical_device_id)
|
|
||||||
except Exception:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def get_requester_local_hostname(local_ip: str) -> str:
|
def get_requester_local_hostname(local_ip: str) -> str:
|
||||||
override = normalize_string_override(envs.MOONCAKE_REQUESTER_LOCAL_HOSTNAME)
|
override = normalize_string_override(envs.MOONCAKE_REQUESTER_LOCAL_HOSTNAME)
|
||||||
if override is not None:
|
if override is not None:
|
||||||
@@ -62,54 +44,3 @@ def get_configured_preferred_segment(
|
|||||||
)
|
)
|
||||||
return env_value
|
return env_value
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _get_explicit_worker_rnic(device_list: str) -> str:
|
|
||||||
entries = [entry.strip() for entry in device_list.split(",")]
|
|
||||||
if any(not entry for entry in entries):
|
|
||||||
raise ValueError(
|
|
||||||
"Mooncake worker device_name contains an empty RDMA device entry"
|
|
||||||
)
|
|
||||||
if len(entries) == 1:
|
|
||||||
return entries[0]
|
|
||||||
|
|
||||||
gpu_index = get_current_physical_gpu_index()
|
|
||||||
if gpu_index is None:
|
|
||||||
raise RuntimeError(
|
|
||||||
"Mooncake RDMA requester could not determine the local physical GPU index"
|
|
||||||
)
|
|
||||||
if gpu_index >= len(entries):
|
|
||||||
raise ValueError(
|
|
||||||
"Mooncake worker device list does not cover local GPU "
|
|
||||||
f"{gpu_index}: {device_list}"
|
|
||||||
)
|
|
||||||
device_name = entries[gpu_index]
|
|
||||||
logger.info(
|
|
||||||
"Mooncake selected worker RNIC %s from explicit device list for local GPU %s",
|
|
||||||
device_name,
|
|
||||||
gpu_index,
|
|
||||||
)
|
|
||||||
return device_name
|
|
||||||
|
|
||||||
|
|
||||||
def get_configured_worker_rnic(
|
|
||||||
*,
|
|
||||||
protocol: str,
|
|
||||||
configured_device: str,
|
|
||||||
) -> str:
|
|
||||||
normalized_device = normalize_string_override(configured_device)
|
|
||||||
if normalized_device is not None:
|
|
||||||
return _get_explicit_worker_rnic(normalized_device)
|
|
||||||
|
|
||||||
if protocol not in {"rdma", "efa"}:
|
|
||||||
return ""
|
|
||||||
|
|
||||||
logger.warning(
|
|
||||||
"No RDMA devices specified for Mooncake backend (protocol=%s). "
|
|
||||||
"Set 'device_name' in mooncake_config.json to a single RNIC name "
|
|
||||||
"or a comma-separated CSV indexed by physical GPU; falling back to "
|
|
||||||
"Mooncake's built-in auto-selection, which may converge on the same "
|
|
||||||
"NIC across all DP ranks and saturate bandwidth.",
|
|
||||||
protocol,
|
|
||||||
)
|
|
||||||
return ""
|
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class MooncakeStoreConfig:
|
|||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load_from_env() -> "MooncakeStoreConfig":
|
def load_from_config() -> "MooncakeStoreConfig":
|
||||||
config_path = os.getenv("MOONCAKE_CONFIG_PATH")
|
config_path = os.getenv("MOONCAKE_CONFIG_PATH")
|
||||||
if not config_path:
|
if not config_path:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
@@ -983,16 +983,12 @@ class MooncakeStoreWorker:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Initialize MooncakeDistributedStore with its own TransferEngine
|
# Initialize MooncakeDistributedStore with its own TransferEngine
|
||||||
store_config = MooncakeStoreConfig.load_from_env()
|
store_config = MooncakeStoreConfig.load_from_config()
|
||||||
extra_config = (
|
extra_config = (
|
||||||
vllm_config.kv_transfer_config.kv_connector_extra_config
|
vllm_config.kv_transfer_config.kv_connector_extra_config
|
||||||
if vllm_config.kv_transfer_config
|
if vllm_config.kv_transfer_config
|
||||||
else {}
|
else {}
|
||||||
)
|
)
|
||||||
store_config.device_name = rdma_utils.get_configured_worker_rnic(
|
|
||||||
protocol=store_config.protocol,
|
|
||||||
configured_device=store_config.device_name,
|
|
||||||
)
|
|
||||||
self.store = MooncakeDistributedStore()
|
self.store = MooncakeDistributedStore()
|
||||||
local_ip = get_ip()
|
local_ip = get_ip()
|
||||||
local_hostname = rdma_utils.get_requester_local_hostname(local_ip)
|
local_hostname = rdma_utils.get_requester_local_hostname(local_ip)
|
||||||
|
|||||||
Reference in New Issue
Block a user