[ci][build] add tests for python only compilation (#10915)
Signed-off-by: youkaichao <youkaichao@gmail.com>
This commit is contained in:
28
tests/standalone_tests/lazy_torch_compile.py
Normal file
28
tests/standalone_tests/lazy_torch_compile.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# Description: Test the lazy import module
|
||||
# The utility function cannot be placed in `vllm.utils`
|
||||
# this needs to be a standalone script
|
||||
import sys
|
||||
from contextlib import nullcontext
|
||||
|
||||
from vllm_test_utils import BlameResult, blame
|
||||
|
||||
module_name = "torch._inductor.async_compile"
|
||||
|
||||
# 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
|
||||
|
||||
if use_blame:
|
||||
assert isinstance(result, BlameResult)
|
||||
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`.")
|
||||
30
tests/standalone_tests/python_only_compile.sh
Normal file
30
tests/standalone_tests/python_only_compile.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
# This script tests if the python only compilation works correctly
|
||||
# for users who do not have any compilers installed on their system
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
cd /vllm-workspace/
|
||||
|
||||
# uninstall vllm
|
||||
pip3 uninstall -y vllm
|
||||
# restore the original files
|
||||
mv test_docs/vllm ./vllm
|
||||
|
||||
# remove all compilers
|
||||
apt remove --purge build-essential -y
|
||||
apt autoremove -y
|
||||
|
||||
echo 'import os; os.system("touch /tmp/changed.file")' >> vllm/__init__.py
|
||||
|
||||
VLLM_USE_PRECOMPILED=1 pip3 install -vvv -e .
|
||||
|
||||
# Run the script
|
||||
python3 -c 'import vllm'
|
||||
|
||||
# Check if the clangd log file was created
|
||||
if [ ! -f /tmp/changed.file ]; then
|
||||
echo "changed.file was not created, python only compilation failed"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user