CoolFace
Modelpublic

dougvk/Unlimited-OCR-RDNA4

sourceHugging Facemitupdated 2mo agoView on Hugging Face
0likes
test_runtime.py44 linesDownload Raw Back to tests
1import os2import sys3 4import pytest5 6from unlimited_ocr_rdna4.errors import RuntimeEnvironmentError7from unlimited_ocr_rdna4.runtime import DeviceInfo, RuntimeInfo, select_device8 9 10def test_runtime_info_serializes() -> None:11    info = RuntimeInfo(12        torch_version="2.9.1+rocm7.2.1",13        hip_version="7.2",14        cuda_available=True,15        bf16_supported=True,16        visible_devices=1,17        devices=(DeviceInfo(0, "AMD Radeon RX 9070 XT", "gfx1201", "uuid"),),18        package_versions={"torch": "different"},19        accepted_architecture=True,20        hardware_verified=True,21        software_verified=False,22        warnings=("different stack",),23    )24    payload = info.to_dict()25    assert payload["devices"][0]["architecture"] == "gfx1201"26    assert payload["hardware_verified"] is True27    assert payload["software_verified"] is False28 29 30def test_device_selection_rejects_conflicting_visibility(monkeypatch) -> None:31    monkeypatch.delitem(sys.modules, "torch", raising=False)32    monkeypatch.setenv("HIP_VISIBLE_DEVICES", "2")33    with pytest.raises(RuntimeEnvironmentError, match="HIP_VISIBLE_DEVICES"):34        select_device("GPU-example")35 36 37def test_device_selection_preserves_matching_rocr_value(monkeypatch) -> None:38    monkeypatch.delitem(sys.modules, "torch", raising=False)39    monkeypatch.delenv("HIP_VISIBLE_DEVICES", raising=False)40    monkeypatch.delenv("CUDA_VISIBLE_DEVICES", raising=False)41    monkeypatch.setenv("ROCR_VISIBLE_DEVICES", "GPU-example")42    select_device("GPU-example")43    assert os.environ["ROCR_VISIBLE_DEVICES"] == "GPU-example"44