ROCm HW support
This commit is contained in:
@@ -128,6 +128,59 @@ def test_nvidia_smi_without_torch_cuda_keeps_cpu_execution(monkeypatch):
|
||||
assert hw["ram_mb"] == 80 * 1024
|
||||
|
||||
|
||||
def test_torch_rocm_inventory_is_reported_when_kernels_are_not_executable(monkeypatch):
|
||||
"""ROCm can expose GPU metadata even when this torch wheel cannot run kernels."""
|
||||
import meshnet_node.hardware as hardware_mod
|
||||
|
||||
class FakeProps:
|
||||
total_memory = 64 * 1024 * 1024 * 1024
|
||||
gcnArchName = "gfx1151"
|
||||
|
||||
class FakeCuda:
|
||||
@staticmethod
|
||||
def is_available():
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def device_count():
|
||||
return 1
|
||||
|
||||
@staticmethod
|
||||
def current_device():
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def get_device_name(_idx):
|
||||
return "AMD Radeon 8060S"
|
||||
|
||||
@staticmethod
|
||||
def get_device_properties(_idx):
|
||||
return FakeProps()
|
||||
|
||||
@staticmethod
|
||||
def synchronize():
|
||||
raise AssertionError("synchronize should not run after empty() fails")
|
||||
|
||||
fake_torch = types.SimpleNamespace(
|
||||
cuda=FakeCuda(),
|
||||
empty=lambda *args, **kwargs: (_ for _ in ()).throw(
|
||||
RuntimeError("HIP error: invalid device function")
|
||||
),
|
||||
)
|
||||
|
||||
monkeypatch.setattr(hardware_mod, "_detect_ram_mb", lambda: 125 * 1024)
|
||||
monkeypatch.setitem(sys.modules, "torch", fake_torch)
|
||||
|
||||
hw = hardware_mod.detect_hardware()
|
||||
|
||||
assert hw["device"] == "cpu"
|
||||
assert hw["cuda_available"] is False
|
||||
assert hw["gpu_name"] == "AMD Radeon 8060S"
|
||||
assert hw["vram_mb"] == 64 * 1024
|
||||
assert hw["shared_vram_mb"] == 64_000
|
||||
assert hw["gcn_arch"] == "gfx1151"
|
||||
|
||||
|
||||
def test_memory_budget_uses_ram_for_cpu_and_shared_memory_for_cuda():
|
||||
assert _memory_budget("cpu", vram_mb=8192, ram_mb=80 * 1024, shared_vram_mb=40 * 1024) == (
|
||||
80 * 1024,
|
||||
|
||||
@@ -24,6 +24,7 @@ from meshnet_node.model_backend import (
|
||||
_should_partial_materialize_shard,
|
||||
_decoder_attention_mask,
|
||||
_int_tensor_header,
|
||||
_torch_cuda_is_executable,
|
||||
build_quantization_config,
|
||||
validate_quantization,
|
||||
)
|
||||
@@ -209,6 +210,26 @@ def test_bitsandbytes_configs_are_created_lazily(monkeypatch):
|
||||
]
|
||||
|
||||
|
||||
def test_rocm_inventory_without_executable_kernels_is_not_used_as_cuda():
|
||||
class FakeCuda:
|
||||
@staticmethod
|
||||
def is_available():
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def synchronize():
|
||||
raise AssertionError("synchronize should not run after empty() fails")
|
||||
|
||||
fake_torch = types.SimpleNamespace(
|
||||
cuda=FakeCuda(),
|
||||
empty=lambda *args, **kwargs: (_ for _ in ()).throw(
|
||||
RuntimeError("HIP error: invalid device function")
|
||||
),
|
||||
)
|
||||
|
||||
assert _torch_cuda_is_executable(fake_torch) is False
|
||||
|
||||
|
||||
def test_head_forward_accepts_text_prompt_and_returns_bfloat16_activations():
|
||||
node = TorchNodeServer(backend=_FakeBackend())
|
||||
port = node.start()
|
||||
|
||||
Reference in New Issue
Block a user