mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-13 22:04:58 +08:00
[ci] fix slow tests (#10698)
Signed-off-by: youkaichao <youkaichao@gmail.com>
This commit is contained in:
parent
9e0a147d50
commit
308cc5e21e
@ -1,6 +1,7 @@
|
|||||||
import sys
|
import sys
|
||||||
|
from contextlib import nullcontext
|
||||||
|
|
||||||
from vllm_test_utils import blame
|
from vllm_test_utils import BlameResult, blame
|
||||||
|
|
||||||
from vllm import LLM, SamplingParams
|
from vllm import LLM, SamplingParams
|
||||||
from vllm.distributed import cleanup_dist_env_and_memory
|
from vllm.distributed import cleanup_dist_env_and_memory
|
||||||
@ -56,9 +57,20 @@ def test_lazy_outlines(sample_regex):
|
|||||||
"""
|
"""
|
||||||
# make sure outlines is not imported
|
# make sure outlines is not imported
|
||||||
module_name = "outlines"
|
module_name = "outlines"
|
||||||
with blame(lambda: module_name in sys.modules) as result:
|
# In CI, we only check finally if the module is imported.
|
||||||
|
# If it is indeed imported, we can rerun the test with `use_blame=True`,
|
||||||
|
# which will trace every function call to find the first import location,
|
||||||
|
# and help find the root cause.
|
||||||
|
# We don't run it in CI by default because it is slow.
|
||||||
|
use_blame = False
|
||||||
|
context = blame(
|
||||||
|
lambda: module_name in sys.modules) if use_blame else nullcontext()
|
||||||
|
with context as result:
|
||||||
run_normal()
|
run_normal()
|
||||||
run_lmfe(sample_regex)
|
run_lmfe(sample_regex)
|
||||||
assert not result.found, (
|
if use_blame:
|
||||||
f"Module {module_name} is already imported, the"
|
assert isinstance(result, BlameResult)
|
||||||
f" first import location is:\n{result.trace_stack}")
|
print(f"the first import location is:\n{result.trace_stack}")
|
||||||
|
assert module_name not in sys.modules, (
|
||||||
|
f"Module {module_name} is imported. To see the first"
|
||||||
|
f" import location, run the test with `use_blame=True`.")
|
||||||
|
|||||||
@ -2,15 +2,27 @@
|
|||||||
# The utility function cannot be placed in `vllm.utils`
|
# The utility function cannot be placed in `vllm.utils`
|
||||||
# this needs to be a standalone script
|
# this needs to be a standalone script
|
||||||
import sys
|
import sys
|
||||||
|
from contextlib import nullcontext
|
||||||
|
|
||||||
from vllm_test_utils import blame
|
from vllm_test_utils import BlameResult, blame
|
||||||
|
|
||||||
module_name = "torch._inductor.async_compile"
|
module_name = "torch._inductor.async_compile"
|
||||||
|
|
||||||
with blame(lambda: module_name in sys.modules) as result:
|
# In CI, we only check finally if the module is imported.
|
||||||
|
# If it is indeed imported, we can rerun the test with `use_blame=True`,
|
||||||
|
# which will trace every function call to find the first import location,
|
||||||
|
# and help find the root cause.
|
||||||
|
# We don't run it in CI by default because it is slow.
|
||||||
|
use_blame = False
|
||||||
|
context = blame(
|
||||||
|
lambda: module_name in sys.modules) if use_blame else nullcontext()
|
||||||
|
with context as result:
|
||||||
import vllm # noqa
|
import vllm # noqa
|
||||||
|
|
||||||
assert not result.found, (f"Module {module_name} is already imported, the"
|
if use_blame:
|
||||||
f" first import location is:\n{result.trace_stack}")
|
assert isinstance(result, BlameResult)
|
||||||
|
print(f"the first import location is:\n{result.trace_stack}")
|
||||||
|
|
||||||
print(f"Module {module_name} is not imported yet")
|
assert module_name not in sys.modules, (
|
||||||
|
f"Module {module_name} is imported. To see the first"
|
||||||
|
f" import location, run the test with `use_blame=True`.")
|
||||||
|
|||||||
@ -46,8 +46,8 @@ def blame(func: Callable) -> Generator[BlameResult, None, None]:
|
|||||||
pass
|
pass
|
||||||
return _trace_calls
|
return _trace_calls
|
||||||
|
|
||||||
sys.settrace(_trace_calls)
|
try:
|
||||||
|
sys.settrace(_trace_calls)
|
||||||
yield result
|
yield result
|
||||||
|
finally:
|
||||||
sys.settrace(None)
|
sys.settrace(None)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user