Upload scripts/b3_long_run.sh with huggingface_hub
Browse files- scripts/b3_long_run.sh +106 -0
scripts/b3_long_run.sh
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# =============================================================================
|
| 3 |
+
# b3_long_run.sh -- long b3 arm at 16k: does MORE long-context training flatten
|
| 4 |
+
# the retrieval-vs-length slope, or only lift the intercept?
|
| 5 |
+
#
|
| 6 |
+
# ./b3_long_run.sh first launch (branches from run7')
|
| 7 |
+
# ./b3_long_run.sh resume <N> continue run N after a stop
|
| 8 |
+
#
|
| 9 |
+
# WHY: l1/l2/l3 all landed on an 8k->16k slope of -18 to -29 pp/doubling and
|
| 10 |
+
# document length only moved the intercept. l3 (b3, truncated) tied l2 exactly
|
| 11 |
+
# at 16k (+0.0pp), so length is exhausted as a lever at this window. Step count
|
| 12 |
+
# is the remaining untested one at 16k.
|
| 13 |
+
#
|
| 14 |
+
# NEAR-ZERO DECAY -- constant LR for 97.5% of the run.
|
| 15 |
+
# A literally decay-free schedule is REFUSED by bluscriptCP.cpp:1006:
|
| 16 |
+
# warmup + stable >= max_steps-1 -> die ("leaves no cosine decay tail")
|
| 17 |
+
# The comment there gives the reason: it stops you running "right up to the
|
| 18 |
+
# point the checkpoint is unusable". So the closest legal setting is a minimal
|
| 19 |
+
# tail: stable = steps-200 -> flat LR for steps 100..3899, decay over the last
|
| 20 |
+
# 100 (2.5%). Every checkpoint you would stop at sits in the flat region, which
|
| 21 |
+
# is the stop/resume property you wanted, and the run still ends decayed.
|
| 22 |
+
# get_lr() computes decay_start = warmup_start + warmup + stable, and returns
|
| 23 |
+
# max_lr for every step below it. Setting CP_STABLE = CP_MAX_STEPS pushes
|
| 24 |
+
# decay_start to 4100 > 4000, so the cosine tail is NEVER entered: warmup 100
|
| 25 |
+
# steps to 3.0e-4, then flat 3.0e-4 to the end.
|
| 26 |
+
# THE TRADE: WSD's decay phase is where a large part of the final loss drop
|
| 27 |
+
# happens. A checkpoint taken mid-stable UNDERSTATES what the model would do
|
| 28 |
+
# after a decay. When you decide to stop for real, run a short decay from the
|
| 29 |
+
# last checkpoint (CP_STABLE=0 CP_MAX_STEPS=<stop+10%>) before the headline
|
| 30 |
+
# eval. Constant LR is what makes stop/resume free -- that is the point.
|
| 31 |
+
#
|
| 32 |
+
# CHECKPOINTS: CP_CKPT_FREQ=25 as requested. Each save is 17.28 GB (8.18 GB
|
| 33 |
+
# cp=2 shard + 0.46 GB zero_g1, x2 ranks) and 88.5 GB is free, so
|
| 34 |
+
# CP_CKPT_KEEP=2 -> 34.6 GB, leaving 54 GB. KEEP=1 would work but leaves no
|
| 35 |
+
# fallback if a save is interrupted mid-write; KEEP=4+ does not fit.
|
| 36 |
+
#
|
| 37 |
+
# RESUME CORRECTNESS: CP_REWARMUP_ANCHOR MUST be pinned to 0 on every resume.
|
| 38 |
+
# Its default (-1) falls back to the *current* start_step, which re-anchors a
|
| 39 |
+
# fresh 100-step warmup ramp at every resume -- the LR would sawtooth instead of
|
| 40 |
+
# staying flat. bluscriptCP.cpp:2105 documents exactly this trap.
|
| 41 |
+
# =============================================================================
|
| 42 |
+
set -uo pipefail
|
| 43 |
+
cd "$(dirname "$0")"
|
| 44 |
+
ROOT="$(cd ../.. && pwd)"
|
| 45 |
+
export LD_LIBRARY_PATH="$ROOT/Tensor-Implementations/lib:$ROOT/Profiler/lib:${LD_LIBRARY_PATH:-}"
|
| 46 |
+
export OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
|
| 47 |
+
|
| 48 |
+
PY=/root/Adhi/BluTrain/envv/bin/python
|
| 49 |
+
EXE=./build/bluscriptCP_exec
|
| 50 |
+
CK=checkpoints_bluscriptcp/rank_0
|
| 51 |
+
LOG=b3long_logs; mkdir -p "$LOG"
|
| 52 |
+
M="$LOG/master.log"
|
| 53 |
+
say(){ echo "[$(date -u +%H:%M:%S)] $*" | tee -a "$M" >&2; }
|
| 54 |
+
die(){ say "FATAL: $*"; exit 1; }
|
| 55 |
+
|
| 56 |
+
STEPS=${STEPS:-4000}
|
| 57 |
+
STABLE=${STABLE:-$(( STEPS - 200 ))} # 100-step tail: the minimum the guard allows
|
| 58 |
+
FREQ=${FREQ:-25}
|
| 59 |
+
KEEP=${KEEP:-2}
|
| 60 |
+
NP=2; GPUS=0,1; T=16384
|
| 61 |
+
PARENT="$CK/blumodelcp_run6_step_750.ckpt" # run7', same parent as l3@400
|
| 62 |
+
ARCH="CP_N_EMBD=1536 CP_N_LAYER=36 CP_N_HEAD=12 CP_N_KVHEAD=4 CP_FFN=4096 CP_WEIGHT_TYING=0"
|
| 63 |
+
BASE="CP_SIZE=$NP CP_ATTN_MODE=ring CP_ATTN_FUSION=split CP_T=$T \
|
| 64 |
+
YARN_SCALE=4 YARN_ORIG_MAXPOS=4096 \
|
| 65 |
+
CP_ZERO=1 CP_ZERO_V2=1 CP_ZERO_SYMMETRIC=1 CP_BF16=1 CP_OPTIMIZER=muon \
|
| 66 |
+
CP_MAX_LR=1e-3 CP_MIN_LR=1e-4 \
|
| 67 |
+
CP_STABLE=$STABLE CP_WARMUP=100 CP_REWARMUP=100 CP_REWARMUP_PEAK=0.3 \
|
| 68 |
+
CP_CKPT=1 CP_CKPT_FREQ=$FREQ CP_CKPT_KEEP=$KEEP"
|
| 69 |
+
|
| 70 |
+
$PY -c "import tiktoken" 2>/dev/null || die "tiktoken missing"
|
| 71 |
+
[ -x "$EXE" ] || die "$EXE not built"
|
| 72 |
+
[ -d lendata/b3_16384_32768 ] || die "b3 data missing"
|
| 73 |
+
|
| 74 |
+
MODE=${1:-start}
|
| 75 |
+
if [ "$MODE" = resume ]; then
|
| 76 |
+
RUN=${2:-}; [ -n "$RUN" ] || die "usage: $0 resume <run_number>"
|
| 77 |
+
ls $CK/blumodelcp_run${RUN}_step_*.ckpt >/dev/null 2>&1 || die "no checkpoint for run $RUN"
|
| 78 |
+
say "RESUMING run $RUN (anchor pinned to 0 so warmup does not restart)"
|
| 79 |
+
EXTRA="CP_CKPT_RESUME=$RUN CP_REWARMUP_ANCHOR=0"
|
| 80 |
+
else
|
| 81 |
+
[ -f "$PARENT" ] || die "parent run7' missing: $PARENT"
|
| 82 |
+
say "=== long b3 arm: START ==="
|
| 83 |
+
say "parent run7' (same as l3@400, so l3@400 vs this isolates STEP COUNT)"
|
| 84 |
+
EXTRA="CP_INIT_FROM=$PWD/$PARENT CP_CKPT_NEW_RUN=1"
|
| 85 |
+
fi
|
| 86 |
+
|
| 87 |
+
say "steps=$STEPS stable=$STABLE -> decay_start=$((100+STABLE)); flat 3.0e-4 for steps 100..$((99+STABLE)), then $((STEPS-100-STABLE))-step tail"
|
| 88 |
+
say "ckpt every $FREQ steps, keep $KEEP (= $(echo "scale=1; $KEEP*17.28" | bc) GB), free $(df -BG --output=avail /root | tail -1 | tr -dc '0-9')G"
|
| 89 |
+
say "tokens $(( STEPS*524288 )) = $(echo "scale=1; $STEPS*524288/2930000000*100" | bc)% of b3's 2.93 B"
|
| 90 |
+
|
| 91 |
+
env $ARCH $BASE $EXTRA CP_DATA_ROOT="$PWD/lendata/b3_16384_32768" \
|
| 92 |
+
CP_B=1 CP_GLOBAL_BATCH=524288 CP_MAX_STEPS=$STEPS \
|
| 93 |
+
CUDA_VISIBLE_DEVICES=$GPUS mpirun --allow-run-as-root -np $NP "$EXE" \
|
| 94 |
+
>> "$LOG/l3long.log" 2>&1
|
| 95 |
+
rc=$?
|
| 96 |
+
say "trainer exited rc=$rc"
|
| 97 |
+
grep -qaiE 'out of memory|bad_alloc' "$LOG/l3long.log" && die "OOM"
|
| 98 |
+
RN=$(grep -aoE 'CP_Training_log[0-9]+' "$LOG/l3long.log" | tail -1 | grep -oE '[0-9]+')
|
| 99 |
+
say "run number: ${RN:-unknown}"
|
| 100 |
+
# prove the schedule stayed FLAT -- a cosine tail would show LR falling here
|
| 101 |
+
say "LR trace: $(grep -aE '^step +100 ' "$LOG/l3long.log" | grep -oE 'lr [0-9.e-]+' | head -1) at step 100"
|
| 102 |
+
say " $(grep -aE '^step +2000 ' "$LOG/l3long.log" | grep -oE 'lr [0-9.e-]+' | head -1) at step 2000 (must equal step 100)"
|
| 103 |
+
say " $(grep -aE '^step ' "$LOG/l3long.log" | tail -1 | grep -oE 'lr [0-9.e-]+') at the last logged step"
|
| 104 |
+
CKF=$(ls -t $CK/blumodelcp_run${RN}_step_*.ckpt 2>/dev/null | head -1)
|
| 105 |
+
[ -n "$CKF" ] && { echo "$CKF" > "$LOG/l3long.ckpt"; say "latest ckpt: $(basename "$CKF")"; }
|
| 106 |
+
say "to continue: ./b3_long_run.sh resume ${RN:-<run>}"
|