forked from vllm-project/vllm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bugfix]: Fix Tensorizer test failures (vllm-project#6835)
- Loading branch information
Showing
3 changed files
with
47 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# isort: skip_file | ||
|
||
import contextlib | ||
import gc | ||
|
||
import pytest | ||
import ray | ||
import torch | ||
|
||
from vllm.distributed import (destroy_distributed_environment, | ||
destroy_model_parallel) | ||
from vllm.model_executor.model_loader.tensorizer import TensorizerConfig | ||
|
||
|
||
def cleanup(): | ||
destroy_model_parallel() | ||
destroy_distributed_environment() | ||
with contextlib.suppress(AssertionError): | ||
torch.distributed.destroy_process_group() | ||
gc.collect() | ||
torch.cuda.empty_cache() | ||
ray.shutdown() | ||
|
||
|
||
@pytest.fixture() | ||
def should_do_global_cleanup_after_test(request) -> bool: | ||
"""Allow subdirectories to skip global cleanup by overriding this fixture. | ||
This can provide a ~10x speedup for non-GPU unit tests since they don't need | ||
to initialize torch. | ||
""" | ||
|
||
return True | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def cleanup_fixture(should_do_global_cleanup_after_test: bool): | ||
yield | ||
if should_do_global_cleanup_after_test: | ||
cleanup() | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def tensorizer_config(): | ||
config = TensorizerConfig(tensorizer_uri="vllm") | ||
return config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters