- collect-env.sh: ReBAR from the GPU's largest BAR (same rule as GGZ14/BetterBench#4), weight size of the model, docker image ID, memory bandwidth measured with mem-bw.py (torch copy of random data inside the server's container; clpeak as fallback) - bench.sh: notes for mem_bw (measured + declared), launch settings (llama.cpp b/ub/fa/ctk/ctv/..., vLLM batching/KV/compilation), env_flags and a temp-0 greedy check with output hash - gpu-power.sh: power, energy counter and clock during the run; post-run energy per token, avg clock/watts and % of memory bandwidth go to meta.json and a terminal summary - short output by default, --verbose for BetterBench's full stream; full output always in betterbench.log - cross-check BetterBench#4's own env.gpu.pci against collect-env.sh Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
"""mem-bw.py - measured GPU memory bandwidth with torch, printed as "GBPS MIB".
|
|
|
|
Copies a buffer of random floats 20 times and counts read + write. Random
|
|
data on purpose: Arc compresses uniform buffers, so a zero-filled test reads
|
|
far too high (1227 GB/s with zeros vs 533 GB/s real on a B70). Best of three
|
|
rounds. Tries 1 GiB, then smaller buffers when the inference server has taken
|
|
most of the VRAM. Prints nothing when there is no usable GPU.
|
|
|
|
Runs with any python that has torch for the GPU: collect-env.sh runs it inside
|
|
the server's own container (docker exec), or with $BW_PYTHON.
|
|
"""
|
|
import sys
|
|
import time
|
|
|
|
import torch
|
|
|
|
if hasattr(torch, "xpu") and torch.xpu.is_available():
|
|
dev, sync = "xpu", torch.xpu.synchronize
|
|
elif torch.cuda.is_available(): # NVIDIA, and AMD through ROCm
|
|
dev, sync = "cuda", torch.cuda.synchronize
|
|
else:
|
|
sys.exit(0)
|
|
|
|
for mib in (1024, 512, 256):
|
|
try:
|
|
x = torch.rand(mib * 2**20 // 4, device=dev)
|
|
y = torch.empty_like(x)
|
|
break
|
|
except RuntimeError: # out of memory
|
|
continue
|
|
else:
|
|
sys.exit(0)
|
|
|
|
y.copy_(x)
|
|
sync()
|
|
best = 0.0
|
|
for _ in range(3):
|
|
t = time.perf_counter()
|
|
for _ in range(20):
|
|
y.copy_(x)
|
|
sync()
|
|
best = max(best, 20 * 2 * x.numel() * 4 / (time.perf_counter() - t) / 1e9)
|
|
print(f"{best:.0f} {mib}")
|