Files
benchmarks/dev/build.sh
T
Claude b36805d1cb bench-standard 0.5.0: fix silent exits and signals, check declared values, hash the model
Fixes:
- A run on a machine without nvidia-smi/xpu-smi (every AMD box) exited
  silently with status 1 after BetterBench: the power sampler had already
  exited, so `kill` failed under set -e. No summary, no post_run, no done.
- Ctrl-C or kill didn't stop the script: the INT/TERM traps cleaned up and
  carried on, so a partial run could print a summary and `done:`. Now
  BetterBench is stopped at once and the folder is renamed .interrupted. The
  one-file bench.sh exec's the real script, so kill PID reaches it.
- Redaction turned --max-num-batched-tokens=8192 into <redacted>, corrupting
  the launch note. Env-style secrets and user:pass@ in URLs are still redacted.
- The --kv check was inverted when only -ctk is set: it warned on the
  correct q8_0/f16 and accepted q8_0.
- Negative flag values (-t -1) were parsed as flags.
- Model sizes in the HF cache counted symlinks, not the weights.
- A failed greedy check was recorded without any message.

Improvements:
- The served model is hashed (cached) and checked against the README's table
  (dev/models.txt), with a --quant cross-check.
- --spec, --thinking and vLLM --tp/--pp are checked against the launch
  command, like --kv; warnings name the value to declare.
- Weights are found through docker -v/--mount for any launch command, not
  only llama-swap's, and vLLM repo ids through the HF cache.
- AMD power and clock are sampled from amdgpu's hwmon sysfs files.
- Warnings are repeated after the summary and in the dry run, and saved in
  meta.json; the summary is saved as summary.txt.
- dev/test.sh: 36 end-to-end tests with a fake server and fake BetterBench,
  no GPU; CI runs them under dash and bash, plus shellcheck and build --check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EooZ9aTJE7srSQEYUqdQio
2026-11-01 20:05:40 +00:00

51 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
# build.sh - pack dev/ into the one bench.sh at the repo root, which is all
# people download. It unpacks the helpers to a temp dir and exec's dev's
# bench.sh from there, with results and bench.local.env next to itself; that
# script removes the temp dir (BENCH_UNPACKED) when it exits.
#
# usage: dev/build.sh (then commit the root bench.sh with dev/)
# dev/build.sh --check (exit 1 if the root bench.sh is out of date)
set -eu
dev=$(cd "$(dirname "$0")" && pwd)
out="$dev/../bench.sh"
files="bench.sh collect-env.sh gpu-power.sh mem-bw.py config.json standard.env models.txt"
eof=__BENCH_STANDARD_EOF__
. "$dev/standard.env"
for f in $files; do
if grep -q "$eof" "$dev/$f"; then echo "build.sh: $f contains $eof" >&2; exit 1; fi
done
tmp=$(mktemp)
trap 'rm -f "$tmp"' EXIT
{
cat <<EOF
#!/bin/sh
# bench.sh - bench-standard $STANDARD_VERSION, everything in one file: run ./bench.sh --help
# Generated by dev/build.sh from dev/ - edit there and rebuild, not here.
set -eu
BENCH_HOME=\${BENCH_HOME:-\$(cd "\$(dirname "\$0")" && pwd)}; export BENCH_HOME
d=\$(mktemp -d)
trap 'rm -rf "\$d"' EXIT
trap 'rm -rf "\$d"; exit 130' INT
trap 'rm -rf "\$d"; exit 143' TERM
EOF
for f in $files; do
printf "cat > \"\$d/%s\" <<'%s'\n" "$f" "$eof"
cat "$dev/$f"
printf '%s\n' "$eof"
done
printf 'trap - EXIT INT TERM\n'
printf 'BENCH_UNPACKED=$d exec sh "$d/bench.sh" "$@"\n'
} > "$tmp"
if [ "${1:-}" = --check ]; then
cmp -s "$tmp" "$out" || { echo "build.sh: bench.sh is out of date, run dev/build.sh" >&2; exit 1; }
echo "bench.sh is up to date"
else
cp "$tmp" "$out" && chmod +x "$out"
echo "built $(cd "$dev/.." && pwd)/bench.sh ($(wc -c < "$out") bytes)"
fi