main
py 15 lines 490 Bytes
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 import pytest
4 import torch
5
6
7 @pytest.fixture(autouse=True)
8 def reset_default_torch_device():
9 """Several kernel tests call torch.set_default_device without restoring
10 it, which poisons subsequent tests in the same pytest run (e.g. CPU
11 tensors silently created on CUDA). Restore the factory default after
12 every test.
13 """
14 yield
15 torch.set_default_device(None)