A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 10, 04:00 UTC
[CI/Build][Hardware][AMD] Fix v1/shutdown (#31997)
Signed-off-by: Ryan Rock <ryan.rock@amd.com>
Ryan Rock committed
Jan 14, 2026 at 22:01 UTC
15422ed3f748b2c26a9446db388979027a254199
3 files changed
+64
-3
tests/v1/shutdown/conftest.py
new
+26
@@ -0,0 +1,26 @@
1
+# SPDX-License-Identifier: Apache-2.0
2
+# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+import os
4
+from collections.abc import Iterable
5
+from pathlib import Path
6
+
7
+import pytest
8
+
9
+from vllm.platforms import current_platform
10
+
11
+
12
+@pytest.fixture
13
+def rocm_sitecustomize_factory(monkeypatch, tmp_path: Path):
14
+ """Return a function that installs a given sitecustomize payload."""
15
+ if not current_platform.is_rocm():
16
+ return lambda _: None
17
+
18
+ def install(lines: Iterable[str]) -> None:
19
+ sc = tmp_path / "sitecustomize.py"
20
+ sc.write_text("\n".join(lines) + "\n")
21
+ monkeypatch.setenv(
22
+ "PYTHONPATH",
23
+ os.pathsep.join(filter(None, [str(tmp_path), os.getenv("PYTHONPATH")])),
24
+ )
25
+
26
+ return install
tests/v1/shutdown/test_forward_error.py
+18
-2
@@ -3,6 +3,7 @@
3
"""Test that we handle an Error in model forward and shutdown."""
4
5
import asyncio
6
+import inspect
7
8
import pytest
9
@@ -38,11 +39,22 @@ def evil_forward(self, *args, **kwargs):
39
return self.model(*args, **kwargs)
40
41
42
+@pytest.fixture
43
+def rocm_evil_forward(rocm_sitecustomize_factory):
44
+ lines = [
45
+ "from vllm.distributed import get_tensor_model_parallel_rank",
46
+ "from vllm.model_executor.models.llama import LlamaForCausalLM",
47
+ inspect.getsource(evil_forward),
48
+ f"LlamaForCausalLM.forward = {evil_forward.__name__}",
49
+ ]
50
+ rocm_sitecustomize_factory(lines)
51
+
52
+
53
@pytest.mark.asyncio
54
@pytest.mark.parametrize("tensor_parallel_size", [2, 1])
55
@pytest.mark.parametrize("model", MODELS)
56
async def test_async_llm_model_error(
45
- monkeypatch, tensor_parallel_size: int, model: str
57
+ monkeypatch, rocm_evil_forward, tensor_parallel_size: int, model: str
58
) -> None:
59
"""Test that AsyncLLM propagates a forward pass error and frees memory.
60
@@ -104,7 +116,11 @@ async def test_async_llm_model_error(
116
@pytest.mark.parametrize("tensor_parallel_size", [2, 1])
117
@pytest.mark.parametrize("model", MODELS)
118
def test_llm_model_error(
107
- monkeypatch, tensor_parallel_size: int, enable_multiprocessing: bool, model: str
119
+ monkeypatch,
120
+ rocm_evil_forward,
121
+ tensor_parallel_size: int,
122
+ enable_multiprocessing: bool,
123
+ model: str,
124
) -> None:
125
"""Test that LLM propagates a forward pass error and frees memory.
126
TODO(andy) - LLM without multiprocessing; LLM with multiprocessing
tests/v1/shutdown/test_startup_error.py
+20
-1
@@ -2,6 +2,8 @@
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
"""Test that we handle a startup Error and shutdown."""
4
5
+import inspect
6
+
7
import pytest
8
9
from tests.utils import wait_for_gpu_memory_to_clear
@@ -28,12 +30,28 @@ def evil_method(self, *args, **kwargs):
30
return self.model(*args, **kwargs, intermediate_tensors=None)
31
32
33
+@pytest.fixture
34
+def rocm_evil_method(rocm_sitecustomize_factory, request):
35
+ failing_method = request.getfixturevalue("failing_method")
36
+ lines = [
37
+ "from vllm.distributed import get_tensor_model_parallel_rank",
38
+ "from vllm.model_executor.models.llama import LlamaForCausalLM",
39
+ inspect.getsource(evil_method),
40
+ f"LlamaForCausalLM.{failing_method} = {evil_method.__name__}",
41
+ ]
42
+ rocm_sitecustomize_factory(lines)
43
+
44
+
45
@pytest.mark.timeout(SHUTDOWN_TEST_TIMEOUT_SEC)
46
@pytest.mark.parametrize("model", MODELS)
47
@pytest.mark.parametrize("tensor_parallel_size", [2, 1])
48
@pytest.mark.parametrize("failing_method", ["forward", "load_weights"])
49
def test_async_llm_startup_error(
36
- monkeypatch, model: str, tensor_parallel_size: int, failing_method: str
50
+ monkeypatch,
51
+ rocm_evil_method,
52
+ model: str,
53
+ tensor_parallel_size: int,
54
+ failing_method: str,
55
) -> None:
56
"""Test that AsyncLLM propagates an __init__ error & frees memory.
57
Test profiling (forward()) and load weights failures.
@@ -67,6 +85,7 @@ def test_async_llm_startup_error(
85
@pytest.mark.parametrize("failing_method", ["forward", "load_weights"])
86
def test_llm_startup_error(
87
monkeypatch,
88
+ rocm_evil_method,
89
model: str,
90
tensor_parallel_size: int,
91
enable_multiprocessing: bool,