|
26 | 26 | from vllm.distributed.kv_transfer.kv_connector.v1.nixl_connector import ( |
27 | 27 | KVConnectorRole, NixlAgentMetadata, NixlConnector, NixlConnectorMetadata, |
28 | 28 | NixlConnectorWorker, NixlKVConnectorStats) |
| 29 | +from vllm.distributed.kv_transfer.kv_transfer_state import ( |
| 30 | + ensure_kv_transfer_shutdown, has_kv_transfer_group) |
29 | 31 | from vllm.forward_context import ForwardContext |
30 | 32 | from vllm.platforms.interface import Platform |
31 | 33 | from vllm.sampling_params import SamplingParams |
|
35 | 37 | from .utils import create_request, create_scheduler, create_vllm_config |
36 | 38 |
|
37 | 39 |
|
| 40 | +@pytest.fixture(scope="module", autouse=True) |
| 41 | +def clear_kv_transfer(): |
| 42 | + """ |
| 43 | + The test cases in this file use `VLLM_ENABLE_V1_MULTIPROCESSING=0`, |
| 44 | + causing the global variable `_KV_CONNECTOR_AGENT` |
| 45 | + to be assigned but never deleted. |
| 46 | +
|
| 47 | + Since the current pytest process does not terminate and instead |
| 48 | + continues running tests from other files, |
| 49 | + this global variable remains in memory and interferes |
| 50 | + with test cases in other modules. |
| 51 | + |
| 52 | + So we use this fixture to ensure that the global variable |
| 53 | + `_KV_CONNECTOR_AGENT` is properly cleaned up after each test. |
| 54 | + """ |
| 55 | + yield |
| 56 | + if has_kv_transfer_group(): |
| 57 | + ensure_kv_transfer_shutdown() |
| 58 | + |
| 59 | + |
38 | 60 | class FakeNixlWrapper: |
39 | 61 | """Mock implementation of NixlWrapper for testing. |
40 | 62 |
|
|
0 commit comments