From aa71f9bcc420241bbbd37c133a0e2b8930878755 Mon Sep 17 00:00:00 2001 From: Luyi Xiao <81631911+luyixiao95@users.noreply.github.com> Date: Tue, 1 Sep 2026 12:11:52 -0700 Subject: [PATCH] [Bugfix] Log platform plugin detection failures (#52285) Signed-off-by: Luyi Xiao Co-authored-by: OpenAI Codex --- tests/test_zen_cpu_platform_detection.py | 36 +++++++++++++++++++++++- vllm/platforms/__init__.py | 6 +++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/tests/test_zen_cpu_platform_detection.py b/tests/test_zen_cpu_platform_detection.py index 2857b1ac11..9f386f70cd 100644 --- a/tests/test_zen_cpu_platform_detection.py +++ b/tests/test_zen_cpu_platform_detection.py @@ -1,10 +1,16 @@ # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project +import builtins +import logging from unittest.mock import mock_open, patch import pytest -from vllm.platforms import _is_amd_zen_cpu, resolve_current_platform_cls_qualname +from vllm.platforms import ( + _is_amd_zen_cpu, + cpu_platform_plugin, + resolve_current_platform_cls_qualname, +) def test_is_amd_zen_cpu_detects_amd_with_avx512(): @@ -57,3 +63,31 @@ def test_cpu_target_selects_cpu_platform_from_non_cpu_wheel( # suffix or host accelerators (a native CI job can reuse a ROCm wheel). version_matches.assert_not_called() rocm_plugin.assert_not_called() + + +def test_platform_detection_logs_zentorch_import_failure(caplog): + original_import = builtins.__import__ + + def import_with_broken_zentorch(name, *args, **kwargs): + if name == "zentorch": + raise OSError("incompatible shared library") + return original_import(name, *args, **kwargs) + + with ( + patch("vllm.platforms.envs.VLLM_TARGET_DEVICE", "cuda"), + patch.dict( + "vllm.platforms.builtin_platform_plugins", + {"cpu": cpu_platform_plugin}, + clear=True, + ), + patch("vllm.platforms.load_plugins_by_group", return_value={}), + patch("vllm.platforms.vllm_version_matches_substr", return_value=True), + patch("vllm.platforms._is_amd_zen_cpu", return_value=True), + patch.object(builtins, "__import__", side_effect=import_with_broken_zentorch), + caplog.at_level(logging.DEBUG, logger="vllm.platforms"), + ): + platform = resolve_current_platform_cls_qualname() + + assert platform == "vllm.platforms.interface.UnspecifiedPlatform" + assert "Platform plugin cpu failed during detection" in caplog.text + assert "OSError: incompatible shared library" in caplog.text diff --git a/vllm/platforms/__init__.py b/vllm/platforms/__init__.py index 8cf8282e5d..b34b0b9a7d 100644 --- a/vllm/platforms/__init__.py +++ b/vllm/platforms/__init__.py @@ -251,7 +251,11 @@ def resolve_current_platform_cls_qualname() -> str: if platform_cls_qualname is not None: activated_plugins.append(name) except Exception: - pass + logger.debug( + "Platform plugin %s failed during detection.", + name, + exc_info=True, + ) activated_builtin_plugins = list( set(activated_plugins) & set(builtin_platform_plugins.keys())