File size: 1,947 Bytes
5ce45af | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #!/usr/bin/env bash
# A second, stronger fine-tune. The first one (rank 16, learning rate 1e-4, 52 steps) did not move: its loss was
# 0.188 over the first ten steps and 0.195 over the last ten, and the weights changed by about 1e-5 on average.
# This round: rank 64, learning rate 4e-4, three epochs, one conversation a step per GPU. Same data, same rule
# (attention weights only, so the result can be served in the released format).
# bash tools/round2.sh (run on the node in tmux; takes whichever of GPUs 0, 1 and 2 are free)
set -u
R=/data/train/mini
log() { echo "$(date -u +%FT%TZ) $*"; }
utc_now() { date -u +%H%M; }
log "round 2: waiting for GPUs 0, 1 and 2 (until ${R2_START_BY:-1350} at the latest)"
while [ -z "${R2_GPUS:-}" ]; do
FREE=""
for g in 0 1 2; do
used=$(nvidia-smi --id=$g --query-gpu=memory.used --format=csv,noheader,nounits | tr -d ' ')
[ "${used:-99999}" -lt 2000 ] && FREE="$FREE $g"
done
n=$(echo $FREE | wc -w)
[ "$n" -ge 3 ] && break
[ "$(utc_now)" -ge "${R2_START_BY:-1350}" ] && [ "$n" -ge 2 ] && break
sleep 20
done
FREE=$(echo ${R2_GPUS:-$FREE})
n=$(echo $FREE | wc -w)
log "round 2: training on GPUs $FREE"
cd $R/src
OUT=$R/runs/sft-r2
CUDA_VISIBLE_DEVICES=$(echo $FREE | tr ' ' ',') UNSLOTH_PARALLEL="dp=$n" UNSLOTH_MOE_DEQUANT_MAX_MB=64 taskset -c 32-255 $R/venv-train/bin/torchrun --nproc_per_node $n train/sft.py \
--model $R/models/Inkling-2-Mini --data $R/results/sft --out $OUT --max-len 32768 --epochs ${R2_EPOCHS:-3} --accum 1 --lr ${R2_LR:-4e-4} --rank 64 --alpha 64 --merge > $R/logs/sft-r2.log 2>&1
log "round 2: training exit $?: $(grep -h -E '^(TRAINED|MERGED)' $R/logs/sft-r2.log | tail -2 | cut -c1-300 | tr '\n' ' ')"
[ -d $OUT/merged-16bit ] || { log "round 2: NO MERGED MODEL: $(grep -E 'Error|error' $R/logs/sft-r2.log | tail -1 | cut -c1-200)"; exit 1; }
RUN=$OUT MNAME=RightNow-Mini-r2 GPUS="$FREE" PREFIX=ft2 bash tools/ft_eval.sh
|