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 16, 05:45 UTC
[ci] fix slow tests (#10698)
Signed-off-by: youkaichao <youkaichao@gmail.com>
youkaichao committed
Nov 27, 2024 at 09:26 UTC
308cc5e21e12fb0eea0a960d147dca7efc59d92f
3 files changed
+39
-15
tests/entrypoints/llm/test_lazy_outlines.py
+17
-5
@@ -1,6 +1,7 @@
1
import sys
2
+from contextlib import nullcontext
3
3
-from vllm_test_utils import blame
4
+from vllm_test_utils import BlameResult, blame
5
6
from vllm import LLM, SamplingParams
7
from vllm.distributed import cleanup_dist_env_and_memory
@@ -56,9 +57,20 @@ def test_lazy_outlines(sample_regex):
57
"""
58
# make sure outlines is not imported
59
module_name = "outlines"
59
- with blame(lambda: module_name in sys.modules) as result:
60
+ # In CI, we only check finally if the module is imported.
61
+ # If it is indeed imported, we can rerun the test with `use_blame=True`,
62
+ # which will trace every function call to find the first import location,
63
+ # and help find the root cause.
64
+ # We don't run it in CI by default because it is slow.
65
+ use_blame = False
66
+ context = blame(
67
+ lambda: module_name in sys.modules) if use_blame else nullcontext()
68
+ with context as result:
69
run_normal()
70
run_lmfe(sample_regex)
62
- assert not result.found, (
63
- f"Module {module_name} is already imported, the"
64
- f" first import location is:\n{result.trace_stack}")
71
+ if use_blame:
72
+ assert isinstance(result, BlameResult)
73
+ print(f"the first import location is:\n{result.trace_stack}")
74
+ assert module_name not in sys.modules, (
75
+ f"Module {module_name} is imported. To see the first"
76
+ f" import location, run the test with `use_blame=True`.")
tests/test_lazy_torch_compile.py
+17
-5
@@ -2,15 +2,27 @@
2
# The utility function cannot be placed in `vllm.utils`
3
# this needs to be a standalone script
4
import sys
5
+from contextlib import nullcontext
6
6
-from vllm_test_utils import blame
7
+from vllm_test_utils import BlameResult, blame
8
9
module_name = "torch._inductor.async_compile"
10
10
-with blame(lambda: module_name in sys.modules) as result:
11
+# In CI, we only check finally if the module is imported.
12
+# If it is indeed imported, we can rerun the test with `use_blame=True`,
13
+# which will trace every function call to find the first import location,
14
+# and help find the root cause.
15
+# We don't run it in CI by default because it is slow.
16
+use_blame = False
17
+context = blame(
18
+ lambda: module_name in sys.modules) if use_blame else nullcontext()
19
+with context as result:
20
import vllm # noqa
21
13
-assert not result.found, (f"Module {module_name} is already imported, the"
14
- f" first import location is:\n{result.trace_stack}")
22
+if use_blame:
23
+ assert isinstance(result, BlameResult)
24
+ print(f"the first import location is:\n{result.trace_stack}")
25
16
-print(f"Module {module_name} is not imported yet")
26
+assert module_name not in sys.modules, (
27
+ f"Module {module_name} is imported. To see the first"
28
+ f" import location, run the test with `use_blame=True`.")
tests/vllm_test_utils/vllm_test_utils/blame.py
+5
-5
@@ -46,8 +46,8 @@ def blame(func: Callable) -> Generator[BlameResult, None, None]:
46
pass
47
return _trace_calls
48
49
- sys.settrace(_trace_calls)
50
-
51
- yield result
52
-
53
- sys.settrace(None)
49
+ try:
50
+ sys.settrace(_trace_calls)
51
+ yield result
52
+ finally:
53
+ sys.settrace(None)