-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathtest_device_utils.py
More file actions
24 lines (17 loc) · 1.1 KB
/
Copy pathtest_device_utils.py
File metadata and controls
24 lines (17 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pytest
import torch
from library import device_utils
def test_validate_cuda_device_compatibility_raises_for_unsupported_arch(monkeypatch):
monkeypatch.setattr(device_utils, "HAS_CUDA", True)
monkeypatch.setattr(torch.cuda, "get_arch_list", lambda: ["sm_80", "sm_90"])
monkeypatch.setattr(torch.cuda, "get_device_capability", lambda device=None: (12, 0))
monkeypatch.setattr(torch.cuda, "get_device_name", lambda device=None: "Blackwell Test GPU")
monkeypatch.setattr(torch.version, "cuda", "12.4", raising=False)
with pytest.raises(RuntimeError, match="sm_120"):
device_utils.validate_cuda_device_compatibility("cuda")
def test_validate_cuda_device_compatibility_allows_supported_arch(monkeypatch):
monkeypatch.setattr(device_utils, "HAS_CUDA", True)
monkeypatch.setattr(torch.cuda, "get_arch_list", lambda: ["sm_80", "sm_90"])
monkeypatch.setattr(torch.cuda, "get_device_capability", lambda device=None: (9, 0))
monkeypatch.setattr(torch.cuda, "get_device_name", lambda device=None: "Hopper Test GPU")
device_utils.validate_cuda_device_compatibility("cuda")