[Bugfix] Log platform plugin detection failures (#52285)
Signed-off-by: Luyi Xiao <xiao.luy@northeastern.edu> Co-authored-by: OpenAI Codex <codex@openai.com>
Luyi Xiao committed
Sep 1, 2026 at 12:11 UTC
aa71f9bcc420241bbbd37c133a0e2b8930878755
2 files changed
+40
-2
tests/test_zen_cpu_platform_detection.py
+35
-1
@@ -1,10 +1,16 @@
1
# SPDX-License-Identifier: Apache-2.0
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+import builtins
4
+import logging
5
from unittest.mock import mock_open, patch
6
7
import pytest
8
7
-from vllm.platforms import _is_amd_zen_cpu, resolve_current_platform_cls_qualname
9
+from vllm.platforms import (
10
+ _is_amd_zen_cpu,
11
+ cpu_platform_plugin,
12
+ resolve_current_platform_cls_qualname,
13
+)
14
15
16
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(
63
# suffix or host accelerators (a native CI job can reuse a ROCm wheel).
64
version_matches.assert_not_called()
65
rocm_plugin.assert_not_called()
66
+
67
+
68
+def test_platform_detection_logs_zentorch_import_failure(caplog):
69
+ original_import = builtins.__import__
70
+
71
+ def import_with_broken_zentorch(name, *args, **kwargs):
72
+ if name == "zentorch":
73
+ raise OSError("incompatible shared library")
74
+ return original_import(name, *args, **kwargs)
75
+
76
+ with (
77
+ patch("vllm.platforms.envs.VLLM_TARGET_DEVICE", "cuda"),
78
+ patch.dict(
79
+ "vllm.platforms.builtin_platform_plugins",
80
+ {"cpu": cpu_platform_plugin},
81
+ clear=True,
82
+ ),
83
+ patch("vllm.platforms.load_plugins_by_group", return_value={}),
84
+ patch("vllm.platforms.vllm_version_matches_substr", return_value=True),
85
+ patch("vllm.platforms._is_amd_zen_cpu", return_value=True),
86
+ patch.object(builtins, "__import__", side_effect=import_with_broken_zentorch),
87
+ caplog.at_level(logging.DEBUG, logger="vllm.platforms"),
88
+ ):
89
+ platform = resolve_current_platform_cls_qualname()
90
+
91
+ assert platform == "vllm.platforms.interface.UnspecifiedPlatform"
92
+ assert "Platform plugin cpu failed during detection" in caplog.text
93
+ assert "OSError: incompatible shared library" in caplog.text
vllm/platforms/__init__.py
+5
-1
@@ -251,7 +251,11 @@ def resolve_current_platform_cls_qualname() -> str:
251
if platform_cls_qualname is not None:
252
activated_plugins.append(name)
253
except Exception:
254
- pass
254
+ logger.debug(
255
+ "Platform plugin %s failed during detection.",
256
+ name,
257
+ exc_info=True,
258
+ )
259
260
activated_builtin_plugins = list(
261
set(activated_plugins) & set(builtin_platform_plugins.keys())