SamJoshua's picture
Training recipe and evaluation code for a fix attempt that does not meet the release gates
8c0ce05 verified
Raw History Blame Contribute Delete
1.43 kB
#!/usr/bin/env bash
# Sequential job runner over an editable queue file: scripts/queue.sh [QUEUE_FILE]
# Each line is "RECIPE SEED" (train + screening evaluation) or "!<shell command>" (e.g. a soup or an evaluation-only run).
# Lines can be appended or reordered while it runs; it waits for any training job already running before starting the next.
set -u
trap 'trap - INT TERM; kill 0; exit 130' INT TERM
cd "$(dirname "$0")/.."
q=${1:-work/queue.txt}
mkdir -p work/logs
touch "$q"
while true; do
while pgrep -f "guardtune.train|guardtune.evaluate|guardtune.soup" >/dev/null; do sleep 15; done
line=$(head -n 1 "$q")
if [ -z "$line" ]; then
sed -i '1{/^$/d}' "$q"
sleep 20
continue
fi
sed -i '1d' "$q"
if [ "${line:0:1}" = "!" ]; then
echo "=== $(date -u +%H:%M:%S) ${line:1}" | tee -a work/logs/screen.txt
bash -c "${line:1}" 2>&1 | grep --line-buffered -v -i -E "unauth|Loading weights|Writing model shards" >> work/logs/commands.log
tail -n 1 work/logs/commands.log | tee -a work/logs/screen.txt
continue
fi
read -r r seed <<< "$line"
seed=${seed:-0}
echo "=== $(date -u +%H:%M:%S) $r s$seed" | tee -a work/logs/screen.txt
python -m guardtune.train --recipe "$r" --seed "$seed" 2>&1 \
| grep --line-buffered -v -i -E "unauth|Loading weights|Writing model shards" > "work/logs/${r}_s${seed}.log"
tail -n 1 "work/logs/${r}_s${seed}.log" | tee -a work/logs/screen.txt
done