Record CUDA benchmark diagnostics
This commit is contained in:
@@ -14,6 +14,6 @@ def _stub_benchmark_throughput(monkeypatch):
|
||||
"""
|
||||
try:
|
||||
import meshnet_node.startup as startup_mod
|
||||
monkeypatch.setattr(startup_mod, "benchmark_throughput", lambda _device: 999.0)
|
||||
monkeypatch.setattr(startup_mod, "benchmark_throughput_checked", lambda _device: (999.0, True, None))
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -173,7 +173,7 @@ def test_benchmark_throughput_is_registered_in_payload(monkeypatch, tmp_path):
|
||||
|
||||
monkeypatch.setattr(startup_mod, "detect_hardware",
|
||||
lambda: {"device": "cpu", "gpu_name": None, "vram_mb": 0, "ram_mb": 16384})
|
||||
monkeypatch.setattr(startup_mod, "benchmark_throughput", lambda _device: 42.5)
|
||||
monkeypatch.setattr(startup_mod, "benchmark_throughput_checked", lambda _device: (42.5, True, None))
|
||||
monkeypatch.setattr(startup_mod, "TorchNodeServer", lambda **_kw: FakeNode())
|
||||
monkeypatch.setattr(startup_mod, "_detect_num_layers", lambda _model_id: 24)
|
||||
monkeypatch.setattr(startup_mod, "RelayHttpBridge", None)
|
||||
@@ -193,6 +193,67 @@ def test_benchmark_throughput_is_registered_in_payload(monkeypatch, tmp_path):
|
||||
node.stop()
|
||||
|
||||
assert captured.get("benchmark_tokens_per_sec") == 42.5
|
||||
assert captured["hardware_profile"]["benchmark_device"] == "cpu"
|
||||
assert captured["hardware_profile"]["benchmark_ok"] is True
|
||||
|
||||
|
||||
def test_cuda_benchmark_failure_is_registered_for_inventory_only_gpu(monkeypatch, tmp_path, capsys):
|
||||
import meshnet_node.startup as startup_mod
|
||||
|
||||
captured: dict = {}
|
||||
|
||||
class FakeNode:
|
||||
backend = None
|
||||
|
||||
def start(self):
|
||||
return 7099
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
def fake_benchmark(device):
|
||||
if device == "cuda":
|
||||
return 1.0, False, "AssertionError: Torch not compiled with CUDA enabled"
|
||||
return 55.0, True, None
|
||||
|
||||
monkeypatch.setattr(
|
||||
startup_mod,
|
||||
"detect_hardware",
|
||||
lambda: {
|
||||
"device": "cpu",
|
||||
"gpu_name": "NVIDIA GeForce RTX 4060 Laptop GPU",
|
||||
"vram_mb": 8188,
|
||||
"dedicated_vram_mb": 8188,
|
||||
"shared_vram_mb": 40555,
|
||||
"ram_mb": 81111,
|
||||
"cuda_available": False,
|
||||
},
|
||||
)
|
||||
monkeypatch.setattr(startup_mod, "benchmark_throughput_checked", fake_benchmark)
|
||||
monkeypatch.setattr(startup_mod, "TorchNodeServer", lambda **_kw: FakeNode())
|
||||
monkeypatch.setattr(startup_mod, "_post_json",
|
||||
lambda _url, payload, timeout=10.0: (captured.update(payload) or {"node_id": "x"}))
|
||||
monkeypatch.setattr(startup_mod, "_start_heartbeat", lambda *a, **kw: None)
|
||||
|
||||
node = run_startup(
|
||||
tracker_url="http://localhost:8080",
|
||||
model_id="Qwen/Qwen2.5-0.5B-Instruct",
|
||||
shard_start=0,
|
||||
shard_end=23,
|
||||
wallet_path=tmp_path / "wallet.json",
|
||||
)
|
||||
node.stop()
|
||||
|
||||
output = capsys.readouterr().out
|
||||
assert "CUDA benchmark unavailable" in output
|
||||
assert "Hardware: CPU (CUDA inactive)" in output
|
||||
hw = captured["hardware_profile"]
|
||||
assert hw["cuda_benchmark_ok"] is False
|
||||
assert "Torch not compiled with CUDA enabled" in hw["cuda_benchmark_error"]
|
||||
assert hw["benchmark_device"] == "cpu"
|
||||
assert hw["benchmark_ok"] is True
|
||||
assert captured["ram_bytes"] == 81111 * 1024 * 1024
|
||||
assert captured["vram_bytes"] == 0
|
||||
|
||||
|
||||
def test_wallet_generates_new_keypair(tmp_path):
|
||||
|
||||
Reference in New Issue
Block a user