Record CUDA benchmark diagnostics

This commit is contained in:
Dobromir Popov
2026-07-01 10:57:44 +02:00
parent c4a63d9461
commit 2d833432bc
4 changed files with 88 additions and 9 deletions

View File

@@ -192,7 +192,7 @@ def detect_hardware() -> dict:
}
def benchmark_throughput(device_str: str = "cpu") -> float:
def benchmark_throughput_checked(device_str: str = "cpu") -> tuple[float, bool, str | None]:
"""
Estimate compute throughput via a synthetic transformer GEMM benchmark.
@@ -201,7 +201,8 @@ def benchmark_throughput(device_str: str = "cpu") -> float:
The value is used as benchmark_tokens_per_sec in tracker registration for
routing tiebreaks; it is not an absolute token rate.
Falls back to 1.0 if torch is unavailable.
Returns (score, ok, error). Score falls back to 1.0 when the requested
device cannot run the benchmark.
"""
try:
import torch # type: ignore[import]
@@ -233,6 +234,12 @@ def benchmark_throughput(device_str: str = "cpu") -> float:
_sync()
elapsed = time.perf_counter() - t0
return round(n_iters / max(elapsed, 1e-9), 2)
except Exception:
return 1.0
return round(n_iters / max(elapsed, 1e-9), 2), True, None
except Exception as exc:
return 1.0, False, f"{type(exc).__name__}: {exc}"
def benchmark_throughput(device_str: str = "cpu") -> float:
"""Return only the numeric throughput index, preserving the legacy API."""
score, _ok, _error = benchmark_throughput_checked(device_str)
return score