[Bugfix][CPU] Fix macOS multimodal SHM cache initialization (#57142)

Signed-off-by: 子华 <huaxi.shx@alibaba-inc.com> Co-authored-by: Codex <noreply@openai.com>

shaohuaxi committed Sep 18, 2026 at 02:05 UTC 67a8a3f9269795d683868254d134a199c29aff4f
2 files changed +14 -1
tests/test_envs.py
+5
@@ -18,6 +18,11 @@ from vllm.envs import (
18 from vllm.exceptions import VLLMValidationError
19
20
21 +def test_object_storage_shm_default_name():
22 + """The generated name must fit macOS's shared-memory name limit."""
23 + assert len(envs._generate_shm_name()) <= 30
24 +
25 +
26 def test_getattr_without_cache(monkeypatch: pytest.MonkeyPatch):
27 assert envs.VLLM_HOST_IP == ""
28 assert envs.VLLM_PORT is None
vllm/envs.py
+9 -1
@@ -535,6 +535,14 @@ def get_vllm_port() -> int | None:
535 raise ValueError(f"VLLM_PORT '{port}' must be a valid integer") from err
536
537
538 +def _generate_shm_name() -> str:
539 + import pybase64
540 +
541 + # Fit macOS's 30-character limit without truncating the UUID.
542 + encoded_uuid = pybase64.urlsafe_b64encode(uuid.uuid4().bytes).decode("ascii")
543 + return "vllm_mm_" + encoded_uuid.rstrip("=")
544 +
545 +
546 def get_env_or_set_default(
547 env_name: str,
548 default_factory: Callable[[], str],
@@ -1943,7 +1951,7 @@ environment_variables: dict[str, Callable[[], Any]] = {
1951 # if not explicitly set.
1952 "VLLM_OBJECT_STORAGE_SHM_BUFFER_NAME": get_env_or_set_default(
1953 "VLLM_OBJECT_STORAGE_SHM_BUFFER_NAME",
1946 - lambda: f"VLLM_OBJECT_STORAGE_SHM_BUFFER_{uuid.uuid4().hex}",
1954 + _generate_shm_name,
1955 ),
1956 # The size in MB of the buffers (NVL and RDMA) used by DeepEP
1957 "VLLM_DEEPEP_BUFFER_SIZE_MB": lambda: int(