unparallelled commited on
Commit
fa955e5
·
verified ·
1 Parent(s): f6e66b8

Upload source/files/run_len_sweep.sh with huggingface_hub

Browse files
Files changed (1) hide show
  1. source/files/run_len_sweep.sh +55 -0
source/files/run_len_sweep.sh ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # run_len_sweep.sh -- locate the context length at which generative retrieval
4
+ # breaks down.
5
+ #
6
+ # WHY: at PROMPT_LEN=16360 every arm scores 0% even at depth 1.0, where the
7
+ # needle sits ~30 tokens before the question -- yet the same harness and format
8
+ # HIT at 2048. So retrieval degrades with TOTAL CONTEXT LENGTH, not with
9
+ # needle-to-question distance, and 16k alone cannot discriminate the arms.
10
+ #
11
+ # CRITICAL: T stays fixed at 16384 across every length. T sets the YaRN cos/sin
12
+ # cache (built for seq_len=T at scale 4), so varying it would change the model's
13
+ # positional encoding and confound length with RoPE. Fixing T and varying only
14
+ # PROMPT_LEN isolates context length as the sole variable.
15
+ #
16
+ # Cost is dominated by the longest point, which the main run already covers, so
17
+ # the added lengths are cheap (~5 min wall on 4 GPUs).
18
+ # =============================================================================
19
+ set -uo pipefail
20
+ cd "$(dirname "$0")"
21
+
22
+ PY=${PY:-/root/Adhi/BluTrain/envv/bin/python}
23
+ LENS=${LENS:-"1024 2048 4096 8192"}
24
+ TASKS=${TASKS:-"niah_single val_backward"}
25
+ CKPTS=${CKPTS:-"base arm_a arm_b arm_c"}
26
+ N=${N:-50}
27
+ MAX_NEW=${MAX_NEW:-24}
28
+ DEPTHS=${DEPTHS:-"0.0,0.25,0.5,0.75,1.0"}
29
+ GPUS=${GPUS:-0,1,2,3}
30
+
31
+ for L in $LENS; do
32
+ echo "=============== PROMPT_LEN=$L (T fixed at 16384) ==============="
33
+ PY="$PY" OUT="longeval_len_${L}" TASKS="$TASKS" CKPTS="$CKPTS" N="$N" \
34
+ PROMPT_LEN="$L" MAX_NEW="$MAX_NEW" T=16384 DEPTHS="$DEPTHS" \
35
+ GPUS="$GPUS" NP=1 BF16=1 GREEDY=1 \
36
+ ./run_longeval.sh 2>&1 | grep -aE '^\[|accuracy:|depth|PRIMARY|^ [0-9]' | tail -25
37
+ done
38
+
39
+ echo
40
+ echo "=============== length sweep summary ==============="
41
+ $PY - "$LENS" "$CKPTS" <<'PY'
42
+ import csv, os, sys
43
+ lens = sys.argv[1].split(); models = sys.argv[2].split()
44
+ print(" depth-1.0 accuracy % (needle ~30 tok before the question = easiest case)")
45
+ print(" " + "len".ljust(8) + "".join(m.rjust(10) for m in models))
46
+ for L in lens:
47
+ p = f"longeval_len_{L}/depth_summary.csv"
48
+ row = {}
49
+ if os.path.exists(p):
50
+ for r in csv.DictReader(open(p)):
51
+ if abs(float(r["depth"]) - 1.0) < 1e-9:
52
+ row[r["model"]] = float(r["pct"])
53
+ print(" " + L.ljust(8) + "".join(
54
+ (f"{row[m]:9.1f}" if m in row else " -").rjust(10) for m in models))
55
+ PY