Files
leleka/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream.sh

49 lines
3.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Ledger row U5: kernel micro-benchmark of upstream Strata's hyper-connection down kernel
# (gr_down_v3_kernel, STRATA_GR_V3_PF masks 0 / 5 / 133) against our chain_gr_down_t2w8_nb4, window rows T = 1..8, on the 5090.
# Small GPU job (about 3 minutes, a few hundred MB of device memory, no model): takes /data/leleka-e2e/gpu.lock like the other short stubs
# (poll up to 30 min) and does not take MODEL.lock. Copy to ~/work/gpu-runs/holder2/jobs/ (installed and queued by the orchestrator).
# Method, inputs, how to read the result:
# MB_ARGS="--tmin 1 --tmax 2 --rounds 2" optional: a short run (the full defaults are in the doc)
set -uo pipefail
D=/data/leleka-e2e/spd-gap/microbench/verify-hc-down-kernel-microbench-vs-upstream
LOCK=/data/leleka-e2e/gpu.lock
OUT=$D/result.txt
cd "$D" || { echo "no $D"; exit 2; }
# measurement inputs are frozen and recorded: refuse to run when one is missing or its digest differs
sha256sum --quiet -c MANIFEST.sha256 || { echo "MANIFEST.sha256 does not match the files in $D"; exit 5; }
got=0
for _ in $(seq 1 360); do
if mkdir "$LOCK" 2>/dev/null; then echo "verify-hc-down-kernel-microbench-vs-upstream $(date -u +%FT%TZ)" >"$LOCK/owner"; got=1; break; fi
sleep 5
done
[ $got = 1 ] || { echo "GPU lock held by: $(cat "$LOCK/owner" 2>/dev/null)"; exit 3; }
release() { if grep -q "verify-hc-down-kernel-microbench-vs-upstream" "$LOCK/owner" 2>/dev/null; then rm -f "$LOCK/owner"; rmdir "$LOCK"; fi; }
trap release EXIT
[ -e "$OUT" ] && mv "$OUT" "$D/result.$(date -u +%Y%m%dT%H%M%SZ).txt"
SMI_PID=
{
echo "== environment"
date -u +%FT%TZ; uname -r
nvidia-smi --query-gpu=name,driver_version,clocks.max.sm,clocks.sm,power.limit,temperature.gpu --format=csv
echo "GPU compute apps at start (an idle resident holder is expected and does not run kernels):"
nvidia-smi --query-compute-apps=pid,name,used_memory --format=csv,noheader || true
echo "binary and inputs (full list: $D/MANIFEST.sha256, verified above):"
sha256sum build/microbench build/chain_window.cubin ours-src/crates/cuda-driver/src/chain_window.ptx upstream-src/src/kernels/cuda/fused_gr.cu harness/microbench.cu
# SM clock, power and throttle reasons once a second during the run (the timings are only comparable at steady clocks)
nvidia-smi --query-gpu=timestamp,clocks.sm,clocks.mem,power.draw,temperature.gpu,clocks_throttle_reasons.active --format=csv,noheader -l 1 >"$D/smi.csv" 2>&1 &
SMI_PID=$!
echo "== microbench"
# shellcheck disable=SC2086
timeout 1800 build/microbench --ptx ours-src/crates/cuda-driver/src/chain_window.ptx --cubin build/chain_window.cubin ${MB_ARGS:-}
echo "microbench exit code $?"
kill "$SMI_PID" 2>/dev/null
echo "== sm clock during the run (MHz): min / max / throttle reasons seen"
awk -F', ' '{c=$2+0; if (min==""||c<min) min=c; if (c>max) max=c; r[$6]++} END {printf "%s / %s\n", min, max; for (k in r) printf " %s x%d\n", k, r[k]}' "$D/smi.csv"
} 2>&1 | tee "$OUT"
# per-T tables and deltas from the CSV lines of the finished file (appended to result.txt)
{ echo "== tables (python3 harness/summarize.py result.txt)"; python3 -I harness/summarize.py "$OUT"; } | tee -a "$OUT"