Upload scripts/t128c_train.sh with huggingface_hub
Browse files- scripts/t128c_train.sh +85 -0
scripts/t128c_train.sh
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# =============================================================================
|
| 3 |
+
# 128k run #3 (t128c) -- 8x H100 80GB, from t64, SAME b6-35 mix as run #2.
|
| 4 |
+
#
|
| 5 |
+
# ONE variable changes from run #2: GB 524288 -> 1048576, i.e. 8 sequences per
|
| 6 |
+
# optimizer step instead of 4. That matches t64 exactly, and t64 at this same
|
| 7 |
+
# LR IMPROVED (90->95->99 @32,744) where run #2 degraded (89->77).
|
| 8 |
+
# Evidence: grad clip (1.0, bluscriptCP.cpp:148) fired on 0.2% of t64 steps and
|
| 9 |
+
# 12.4% of run #2 steps, pre-clip norms to 7.38.
|
| 10 |
+
#
|
| 11 |
+
# Memory: grad_accum does NOT change peak activation memory (B=1 x T per
|
| 12 |
+
# micro-step). H100 80GB needs CP_SAVE_KV_BF16=1 CP_RING_BF16=1 -- run #2 used
|
| 13 |
+
# 87,025 MB on H200 and will not fit here without them.
|
| 14 |
+
#
|
| 15 |
+
# LR: UNCHANGED at 1.8e-4 (6e-4 hardcoded x REWARMUP_PEAK 0.3). Deliberate --
|
| 16 |
+
# changing batch AND lr would confound the test.
|
| 17 |
+
#
|
| 18 |
+
# Stops pre-anneal (decay_start=597 of 600) so the stable phase can be extended
|
| 19 |
+
# when the new data lands.
|
| 20 |
+
# =============================================================================
|
| 21 |
+
set -uo pipefail
|
| 22 |
+
cd "$(dirname "$0")"
|
| 23 |
+
ROOT="$(cd ../.. && pwd)"
|
| 24 |
+
export LD_LIBRARY_PATH="$ROOT/Tensor-Implementations/lib:$ROOT/Profiler/lib:${LD_LIBRARY_PATH:-}"
|
| 25 |
+
export OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
|
| 26 |
+
export PATH=/usr/local/cuda/bin:$PATH
|
| 27 |
+
PY=/root/Adhi/BluTrain/envv/bin/python
|
| 28 |
+
EXE=./build/bluscriptCP_exec
|
| 29 |
+
LOG=t128c_logs; mkdir -p "$LOG"; M="$LOG/master.log"
|
| 30 |
+
|
| 31 |
+
T=131072; NP=8; CPSZ=8; SCALE=32; ORIG=4096
|
| 32 |
+
GB=1048576 # 8 seqs/step (was 524288 = 4)
|
| 33 |
+
STEPS=600; WARM=60; STABLE=537; FREQ=50; KEEP=4 # decay_start=597 -> no anneal
|
| 34 |
+
DATA=data/mix128_b6_35_640M
|
| 35 |
+
CK=checkpoints_bluscriptcp/rank_0
|
| 36 |
+
PARENT="${PARENT_OVERRIDE:-$CK/t64.ckpt}"
|
| 37 |
+
say(){ echo "[$(date -u +%H:%M:%S)] $*" | tee -a "$M" >&2; }
|
| 38 |
+
die(){ say "FATAL: $*"; exit 1; }
|
| 39 |
+
|
| 40 |
+
[ -x "$EXE" ] || die "binary missing"
|
| 41 |
+
grep -q 'CP_FUSED_ROPE=1' build/objects/.cp_rope_flags && grep -q 'CP_ATTN_SPLIT=1' build/objects/.cp_rope_flags || die "binary lacks split kernels"
|
| 42 |
+
[ -s "$PARENT" ] || die "parent missing: $PARENT"
|
| 43 |
+
[ -d "$DATA" ] || die "$DATA missing"
|
| 44 |
+
[ $((SCALE*ORIG)) -eq $T ] || die "YaRN INVARIANT BROKEN: $SCALE*$ORIG != $T"
|
| 45 |
+
[ $(( WARM + STABLE )) -lt $(( STEPS - 1 )) ] || die "illegal WSD"
|
| 46 |
+
# KEEP x 17.6 GB must fit the disk
|
| 47 |
+
AV=$(df -BG --output=avail . | tail -1 | tr -dc 0-9)
|
| 48 |
+
[ "$AV" -gt $(( KEEP * 18 + 20 )) ] || die "disk: ${AV}G free, KEEP=$KEEP needs $(( KEEP*18+20 ))G"
|
| 49 |
+
|
| 50 |
+
U=$($PY - "$DATA" "$T" "$GB" <<'PY'
|
| 51 |
+
import glob,os,sys
|
| 52 |
+
d,BT,G=sys.argv[1],int(sys.argv[2]),int(sys.argv[3]); GA=G//BT; t=0
|
| 53 |
+
for p in sorted(glob.glob(f"{d}/train_shard_*.bin")):
|
| 54 |
+
n=os.path.getsize(p)//2; pos=0; b=0
|
| 55 |
+
while pos+BT+1<=n:
|
| 56 |
+
b+=1; pos+=BT
|
| 57 |
+
if pos+(BT+1)>n: break
|
| 58 |
+
t+=b
|
| 59 |
+
print(t//GA)
|
| 60 |
+
PY
|
| 61 |
+
)
|
| 62 |
+
[ "$STEPS" -le "$U" ] || die "STEPS=$STEPS > usable=$U at GB=$GB"
|
| 63 |
+
|
| 64 |
+
ARCH="CP_N_EMBD=1536 CP_N_LAYER=24 CP_N_HEAD=12 CP_N_KVHEAD=4 CP_FFN=4096 CP_WEIGHT_TYING=1"
|
| 65 |
+
BASE="CP_SIZE=$CPSZ CP_ATTN_MODE=ring CP_ATTN_FUSION=split CP_T=$T \
|
| 66 |
+
CP_SAVE_KV_BF16=1 CP_RING_BF16=1 \
|
| 67 |
+
YARN_SCALE=$SCALE YARN_ORIG_MAXPOS=$ORIG CP_ROPE_THETA=500000 \
|
| 68 |
+
CP_ZERO=1 CP_ZERO_V2=1 CP_BF16=1 CP_OPTIMIZER=muon \
|
| 69 |
+
CP_WARMUP=$WARM CP_REWARMUP=$WARM CP_REWARMUP_PEAK=0.3 \
|
| 70 |
+
CP_STABLE=$STABLE CP_CKPT=1 CP_CKPT_FREQ=$FREQ CP_CKPT_KEEP=$KEEP"
|
| 71 |
+
|
| 72 |
+
say "=== 128k run #3 (t128c) -- 8x H100, batch fix only ==="
|
| 73 |
+
say "parent : $PARENT"
|
| 74 |
+
say "data : $DATA (UNCHANGED from run #2) usable $U steps at GB=$GB"
|
| 75 |
+
say "batch : $GB = $(( GB / T )) seqs/step <-- the only change (run #2 was 4)"
|
| 76 |
+
say "LR : 1.8e-4 flat, decay_start=$(( WARM + STABLE )) of $STEPS -> pre-anneal stop"
|
| 77 |
+
say "ckpts : every $FREQ steps, KEEP=$KEEP (disk ${AV}G free)"
|
| 78 |
+
say "GATE : eval at every ckpt. If niah_single @4096 < 98, STOP and diagnose."
|
| 79 |
+
env $ARCH $BASE CP_INIT_FROM="$PWD/$PARENT" CP_CKPT_NEW_RUN=1 CP_DATA_ROOT="$PWD/$DATA" \
|
| 80 |
+
CP_B=1 CP_GLOBAL_BATCH=$GB CP_MAX_STEPS=$STEPS \
|
| 81 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 mpirun --allow-run-as-root -np $NP "$EXE" >> "$LOG/train.log" 2>&1
|
| 82 |
+
grep -qaiE 'out of memory|bad_alloc' "$LOG/train.log" && die "OOM -- check CP_SAVE_KV_BF16/CP_RING_BF16 took effect"
|
| 83 |
+
RN=$(grep -aoE 'CP_Training_log[0-9]+' "$LOG/train.log" | head -1 | grep -oE '[0-9]+')
|
| 84 |
+
echo "${RN:-?}" > "$LOG/runnum"
|
| 85 |
+
say "done, run ${RN:-?}, $(grep -aE '^step ' "$LOG/train.log"|tail -1|grep -oE 'loss: [0-9.]+')"
|