#!/usr/bin/env bash # After training: put the fine-tuned weights into the released format, then evaluate them exactly as the stock model # was evaluated (the same engine line with no drafting, the same agent, the same subset), three passes. # bash tools/ft_eval.sh (run on the node in tmux; uses GPUs 3, 4 and 5) set -u R=/data/train/mini RUN=${RUN:-$R/runs/sft-r1}; MNAME=${MNAME:-RightNow-Mini}; GPUS=${GPUS:-3 4 5}; PREFIX=${PREFIX:-ft} G1=${GPUS%% *} log() { echo "$(date -u +%FT%TZ) $*"; } cd $R/src [ -d $RUN/merged-16bit ] || { log "ft: no merged model in $RUN"; exit 1; } if [ ! -s $R/models/$MNAME/graft_report.json ]; then sudo -n rm -rf $R/models/$MNAME taskset -c 32-255 $R/venv-train/bin/python train/graft.py apply --stock $R/models/Inkling-2-Mini --identity $R/models/mergetest-16bit \ --merged $RUN/merged-16bit --map $R/runs/graft_map.json --lora $RUN/lora --out $R/models/$MNAME > $R/logs/graft_apply.log 2>&1 log "ft: graft exit $?: $(tail -1 $R/logs/graft_apply.log | cut -c1-300)" fi [ -s $R/models/$MNAME/model-00001-of-00001.safetensors ] || { log "ft: NO GRAFTED MODEL"; exit 1; } for g in $GPUS; do ( ENGINE=vllm GPU=$g PORT=900$g SPEC=0 NAME=mini-vllm-g$g MODEL=/models/$MNAME bash tools/serve.sh > $R/logs/serve-ft-g$g.log 2>&1 ) & done wait log "ft: servers: $(for g in $GPUS; do tail -1 $R/logs/serve-ft-g$g.log; done | tr '\n' '/')" curl -s -m 5 http://127.0.0.1:900$G1/v1/models | grep -q inkling || { log "ft: THE ENGINE DID NOT SERVE THE FINE-TUNED MODEL: $(tail -5 $R/logs/serve-ft-g$G1.log | cut -c1-200 | tr '\n' ' ')"; exit 1; } $R/venv/bin/python tools/parity.py capture --url http://127.0.0.1:900$G1 --model inkling-2-mini --label $PREFIX --out $R/results/raw/parity/$PREFIX.json > /dev/null 2>&1 log "ft: tokens against stock (expected to differ: the weights changed): $($R/venv/bin/python tools/parity.py compare $R/results/raw/parity/stock.json $R/results/raw/parity/$PREFIX.json --json $R/results/raw/parity/compare-$PREFIX.json | cut -c1-200)" i=0 for g in $GPUS; do i=$((i + 1)) ( LABEL=$PREFIX-$i URL=http://127.0.0.1:900$g/v1 WORKERS=32 taskset -c 32-255 bash eval/run_agent.sh > $R/logs/$PREFIX-$i.log 2>&1 LABEL=$PREFIX-$i EW=12 bash eval/score.sh >> $R/logs/$PREFIX-$i.log 2>&1 log "$PREFIX-$i: $(tail -1 $R/logs/$PREFIX-$i.log | cut -c1-200)" ) & done wait log "ft: done"