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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Handoff: 16k -> 32k YaRN extension on the 2x H200
|
| 2 |
+
|
| 3 |
+
Written 2026-09-09 from the 2x H100 box. Everything below is measured on this
|
| 4 |
+
box unless marked as a projection.
|
| 5 |
+
|
| 6 |
+
## What the 2x H200 CAN and CANNOT do
|
| 7 |
+
|
| 8 |
+
`cp` cannot exceed the GPU count, so on 2 GPUs `tokens/rank = T/2`.
|
| 9 |
+
|
| 10 |
+
| target | tok/rank | total/GPU | 2x H200 (143 GB) |
|
| 11 |
+
|---|---|---|---|
|
| 12 |
+
| 16k | 8,192 | 70.7 GB (measured) | comfortable |
|
| 13 |
+
| **32k** | 16,384 | **130.8 GB (projected)** | **91.4% -- tight, probe first** |
|
| 14 |
+
| 64k | 32,768 | 250.9 GB | 175% -- impossible |
|
| 15 |
+
|
| 16 |
+
- **32k: run it.** `ext_32k.sh` starts with a 3-step probe and aborts on OOM.
|
| 17 |
+
- **64k: needs 4+ GPUs.** 4x H200 at cp=4 = 127.6 GB/GPU fits. Nothing to tune
|
| 18 |
+
on 2 GPUs: `CP_B` is already 1, and there is no activation-recompute flag in
|
| 19 |
+
bluscriptCP.cpp (checked: no `CP_RECOMPUTE`, no gradient checkpointing).
|
| 20 |
+
- 64k **evaluation** is fine on 2 GPUs -- generation stores no activations for
|
| 21 |
+
backward, so the training memory figure does not apply.
|
| 22 |
+
|
| 23 |
+
Measured activation cost is 7.51 MB/token/rank. A first-principles estimate for
|
| 24 |
+
this architecture is 1.3-2.5 MB, so actual is 3-6x higher than it needs to be
|
| 25 |
+
(the config keeps fp32 norms/residual/logits across 36 layers). If that gap is
|
| 26 |
+
real, a memory pass could make 32k comfortable and 64k possible on 2 GPUs -- but
|
| 27 |
+
that is a C++ change, not a flag, and it is unprofiled.
|
| 28 |
+
|
| 29 |
+
## Setup on the new box (nothing is pre-installed)
|
| 30 |
+
|
| 31 |
+
```bash
|
| 32 |
+
cd /root/Adhi/BluTrain/dist/Context_Parallelism
|
| 33 |
+
|
| 34 |
+
# 1. build -- BOTH targets, libtensor first
|
| 35 |
+
make libtensor SM_ARCH=90 -j$(nproc)
|
| 36 |
+
make CP_FUSED_ROPE=1 CP_ATTN_SPLIT=1 SM_ARCH=90 bluscript-cp -j$(nproc)
|
| 37 |
+
|
| 38 |
+
# 2. tiktoken -- longeval_gen.py needs it. WITHOUT IT training runs fine and the
|
| 39 |
+
# eval silently produces "no prompts" / "no scores yet". This has bitten twice.
|
| 40 |
+
/root/Adhi/BluTrain/envv/bin/pip install tiktoken
|
| 41 |
+
|
| 42 |
+
# 3. hf auth (the dataset is public now, but the model repo push needs a token)
|
| 43 |
+
hf auth login
|
| 44 |
+
|
| 45 |
+
# 4. parent checkpoint: l2, the best 16k arm. cp=2 needs it on BOTH ranks.
|
| 46 |
+
python - <<'PY'
|
| 47 |
+
from huggingface_hub import hf_hub_download
|
| 48 |
+
import shutil, os
|
| 49 |
+
p = hf_hub_download("unparallelled/BluScriptCP",
|
| 50 |
+
"checkpoints/lenbucket_l2_blumodelcp_run2_step_400.ckpt")
|
| 51 |
+
for r in (0, 1):
|
| 52 |
+
d = f"checkpoints_bluscriptcp/rank_{r}/lenbucket_l2_blumodelcp_run2_step_400.ckpt"
|
| 53 |
+
os.makedirs(os.path.dirname(d), exist_ok=True)
|
| 54 |
+
if not os.path.exists(d):
|
| 55 |
+
shutil.copyfile(p, d)
|
| 56 |
+
PY
|
| 57 |
+
|
| 58 |
+
# 5. b3 data (4 train shards + val ~ 930 MB) and the b2-val haystack
|
| 59 |
+
hf download unparallelled/BluScriptCP-data --repo-type dataset \
|
| 60 |
+
--include "cp_data_by_length/b3_16384_32768/train_shard_0000[0-3].bin" \
|
| 61 |
+
--include "cp_data_by_length/b3_16384_32768/val_shard_00000.bin" \
|
| 62 |
+
--include "cp_data_by_length/b2_8192_16384/val_shard_00000.bin" \
|
| 63 |
+
--local-dir ./dl
|
| 64 |
+
mkdir -p lendata/b3_16384_32768 lendata/haystack
|
| 65 |
+
cp dl/cp_data_by_length/b3_16384_32768/*.bin lendata/b3_16384_32768/
|
| 66 |
+
cp dl/cp_data_by_length/b2_8192_16384/val_shard_00000.bin lendata/haystack/b2val_haystack.bin
|
| 67 |
+
|
| 68 |
+
# VERIFY -- `hf download` exits 0 and prints a path even when --include matches
|
| 69 |
+
# NOTHING. Always ls, never trust the exit code.
|
| 70 |
+
ls -la lendata/b3_16384_32768/ lendata/haystack/
|
| 71 |
+
|
| 72 |
+
# 6. run it
|
| 73 |
+
./ext_32k.sh
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
## The run
|
| 77 |
+
|
| 78 |
+
```
|
| 79 |
+
CP_T=32768 YARN_SCALE=2 YARN_ORIG_MAXPOS=16384
|
| 80 |
+
parent: lenbucket_l2_blumodelcp_run2_step_400.ckpt
|
| 81 |
+
data: b3_16384_32768 (docs 16-32k -- these now FIT inside the window)
|
| 82 |
+
750 steps x 1,048,576 = 786 M tokens, matching run7's original 4k->16k extension
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
**The YaRN invariant, which cost 27pp when it was wrong:** `YARN_SCALE *
|
| 86 |
+
YARN_ORIG_MAXPOS` must equal `CP_T` exactly, and `ORIG_MAXPOS` must be the
|
| 87 |
+
model's ORIGINAL PRETRAIN length -- for this family, 4096. The default at
|
| 88 |
+
`YARNOps.cpp:57` is **1024** -- always set it explicitly. `ext_32k.sh` asserts
|
| 89 |
+
the product.
|
| 90 |
+
|
| 91 |
+
**CORRECTION 2026-09-15.** This rule previously read "`ORIG_MAXPOS` must be the
|
| 92 |
+
length the weights were ACTUALLY trained at". That is right for a single
|
| 93 |
+
extension but WRONG for a staged ladder, where after stage one the two stop
|
| 94 |
+
being the same number. Hold `ORIG_MAXPOS` at 4096 and raise `SCALE` instead:
|
| 95 |
+
4 -> 8 -> 16 for 16k -> 32k -> 64k.
|
| 96 |
+
|
| 97 |
+
Why: `build_rope_cache` is rebuilt FROM BASE THETA every run (it takes
|
| 98 |
+
`rope_theta`, not the previous stage's cache), so `SCALE` always applies to the
|
| 99 |
+
ORIGINAL frequencies and never composes with the previous stage's. Re-basing
|
| 100 |
+
therefore freezes interpolation instead of deepening it:
|
| 101 |
+
|
| 102 |
+
stage as-run (re-based) interp last tok -> virtual ramp
|
| 103 |
+
16k 4 x 4096 theta/4 4,096 [14,32]
|
| 104 |
+
32k 2 x 16384 theta/2 16,384 [21,39]
|
| 105 |
+
64k 2 x 32768 theta/2 32,768 [24,42]
|
| 106 |
+
|
| 107 |
+
stage corrected (orig=4096) interp last tok -> virtual ramp
|
| 108 |
+
16k 4 x 4096 theta/4 4,096 [14,32]
|
| 109 |
+
32k 8 x 4096 theta/8 4,096 [14,32]
|
| 110 |
+
64k 16 x 4096 theta/16 4,096 [14,32]
|
| 111 |
+
|
| 112 |
+
Holding orig=4096 pins the far end of every window onto the 4096 range the base
|
| 113 |
+
was actually pretrained on, and keeps the ramp fixed, because `find_dim()` takes
|
| 114 |
+
(num_rot, L, head_dim, base) -- `scale` is NOT an argument, so the interpolated
|
| 115 |
+
dimension set moves only when `ORIG_MAXPOS` moves. Re-basing instead puts the
|
| 116 |
+
64k model at virtual position 32,768, i.e. 8x beyond anything it ever saw, with
|
| 117 |
+
YaRN doing almost none of the work it exists to do.
|
| 118 |
+
|
| 119 |
+
The 1.06B ladder (ext_32k.sh, b4_full_epoch.sh, ext64k_b5.sh, mix64k_h200.sh,
|
| 120 |
+
mixcont_h100.sh) followed the OLD rule and is affected from the 32k stage on.
|
| 121 |
+
This is NOT thought to be the cause of the retrieval collapse -- a wrong cache
|
| 122 |
+
is a static defect, while the collapse was progressive and tracked cumulative
|
| 123 |
+
b5 exposure across two lineages -- but it plausibly lowered the ceiling.
|
| 124 |
+
The 680M ladder (p1/p2/p3_680m.sh) uses the corrected scheme.
|
| 125 |
+
|
| 126 |
+
Projected step time ~25-29 s (2x the 16k tokens/rank plus attention's quadratic
|
| 127 |
+
term), so **750 steps ~ 5-6.5 h**. Unmeasured; the probe prints the real number.
|
| 128 |
+
|
| 129 |
+
## Why this run, in one paragraph
|
| 130 |
+
|
| 131 |
+
The document-length ladder is finished and it ended in a tie. Holding everything
|
| 132 |
+
else fixed at a 16k window:
|
| 133 |
+
|
| 134 |
+
| arm | training docs | 4096 | 8192 | 16360 |
|
| 135 |
+
|---|---|---|---|---|
|
| 136 |
+
| armA_c | flux, median 826 | 73.0 | 53.0 | 33.0 |
|
| 137 |
+
| l1 | b1 4-8k (fits) | 75.0 | 48.0 | 30.0 |
|
| 138 |
+
| l2 | b2 8-16k (fits) | **80.0** | 62.0 | **35.0** |
|
| 139 |
+
| l3 | b3 16-32k (TRUNCATED) | 74.0 | **64.0** | **35.0** |
|
| 140 |
+
|
| 141 |
+
l3 - l2 = -6.0 / +2.0 / +0.0 pp, none resolvable (combined 95% bars +-11.5 to
|
| 142 |
+
+-13.1). The haystack (b2-val) is in-distribution for l2 and out-of-distribution
|
| 143 |
+
for l3, so the bias runs TOWARD l2 and l3 still only drew level. Conclusion:
|
| 144 |
+
**document length helps only while documents fit inside the window.** Hence widen
|
| 145 |
+
the window, then feed b3.
|
| 146 |
+
|
| 147 |
+
## Gate the result on SHORT context, not perplexity
|
| 148 |
+
|
| 149 |
+
On 2026-09-02 a mismatched cache IMPROVED 16k (0 -> 14-17%) while COLLAPSING 4k
|
| 150 |
+
from 74% to 16%. Perplexity at the new length looked fine. `ext_32k.sh` therefore
|
| 151 |
+
evaluates 1024 / 4096 / 16360 / 32744 and **a regression at 1k or 4k is a failure
|
| 152 |
+
even if 32k improves.** Compare against l2's row above.
|
| 153 |
+
|
| 154 |
+
(32744 is not arbitrary: `PROMPT_LEN + MAX_NEW` must pad up to <= `CP_T` with
|
| 155 |
+
PAD=256, and 32744 + 24 = 32768 exactly.)
|
| 156 |
+
|
| 157 |
+
## Traps already paid for
|
| 158 |
+
|
| 159 |
+
1. **Never edit a running bash script.** Bash reads incrementally from a byte
|
| 160 |
+
offset; an insert shifts it and the interpreter resumes mid-line. This killed
|
| 161 |
+
`ladder_456.sh` with `syntax error near unexpected token 'do'`.
|
| 162 |
+
2. **`pgrep -f <script>.sh` matches the shell running it.** Killed my own shell
|
| 163 |
+
twice (exit 144). Exclude `$$`.
|
| 164 |
+
3. **Verify all rank shards** before trusting a checkpoint. A 3-of-4 set loads
|
| 165 |
+
silently wrong, and a zero exit code is not proof -- bluscriptCP catches a
|
| 166 |
+
failed save and only prints `[WARN]`.
|
| 167 |
+
4. **`say()` must write to stderr.** On stdout it poisons `$(...)` capture; that
|
| 168 |
+
fed a 3-line path into `CP_INIT_FROM` and aborted a run on rank 2.
|
| 169 |
+
5. **Run-number collisions.** `run_number` is the first free
|
| 170 |
+
`CP_BluScreipt_Training_logs/CP_Training_log<N>.csv`. A collision with an
|
| 171 |
+
existing checkpoint prefix let `CP_CKPT_KEEP=1` prune a live shard.
|
| 172 |
+
6. **`CP_STABLE` cannot equal `CP_MAX_STEPS`** -- `bluscriptCP.cpp:1006` aborts
|
| 173 |
+
with "leaves no cosine decay tail". Leave at least a 2-step tail; the guard
|
| 174 |
+
reads `CP_WARMUP` while `get_lr` uses `CP_REWARMUP`, so pin both.
|
| 175 |
+
7. **`CP_REWARMUP_ANCHOR=0` on every resume**, or each resume re-anchors a fresh
|
| 176 |
+
warmup ramp and the LR sawtooths (`bluscriptCP.cpp:2105`).
|
| 177 |
+
|
| 178 |
+
## Concurrently, on the 2x H100 box
|
| 179 |
+
|
| 180 |
+
Long b3 arm at 16k: run 17, 4,000 steps, WSD with flat 3.0e-4 for steps
|
| 181 |
+
100-3899 then a 100-step tail. Tests whether more long-context STEPS flatten the
|
| 182 |
+
slope -- the open question, since all arms sat at -18 to -29 pp/doubling while
|
| 183 |
+
Phi-3.5-mini (3.8B) manages -3.6. Checkpointed every 25 steps, `KEEP=2`. An
|
| 184 |
+
eval at step 1000 fires automatically, then the run resumes to 4000.
|
| 185 |
+
|
| 186 |
+
## Not to do
|
| 187 |
+
|
| 188 |
+
- **b4/b5/b6 at a 16k window** -- l3 already showed truncated documents add
|
| 189 |
+
nothing. b4 only becomes useful after a 64k extension.
|
| 190 |
+
- **b6 in a matched ladder** -- 57 M training tokens is 0.27x of one 400-step
|
| 191 |
+
arm; it would cycle 3.7x through all 790 documents.
|
| 192 |
+
- **Chasing 128k.** No 4B-class model has effective 128k: applying RULER's own
|
| 193 |
+
threshold (Llama2-7B at 4k = 85.6), Phi-3.5-mini (3.8B, 128k claimed) has an
|
| 194 |
+
effective context of **32k**, and so does Llama-3.1-8B-instruct. 32k is the
|
| 195 |
+
right target, and it is also where this corpus runs out (2.35 B tokens above
|
| 196 |
+
32k, total).
|