change-bench / scripts /told_check2.sh
Mimarin's picture
Change Bench v0 (manifest e9200d808c16f8ecde8589ab612ec99b2f178e6c7593f64b3ab7738637add2c6)
68d3a5d verified
Raw History Blame Contribute Delete
4.9 kB
#!/usr/bin/env bash
# told_check2.sh: the card 03 RERUN with the replica-free runner (review/CLAUDE-QUESTION-TOLD-V2-2026-10-13.md). Runs
# told_check2.py: torque check; identity arm (the UNMODIFIED upstream planner through the boundary wrappers at factor 1,
# must reproduce the saved A block; on failure the job writes INVALID and stops before any told evaluation); K-plan2
# (knee reparametrised at the model boundary, half 0.5). walker-run 10 episodes per arm; 21 progress lines (11 if
# identity fails) to $BENCH_PROGRESS_FILE, which must be set. Outputs: $TOLD_OUT/{told2.json,torque_check.json,arms/,
# resolved_config.json}, $TOLD_OUT.log, a line in TOLD2.log. Refuses if any output exists or if the output path lies in
# another result tree. Copies only its own new files into the source dir; requires the audited card 03 and idea 01 files
# it imports to be in place unchanged. A NEW implementation of the same comparator; never pooled with results/told/.
set -uo pipefail
# RELEASE NOTE (change bench): the private default paths of the original run are replaced by placeholders. Set
# CHANGE_BENCH_ROOT to a working directory of your own that holds src/tdmpc2-<commit>/tdmpc2 (the pinned upstream
# checkout with these scripts copied in), ckpt/mt30-48M.pt, calib-inputs/ and told-inputs/; set BRIDGE_PY to the Python
# of an environment with upstream's dependencies. Every individual path can still be overridden as before.
ROOT=${CHANGE_BENCH_ROOT:?"PLACEHOLDER: set CHANGE_BENCH_ROOT to <YOUR_WORKING_DIRECTORY>"}
OUT=${TOLD_OUT:-$ROOT/told2}
case "$(cd "$(dirname "$OUT")" 2>/dev/null && pwd)/$(basename "$OUT")" in
"$ROOT"/bridge|"$ROOT"/bridge/*|"$ROOT"/bridge-*|"$ROOT"/calib|"$ROOT"/calib/*|"$ROOT"/told|"$ROOT"/told/*|"$ROOT"/told-diag|"$ROOT"/told-diag/*) echo "told_check: refusing TOLD_OUT inside another result tree: $OUT" >&2; exit 2;;
esac
PY=${BRIDGE_PY:?"PLACEHOLDER: set BRIDGE_PY to <PATH_TO_YOUR_PYTHON>"}
SRC=${BRIDGE_SRC:-$(ls -d "$ROOT"/src/tdmpc2-*/tdmpc2 | head -1)}
HERE=$(cd "$(dirname "$0")" && pwd)
CKPT=${BRIDGE_CKPT:-$ROOT/ckpt/mt30-48M.pt}
GATE_A=${TOLD_GATE_A:-$ROOT/calib-inputs/gate_a_reading_2026-10-11.json}
A_BLOCK=${TOLD_A_BLOCK:-$ROOT/calib-inputs/seed2-Df-bridge_adapt.json}
DF_DIR=${TOLD_DF_DIR:-$ROOT/told-inputs}
# RELEASE NOTE: the original run checked md5 b9755553a931170680ddaa5380942c1f; the released bridge_adapt3.py differs only
# in the progress variable's name (BENCH_PROGRESS_FILE), so this is the released file's md5.
REGISTERED_BA3=ba9a1f23de42756163ae14c277f531ea
CKPT_MD5=d44e05ecce371b1fb7965d54bd23b3a1 # the checkpoint every bridge, cross-body and calibration run loaded
md5of() { md5sum "$1" 2>/dev/null | cut -d' ' -f1 || md5 -q "$1"; }
[ -n "${BENCH_PROGRESS_FILE:-}" ] || { echo "REFUSED: BENCH_PROGRESS_FILE is not set (no dashboard progress)"; exit 1; }
if [ -n "$(ls -A "$OUT" 2>/dev/null)" ] || [ -e "$OUT.log" ]; then
echo "REFUSED: $OUT or $OUT.log exists (never overwritten)"; exit 1
fi
for f in "$GATE_A" "$A_BLOCK" "$DF_DIR"/seed2-Df-bridge_adapt.json "$DF_DIR"/seed3-Df-bridge_adapt.json "$DF_DIR"/seed4-Df-bridge_adapt.json; do
[ -f "$f" ] || { echo "REFUSED: input $f missing"; exit 1; }
done
[ "$(md5of "$CKPT")" = "$CKPT_MD5" ] || { echo "REFUSED: checkpoint md5 differs from the one the recorded runs used"; exit 1; }
[ "$(md5of "$SRC/bridge_adapt3.py")" = "$REGISTERED_BA3" ] || { echo "REFUSED: $SRC/bridge_adapt3.py is not the registered v2.2"; exit 1; }
for n in calib_check.py calib_logic.py told_check.py told_logic.py; do
[ "$(md5of "$SRC/$n")" = "$(md5of "$HERE/$n")" ] || { echo "REFUSED: $SRC/$n is missing or differs from $HERE/$n"; exit 1; }
done
for n in told2_logic.py told_check2.py; do
if [ -e "$SRC/$n" ]; then
[ "$(md5of "$SRC/$n")" = "$(md5of "$HERE/$n")" ] || { echo "REFUSED: a different $SRC/$n exists (never overwritten)"; exit 1; }
else
cp "$HERE/$n" "$SRC/.$n.tmp.$$" && mv -n "$SRC/.$n.tmp.$$" "$SRC/$n" || { echo "cannot copy $n"; exit 1; }
[ "$(md5of "$SRC/$n")" = "$(md5of "$HERE/$n")" ] || { echo "REFUSED: $SRC/$n appeared during the copy and differs"; exit 1; }
fi
done
mkdir -p "$(dirname "$OUT")"
export MUJOCO_GL=egl HYDRA_FULL_ERROR=1 WANDB_MODE=disabled
log() { echo "$(date -u +%FT%TZ) $*" | tee -a "$(dirname "$OUT")/TOLD2.log"; }
log "told_check2 $(md5of "$SRC/told_check2.py") told2_logic $(md5of "$SRC/told2_logic.py") bridge_adapt3 $(md5of "$SRC/bridge_adapt3.py") out $OUT"
( cd "$SRC" && "$PY" -u told_check2.py task=mt30 model_size=48 checkpoint="$CKPT" seed=2 compile=false \
enable_wandb=false save_video=false +out_dir="$OUT" +gate_a="$GATE_A" +a_block="$A_BLOCK" +df_dir="$DF_DIR" ) > "$OUT.log" 2>&1
rc=$?
if [ "$rc" -ne 0 ] || [ ! -e "$OUT/told2.json" ]; then
log "told2 FAILED exit $rc: $(tail -n 3 "$OUT.log" | tr '\n' ' ')"; exit 1
fi
log "told2 exit 0: $(grep -E '^(K-plan2:|checks|told2:)' "$OUT.log" | tr '\n' ' ')"