#!/bin/zsh # Whisper large-v3 vs large-v3-turbo vs tiny on MLX (Apple Silicon). Offline. <= 40 min. # ./run.sh real run (needs Metal GPU, models + data already cached) # ./run.sh --dry-run plumbing test with a FAKE backend (no GPU); writes raw_dryrun/ + results_dryrun.json # No server is started by this benchmark (everything is in-process), so there is nothing to stop. set -euo pipefail cd "${0:A:h}" DRY="" [[ "${1:-}" == "--dry-run" ]] && DRY="--dry-run" export HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1 HF_DATASETS_OFFLINE=1 HF_HUB_DISABLE_TELEMETRY=1 export PYTHONHASHSEED=0 TOKENIZERS_PARALLELISM=false # Keep temp files inside the run dir unless the harness already gave us a writable TMPDIR. if [[ -z "${TMPDIR:-}" || ! -w "${TMPDIR:-/nonexistent}" ]]; then mkdir -p tmp; export TMPDIR=$PWD/tmp; fi PY=./.venv/bin/python [[ -x $PY ]] || { echo "missing .venv (see README: setup)"; exit 1; } START=$(date +%s) TOTAL=$((37 * 60)) # hard budget for all blocks; aggregate needs only seconds END=$((START + TOTAL)) mkdir -p logs # NB: no `$( [[ ... ]] && echo ...)` here: under `set -e`, zsh gives the assignment the # substitution's exit status (1 when not dry-run) and the script died silently. Use if/else. if [[ -n $DRY ]]; then LOG=logs/run_dryrun.log; else LOG=logs/run.log; fi : > $LOG echo "run.sh start $(date '+%Y-%m-%d %H:%M:%S') mode=${DRY:-real}" | tee -a $LOG if [[ -z $DRY ]]; then # Fresh raw dir per real run (previous one kept with a timestamp). [[ -d raw ]] && mv raw "raw.prev.$(date +%Y%m%d-%H%M%S)" else rm -rf raw_dryrun fi rm -f logs/thermal.jsonl # deadline for a block = min(now + budget, global end) dl() { local b=$(( $(date +%s) + $1 )); (( b > END )) && b=$END; echo $b; } blk() { # blk [extra args] local name=$1 budget=$2; shift 2 local d=$(dl $budget) if (( $(date +%s) >= END - 5 )); then echo "[$name] skipped: global budget exhausted" | tee -a $LOG; return 0; fi echo "=== $name (budget ${budget}s, $(( END - $(date +%s) ))s left overall)" | tee -a $LOG $PY bench.py $name --deadline $d $DRY "$@" 2>&1 | tee -a $LOG || echo "[$name] FAILED (continuing)" | tee -a $LOG } $PY prepare_data.py 2>&1 | tee -a $LOG # no-op if data/ is already built (it is shipped prepared) blk env 120 blk loadmem 240 blk breakdown 120 blk speed 540 blk accuracy 720 blk halluc 900 # gets whatever remains of the 37 min ELAPSED=$(( $(date +%s) - START )) $PY aggregate.py $DRY --elapsed $ELAPSED 2>&1 | tee -a $LOG echo "done in ${ELAPSED}s" | tee -a $LOG