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

Upload source/files/run_longeval.sh with huggingface_hub

Browse files
Files changed (1) hide show
  1. source/files/run_longeval.sh +343 -0
source/files/run_longeval.sh ADDED
@@ -0,0 +1,343 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # run_longeval.sh -- batch RULER / NIAH / VAL generative evaluation for bluscriptCP.
4
+ #
5
+ # Scores what the model GENERATES (substring match), unlike probe_1b.sh which
6
+ # measures teacher-forced NLL over an answer span already present in the input.
7
+ #
8
+ # Requires a binary built with generation support:
9
+ # make CP_FUSED_ROPE=1 CP_ATTN_SPLIT=1 SM_ARCH=90 bluscript-cp -j$(nproc)
10
+ #
11
+ # Usage:
12
+ # ./run_longeval.sh # all tasks, all checkpoints
13
+ # TASKS="niah_single vt" ./run_longeval.sh # subset
14
+ # CKPTS="arm_c" N=20 ./run_longeval.sh # quick smoke
15
+ #
16
+ # Resumable: each (ckpt,task) writes a .done marker; re-running skips finished
17
+ # pairs. Kill it any time -- completed pairs survive.
18
+ # =============================================================================
19
+ set -uo pipefail
20
+ cd "$(dirname "$0")"
21
+
22
+ ROOT="$(cd ../.. && pwd)"
23
+ export LD_LIBRARY_PATH="$ROOT/Tensor-Implementations/lib:$ROOT/Profiler/lib:${LD_LIBRARY_PATH:-}"
24
+ export OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
25
+
26
+ EXE=./build/bluscriptCP_exec
27
+ PY=${PY:-python3}
28
+ OUT=${OUT:-longeval_runs}
29
+ CK=checkpoints_bluscriptcp/rank_0
30
+
31
+ # CP_T is the RoPE cache length. The C++ side pads each decode step up to a
32
+ # multiple of 256 (the Hopper split kernel's T_q guard), so
33
+ # pad_up(PROMPT_LEN + MAX_NEW) must be <= CP_T or it aborts up front.
34
+ T=${T:-16384}
35
+ # COST: a forward at T=16384 fp32 measures 17.8 s on H200 / ~25 s on H100
36
+ # (probe_arm_c: 21 jobs x 8 windows in 12.5 min at slots=4). Naive re-forward
37
+ # decoding costs ONE such forward per generated token, so the defaults matter:
38
+ # fp32 MAX_NEW=32 N=50 -> 190 GPU-h <- do not
39
+ # bf16, early stop, 4 tasks at ~6 forwards + niah_multivalue at ~24 (its
40
+ # MIN_TOK=14 blocks an early break) -> weighted (4*6+24)/5 = 9.6 /prompt
41
+ # -> ~18.7 GPU-h for 1000 prompts -> ~4.7 h on 4 GPUs. Step 2 measures this
42
+ # on BOTH niah_single and niah_multivalue rather than assuming it.
43
+ # HARD CONSTRAINT: PROMPT_LEN + MAX_NEW must be <= 16384 AND pad up to exactly it.
44
+ # bluscriptCP.cpp:2446 dies when pad_up(P_LEN+MAX_NEW) > CP_T, and PAD=256, so
45
+ # pad_up(16368+24)=16640 > 16384 would abort EVERY job. 16360+24 = 16384 exactly.
46
+ MAX_NEW=${MAX_NEW:-24}
47
+ PROMPT_LEN=${PROMPT_LEN:-16360}
48
+ N=${N:-50}
49
+ BF16=${BF16:-1}
50
+ GPUS=${GPUS:-0} # comma list, e.g. "0,1,2,3" -> (ckpt,task) jobs fan out
51
+ NP=${NP:-1} # CP_SIZE per job; GPUs are used for THROUGHPUT, not size
52
+ YARN=${YARN:-4}
53
+ # YARN_ORIG_MAXPOS (YARNOps.cpp:57) defaults to 1024, but the base model was
54
+ # trained at context_length 4096 -- hence the warning EVERY run emits:
55
+ # seq_len(16384) != scale(4.000)*orig_maxpos(1024.0)=4096.0
56
+ # i.e. the YaRN ramp targets 4096 while the cache is SIZED 16384, so positions
57
+ # past ~4k sit outside the range it was parameterised for. YARN_ORIG=4096 makes
58
+ # scale*orig == seq_len exactly. CAUTION: this is a train/eval MISMATCH -- the
59
+ # checkpoints were trained under the 1024 default, so a correctly-parameterised
60
+ # cache is not one they ever saw. Diagnostic, not a guaranteed fix.
61
+ YARN_ORIG=${YARN_ORIG:-}
62
+ GREEDY=${GREEDY:-1} # deterministic: benchmarks must be reproducible
63
+
64
+ # Needle depth grid. MUST match needle_gen.py's p_frac points or the generative
65
+ # curve cannot be overlaid on the NLL curve. Both place the needle at a fraction
66
+ # of ABSOLUTE POSITION (needle_gen p0.25 -> slot 4087 -> fraction 0.25), so the
67
+ # grids correspond directly.
68
+ DEPTHS=${DEPTHS:-"0.0,0.25,0.5,0.75,1.0"}
69
+
70
+ # Minimum substantive tokens before a newline may end generation. 3 suits a
71
+ # 7-digit number or a single word, but niah_multivalue needs THREE values
72
+ # (~12-15 tokens): at 3 a model that emits value 1 then a newline would stop with
73
+ # 1 of 3 and score MISS -- re-creating the bug the guard exists to prevent,
74
+ # precisely for the long-answer task.
75
+ declare -A MINTOK=( [niah_multivalue]=14 )
76
+
77
+ TASKS=${TASKS:-"niah_single niah_multikey niah_multivalue vt val_forward val_backward"}
78
+ # name:checkpoint-file
79
+ CKPTS=${CKPTS:-"base arm_a arm_b arm_c"}
80
+ declare -A CKPT_FILE=(
81
+ [base]=blumodelcp_run7_step_750.ckpt
82
+ [arm_a]=blumodelcp_run12_step_400.ckpt
83
+ [arm_b]=blumodelcp_run15_step_400.ckpt
84
+ [arm_c]=blumodelcp_run16_step_400.ckpt
85
+ )
86
+
87
+ A1B="CP_N_EMBD=1536 CP_N_LAYER=36 CP_N_HEAD=12 CP_N_KVHEAD=4 CP_FFN=4096 CP_WEIGHT_TYING=0"
88
+ ARCH="$A1B CP_ATTN_MODE=ring CP_ATTN_FUSION=split"
89
+
90
+ mkdir -p "$OUT"/{prompts,gen,state,scores}
91
+ M="$OUT/master.log"
92
+ say() { echo "[$(date -u +%H:%M:%S)] $*" | tee -a "$M"; }
93
+
94
+ [ -x "$EXE" ] || { echo "ERROR: $EXE missing -- build first:"; \
95
+ echo " make CP_FUSED_ROPE=1 CP_ATTN_SPLIT=1 SM_ARCH=90 bluscript-cp -j\$(nproc)"; exit 1; }
96
+
97
+ # Fail early on a binary built without generation support rather than after an
98
+ # hour of prompt generation.
99
+ if ! grep -q CP_GENERATE "$EXE" 2>/dev/null; then
100
+ echo "ERROR: $EXE has no CP_GENERATE support (stale build). Rebuild:"
101
+ echo " make CP_FUSED_ROPE=1 CP_ATTN_SPLIT=1 SM_ARCH=90 bluscript-cp -j\$(nproc)"
102
+ exit 1
103
+ fi
104
+
105
+ say "longeval: T=$T prompt_len=$PROMPT_LEN max_new=$MAX_NEW n=$N greedy=$GREEDY gpus=$GPUS"
106
+
107
+ # ---- 1. prompts (shared across checkpoints; identical bytes => fair compare) --
108
+ HAY=$(ls Data_Loader/Data/flux_val_*.bin 2>/dev/null | head -1)
109
+ [ -z "$HAY" ] && HAY=$(ls Data_Loader/Data/flux_train_*.bin 2>/dev/null | head -1)
110
+ say "haystack: ${HAY:-<synthetic fallback>}"
111
+ [ -z "$HAY" ] && say " WARN: synthetic filler is a weaker distractor than real text -- it INFLATES accuracy. Record this."
112
+
113
+ # A bare "-f the .bin exists" test silently reuses prompts from a different run:
114
+ # a smoke run at N=2 then poisons a main run at N=50 (the C++ dies on "short read
115
+ # on prompt 2" AFTER flushing 2 rows, which the old [ -s ] scoring gate happily
116
+ # scored and marked .done, permanently). The signature covers everything that
117
+ # changes prompt content -- N, length, depths, seed, AND the haystack, so a
118
+ # synthetic-filler run is not reused once the flux shard arrives.
119
+ SIG="N=$N|LEN=$PROMPT_LEN|DEPTHS=$DEPTHS|SEED=0|HAY=$(basename "${HAY:-none}")|HAYSZ=$(stat -c %s "${HAY:-/nonexistent}" 2>/dev/null || echo 0)"
120
+ if [ "$(cat "$OUT/prompts/.signature" 2>/dev/null)" != "$SIG" ]; then
121
+ say "prompt signature changed -- regenerating prompts and clearing state"
122
+ rm -f "$OUT"/prompts/*_prompts.bin "$OUT"/prompts/*_meta.json
123
+ # MUST clear state too: the generation skip below tests .gen, so leaving those
124
+ # markers would skip regeneration and score OLD tokens against the NEW
125
+ # meta.json -- attributing accuracy to depths the tokens never came from.
126
+ rm -f "$OUT"/state/*
127
+ fi
128
+
129
+ GEN_OK=1
130
+ for TASK in $TASKS; do
131
+ if [ ! -f "$OUT/prompts/${TASK}_prompts.bin" ]; then
132
+ say "generating prompts: $TASK"
133
+ $PY Tests/bluscriptcp/longeval_gen.py --task "$TASK" --prompt-len "$PROMPT_LEN" \
134
+ --n "$N" --seed 0 --depths "$DEPTHS" ${HAY:+--haystack "$HAY"} \
135
+ --out-dir "$OUT/prompts" \
136
+ >>"$M" 2>&1 || { say " FAILED to generate $TASK"; GEN_OK=0; continue; }
137
+ fi
138
+ # exact stride: the C++ reader slices the stream at N x PROMPT_LEN x 4 bytes
139
+ WANT=$(( N * PROMPT_LEN * 4 ))
140
+ GOT=$(stat -c %s "$OUT/prompts/${TASK}_prompts.bin" 2>/dev/null || echo 0)
141
+ [ "$GOT" = "$WANT" ] || { say " BAD SIZE $TASK: ${GOT}B want ${WANT}B"; GEN_OK=0; }
142
+ done
143
+ # Only claim the signature if every task really produced prompts, else the next
144
+ # run would match it and never retry the missing ones.
145
+ [ "$GEN_OK" = 1 ] && echo "$SIG" > "$OUT/prompts/.signature"
146
+
147
+ # ---- 2. generate (fanned out over GPUs) -------------------------------------
148
+ # Each (checkpoint, task) pair is one independent job needing NP GPUs, so the
149
+ # GPU list is used for THROUGHPUT: slots = nGPU / NP jobs run concurrently.
150
+ # 24 pairs (4 ckpts x 6 tasks) on 8 GPUs at NP=1 is 8-way parallel.
151
+ IFS=',' read -r -a GPUARR <<< "$GPUS"
152
+ NGPU=${#GPUARR[@]}
153
+ # One job needs ~24.3 GB (measured) of an 80 GB card and drives it to only ~42%
154
+ # util -- B=1 decoding of a 1.06B model cannot saturate an H100, and memory is
155
+ # nowhere near the limit. So oversubscribe: JOBS_PER_GPU>1 runs several jobs per
156
+ # card and buys ~1.8x at 2/GPU. 3/GPU is ~73 GB of 81 -- it fits but leaves
157
+ # little headroom, so it is opt-in rather than the default.
158
+ JOBS_PER_GPU=${JOBS_PER_GPU:-1}
159
+ SLOTS=$(( (NGPU / NP) * JOBS_PER_GPU )); [ "$SLOTS" -lt 1 ] && SLOTS=1
160
+ say "fan-out: ${NGPU} GPU(s), NP=$NP -> $SLOTS concurrent job(s)"
161
+
162
+ jobs=()
163
+ for NAME in $CKPTS; do
164
+ F="${CKPT_FILE[$NAME]:-}"
165
+ [ -n "$F" ] || { say "unknown checkpoint key: $NAME"; continue; }
166
+ [ -f "$CK/$F" ] || { say "SKIP $NAME: $CK/$F not present"; continue; }
167
+ for TASK in $TASKS; do
168
+ # Skip on .gen, not .done: .done is written only by the scoring loop, which
169
+ # runs after `wait` for ALL generation, so a teardown mid-run would otherwise
170
+ # lose every completed pair. Safe because a signature change clears state/.
171
+ [ -f "$OUT/state/${NAME}.${TASK}.gen" ] && { say " $NAME/$TASK already generated"; continue; }
172
+ [ -f "$OUT/prompts/${TASK}_prompts.bin" ] || { say " SKIP $NAME/$TASK: no prompts"; continue; }
173
+ jobs+=("$NAME:$TASK")
174
+ done
175
+ done
176
+ say "${#jobs[@]} job(s) to run"
177
+
178
+ running=0; g=0
179
+ for J in "${jobs[@]:-}"; do
180
+ [ -z "$J" ] && continue
181
+ NAME=${J%%:*}; TASK=${J##*:}
182
+ F="${CKPT_FILE[$NAME]}"
183
+ PB="$OUT/prompts/${TASK}_prompts.bin"
184
+ G="$OUT/gen/${NAME}_${TASK}.csv"
185
+ # g cycles over SLOTS, which now EXCEEDS the GPU count when JOBS_PER_GPU>1,
186
+ # so the device offset must wrap modulo NGPU -- otherwise slots beyond the
187
+ # last GPU would compute an empty CUDA_VISIBLE_DEVICES and every job there
188
+ # would silently land on device 0.
189
+ dev_off=$(( (g * NP) % NGPU ))
190
+ devs=$(IFS=,; echo "${GPUARR[*]:$dev_off:$NP}")
191
+ say " [gpu $devs] $NAME / $TASK"
192
+ (
193
+ env $ARCH CP_SIZE=$NP CP_T=$T CP_B=1 YARN_SCALE=$YARN \
194
+ ${BF16:+CP_BF16=$BF16} \
195
+ ${YARN_ORIG:+YARN_ORIG_MAXPOS=$YARN_ORIG} \
196
+ CP_INIT_FROM="$PWD/$CK/$F" \
197
+ CP_GENERATE=1 CP_GEN_TOKENS_BIN="$PWD/$PB" \
198
+ CP_GEN_PROMPT_LEN=$PROMPT_LEN CP_GEN_N=$N CP_GEN_MAX_NEW=$MAX_NEW \
199
+ CP_GEN_GREEDY=$GREEDY CP_GEN_OUT="$PWD/$G" \
200
+ CP_GEN_MIN_TOKENS=${MINTOK[$TASK]:-3} \
201
+ CUDA_VISIBLE_DEVICES=$devs \
202
+ mpirun --allow-run-as-root -np $NP "$EXE" \
203
+ > "$OUT/gen/${NAME}_${TASK}.log" 2>&1 \
204
+ && [ -s "$G" ] && touch "$OUT/state/${NAME}.${TASK}.gen"
205
+ ) &
206
+ g=$(( (g + 1) % SLOTS )); running=$(( running + 1 ))
207
+ if [ "$running" -ge "$SLOTS" ]; then wait -n; running=$(( running - 1 )); fi
208
+ done
209
+ wait
210
+
211
+ # ---- 2b. score (cheap, CPU-only, after all generation) ----------------------
212
+ for NAME in $CKPTS; do
213
+ for TASK in $TASKS; do
214
+ G="$OUT/gen/${NAME}_${TASK}.csv"
215
+ MK="$OUT/state/${NAME}.${TASK}.done"
216
+ [ -f "$MK" ] && continue
217
+ if [ ! -s "$G" ]; then
218
+ [ -f "$OUT/gen/${NAME}_${TASK}.log" ] && \
219
+ say " NO OUTPUT $NAME/$TASK -- see $OUT/gen/${NAME}_${TASK}.log"
220
+ continue
221
+ fi
222
+ # A non-empty file is NOT a complete one. If the C++ died partway (e.g. a
223
+ # short read on a stale prompt file) it still flushed the rows it managed,
224
+ # and scoring those would report an accuracy over a handful of prompts and
225
+ # then mark the pair .done. Note: `$(grep -c . f || echo 0)` is WRONG --
226
+ # grep -c prints 0 AND exits 1, so the substitution yields $'0\n0' and
227
+ # [ -eq ] throws. stat above is fine; it prints nothing on failure.
228
+ ROWS=$(grep -c . "$G" 2>/dev/null); ROWS=${ROWS:-0}
229
+ if [ "$ROWS" -ne "$N" ]; then
230
+ say " INCOMPLETE $NAME/$TASK ($ROWS/$N rows) -- not scoring, not marking done"
231
+ continue
232
+ fi
233
+ say " scoring $NAME / $TASK"
234
+ $PY Tests/bluscriptcp/longeval_score.py --gen "$G" \
235
+ --meta "$OUT/prompts/${TASK}_meta.json" \
236
+ --out "$OUT/scores/${NAME}_${TASK}.csv" --show 2 | tee -a "$M"
237
+ touch "$MK"
238
+ done
239
+ done
240
+
241
+ # ---- 3. summary -------------------------------------------------------------
242
+ say "building summary"
243
+ # TASKS must come through argv: the heredoc is QUOTED (<<'PY'), so $TASKS would
244
+ # never expand inside it.
245
+ $PY - "$OUT" "$TASKS" <<'PY' | tee -a "$M"
246
+ import csv, math, os, sys, collections
247
+ out, tasks = sys.argv[1], sys.argv[2].split()
248
+ d = os.path.join(out, "scores")
249
+
250
+ # Filenames are <model>_<task>.csv and BOTH halves contain underscores, so
251
+ # fn.split("_", 1) mis-parses every arm ("arm_b_niah_single" -> "arm").
252
+ # Match the known task list from the tail instead; for/else skips non-matches so
253
+ # `name` cannot silently carry over from the previous iteration.
254
+ per_task = collections.defaultdict(dict) # task -> model -> (hits, n)
255
+ per_depth = collections.defaultdict(dict) # depth -> model -> (hits, n)
256
+ per_task_depth = collections.defaultdict(dict) # (task,depth) -> model -> (hits,n)
257
+ for fn in sorted(os.listdir(d)) if os.path.isdir(d) else []:
258
+ if not fn.endswith(".csv"):
259
+ continue
260
+ for task in tasks:
261
+ if fn.endswith("_" + task + ".csv"):
262
+ name = fn[:-(len(task) + 5)]
263
+ break
264
+ else:
265
+ continue
266
+ rows = list(csv.DictReader(open(os.path.join(d, fn))))
267
+ if not rows:
268
+ continue
269
+ per_task[task][name] = (sum(int(r["ok"]) for r in rows), len(rows))
270
+ for r in rows:
271
+ dep = float(r["depth"])
272
+ h, n = per_task_depth[(task, dep)].get(name, (0, 0))
273
+ per_task_depth[(task, dep)][name] = (h + int(r["ok"]), n + 1)
274
+
275
+ if not per_task:
276
+ print(" no scores yet"); raise SystemExit
277
+
278
+ models = sorted({m for t in per_task.values() for m in t})
279
+ pct = lambda hn: 100.0 * hn[0] / hn[1] if hn[1] else float("nan")
280
+
281
+ print("\n=== per-task accuracy % (secondary/descriptive: ~10 per depth cell) ===")
282
+ print(" " + "task".ljust(18) + "".join(m.rjust(9) for m in models))
283
+ for task in sorted(per_task):
284
+ print(" " + task.ljust(18) + "".join(
285
+ (f"{pct(per_task[task][m]):8.1f}" if m in per_task[task] else " -").rjust(9)
286
+ for m in models))
287
+
288
+ # Degenerate-task exclusion, pre-registered: a task at <=1% overall for EVERY
289
+ # model adds n without information and would shrink the pooled CI spuriously.
290
+ degenerate = {t for t in per_task
291
+ if all(pct(per_task[t][m]) <= 1.0 for m in per_task[t])}
292
+ if degenerate:
293
+ print(f"\n degenerate (<=1% for every model): {sorted(degenerate)}")
294
+ # If EVERY task is degenerate the exclusion would empty the primary table and
295
+ # report nothing at all -- a floor effect is a result, not an absence of one.
296
+ # Fall back to pooling everything and say so, rather than printing a blank table.
297
+ if len(degenerate) == len(per_task):
298
+ print(" ALL tasks degenerate -> FLOOR EFFECT. Pooling everything anyway;")
299
+ print(" differences between models are untestable at this setting (no power).")
300
+ degenerate = set()
301
+
302
+ for (task, dep), byname in per_task_depth.items():
303
+ if task in degenerate:
304
+ continue
305
+ for name, (h, n) in byname.items():
306
+ ph, pn = per_depth[dep].get(name, (0, 0))
307
+ per_depth[dep][name] = (ph + h, pn + n)
308
+
309
+ def wilson(h, n):
310
+ """95% Wilson half-width in points -- honest near 0, unlike the normal approx."""
311
+ if not n:
312
+ return float("nan")
313
+ z, p = 1.96, h / n
314
+ return 100.0 * z * math.sqrt(p * (1 - p) / n + z * z / (4 * n * n)) / (1 + z * z / n)
315
+
316
+ print("\n=== PRIMARY: accuracy % pooled by depth across tasks (+-95% Wilson) ===")
317
+ print(" " + "depth".ljust(8) + "".join(m.rjust(16) for m in models))
318
+ for dep in sorted(per_depth):
319
+ cells = []
320
+ for m in models:
321
+ if m in per_depth[dep]:
322
+ h, n = per_depth[dep][m]
323
+ cells.append(f"{pct((h,n)):6.1f}+-{wilson(h,n):4.1f}".rjust(16))
324
+ else:
325
+ cells.append("-".rjust(16))
326
+ print(" " + f"{dep:<8.2f}" + "".join(cells))
327
+
328
+ with open(os.path.join(out, "summary.csv"), "w", newline="") as f:
329
+ w = csv.writer(f); w.writerow(["task"] + models)
330
+ for task in sorted(per_task):
331
+ w.writerow([task] + [f"{pct(per_task[task][m]):.1f}" if m in per_task[task] else ""
332
+ for m in models])
333
+ with open(os.path.join(out, "depth_summary.csv"), "w", newline="") as f:
334
+ w = csv.writer(f); w.writerow(["depth", "model", "hits", "n", "pct", "wilson95"])
335
+ for dep in sorted(per_depth):
336
+ for m in models:
337
+ if m in per_depth[dep]:
338
+ h, n = per_depth[dep][m]
339
+ w.writerow([dep, m, h, n, f"{pct((h,n)):.1f}", f"{wilson(h,n):.1f}"])
340
+ print(f"\n wrote {out}/summary.csv and {out}/depth_summary.csv")
341
+ PY
342
+
343
+ say "DONE -> $OUT/summary.csv"