#!/usr/bin/env bash # Does the wider cache COST anything at short context? # retrain_corrected_cache.sh measured a prior cache switch going 75 -> 14-33 at # ~4k while improving 1k and 16k. My 32k-cache result only covered 8k/16k/32k, # so the regime where the known regression lives is UNMEASURED. This runs # 1,024 and 4,096 under BOTH caches for both models. set -uo pipefail cd "$(dirname "$0")" export PATH=/root/Adhi/BluTrain/envv/bin:$PATH source /root/Adhi/BluTrain/envv/bin/activate 2>/dev/null L=eshort_logs; mkdir -p "$L"; M="$L/master.log" say(){ echo "[$(date -u +%H:%M:%S)] $*" | tee -a "$M" >&2; } A1B_680="CP_N_EMBD=1536 CP_N_LAYER=24 CP_N_HEAD=12 CP_N_KVHEAD=4 CP_FFN=4096 CP_WEIGHT_TYING=1" HAY=Data_Loader/Data/b2_8192_16384/val_shard_00000.bin run(){ # T SCALE PL tag local T=$1 S=$2 PL=$3 TAG=$4 local O="eshort_${TAG}_len${PL}" [ $((S*4096)) -eq $T ] || { say "YaRN invariant broken: $S*4096 != $T"; return 1; } [ -s "$O/summary.csv" ] && [ "$(wc -l < "$O/summary.csv")" -gt 1 ] && { say " $TAG len $PL cached: $(grep '^niah_single,' $O/summary.csv)"; return 0; } A1B="$A1B_680" HAY="$HAY" GEN_DATA_ROOT="Data_Loader/Data/evalsrc" \ CKPT_EXTRA="p1final=blumodelcp_run12_step_1200.ckpt base680=varybatch.ckpt" \ CKPTS="p1final base680" TASKS=niah_single N=100 \ T=$T YARN=$S YARN_ORIG=4096 PROMPT_LEN=$PL GPUS=0,1 NP=1 OUT="$O" \ ./run_longeval.sh >> "$L/${TAG}_${PL}.log" 2>&1 if [ -s "$O/summary.csv" ] && [ "$(wc -l < "$O/summary.csv")" -gt 1 ]; then say " $TAG len $PL -> $(head -1 $O/summary.csv) | $(grep '^niah_single,' $O/summary.csv)" else say " $TAG len $PL FAILED"; grep -ahA2 'what()' "$O"/gen/*.log 2>/dev/null|head -3|tee -a "$M" >&2; fi } say "=== short-context cost of the wider cache ===" for PL in 1024 4096; do run 16384 4 $PL cache16k run 32768 8 $PL cache32k done say "=== SHORT-CONTEXT RESULTS (cols: base680,p1final) ===" for PL in 1024 4096; do for TAG in cache16k cache32k; do f="eshort_${TAG}_len${PL}/summary.csv" [ -f "$f" ] && say " len $PL $TAG $(head -1 $f) -> $(grep '^niah_single,' $f)" done; done say "DONE"