From 67a8a3f9269795d683868254d134a199c29aff4f Mon Sep 17 00:00:00 2001 From: shaohuaxi Date: Fri, 18 Sep 2026 02:05:13 -0700 Subject: [PATCH] [Bugfix][CPU] Fix macOS multimodal SHM cache initialization (#57142) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 子华 Co-authored-by: Codex --- tests/test_envs.py | 5 +++++ vllm/envs.py | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/test_envs.py b/tests/test_envs.py index 1ef40cde0c..dfd08a9ec2 100644 --- a/tests/test_envs.py +++ b/tests/test_envs.py @@ -18,6 +18,11 @@ from vllm.envs import ( from vllm.exceptions import VLLMValidationError +def test_object_storage_shm_default_name(): + """The generated name must fit macOS's shared-memory name limit.""" + assert len(envs._generate_shm_name()) <= 30 + + def test_getattr_without_cache(monkeypatch: pytest.MonkeyPatch): assert envs.VLLM_HOST_IP == "" assert envs.VLLM_PORT is None diff --git a/vllm/envs.py b/vllm/envs.py index 82d6e771b5..26c00c6da6 100755 --- a/vllm/envs.py +++ b/vllm/envs.py @@ -535,6 +535,14 @@ def get_vllm_port() -> int | None: raise ValueError(f"VLLM_PORT '{port}' must be a valid integer") from err +def _generate_shm_name() -> str: + import pybase64 + + # Fit macOS's 30-character limit without truncating the UUID. + encoded_uuid = pybase64.urlsafe_b64encode(uuid.uuid4().bytes).decode("ascii") + return "vllm_mm_" + encoded_uuid.rstrip("=") + + def get_env_or_set_default( env_name: str, default_factory: Callable[[], str], @@ -1943,7 +1951,7 @@ environment_variables: dict[str, Callable[[], Any]] = { # if not explicitly set. "VLLM_OBJECT_STORAGE_SHM_BUFFER_NAME": get_env_or_set_default( "VLLM_OBJECT_STORAGE_SHM_BUFFER_NAME", - lambda: f"VLLM_OBJECT_STORAGE_SHM_BUFFER_{uuid.uuid4().hex}", + _generate_shm_name, ), # The size in MB of the buffers (NVL and RDMA) used by DeepEP "VLLM_DEEPEP_BUFFER_SIZE_MB": lambda: int(