[XPU][Tests] Make tests device-agnostic (#51968)

Signed-off-by: pmanczak <pawel.manczak@intel.com>
This commit is contained in:
pmanczak
2026-08-20 02:25:41 -07:00
committed by GitHub
parent 38e9cefdef
commit 44cf3f0466
12 changed files with 148 additions and 111 deletions
+6 -7
View File
@@ -284,19 +284,18 @@ def cleanup_fixture(should_do_global_cleanup_after_test: bool):
def workspace_init():
"""Initialize the workspace manager for tests that need it.
This fixture initializes the workspace manager with a CUDA device
if available, and resets it after the test completes. Tests that
create a full vLLM engine should NOT use this fixture as the engine
will initialize the workspace manager itself.
This fixture initializes the workspace manager with the current
platform's accelerator device if available, and resets it after the test
completes. Tests that create a full vLLM engine should NOT use this
fixture as the engine will initialize the workspace manager itself.
"""
from vllm.v1.worker.workspace import (
init_workspace_manager,
reset_workspace_manager,
)
if torch.cuda.is_available():
device = torch.device("cuda:0")
init_workspace_manager(device)
if torch.accelerator.is_available():
init_workspace_manager(torch.device(0))
yield
reset_workspace_manager()