From d6cf8777bede6fd09449c124711e5df169d4d01b Mon Sep 17 00:00:00 2001 From: claude Date: Thu, 29 Oct 2026 15:15:51 +0100 Subject: [PATCH] Name run folders and exported results after the run ____x-[_quick][_2], with N the GPUs the model runs on (tp x pp). The results .json/.html carry the same name as the folder, so a file sent on its own still says what it is. Another run of the same setup on the same day gets _2, _3, ... Co-Authored-By: Claude Opus 5.5 --- README.md | 20 +++++++++++++++----- bench.sh | 44 ++++++++++++++++++++++++++++---------------- dev/DETAILS.md | 9 ++++++--- dev/bench.sh | 29 ++++++++++++++++++++--------- dev/postrun.py | 15 ++++++++------- 5 files changed, 77 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 020b274..875ddf3 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ file next to `bench.sh`. bandwidth reached, average power and clock, and energy: J per token for decode and each concurrency level, J per 1000 tokens for prefill. -Everything is recorded as notes in `results.json`, so it shows in the report and in +Everything is recorded as notes in the results `.json`, so it shows in the report and in `compare`. Example notes: ``` @@ -160,12 +160,22 @@ run full · concurrency on · bench-standard 0.5.0 · betterbench 0.6.1 ## Your result -Each run makes a folder `results/----/`: +Each run makes a folder `results//`, and the report and results inside it carry the +same name, so they still say what they are when sent on their own: + +```text +____x-[_quick][_2] +261029_pascal_qwen3.5-9b_llama.cpp_1x-intel-arc-pro-b65 +``` + +`N` is the number of GPUs the model runs on (`--tp` × `--pp`). Fields are separated by +`_`, words within a field by `-`. Quick runs end in `_quick`. Another run of the same +setup on the same day gets `_2`, `_3`, ... | file | what | |---|---| -| `results.html` | the report; open it in a browser | -| `results.json` | the results, with all notes | +| `.html` | the report; open it in a browser | +| `.json` | the results, with all notes | | `meta.json` | every raw value, plus energy and % of bandwidth | | `server-cmd.txt` | your server's launch command, secrets redacted | | `config.json`, `power.csv`, `timeline.tsv`, `betterbench.log` | the config used, power samples, when each phase ran, the full output | @@ -176,7 +186,7 @@ first. Tokens, keys and passwords are redacted automatically. Compare two runs: ```sh -betterbench compare A/results.json B/results.json +betterbench compare A/A.json B/B.json ``` Every recorded difference shows up as a mismatch chip, so you can see exactly what diff --git a/bench.sh b/bench.sh index 20d646b..3832bf8 100755 --- a/bench.sh +++ b/bench.sh @@ -277,21 +277,32 @@ fi python3 "$here/notes.py" "$tmp/mandatory" "$tmp/collected" "$tmp/measured" "$tmp/cmd.red" \ "$tmp/launch.json" "$here/models.tsv" > "$tmp/notes" -engine=$(get engine) gpu=$(get gpu_model) count=$(get gpu_count) ctx=$(get ctx) +engine=$(get engine) gpu=$(get gpu_model) ctx=$(get ctx) [ "$engine" != unknown ] || echo "bench.sh: warning: engine not detected; result is hard to compare" >&2 if [ "$power_src" = declared ] && [ "$power_limit" != stock ] && matches "$pl" '[0-9.]+' && [ "$(awk -v a="$pl" -v b="$power_limit" 'BEGIN{print (a-b>1||b-a>1)}')" = 1 ]; then echo "bench.sh: warning: --power-limit $power_limit W but the GPU reports $pl W" >&2 fi -matches "$count" '[2-9]|[1-9][0-9]+' && gpu="${count}x-$gpu" +# File names: ____x-[_quick][_2], +# with N the GPUs the model runs on (tp x pp); _2, _3, ... for another run of +# the same setup on the same day. Fields are joined with _ since +# model names have dashes. The run folder and the exported results.json/.html +# are named alike, so a file sent on its own still says what it is. slug() { tr 'A-Z' 'a-z' | sed -e 's/[^a-z0-9.]\{1,\}/-/g' -e 's/^-//' -e 's/-$//'; } -name=$(printf '%s-%s-%s' "$model" "$engine" "$gpu" | slug) - -run_dir="$results_dir/$(date +%Y%m%d-%H%M%S)-$(printf '%s' "$submitter" | slug)-$name" +gpu=$(printf '%s' "$gpu" | slug) +name="$(printf '%s' "$model" | slug)_$(printf '%s' "$engine" | slug)_$((tp * pp))x-${gpu:-unknown}" +run_id="$(date +%y%m%d)_$(printf '%s' "$submitter" | slug)_$name" +[ $quick = 1 ] && run_id="${run_id}_quick" +base=$run_id i=1 +while [ -e "$results_dir/$run_id" ] || [ -e "$results_dir/$run_id.failed" ]; do + i=$((i + 1)); run_id="${base}_$i" +done +run_dir="$results_dir/$run_id" +results="$run_dir/$run_id.json" # ---------------------------------------------------------------- run set -- run --no-update-check --endpoint "$endpoint" --model "$model" \ - --config "$run_dir/config.json" --name "$name" --out "$run_dir/results.json" + --config "$run_dir/config.json" --name "$name" --out "$results" [ $quick = 1 ] && set -- "$@" --quick [ $no_conc = 1 ] && set -- "$@" --no-concurrency # Through a proxy /v1/models often lacks the context size; hand over what the @@ -374,14 +385,14 @@ fi # Energy (whole run and per phase) and decode as % of memory bandwidth, from # what the run measured. They come after the run, so they go to meta.json -# ("post_run"), not into the notes of results.json. -T0=$t_start T1=$t_end python3 "$here/postrun.py" "$run_dir" || +# ("post_run"), not into the notes of the results file. +T0=$t_start T1=$t_end python3 "$here/postrun.py" "$run_dir" "$results" || echo "bench.sh: warning: post-run figures failed" >&2 # BetterBench with GGZ14/BetterBench#4 fingerprints PCIe and BAR itself # (env.gpu.pci), on the machine BetterBench runs on. Say so when that is not # the benchmarked GPU, or when it disagrees with collect-env.sh. -ENV_FILE=$env_file python3 - "$run_dir/results.json" "$tmp/collected" <<'PY' || true +ENV_FILE=$env_file python3 - "$results" "$tmp/collected" <<'PY' || true import json, os, sys pci = ((json.load(open(sys.argv[1], encoding="utf-8")).get("env") or {}).get("gpu") or {}).get("pci") if not pci: @@ -1154,10 +1165,11 @@ __BENCH_STANDARD_EOF__ cat > "$d/postrun.py" <<'__BENCH_STANDARD_EOF__' """postrun.py - figures that need the finished run, and the summary. -usage: T0=epoch T1=epoch postrun.py RUN_DIR +usage: T0=epoch T1=epoch postrun.py RUN_DIR [RESULTS_JSON] -Reads results.json, meta.json, power.csv (epoch_s,watts,joules,mhz) and -timeline.tsv (epochBetterBench progress line) from RUN_DIR. Writes +Reads RESULTS_JSON (default RUN_DIR/results.json), and meta.json, power.csv +(epoch_s,watts,joules,mhz) and timeline.tsv (epochBetterBench progress +line) from RUN_DIR. Writes energy (whole run and per phase) and the bandwidth figure to meta.json under "post_run", and prints the summary to stderr. """ @@ -1232,7 +1244,7 @@ def segments(timeline, t_end): def phase_energy(res, rows, timeline, t_end): """Joules and joules per token for decode, prefill and each concurrency - level. Warm-up passes draw power but aren't in results.json, so their + level. Warm-up passes draw power but aren't in the results, so their tokens are estimated from the measured passes of the same piece.""" ts, cum, _ = energy_curve(rows) single = res.get("single_stream") or {} @@ -1300,8 +1312,8 @@ def roofline(single, c, m): "pct_of_mem_bw": round(100 * eff / (bw * tp), 1)} -def main(d): - res = json.load(open(f"{d}/results.json", encoding="utf-8")) +def main(d, results=None): + res = json.load(open(results or f"{d}/results.json", encoding="utf-8")) meta = json.load(open(f"{d}/meta.json", encoding="utf-8")) c, m = meta["collected"], meta["mandatory"] t0, t1 = float(os.environ["T0"]), float(os.environ["T1"]) @@ -1396,7 +1408,7 @@ def main(d): if __name__ == "__main__": - main(sys.argv[1]) + main(*sys.argv[1:3]) __BENCH_STANDARD_EOF__ cat > "$d/models.tsv" <<'__BENCH_STANDARD_EOF__' # name engine quant sha256 (a GGUF file, or a safetensors directory: README, Models) diff --git a/dev/DETAILS.md b/dev/DETAILS.md index f82d045..97e5e41 100644 --- a/dev/DETAILS.md +++ b/dev/DETAILS.md @@ -14,10 +14,13 @@ What `bench.sh` records, how, and how it's built. For running it, see ## Files in a run folder +`` is the folder's name, `____x-[_quick][_2]` +with `N` = tp × pp; see the README. + | file | what | |---|---| -| `results.json` | BetterBench results; the notes below are under `env.notes` | -| `results.html` | the standalone report | +| `.json` | BetterBench results; the notes below are under `env.notes` | +| `.html` | the standalone report | | `config.json` | the BetterBench config the run used | | `meta.json` | every raw value: `mandatory` (declared), `collected` (detected), `measured`, `launch`, `post_run` | | `server-cmd.txt` | the server launch command, secrets redacted | @@ -117,7 +120,7 @@ fixed before BetterBench starts. `timeline.tsv`, and a piece of work lasts until the next line. That gives joules and average W for decode (J per output token), prefill (J per 1000 prompt tokens) and each concurrency level (J per token). The warm-up passes draw power but aren't in - `results.json`, so their tokens are estimated from the measured passes of the same + the results, so their tokens are estimated from the measured passes of the same piece (`tokens_incl_warmup_est`). These compare across quick and full runs; the whole-run figure doesn't. - **roofline:** median batch-1 decode t/s × weight bytes ÷ memory bandwidth = % of diff --git a/dev/bench.sh b/dev/bench.sh index 8135fc1..c9594b5 100755 --- a/dev/bench.sh +++ b/dev/bench.sh @@ -267,21 +267,32 @@ fi python3 "$here/notes.py" "$tmp/mandatory" "$tmp/collected" "$tmp/measured" "$tmp/cmd.red" \ "$tmp/launch.json" "$here/models.tsv" > "$tmp/notes" -engine=$(get engine) gpu=$(get gpu_model) count=$(get gpu_count) ctx=$(get ctx) +engine=$(get engine) gpu=$(get gpu_model) ctx=$(get ctx) [ "$engine" != unknown ] || echo "bench.sh: warning: engine not detected; result is hard to compare" >&2 if [ "$power_src" = declared ] && [ "$power_limit" != stock ] && matches "$pl" '[0-9.]+' && [ "$(awk -v a="$pl" -v b="$power_limit" 'BEGIN{print (a-b>1||b-a>1)}')" = 1 ]; then echo "bench.sh: warning: --power-limit $power_limit W but the GPU reports $pl W" >&2 fi -matches "$count" '[2-9]|[1-9][0-9]+' && gpu="${count}x-$gpu" +# File names: ____x-[_quick][_2], +# with N the GPUs the model runs on (tp x pp); _2, _3, ... for another run of +# the same setup on the same day. Fields are joined with _ since +# model names have dashes. The run folder and the exported results.json/.html +# are named alike, so a file sent on its own still says what it is. slug() { tr 'A-Z' 'a-z' | sed -e 's/[^a-z0-9.]\{1,\}/-/g' -e 's/^-//' -e 's/-$//'; } -name=$(printf '%s-%s-%s' "$model" "$engine" "$gpu" | slug) - -run_dir="$results_dir/$(date +%Y%m%d-%H%M%S)-$(printf '%s' "$submitter" | slug)-$name" +gpu=$(printf '%s' "$gpu" | slug) +name="$(printf '%s' "$model" | slug)_$(printf '%s' "$engine" | slug)_$((tp * pp))x-${gpu:-unknown}" +run_id="$(date +%y%m%d)_$(printf '%s' "$submitter" | slug)_$name" +[ $quick = 1 ] && run_id="${run_id}_quick" +base=$run_id i=1 +while [ -e "$results_dir/$run_id" ] || [ -e "$results_dir/$run_id.failed" ]; do + i=$((i + 1)); run_id="${base}_$i" +done +run_dir="$results_dir/$run_id" +results="$run_dir/$run_id.json" # ---------------------------------------------------------------- run set -- run --no-update-check --endpoint "$endpoint" --model "$model" \ - --config "$run_dir/config.json" --name "$name" --out "$run_dir/results.json" + --config "$run_dir/config.json" --name "$name" --out "$results" [ $quick = 1 ] && set -- "$@" --quick [ $no_conc = 1 ] && set -- "$@" --no-concurrency # Through a proxy /v1/models often lacks the context size; hand over what the @@ -364,14 +375,14 @@ fi # Energy (whole run and per phase) and decode as % of memory bandwidth, from # what the run measured. They come after the run, so they go to meta.json -# ("post_run"), not into the notes of results.json. -T0=$t_start T1=$t_end python3 "$here/postrun.py" "$run_dir" || +# ("post_run"), not into the notes of the results file. +T0=$t_start T1=$t_end python3 "$here/postrun.py" "$run_dir" "$results" || echo "bench.sh: warning: post-run figures failed" >&2 # BetterBench with GGZ14/BetterBench#4 fingerprints PCIe and BAR itself # (env.gpu.pci), on the machine BetterBench runs on. Say so when that is not # the benchmarked GPU, or when it disagrees with collect-env.sh. -ENV_FILE=$env_file python3 - "$run_dir/results.json" "$tmp/collected" <<'PY' || true +ENV_FILE=$env_file python3 - "$results" "$tmp/collected" <<'PY' || true import json, os, sys pci = ((json.load(open(sys.argv[1], encoding="utf-8")).get("env") or {}).get("gpu") or {}).get("pci") if not pci: diff --git a/dev/postrun.py b/dev/postrun.py index b8eaaf2..126e5f5 100644 --- a/dev/postrun.py +++ b/dev/postrun.py @@ -1,9 +1,10 @@ """postrun.py - figures that need the finished run, and the summary. -usage: T0=epoch T1=epoch postrun.py RUN_DIR +usage: T0=epoch T1=epoch postrun.py RUN_DIR [RESULTS_JSON] -Reads results.json, meta.json, power.csv (epoch_s,watts,joules,mhz) and -timeline.tsv (epochBetterBench progress line) from RUN_DIR. Writes +Reads RESULTS_JSON (default RUN_DIR/results.json), and meta.json, power.csv +(epoch_s,watts,joules,mhz) and timeline.tsv (epochBetterBench progress +line) from RUN_DIR. Writes energy (whole run and per phase) and the bandwidth figure to meta.json under "post_run", and prints the summary to stderr. """ @@ -78,7 +79,7 @@ def segments(timeline, t_end): def phase_energy(res, rows, timeline, t_end): """Joules and joules per token for decode, prefill and each concurrency - level. Warm-up passes draw power but aren't in results.json, so their + level. Warm-up passes draw power but aren't in the results, so their tokens are estimated from the measured passes of the same piece.""" ts, cum, _ = energy_curve(rows) single = res.get("single_stream") or {} @@ -146,8 +147,8 @@ def roofline(single, c, m): "pct_of_mem_bw": round(100 * eff / (bw * tp), 1)} -def main(d): - res = json.load(open(f"{d}/results.json", encoding="utf-8")) +def main(d, results=None): + res = json.load(open(results or f"{d}/results.json", encoding="utf-8")) meta = json.load(open(f"{d}/meta.json", encoding="utf-8")) c, m = meta["collected"], meta["mandatory"] t0, t1 = float(os.environ["T0"]), float(os.environ["T1"]) @@ -242,4 +243,4 @@ def main(d): if __name__ == "__main__": - main(sys.argv[1]) + main(*sys.argv[1:3])