[ROCm][CI] Select CPU platform for native no-GPU jobs (#49515)
Signed-off-by: Andreas Karatzas <Andreas.Karatzas@amd.com>
Andreas Karatzas committed
Aug 15, 2026 at 01:30 UTC
44fc57d7b72eafaaefdcb0983451e08648be4d49
3 files changed
+60
-15
.buildkite/scripts/hardware_ci/run-amd-test.sh
+6
@@ -434,6 +434,12 @@ initialize_native_environment() {
434
TIKTOKEN_RS_CACHE_DIR="${HF_HOME}/tiktoken-rs-cache"
435
: "${HF_HUB_DOWNLOAD_TIMEOUT:=300}"
436
: "${HF_HUB_ETAG_TIMEOUT:=60}"
437
+ if [[ "${VLLM_CI_EXPECTED_GPU_COUNT:-1}" == "0" ]]; then
438
+ # CPU-only native jobs intentionally reuse the ROCm wheel. Make that target
439
+ # explicit so platform selection does not depend on wheel metadata.
440
+ VLLM_TARGET_DEVICE=cpu
441
+ export VLLM_TARGET_DEVICE
442
+ fi
443
export TMPDIR VLLM_RPC_BASE_PATH
444
export TORCHINDUCTOR_CACHE_DIR TRITON_CACHE_DIR VLLM_CACHE_ROOT XDG_CACHE_HOME
445
export HF_HOME HF_DATASETS_CACHE HF_HUB_DOWNLOAD_TIMEOUT HF_HUB_ETAG_TIMEOUT
tests/test_zen_cpu_platform_detection.py
+23
-1
@@ -2,7 +2,9 @@
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
from unittest.mock import mock_open, patch
4
5
-from vllm.platforms import _is_amd_zen_cpu
5
+import pytest
6
+
7
+from vllm.platforms import _is_amd_zen_cpu, resolve_current_platform_cls_qualname
8
9
10
def test_is_amd_zen_cpu_detects_amd_with_avx512():
@@ -35,3 +37,23 @@ def test_is_amd_zen_cpu_returns_false_for_intel_with_avx512():
37
def test_is_amd_zen_cpu_returns_false_when_cpuinfo_missing():
38
with patch("os.path.exists", return_value=False):
39
assert not _is_amd_zen_cpu()
40
+
41
+
42
+def test_cpu_target_selects_cpu_platform_from_non_cpu_wheel(
43
+ monkeypatch: pytest.MonkeyPatch,
44
+):
45
+ monkeypatch.setenv("VLLM_TARGET_DEVICE", "cpu")
46
+
47
+ with (
48
+ patch("vllm.platforms.vllm_version_matches_substr") as version_matches,
49
+ patch("vllm.platforms._is_amd_zen_cpu", return_value=False),
50
+ patch("vllm.platforms.rocm_platform_plugin") as rocm_plugin,
51
+ ):
52
+ assert (
53
+ resolve_current_platform_cls_qualname() == "vllm.platforms.cpu.CpuPlatform"
54
+ )
55
+
56
+ # An explicit target does not depend on the installed wheel's version
57
+ # suffix or host accelerators (a native CI job can reuse a ROCm wheel).
58
+ version_matches.assert_not_called()
59
+ rocm_plugin.assert_not_called()
vllm/platforms/__init__.py
+31
-14
@@ -160,24 +160,32 @@ def _is_amd_zen_cpu() -> bool:
160
161
162
def cpu_platform_plugin() -> str | None:
163
- is_cpu = False
163
logger.debug("Checking if CPU platform is available.")
165
- try:
166
- is_cpu = vllm_version_matches_substr("cpu")
167
- if is_cpu:
168
- logger.debug(
169
- "Confirmed CPU platform is available because vLLM is built with CPU."
170
- )
171
- if not is_cpu:
172
- import sys
173
-
174
- is_cpu = sys.platform.startswith("darwin")
164
+ is_cpu = envs.VLLM_TARGET_DEVICE == "cpu"
165
+ if is_cpu:
166
+ logger.debug(
167
+ "Confirmed CPU platform is available because "
168
+ "VLLM_TARGET_DEVICE is set to CPU."
169
+ )
170
+ else:
171
+ try:
172
+ is_cpu = vllm_version_matches_substr("cpu")
173
if is_cpu:
174
logger.debug(
177
- "Confirmed CPU platform is available because the machine is MacOS."
175
+ "Confirmed CPU platform is available because vLLM is built "
176
+ "with CPU."
177
)
179
- except Exception as e:
180
- logger.debug("CPU platform is not available because: %s", str(e))
178
+ if not is_cpu:
179
+ import sys
180
+
181
+ is_cpu = sys.platform.startswith("darwin")
182
+ if is_cpu:
183
+ logger.debug(
184
+ "Confirmed CPU platform is available because the machine "
185
+ "is MacOS."
186
+ )
187
+ except Exception as e:
188
+ logger.debug("CPU platform is not available because: %s", str(e))
189
190
if not is_cpu:
191
return None
@@ -209,6 +217,15 @@ builtin_platform_plugins = {
217
218
219
def resolve_current_platform_cls_qualname() -> str:
220
+ # An explicit CPU target is authoritative. Native CPU-only CI jobs reuse
221
+ # an accelerator wheel and can run on accelerator hosts, so probing every
222
+ # plugin would otherwise activate both CPU and the host accelerator.
223
+ if envs.VLLM_TARGET_DEVICE == "cpu":
224
+ cpu_platform_cls_qualname = cpu_platform_plugin()
225
+ assert cpu_platform_cls_qualname is not None
226
+ logger.debug("Explicitly selected CPU platform.")
227
+ return cpu_platform_cls_qualname
228
+
229
platform_plugins = load_plugins_by_group(PLATFORM_PLUGINS_GROUP)
230
231
activated_plugins = []