@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / eb69d68804
Fork 0

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 17, 03:00 UTC

[Misc] [CI/Build] Speed up block manager CPU-only unit tests ~10x by opting-out of GPU cleanup (#3783)

Cade Daniel committed Apr 1, 2024 at 17:49 UTC eb69d68804840b1108608316fe643e6a74ae44d0
3 files changed +25 -18
tests/conftest.py
+12 -2
@@ -55,10 +55,20 @@ def cleanup():
55 torch.cuda.empty_cache()
56
57
58 +@pytest.fixture()
59 +def should_do_global_cleanup_after_test() -> bool:
60 + """Allow subdirectories to skip global cleanup by overriding this fixture.
61 + This can provide a ~10x speedup for non-GPU unit tests since they don't need
62 + to initialize torch.
63 + """
64 + return True
65 +
66 +
67 @pytest.fixture(autouse=True)
59 -def cleanup_fixture():
68 +def cleanup_fixture(should_do_global_cleanup_after_test: bool):
69 yield
61 - cleanup()
70 + if should_do_global_cleanup_after_test:
71 + cleanup()
72
73
74 @pytest.fixture(scope="session")
tests/core/block/conftest.py new
+12
@@ -0,0 +1,12 @@
1 +import pytest
2 +
3 +
4 +@pytest.fixture()
5 +def should_do_global_cleanup_after_test() -> bool:
6 + """Disable the global cleanup fixture for tests in this directory. This
7 + provides a ~10x speedup for unit tests that don't load a model to GPU.
8 +
9 + This requires that tests in this directory clean up after themselves if they
10 + use the GPU.
11 + """
12 + return False
tests/core/block/e2e/conftest.py
+1 -16
@@ -1,25 +1,10 @@
1 -import contextlib
2 -import gc
3 -
1 import pytest
5 -import ray
6 -import torch
2
3 +from tests.conftest import cleanup
4 from vllm import LLM
9 -from vllm.model_executor.parallel_utils.parallel_state import (
10 - destroy_model_parallel)
5 from vllm.model_executor.utils import set_random_seed
6
7
14 -def cleanup():
15 - destroy_model_parallel()
16 - with contextlib.suppress(AssertionError):
17 - torch.distributed.destroy_process_group()
18 - gc.collect()
19 - torch.cuda.empty_cache()
20 - ray.shutdown()
21 -
22 -
8 @pytest.fixture
9 def baseline_llm_generator(common_llm_kwargs, per_test_common_llm_kwargs,
10 baseline_llm_kwargs, seed):