Cion-lab commited on
Commit
f345921
·
verified ·
1 Parent(s): 03388e8

publish docs/: plan, mix rationale, preflight report, run log, frozen eval protocol, final report

Browse files
docs/00-platform-notes.md ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 00 — Platform notes (Phase 0)
2
+
3
+ Observed mechanics of the two execution environments this project spans: this workspace and the
4
+ Kaggle image. Everything here was **measured on 2026-09-19**, not recalled. Where a claim contradicts
5
+ prior documentation (including the Kaggle skill's own notes), the contradiction is called out, because
6
+ a future session will otherwise trust the older statement.
7
+
8
+ Raw probe JSON lives in the run logs of the kernels listed in `memory/ASSETS.md`.
9
+
10
+ ---
11
+
12
+ ## 1. The two environments are not the same machine
13
+
14
+ | | this workspace | Kaggle CPU session | Kaggle GPU session (2xT4) |
15
+ |---|---|---|---|
16
+ | OS | Windows 11, git-bash | Linux 6.12.90+, glibc 2.35 | Linux 6.12.90+, glibc 2.35 |
17
+ | Python | 3.11 (and 3.14) | **3.12.13** | **3.12.13** |
18
+ | Docker image | n/a | `gcr.io/kaggle-images/python@sha256:dafd4ce5…c40b9` | `gcr.io/kaggle-gpu-images/python@sha256:37c64f7d…7d461` |
19
+ | torch | — | **2.10.0+cpu** | **2.10.0+cu128** |
20
+ | internet | — | yes (needs `enableInternet: true`) | yes (needs `enableInternet: true`) |
21
+ | GPU | none | `device_count()==0` | **2x Tesla T4, cc 7.5, 40 SM, 14.56 GiB usable each** |
22
+
23
+ **Consequence:** CPU and GPU sessions are *different images*, not one image with a GPU attached. The
24
+ CPU image's `torch` is a `+cpu` build, so a script that imports `torch.cuda` will work on the GPU
25
+ shape and silently do nothing useful on the CPU shape. Pin these digests in any job that must be
26
+ reproducible; a "latest" Kaggle image can move under the run.
27
+
28
+ `huggingface_hub` is **1.32.0 locally** and reported as `huggingface-hub 1.11.0` inside the Kaggle
29
+ image. Local code and in-job code are therefore on different minor versions — an API that exists
30
+ locally may not exist in the job (`create_repo(tags=…)` is one such example; it raised
31
+ `TypeError` locally). Check the target environment's version before using a new API.
32
+
33
+ ## 2. Job mechanics that the main run will depend on
34
+
35
+ - **Submission is one call.** `save_notebook` with `kernelExecutionType: "SaveAndRunAll"` creates
36
+ *and* runs. `kernelType: "script"` and `machineShape` must both be present or the call fails with a
37
+ message-less error. `machineShape: "GPU"` + `enableGpu: true` is accepted and yields 2xT4 — no
38
+ T4-specific shape string is needed, and none should be invented.
39
+ - **`newTitle` rewrites the slug.** Kept `newTitle` equal to the slug suffix in every probe so the
40
+ returned `ref` matched what was requested. Still: **poll the returned slug, never the requested one.**
41
+ - **Latency.** A ~30 s CPU script went submit → `COMPLETE` in ~85 s; a ~58 s GPU script in ~145 s.
42
+ So budget **~60–90 s of queue+boot per job**, and don't poll sooner than ~60 s. Both figures are
43
+ single samples from an uncongested account at ~15:20 UTC.
44
+ - **Where output lands.** `list_notebook_session_output` returns `files[]` (signed URLs, expiry
45
+ unknown — download promptly) and `log`, a JSON array of `{stream_name, time, data}` where `time` is
46
+ **seconds since session start**, one array element per line. The log carries the whole stdout, so a
47
+ probe that prints its result as JSON needs no file download. **Only files written under
48
+ `/kaggle/working` are returned** — the probes deliberately wrote nothing to `/tmp`, because `/tmp`
49
+ looks enormous (§4) and is therefore the easiest place to silently lose an artifact.
50
+ - **Kernel logs are not secret-safe.** Anything printed is retained in the kernel revision. No token
51
+ may be printed, and by extension no token may be *in the kernel source*, since source and logs are
52
+ both Kaggle-held.
53
+ - **`CUDA_VISIBLE_DEVICES` is unset in both shapes** — it is absent from the environment entirely, not
54
+ set to the string `"None"`. The Kaggle skill documents `CUDA_VISIBLE_DEVICES=None` for CPU runs;
55
+ that is wrong for this image (E-002 in `memory/ERRORS.md`), and code that branches on
56
+ `== "None"` will take the GPU branch on a CPU box. Gate on `torch.cuda.is_available()` or
57
+ `torch.cuda.device_count()` instead.
58
+
59
+ ## 3. Quota accounting
60
+
61
+ - Readout is **seconds**: `total_time_allowed: "108000s"` = 30 h, `quota_refresh_time:
62
+ 2026-09-26T00:00:00Z`. Weekly reset is **Saturday 00:00 UTC**.
63
+ - CPU sessions cost **zero** GPU quota, confirmed: two CPU probes ran and `time_used` stayed `0s`.
64
+ - A 2xT4 session charged **66.411 s** for **58.4 s** of script time → **~1x wall-clock, not 2x**.
65
+ Full reasoning, the caveat, and the second sample pending in `memory/QUOTA.md`. This is the single
66
+ most schedule-relevant number measured in Phase 0: at 1x, 30 h/week is 30 wall-clock hours with
67
+ both cards, not the 15 that §2's "shared across both cards" phrasing suggests.
68
+
69
+ ## 4. Disk and memory — the assumption in §2 is only half right
70
+
71
+ | Mount | Total | Free | Notes |
72
+ |---|---|---|---|
73
+ | `/kaggle/working`, `/kaggle/input` | **19.5 GB** | 19.5 GB | the small Kaggle disk; **only this is retrieved as output** |
74
+ | `/dev/loop1` → `/kaggle/src` | 20 GB | 20 GB | separate loop device |
75
+ | `/`, `/tmp`, `/usr`, `/root/.cache` (overlay) | 7.9 TB | **1.1 TB** | **shared host filesystem, 88 % used by other tenants** |
76
+ | `/dev/shm` | 14 GB | 14 GB | useful for DataLoader worker traffic |
77
+ | RAM | 32 GB (`cgroup memory.max` = 30 GiB) | 31.2 GB available | `SwapTotal: 0` |
78
+ | CPU | 4 vCPU (`cpu.max` = `400000 100000`), Intel Xeon @ 2.20 GHz | | |
79
+
80
+ **Read this carefully before planning the checkpoint cycle.** §2 says "Kaggle disk is small", and for
81
+ `/kaggle/working` that is exactly true: 19.5 GB. But the root overlay reports ~1 TB free, and a naive
82
+ optimisation would write caches or staged shards there. Two reasons not to:
83
+
84
+ 1. The overlay is a **shared host volume already at 88 %**, so "1 TB free" is other tenants' headroom
85
+ and can disappear mid-run. §3.13's "never let it fill the disk" must be enforced against a number
86
+ we do not control.
87
+ 2. Nothing outside `/kaggle/working` is retrievable when the session ends, so it is not storage in
88
+ any sense that matters.
89
+
90
+ Default `HF_HOME`/datasets cache resolves under `/root/.cache`, i.e. the overlay, not the 19.5 GB
91
+ volume. So **a training job's apparent free space can be large while `/kaggle/working` fills up** —
92
+ the failure mode §3.13 warns about is invisible to a naive `disk_usage("/")` check. **Every job must
93
+ measure the specific filesystem it writes to, and log free space for that path.** On the CPU shape the
94
+ effective budget is ~19.5 GB; treat that as the design number for shards resident at once.
95
+
96
+ No swap: a tokenizer build or a large in-memory dedup on a 30 GiB cgroup must be sized, not streamed
97
+ optimistically.
98
+
99
+ ## 5. Network behaviour, including one thing that does not resolve
100
+
101
+ Working, measured from inside a GPU and a CPU session:
102
+ `huggingface.co/api/models` → 200 in 149 ms; `pypi.org/simple/` → 200 in 73 ms;
103
+ `datasets/…/resolve/main/README.md` → 200 via `api/resolve-cache/…`;
104
+ `datasets.load_dataset("wikimedia/wikipedia", "20231101.en", streaming=True)` → first row in **7.4 s**,
105
+ unauthenticated. `pip install` from PyPI works: `xxhash` in **5.8 s**, import verified.
106
+
107
+ **Does not resolve:** `cdn-lfs.huggingface.co`, `cdn-lfs-us-1.huggingface.co`, `xethub.huggingface.co`
108
+ → `gaierror`. That looked alarming, so probe D tested it directly by pulling 300 MB from two large
109
+ public parquet files.
110
+
111
+ **Sustained Hub download throughput from inside a session: 72.8 MB/s** (`wikimedia/wikipedia`, 745 MB
112
+ file) **and 88.9 MB/s** (`HuggingFaceFW/fineweb-edu`, 2334 MB file), with 0.8–0.94 s time-to-first-byte.
113
+ So the non-resolving LFS hostnames do not block bulk transfer — `resolve/` redirects land on hosts that
114
+ do resolve. **Ingest of the mix is not network-bound:** at a conservative 70 MB/s, one billion tokens
115
+ (≈3.6 GB of raw text at ~3.6 chars/token, or ~4–6 GB as parquet) downloads in single-digit minutes.
116
+ Phase 2 should plan shard staging around CPU and disk limits, not bandwidth.
117
+
118
+ Also measured in the same probe: `datasets` streaming at **139.5 rows/s ≈ 3.0 MB of text per second**
119
+ single-process, unauthenticated (83 rows/s / 1.8 MB/s cold, ~3 MB/s warm). Unauthenticated Hub access
120
+ works but the API warns about rate limits (`Please set a HF_TOKEN`); at multi-hundred-shard scale that
121
+ is a plausible 429 source, which is an argument for the token-in-job path (D-002) for the *data plane*
122
+ even if the *checkpoint plane* stays local.
123
+
124
+ Enumerating repo files without a client library: `GET https://huggingface.co/api/datasets/<id>/tree/main?recursive=true`
125
+ returns `path`/`size`/`type` and works with plain `urllib`. It appeared to cap at 1000 entries
126
+ (`fineweb-edu` returned exactly 1000), so **assume pagination is required** for a large repo.
127
+
128
+ ### CPU-side ingest throughput, and what it rules out
129
+
130
+ Measured on the Kaggle CPU shape (4 vCPU Xeon @ 2.2 GHz) with the gpt2 tokenizer over 6 MB of real
131
+ Wikipedia English, `tokenizers 0.22.2` `Tokenizer.encode_batch`:
132
+
133
+ | cores | tokens/s | hours to tokenize 1B tokens |
134
+ |---|---|---|
135
+ | 1 | 245,660 | 1.13 |
136
+ | 2 | 492,191 | 0.56 |
137
+ | 4 | **660,943** | **0.42** |
138
+
139
+ `chars_per_token` 4.53 on this corpus. Scaling is near-linear to 2 cores and then sub-linear
140
+ (2.7x at 4 cores), which is what a GIL-bound parent feeding rayon workers looks like — so a Phase 2
141
+ pipeline that shards by **process**, not by thread, should recover the rest. `datasets` streaming ran
142
+ at 151.6 rows/s ≈ **3.26 MB of text per second** single-process, unauthenticated.
143
+
144
+ **The conclusion is a negative result, which is the useful kind:** tokenizing 1B tokens costs ~0.4 h of
145
+ the 4-core budget, and at 35–89 MB/s the raw bytes arrive faster than `datasets` can stream them.
146
+ **Phase 2 is therefore not CPU-bound and not bandwidth-bound — it is bound by dedup memory and by the
147
+ 30 GiB cgroup with no swap.** Budget the design accordingly: the dedup/audit stage must be written to
148
+ stream and shard against fixed RAM, not to hold a billion sketches, and the only real wall-clock cost
149
+ in building the mix is the exact-duplicate/n-gram overlap pass. Note also that download throughput
150
+ varied by 2.5x between identical runs (36.9 → 72.8 → 63.2 MB/s), so it should be measured inside the
151
+ actual ingest job rather than treated as a constant.
152
+
153
+
154
+ ## 6. Accelerator capability envelope (Turing, cc 7.5)
155
+
156
+ Established inside a GPU session, not assumed:
157
+
158
+ - **`torch.compile` works** (`warm + 20 steps` of an MLP in 6.0 s, incl. first-call compile).
159
+ - **Flash-attention is not available.** `SDPBackend.FLASH_ATTENTION` raises
160
+ `No available kernel. Aborting execution.`, preceded by
161
+ `Flash attention only supports gpu architectures in the range [sm80, sm121]. Attempting to run on
162
+ a sm 7.5 gpu.` — so this is architectural, not a missing dependency, and installing `flash-attn`
163
+ cannot fix it. **§3's "never touch Hopper-only kernels" now has a concrete instance.**
164
+ - **`EFFICIENT_ATTENTION` and `MATH` SDPA backends both run.** Memory-efficient attention is the
165
+ viable fast path; note torch warns "Memory efficient attention has been runtime disabled" *when
166
+ flash is force-requested*, so backend selection must be explicit.
167
+ - `torch.cuda.get_arch_list()` includes `sm_75` (also 70, 80, 86, 90, 100, 120) — this torch build
168
+ does have kernels for the card.
169
+ - CUDA 12.8, cuDNN 9.10.2, **NCCL 2.27.5** present; `triton 3.6.0` present.
170
+ - Absent from the image: `flash-attn`, `xformers`, `trl`, `deepspeed`, `bitsandbytes`, `liger-kernel`,
171
+ `evaluate`. Present: `transformers 5.0.0`, `datasets 5.0.0`, `accelerate 1.13.0`,
172
+ `tokenizers 0.22.2`, `safetensors 0.7.0`, `numpy 2.0.2`, `pyarrow 24.0.0`, `peft 0.19.1`.
173
+ - bf16 is a hardware question, not a torch one: `torch.bfloat16` *tensors* exist, and bf16 on cc 7.5
174
+ is at best emulated. Probe C records whether an autocast-bf16 forward even completes and what it
175
+ costs, so the Phase 1 precision decision is evidence-backed rather than a recitation of "no bf16".
176
+ - `nvidia-smi` has no `multiprocessor_count` query field (rc=2); use `torch.cuda.…
177
+ get_device_properties(i).multi_processor_count` (40/SM) instead.
178
+
179
+ ## 7. fp16 training trap found by accident
180
+
181
+ Probe B ran a small Llama with **weights cast to fp16** (`model.cuda().to(torch.float16)`) under
182
+ autocast with a plain AdamW and **no GradScaler**: every loss came back `NaN` in 65 steps. That is the
183
+ classic fp16 underflow/overflow signature, and it is exactly the kind of bug that would otherwise be
184
+ discovered 10 hours into the main run. Probe C re-runs the throughput measurements with the correct
185
+ recipe — **fp32 master weights + `torch.autocast(fp16)` + `torch.amp.GradScaler("cuda")` + grad
186
+ clipping** — and asserts finiteness, because on T4 there is no bf16 fallback: fp16 with loss scaling
187
+ is the only mixed-precision option, so getting it right is not optional.
188
+
189
+ ## 8. What Phase 0 has *not* yet proven
190
+
191
+ Be honest about the boundary of this gate:
192
+
193
+ - **Hub writes from inside a Kaggle job** — never attempted. No credential path chosen (D-002 open).
194
+ - **NCCL across these two T4s** — still unproven; probe B's attempt was defeated by its own parser,
195
+ and one failed `all_reduce` is not evidence either way. Probe C is fixing that now.
196
+ - **Checkpoint upload → independent verification → local delete → free-space-confirmed (§3.13)** —
197
+ untouched; that is a Phase 3 gate, and it needs the real 100M-model sizing arithmetic first.
198
+ - **Cold resume on a fresh instance with an empty disk** — Phase 3.
199
+ - **Real session caps**: `sessionTimeoutSeconds` was accepted and no session ran long enough to hit
200
+ any limit. The actual wall-clock ceiling, idle-timeout behaviour, and preemption policy are
201
+ **unknown**, and the multi-week resume plan in Phase 4 depends on them. Probe E
202
+ (`ounce100m-p0e-session-cap`) is a ~12.5 h CPU heartbeat running now specifically to find this;
203
+ if Kaggle kills it, the last heartbeat is the answer. **Update while writing: the session was still
204
+ `RUNNING` at 108 minutes** (submitted 15:38Z, checked 17:26Z), so no CPU cap exists below ~1.8 h. That
205
+ already rules out the worst case for Phase 4 — a session that dies inside an hour — and the build is
206
+ sized so one source (~5–40 min) is the unit of lost work either way.
207
+
208
+ ## 9. GPU probe C results — the numbers the schedule is built on
209
+
210
+ Kernel `dodosoomro/ounce100m-p0c-fp16-ddp` v2, GPU image
211
+ `gcr.io/kaggle-gpu-images/python@sha256:37c64f7d…7d461`, 2x Tesla T4, charged 157.704 s of quota.
212
+
213
+ Probe B's two void measurements are now replaced. Model shape used — deliberately near the likely
214
+ main-run shape so the arithmetic is about the real run and not a toy:
215
+ `hidden 768, layers 12, heads 12, GQA kv_heads 3, FFN 2048, vocab 50257, tied embeddings, seq 1024`
216
+ → **112,934,400 parameters**, of which 38,597,376 are the (tied) embedding.
217
+
218
+ | measurement | result |
219
+ |---|---|
220
+ | fp32 master weights + `autocast(fp16)` + `GradScaler` + clip | **loss 9.988, finite** — the recipe works; probe B's NaN was the recipe, not the hardware |
221
+ | bf16 `autocast` on cc 7.5 | **runs** (loss 10.966, first fwd 0.36 s) — i.e. *emulated*, not tensor-cored |
222
+ | tokens/s, 1 GPU, sdpa, bs4×1024 | 6,478 |
223
+ | tokens/s, 1 GPU, **eager**, bs4×1024 | **7,239** |
224
+ | tokens/s per rank, DDP 2 ranks, sdpa, bs4×1024 | 5,531 → **11,062 aggregate** |
225
+ | DDP scaling efficiency | 11,062 / 6,478 = **1.71x** (85 % of ideal) |
226
+ | NCCL across these two T4s | **works** — `rc 0`, `backend nccl`, `world 2`, both ranks finite, 30 steps |
227
+ | peak CUDA memory, bs4×1024, 1 GPU | **11.51 GB** (sdpa) / 13.79 GB (eager) of 14.56 GB usable |
228
+ | peak CUDA memory, bs4×1024, DDP | 8.68 GB per rank |
229
+ | micro-batch ceiling at this shape | **bs 8 OOMs** (`Tried to allocate 1.54 GiB… 520 MiB free`) |
230
+
231
+ ### What each line forces
232
+
233
+ - **`eager` beat `sdpa` here (7,239 vs 6,478 tok/s).** At `seq_len 1024` the memory-efficient kernel's
234
+ overhead is not repaid, and flash-attention is unavailable on sm 7.5 anyway. Do not assume "flash is
235
+ the fast one" — Phase 3 must re-measure at the frozen sequence length, because the crossover is
236
+ length-dependent.
237
+ - **Memory, not compute, is the binding constraint on batch size.** bs4 fits in 11.5 GB of 14.56 GB;
238
+ bs8 does not fit at all. So global batch must be built with **gradient accumulation**, not larger
239
+ micro-batches — which also means the usual "increase batch until full" advice is unavailable here.
240
+ The fp32 AdamW state for a 100M model (≈1.2 GB) plus fp32 master weights is a fixed floor that
241
+ does not shrink with batch size.
242
+ - **85 % DDP efficiency is good enough to plan on**, and is the number the ETA below uses. It was
243
+ measured on 30 steps with NCCL over PCIe between two T4s; treat it as optimistic-typical, not a
244
+ guaranteed constant.
245
+ - **bf16 running is a trap, not a permission.** §2 and §8 both rule it out. On Turing it is emulated,
246
+ so a config that silently selects bf16 will "work" and be slow. Precision must be asserted to be
247
+ fp16 in the frozen config, not left to a library default.
248
+
249
+ ### First ETA, from measurement rather than hope
250
+
251
+ `1e9 tokens ÷ 11,062 tok/s = 90,400 s ≈ 25.1 wall-clock hours` at the measured aggregate rate.
252
+
253
+ Against a 30 h weekly allowance accruing at 1x, **the main run fits inside one week of quota on this
254
+ shape — but with only ~5 h of headroom**, which is not enough to survive both checkpoint upload time
255
+ and the multi-session restarts that §4/Phase 4 assume. Three honest caveats on that number:
256
+
257
+ 1. It is a 30-step measurement on one shape that is **over the parameter budget** (112.9 M > 110 M),
258
+ so the frozen config will differ and throughput with it.
259
+ 2. It excludes checkpoint write/upload/verify cycles, `DataLoader` stalls, and any
260
+ tokenisation-time-vs-disk tradeoff in the input pipeline.
261
+ 3. It assumes sessions can run long enough to be efficient; the cap is unknown until probe E reports.
262
+
263
+ Planning stance for `docs/01-plan.md`: treat **~9–11k tok/s aggregate** as the working band, size the
264
+ token target from the *low* end (~28–31 h for 1 B tokens → exceeds a single week, so plan for a
265
+ two-week run), and revisit once Gate 3 measures the frozen configuration. Do not let the 25 h figure
266
+ become the plan's basis, because it leaves no room for the interruption budget that §3.1 explicitly
267
+ expects to be spent.
268
+
269
+ ## 10. Credentials and the Kaggle-side secret store
270
+
271
+ `dodosoomro/ounce100m-p1-credential-path` (CPU, read-only) established:
272
+
273
+ - Internet-enabled Kaggle sessions **arrive pre-authenticated against the Kaggle API**. The `kaggle`
274
+ CLI **2.0.2 is preinstalled**, and `kaggle config view` reports `username: dodosoomro`,
275
+ `auth_method: ACCESS_TOKEN`, config from `/root/.config/kaggle` — with no `kaggle.json` written by
276
+ us. `kaggle kernels list --mine` returns real rows, so the principal is genuinely usable, not merely
277
+ present. Injected env vars: `KAGGLE_API_V1_TOKEN` (32 ch), `KAGGLE_DATA_PROXY_TOKEN` (473),
278
+ `KAGGLE_USER_SECRETS_TOKEN` (245).
279
+ - **No Hugging Face credential exists in the container**: `HF_TOKEN` and `HUGGING_FACE_HUB_TOKEN` are
280
+ both absent, `HF_HOME` unset, `~/.cache/huggingface` does not exist. An anonymous Hub *write* is
281
+ correctly rejected — `POST /api/models/…/commit/main` → **401 Unauthorized** — while anonymous reads
282
+ work. So jobs can pull data freely and cannot push anything until given a token.
283
+ - `/kaggle/input` is empty and `/kaggle/input/.secrets/` **does not exist**, so Kaggle's UI-configured
284
+ "user input / secrets" facility is unavailable: enabling it is a web-UI action, and there are no
285
+ locally usable Kaggle credentials to do it with (`~/.kaggle` absent on this machine; Kaggle auth lives
286
+ in the MCP server and inside the container). That rules out option 1 of D-002 for a concrete reason.
287
+ - **Consequence: the in-job authenticated Kaggle API is the usable secret store.** A job can create a
288
+ **private** Kaggle dataset holding the HF token; later jobs mount it via `datasetDataSources` and read
289
+ it from `/kaggle/input/…`, so the token appears in exactly one private kernel revision instead of in
290
+ every job's source. §2 explicitly sanctions "a secret store", so this is the intended mechanism.
291
+
292
+ **Ordering used, because the failure mode is unrecoverable.** `kaggle datasets create` derives
293
+ visibility from a metadata field whose name has moved between CLI versions, and an unrecognised key is
294
+ **silently ignored** — which would create a *public* dataset containing the token. So the bootstrap
295
+ worker (a) creates the dataset with an inert placeholder only, (b) proves privacy by confirming an
296
+ **anonymous** download fails, and (c) uploads the credential as a later version only if (b) passes,
297
+ then re-proves. If anonymous read ever succeeds, the secret is never written and the job says so loudly.
298
+
299
+ **Residual risk, stated:** kernel `p1-secret-bootstrap` v1 necessarily contains the token inline, and
300
+ Kaggle retains private kernel revisions — overwrite-after-use does not erase history, and there is no
301
+ delete-kernel operation in CLI 2.0.2 or in the MCP toolset. This is a strictly smaller exposure than
302
+ putting the token in every training job and in anything that mirrors kernel source.
303
+
304
+ ## 11. Pre-existing Kaggle kernels, not ours
305
+
306
+ `kaggle kernels list --mine` also returned five kernels predating this project
307
+ (`quick-python-cpu-smoke-test`, `monte-carlo-cpu-smoke-test`, `cpu-test`, `exam-80-monte-carlo`,
308
+ `workbuddy-cpu-probe`; last run 2026-09-17 → 2026-09-19). They are **not touched** (§3.10). This also
309
+ explains E-002: `search_notebooks` returning `{}` for this account was the search tool failing, not the
310
+ account being empty — so an empty search must never be read as "no prior work".
311
+
312
+
313
+
314
+ ## 12. Measured notebook session cap: 12.0 h survived, the instance reported 45,000 s
315
+
316
+ `dodosoomro/ounce100m-p0e-session-cap` — a CPU kernel that printed one heartbeat every two minutes and
317
+ nothing else, costing zero GPU quota, left running since 2026-09-19T15:38Z purely as a measurement.
318
+
319
+ ```
320
+ CAP_START {"epoch": 1789832305.41, "host": "096ef365b02e", "pid": 7, "limit": 45000}
321
+ HB 1 elapsed=0 free_GB=19.5 mem_avail_MB=31204 load=0.41 net=204
322
+ HB 361 elapsed=43204 free_GB=19.5 mem_avail_MB=31288 load=0.00 net=204
323
+ ```
324
+
325
+ **361 heartbeats, 43,204 s = 12.0 h of continuous running, then the platform took it**
326
+ (`CANCEL_ACKNOWLEDGED`, not a crash — the last heartbeat is clean and disk/RAM are unchanged at 19.5 GB
327
+ free and 31.3 GB available). The instance itself reported `limit: 45000` s, i.e. **12.5 h**, so the kill
328
+ arrived at ~96 % of its own stated budget.
329
+
330
+ What this does and does not license:
331
+
332
+ - It is a **CPU** measurement. The GPU accelerator quota is tracked separately, and nothing here proves a
333
+ GPU session is allowed to run 12.5 h. So Phase 4 plans `SESSION_GPU_HOURS=6.9` for session 1 — well
334
+ inside every plausible cap — and can extend later sessions only on evidence from earlier ones.
335
+ - It does settle the question that the plan had been hedging since §2 of `04-run-log.md` ("the session cap
336
+ is unmeasured"): an interruption at 6 h is not the platform's limit, so a long session is not doomed, and
337
+ a `--stop-after-steps` schedule sized for 6-7 h is conservative rather than necessary.
338
+ - It confirms the working volume is stable for the whole duration — `free_GB` never moved from 19.5, so an
339
+ 11 GB drift over a session is not a thing to plan for, and the disk floor in the launcher is about the
340
+ mix and checkpoints, not about slow leaks.
docs/01-plan.md ADDED
@@ -0,0 +1,354 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 01 — Plan: architecture, hyperparameters, throughput, targets
2
+
3
+ Phase 1 deliverable. Every choice below cites a source actually inspected on 2026-09-19, as Gate 1
4
+ requires. Items marked **→ test** are decisions whose *numbers* Phase 3 must validate on the real
5
+ pipeline before the run freezes; the design itself is settled.
6
+
7
+ ---
8
+
9
+ ## 1. The envelope the design has to fit
10
+
11
+ Measured in Phase 0 (`docs/00-platform-notes.md`), not assumed:
12
+
13
+ | Constraint | Value | Consequence |
14
+ |---|---|---|
15
+ | Accelerator | 2x Tesla T4, cc 7.5, **14.56 GiB usable each** | fp16 only; no bf16 tensor cores; no flash-attention (sm80+ only) |
16
+ | GPU quota | 108,000 s/week, billed at **~1x container wall-clock** (3 samples) | ≈30 wall-clock h/week, both cards |
17
+ | Test budget | ≤6 GPU-h lifetime | 0.073 h spent; **5.93 h remains for all of Phase 3** |
18
+ | Working disk in a job | **19.5 GB** `/kaggle/working` | shards consumed a few at a time, never whole (§3.13) |
19
+ | RAM / CPU | 30 GiB cgroup, 4 vCPU, **no swap** | input pipeline memory-bounded by design |
20
+ | Image | torch 2.10.0+cu128, **transformers 5.0.0**, datasets 5.0.0, accelerate 1.13.0, triton 3.6.0; **no** trl/deepspeed/flash-attn/xformers/bnb | prefer the preinstalled stack; each install is risk + round trip |
21
+ | Hub from a job | reads anonymous & fine, 35–89 MB/s; writes **401** until given a token | credential path: private Kaggle dataset mount (§8) |
22
+
23
+ **Parameter convention.** §2's 90–110M is *including embeddings* — the Pythia convention (Pythia was
24
+ explicitly renamed to include embedding + unembedding, [pythia README](https://raw.githubusercontent.com/pythia/main/README.md)).
25
+ This matters more at 100M than anywhere else: the tied embedding is 21–37 % of the model across the
26
+ candidates below. `code/config/param_count.py` computes it two ways and both were checked to agree
27
+ exactly against transformers 5.0.0 in `dodosoomro/ounce100m-p1-param-count`.
28
+
29
+ ## 2. Architecture
30
+
31
+ ### 2.1 The shape: deep-thin, tied, GQA, SwiGLU, pre-norm
32
+
33
+ **Choice: `hidden 576, layers 22, 9 Q heads / 3 KV heads (GQA 3:1), SwiGLU intermediate 1536, RMSNorm
34
+ pre-norm eps 1e-5, attention_bias false, RoPE theta 10,000, tied embeddings, vocab 49,152, seq 2048`.**
35
+
36
+ Evidence, and it is convergent rather than a single citation:
37
+
38
+ - **Deep-thin beats wide at this size.** Meta's MobileLLM ablated exactly this at a fixed 135M: 30
39
+ layers × d512 scored **44.8 avg vs 43.9 for 12 × d768**, with embedding-sharing removing 13 % of
40
+ parameters at ~equal accuracy ([arXiv 2402.14905](https://arxiv.org/abs/2402.14905), HIGH). Its
41
+ shipped 125M model is **30 layers, d576, 9Q/3KV GQA, SwiGLU, tied**, 124.6M total.
42
+ - **The same shape is what HF's SmolLM2-135M uses**: 30 layers, d576, 9Q/**3KV**, `intermediate_size`
43
+ 1536 (2.67×d), silu, `attention_bias=false`, **`tie_word_embeddings=true`**, RMSNorm 1e-5,
44
+ [model config](https://huggingface.co/HuggingFaceTB/SmolLM2-135M/blob/main/config.json) +
45
+ [arXiv 2502.02737 §6](https://arxiv.org/abs/2502.02737). Two independent labs landing on
46
+ d576 + GQA 3:1 + SwiGLU at ~130M is the strongest available signal.
47
+ - Our budget is 110M, not 135M, so the same d576/GQA3:1/SwiGLU-1536 stack is cut to **22 layers**
48
+ rather than 30 — verified count below — and RoPE θ drops to 10,000 to match the shorter context
49
+ (SmolLM **v1** used θ=10,000 at ctx 2048; SmolLM2's 100,000 accompanies ctx 8192, which we cannot
50
+ afford and do not need for these benchmarks).
51
+ - **GQA at 3:1 is a parameter choice as much as an attention choice**, since k/v are `d_head × n_kv`
52
+ wide; MobileLLM reports GQA-plus-enlarged-d as +0.4 avg.
53
+
54
+ **Not chosen: Mamba/SSM or hybrid.** The official kernels *do* build for `sm_75`
55
+ ([state-spaces/mamba setup.py](https://github.com/state-spaces/mamba)), which corrects the common
56
+ assumption that they are Ampere-only — but they are absent from the image (source install only), and
57
+ the research found **no published 50–200M SSM/hybrid with released hyperparameters** to imitate. That is
58
+ research risk, not a default, and §4 forbids the kind of custom code where autonomous projects die.
59
+
60
+ ### 2.2 Verified parameter counts
61
+
62
+ Closed form and `sum(p.numel())` agreed exactly on all eight shapes, in the target environment.
63
+ Tying confirmed genuinely tied, not merely declared.
64
+
65
+ | candidate | H | L | heads | kv | FFN | vocab | **total params** | emb share | in 90–110M |
66
+ |---|---|---|---|---|---|---|---|---|---|
67
+ | Phase-0 probe shape | 768 | 12 | 12 | 3 | 2048 | 50257 | 112,934,400 | 34.2 % | ✗ |
68
+ | A | 768 | 11 | 12 | 3 | 2048 | 50257 | 106,739,712 | 36.2 % | ✓ |
69
+ | B | 768 | 12 | 12 | 3 | 1792 | 50257 | 105,856,512 | 36.5 % | ✓ |
70
+ | C | 768 | 12 | 12 | 2 | 1824 | 50257 | 105,561,600 | 36.6 % | ✓ |
71
+ | D | 640 | 16 | 10 | 4 | 2048 | 50257 | 113,450,240 | 28.4 % | ✗ |
72
+ | E | 768 | 12 | 12 | 3 | 2048 | 32768 | 99,502,848 | 25.3 % | ✓ |
73
+ | F | 896 | 9 | 14 | 2 | 2432 | 50257 | 120,397,312 | 37.4 % | ✗ |
74
+ | G | 1024 | 8 | 8 | 2 | 2816 | 50257 | 141,658,112 | 36.3 % | ✗ |
75
+
76
+ **The binding insight: the tokenizer decides how much model you are allowed to have.** At 50,257 vocab
77
+ and d768 the tied embedding is 38.6M — a third of the entire budget — which is why every 50k candidate
78
+ clusters at 105–113M and must trim depth or FFN. MobileLLM's own ablation reached the same conclusion
79
+ (embedding sharing: −13 % parameters at ~equal accuracy). Choosing a smaller `hidden` is therefore not
80
+ a weakening, it is how the embedding tax gets paid for.
81
+
82
+ **→ test:** the frozen shape's exact count was re-derived from the constructed model — see §2.3.
83
+
84
+ ### 2.3 The frozen shape, counted to the unit
85
+
86
+ `dodosoomro/ounce100m-p1-param-count` v2 built each candidate as a real `LlamaForCausalLM` under
87
+ transformers 5.0.0. Closed form and `sum(p.numel())` agree exactly on every row.
88
+
89
+ | candidate | H | L | Q/KV | FFN | vocab | **total params** | emb share | in 90–110M |
90
+ |---|---|---|---|---|---|---|---|---|
91
+ | H | 576 | 20 | 9/3 | 1536 | 49,152 | 99,114,048 | 28.6 % | ✓ |
92
+ | **I — CHOSEN** | **576** | **22** | **9/3** | **1536** | **49,152** | **106,194,240** | **26.7 %** | ✓ |
93
+ | J | 576 | 24 | 9/3 | 1536 | 49,152 | 113,274,432 | 25.0 % | ✗ over |
94
+ | K | 576 | 26 | 9/3 | 1536 | 49,152 | 120,354,624 | 23.5 % | ✗ over |
95
+ | L | 640 | 20 | 10/4 | 1728 | 49,152 | 120,776,320 | 26.0 % | ✗ over |
96
+
97
+ **Frozen: 106,194,240 parameters (embeddings included, tied), counted as
98
+ `vocab×h` once + `L × (attn + SwiGLU)` + norms + final norm, and confirmed by constructing the model.**
99
+ The counting method is stated here because §2 requires the number *and* how it was counted.
100
+
101
+ Two consequences worth recording:
102
+
103
+ - **Depth is capped at 22 by the budget, not by taste.** Each layer at d576 costs 3,538,944 parameters,
104
+ so 24 layers is 113.3M — over. That is a hard stop, and it means the Phase-3 "deep-thin vs wide"
105
+ throughput test (T1) must compare **H (20 layers, 99.1M) against I (22 layers, 106.2M)**, both
106
+ in-budget, rather than the 12-layer d768 probe shape which cannot fit the SmolLM2 vocab without
107
+ trimming elsewhere.
108
+ - **Widening is not a free alternative to deepening.** Candidate L at d640 × 20 layers is *over* budget
109
+ (120.8M) despite having fewer layers than I, because attention and MLP cost scale with `h²`/`h·ff`.
110
+ So the deep-thin choice is forced from two directions: it is better per parameter (MobileLLM's
111
+ ablation) and it is the only way to spend the 78M non-embedding budget on 22 layers.
112
+
113
+
114
+ ## 3. Tokenizer
115
+
116
+ **Choice: reuse the SmolLM2 BPE tokenizer** — vocab 49,152, byte-level, **Apache-2.0**, from
117
+ [`HuggingFaceTB/SmolLM2-135M`](https://huggingface.co/HuggingFaceTB/SmolLM2-135M)'s `tokenizer.json`;
118
+ trained on SmolCorpus per [arXiv 2502.02737](https://arxiv.org/abs/2502.02737). Not trained by us.
119
+
120
+ §4 says maximum reuse, minimal custom code, and training a tokenizer from scratch is precisely the
121
+ kind of optional machinery that adds failure surface without adding capability. Candidates checked today:
122
+ SmolLM2 **49,152 / Apache-2.0**; `gpt2` 50,257 / MIT; `pythia-160m` 50,304 / Apache-2.0;
123
+ `t5-v1_1-small` 32,128 Unigram (not byte-level, carries `extra_ids` sentinels); `Qwen3-0.6B` 151,936
124
+ (disqualifying — its embedding alone would be ~78M at d512); `TinyLlama` 32,000 but Llama-2-derived and
125
+ **redistribution status unverified** → excluded.
126
+
127
+ SmolLM2 wins on three counts: licence is clean and permissive, it is byte-level and English-curated at
128
+ exactly this model scale, and sharing it with a family of released 135M models gives the benchmark
129
+ numbers somebody else's token statistics to be compared against. Its 49,152 × 576 tied embedding is
130
+ 28.3M = **21 %** of budget, versus 34–37 % for the 50k/d768 shapes.
131
+
132
+ ## 4. Optimizer, batch, schedule, precision
133
+
134
+ | | choice | justification |
135
+ |---|---|---|
136
+ | Optimizer | AdamW, β=(0.9, 0.95), wd 0.1, clip 1.0 | Pythia-160M and SmolLM2 both use β₂=0.95 at small scale ([2304.01373](https://arxiv.org/abs/2304.01373), [2502.02737](https://arxiv.org/abs/2502.02737)) |
137
+ | Peak LR | **6e-4** | bracketed from three directions: Cerebras-111M 6.0e-4, Pythia-160M 6e-4, and the 150M low-tokens/param run of Sardana et al. at 4.6e-4 ([2304.03208](https://arxiv.org/abs/2304.03208), [2401.00448](https://arxiv.org/abs/2401.00448)). The 2e-3/3e-3 figures that appear in small-model recipes belong to 1–2 T-token runs, which this is not. |
138
+ | Warmup | 2 % of steps, floor 100 steps | Pythia used 1 %; SmolLM2 used 2,000 steps at 2M tok/batch (~0.2 %). Warmer than 1 % because **fp16 without bf16 needs the ramp** — Phase 0 showed an unramped/unscaled fp16 run going straight to NaN (E-006). |
139
+ | Schedule | **trapezoid / WSD: constant, then linear decay to 0 over the final 20 %** — *not* cosine-to-10 % | SmolLM1 used a trapezoid with 20 % cooldown; SmolLM2 used WSD ([blog/smollm](https://huggingface.co/blog/smollm), [2502.02737 App. A](https://arxiv.org/abs/2502.02737)). *Straight to Zero* finds linear-decay-to-zero beats cosine-to-10 % when peak LR is optimal, across sizes/batch/data ([2502.15938](https://arxiv.org/abs/2502.15938)); COLT 2026 theory says decay *shape* barely matters but **overly slow terminal decay causes schedule-induced capacity saturation** ([2602.06797](https://arxiv.org/abs/2602.06797)). Its caveat applies: their evidence is at/above compute-optimal tokens/param, we are at half. |
140
+ | Global batch | **≈262 k tokens/step** (~3,815 steps for 1 B tokens) | Critical batch size fits `B* = 621.341·N^0.087`, i.e. **nearly independent of model size** ([2410.21676](https://arxiv.org/abs/2410.21676)) — no reason to chase 2–4M-token batches. Sardana et al. deliberately used *smaller* batches for smaller models "so that low-token-count training runs see enough steps". At 10 tokens/param we are such a run. |
141
+ | Micro-batch | **2 × 2048 per GPU × 2 GPUs × 32 accumulation** | Set by memory, not taste: Phase 0 measured bs4×1024 at 11.5–13.8 GB of 14.56 GB and **bs8 OOMed outright**. → test |
142
+ | Precision | **fp16 autocast + fp32 master weights + `GradScaler` + grad clip** | Only mixed-precision option on Turing; transformers v5 documents this path by name ("fall back to fp16 on older hardware like V100 or T4") and warns **load the model in fp32 or autocast is a no-op** ([v5 mixed_precision docs](https://huggingface.co/docs/transformers/perf_training)). Verified finite in Phase 0 probe C; bf16 *runs* but is emulated → must be asserted off, not defaulted. |
143
+ | Seed / RNG | single fixed seed, recorded | §3.1 requires "same RNG semantics" across resumes |
144
+
145
+ **Undertrained by design, and honestly so.** 1 B tokens on ~100M ≈ **10 tokens/param**, about half
146
+ Chinchilla-optimal (Cerebras-111M's compute-optimal point was 2.2 B tokens = 20 t/p). That is mildly
147
+ undertrained, not pathological — the genuine anomaly is 2025-26 practice, which overtrains tiny models
148
+ by three orders of magnitude (SmolLM2-135M at 2 T tokens ≈ 14,800 t/p). Sardana et al. trained a
149
+ 150M/d768/12L model across 3→10,000 t/p and quality kept improving; Gadre et al. show scaling laws
150
+ extrapolate across over-training ([2403.08540](https://arxiv.org/abs/2403.08540)). We are on the
151
+ left-hand side of that curve because the quota puts us there, and the report should say so.
152
+
153
+ ## 5. Training stack
154
+
155
+ **Choice: `torchrun --nproc_per_node=2` + Hugging Face `Trainer` / `TrainingArguments`, `fp16=True`,
156
+ on a pre-tokenised **map-style** `Dataset`.** Minimal glue, no framework authored here (§4).
157
+
158
+ - Everything needed is already in the image: transformers 5.0.0, accelerate 1.13.0, datasets 5.0.0.
159
+ - v5 `Trainer` restores **RNG (`_save_rng_state`/`_load_rng_load`), optimizer, LR scheduler and the fp16
160
+ GradScaler** — the exact set §3.1 demands — via `Accelerator.save_state`. Verified against
161
+ v5.17.0 source; the image's 5.0.0 is ~8 patch releases behind but the same major. **→ test at Gate 3.**
162
+ - **The resume trap, stated plainly:** v5 recovers data position with `skip_first_batches`, which
163
+ **replays** discarded batches — O(steps) wasted work on an `IterableDataset`, up to 3,815 steps of
164
+ pure I/O after every interruption. Mitigation is architectural, not a flag: a **map-style, concatenated
165
+ token store** makes skipping an index advance rather than a decode. A `dataset_shard` layout with an
166
+ explicit recorded cursor is what Gate 3 must prove, and §Phase 2's "exact positional resumption"
167
+ requirement is the reason it is designed that way up front.
168
+ - **v5 migration traps to check in preflight** ([MIGRATION_GUIDE_V5.md](https://github.com/huggingface/transformers/blob/main/MIGRATION_GUIDE_V5.md), HF *Transformers v5* blog): PyTorch-only backend;
169
+ slow tokenizers gone (irrelevant, we use `tokenizers`); several `TrainingArguments` removed **without
170
+ a deprecation cycle**; attention moved to `AttentionInterface`; `remove_unused_columns` **still
171
+ defaults True** (silently drops dataset columns a loss function needs); `lr_scheduler_type` default is
172
+ still `"linear"`, *not* cosine — so an unstated schedule is a linear decay to zero over the whole run;
173
+ new `train_sampling_strategy` replaces the `group_by_length` bool;
174
+ `restore_callback_states_from_checkpoint` is required to restore scheduler state properly.
175
+ - **Disqualified:** **torchtitan** — `training_dtype` is typed `Literal["bfloat16","float32"]`, i.e.
176
+ **no fp16 path at all**, plus Hopper-oriented CI → unusable on T4 ([torchtitan config](https://github.com/pytorch/torchtitan)).
177
+ **unsloth** — fine-tuning/GRPO only, no from-scratch pretraining path. **nanoGPT** — dormant since
178
+ 2025-11, no HF export, no distributed input pipeline. **FSDP** — ~100M params in fp32 master +
179
+ grads + AdamW is ~1.8 GB; DDP on 2×16 GB does not need sharding, and sharding would add failure
180
+ surface for nothing. **DeepSpeed / flash-attn / xformers / trl** — absent from the image; installing
181
+ them is risk without a capability we lack.
182
+
183
+ ## 6. Throughput, and the token target it implies
184
+
185
+ Measured on a main-run-shaped model, `seq 1024`, bs4/card, DDP over both T4s: **11,062 tok/s
186
+ aggregate** (5,531/rank; single-GPU 6,478 SDPA / 7,239 eager; **85 % DDP efficiency**).
187
+
188
+ Sanity-checking that against compute: `6ND ≈ 6 × 1.13e8 × 11,062 ≈ 7.5e12 FLOP/s`, which is **~6 % of a
189
+ 2×T4 fp16 tensor peak** (65 TFLOPS/card — an *unverified* datasheet prior; the spec page could not be
190
+ retrieved). Independent corroboration: a documented 163M / ctx-1024 run reached ~19.9k tok/s on a single
191
+ RTX 3090 ([gilesthomas.com](https://gilesthomas.com/2025/12/llm-from-scratch-28-training-a-base-model-from-scratch)),
192
+ and Pythia-160M's 1,030 A100-hours for 300 B tokens implies ~81k tok/s per A100. So ~11k tok/s on two
193
+ Turing cards is the right order of magnitude, and **the low implied MFU means this is a floor with headroom,
194
+ not a ceiling** — which is the opposite of the risk I most wanted to rule out.
195
+
196
+ **The tension to resolve by measurement, not argument:** deep-thin is better per *parameter*
197
+ (MobileLLM's ablation) but worse per *second* on 2018 hardware, because 22 small layers issue more
198
+ sequential kernel launches than 12 fat ones, and we are wall-clock-bound rather than
199
+ parameter-bound. Phase 3 therefore measures both shapes.
200
+
201
+ | token target | at 11.1k tok/s (measured) | at 9k tok/s (planning floor) |
202
+ |---|---|---|
203
+ | 1.10 B | 27.6 h | 34.0 h |
204
+ | **1.00 B** | **25.1 h** | **30.9 h** |
205
+ | 0.90 B | 22.6 h | 27.8 h |
206
+
207
+ **Decision: target 1.0 B tokens, with a pre-registered fallback to 0.9 B if Gate 3's end-to-end rate on
208
+ the frozen config and real input pipeline is below ~10.5k tok/s.** Both are inside §2's band, and the
209
+ fallback is chosen *now* rather than later so it cannot become a post-hoc excuse. Even the optimistic
210
+ column leaves under 5 h of slack in a 30 h week, which the interruption budget in §3.1 will eat; so the
211
+ plan assumes **a two-week run crossing the 2026-09-26 quota reset**, with a checkpoint at every 10 % and
212
+ a rolling `latest`, exactly as §2 requires.
213
+
214
+ ## 6.1 Amendment after Gate 3's measurements — the fallback trigger fired, and here is what was done about it
215
+
216
+ **Read §6 above first: it is kept verbatim, including its numbers, which are now known to be wrong.** The
217
+ 11,062 tok/s figure came from p0c's *raw* training loop at seq 1024 on a 113M model — no `Trainer`, no
218
+ real input pipeline, no fp16-master/GradScaler bookkeeping, no seq-2048 activations. Gate 3 measured the
219
+ frozen 106,194,240-parameter shape inside the actual stack on 2×T4 (ledger rows 10-14, `memory/QUOTA.md`):
220
+
221
+ | config | tok/s | peak GB | 1.0 B tokens |
222
+ |---|---|---|---|
223
+ | sdpa @2048 micro 2 (the §6 plan-of-record) | 4,071 | 14.22 | **68.2 h** |
224
+ | eager + grad-ckpt @2048 micro 2 | 4,679 | 10.04 | 59.4 h |
225
+ | eager @1024 micro 4 | 7,732 | 12.25 | 35.9 h |
226
+ | eager + grad-ckpt @1024 micro 8 | 7,828 | 7.12 | 35.5 h |
227
+ | eager @2048 micro 2 | OOM | — | — |
228
+
229
+ Three consequences, in the order that matters:
230
+
231
+ 1. **Sequence length changed to 1024** — that is **D-011**, decided on these numbers and documented in
232
+ `memory/DECISIONS.md`. Micro-batch 4 × accum 32 × 2 cards keeps tokens/step at **262,144**, so the
233
+ batch size in tokens, the ~3,815 steps, the LR and the trapezoid are all unchanged. §2.3's parameter
234
+ table is unaffected — it never depended on the measurement.
235
+ 2. **The pre-registered fallback condition in §6 fired.** "Below ~10.5k tok/s" is satisfied: every
236
+ measured seq-1024 cell is ~7.7-7.8k. Mechanically that means 0.9 B.
237
+ 3. **The premise of that trigger is gone.** 10.5k was chosen so 1.0 B would fit *one* 30 h week with
238
+ enough slack for interruption overhead. At the measured rate neither 1.0 B (35.9 h) nor 0.9 B (32.3 h)
239
+ fits week 1, so the trigger no longer discriminates between the two — it only buys 3.6 GPU-hours for a
240
+ 10 % cut in training tokens. Against the two-week schedule in `docs/04-run-log.md` §2 (60 h of quota,
241
+ 35.9 h of training, **~22 h of slack**) the 1.0 B target is affordable.
242
+
243
+ **Therefore, re-registered before launch and before any checkpoint or score exists (D-012): the token
244
+ target stays 1.0 B, and the fallback trigger is restated against measured throughput rather than against
245
+ p0c's number.** New mechanical rule, same purpose as the old one: **if preflight P3's end-to-end rate at
246
+ the frozen geometry (22L/576, seq 1024, eager, grad-ckpt on, micro 4, accum 32) is below 5,150 tok/s —
247
+ i.e. 1 B tokens needs more than ~54 h of the ~60 h available across the two weeks after allowing 6 h for
248
+ interruption overhead and Phase 6's GPU evaluation — the target drops to 0.9 B at launch, not later.**
249
+ 5,150 tok/s is 33 % below the planning rate, so this is a genuine tripwire, not a formality. What did
250
+ *not* change: D-005's benchmark bands, the harness pin (D-010), the mix, the model shape, the optimiser,
251
+ the schedule, or the one-run rule. If the 0.9 B fallback fires, it fires as a documented arithmetic
252
+ consequence, and this section is where a reader can check it.
253
+
254
+ ## 7. Benchmark targets — pre-registered before the main run (§4)
255
+
256
+ Recorded now, before any training, so the goalposts cannot move. Full anchor table, protocol and noise
257
+ floor in §7.1–7.3. Sources: archived Open LLM Leaderboard run metadata and Pythia Appendix G
258
+ ([arXiv 2304.01373](https://arxiv.org/pdf/2304.01373)), read 2026-09-19.
259
+
260
+ **The dominant fact: every published ≥100M base anchor was trained on ~300 B tokens.** Our budget is
261
+ ~1 B — a **300× gap**. Those anchors are therefore ceilings, not expectations. No harness score for any
262
+ 50–350M base trained at ~1–3 B tokens could be found published anywhere, so these bands are
263
+ extrapolations from the low end of the size curve and are labelled as such.
264
+
265
+ | Task | metric | band | chance |
266
+ |---|---|---|---|
267
+ | ARC-Easy | `acc` | **26–34** | 25 |
268
+ | ARC-Challenge | `acc` / `acc_norm` | **17–22** / **20–25** | 25 |
269
+ | HellaSwag | `acc_norm` (report `acc` too) | **26–32** (acc 25–30) | 25 |
270
+ | PIQA | `acc` | **52–60** | 50 |
271
+ | WinoGrande | `acc` | **49–53** | 50 |
272
+ | MMLU | `acc` | **24–27** | 25 |
273
+ | TruthfulQA | `mc2` / `mc1` | **36–46** / **21–26** | ≈38 / ≈22 |
274
+ | GSM8K | `exact_match,strict-match` | **0.0–1.5** | ≈0 |
275
+
276
+ - **MMLU, WinoGrande, GSM8K and ARC-Challenge are expected to be indistinguishable from chance.** MMLU
277
+ measures flat 24.9–27.3 from 70M to 1.4B — OPT-1.3B scores *lower* than OPT-125M — so it has almost
278
+ no discriminative power at this scale. GSM8K anchors: 0.23 (OPT-125M), 0.68 (GPT-2, Pythia-410M),
279
+ 1.52 (Pythia-1.4B), 1.4 even for SmolLM2-135M at 11.2 T tokens. Multi-step arithmetic does not emerge
280
+ from a 100M base at 1 B tokens; predicting otherwise would be the inflation §3.12 forbids.
281
+ - **The real signals are ARC-Easy, HellaSwag and PIQA** — the three where anchors clear chance by a
282
+ visible margin. Failing to beat chance there is a finding about the mix or the run, not the benchmarks.
283
+ - **Noise floor:** SE ≈ 1.3 pp ARC-C (n=1172), 1.4 pp WinoGrande (1267), 1.2 pp PIQA (1838), 1.5 pp
284
+ TruthfulQA (817), 0.45 pp HellaSwag (10042). **Differences under ~2 pp on ARC/WinoGrande/TruthfulQA
285
+ are not results**, and no shot count or prompt format gets chosen per-task after seeing scores (§3.3).
286
+
287
+ ### 7.1 Protocol, pinned for Phase 6
288
+
289
+ Harness **EleutherAI `lm-evaluation-harness` v0.4.13** (2026-08-31) — still what published anchors
290
+ report against; Lighteval v0.13.0 is the active HF alternative but switching would break comparability.
291
+ Record the git SHA per run; cadence is real (v0.4.10 2026-01 → v0.4.13 2026-08).
292
+
293
+ | Task | dataset / config | split | shots |
294
+ |---|---|---|---|
295
+ | `arc_easy`, `arc_challenge` | `allenai/ai2_arc` | **test** (2376 / 1172) | **25** |
296
+ | `hellaswag` | `Rowan/hellaswag` | **validation** (10042; no test split) | **10** |
297
+ | `piqa` | `baber/piqa` default | **validation** (1838) | **10** |
298
+ | `winogrande` | `allenai/winogrande`, **`winogrande_xl`** | **validation** (1267) | **5** |
299
+ | `mmlu` | group of 57 `mmlu_<subject>` | test | **5** |
300
+ | `truthfulqa_mc1`, `_mc2` | `sylinrl/TruthfulQA` | validation | **0** (pinned) |
301
+ | `gsm8k` | `openai/gsm8k` `main` | test | **5** |
302
+
303
+ ### 7.2 Traps that would silently falsify the numbers
304
+
305
+ 1. **Shots are NOT pinned in the ARC/HellaSwag/PIQA/WinoGrande/MMLU YAMLs** — an omitted
306
+ `--num_fewshot` silently yields 0-shot. Pass shots explicitly for every task.
307
+ 2. **No chat templates.** `--apply_chat_template` / `--fewshot_as_multiturn` are for fine-tuned models
308
+ (§3.9 makes this a base model). `gsm8k_cot_llama` requires them → not used.
309
+ 3. Everything but GSM8K is `output_type: multiple_choice` = loglikelihood ranking; the model never
310
+ generates, so only GSM8K is sensitive to generation settings.
311
+ 4. **MMLU aggregation:** the `mmlu` group uses `weight_by_size: True`, while archived leaderboard numbers
312
+ were an *unweighted* subject mean. Compute and state which was used.
313
+ 5. **TruthfulQA mc2 changed definition** 2024-03-11 (PR #2768); pre-April-2024 mc2 is not comparable.
314
+ mc1/mc2 differ by ~20 pp and both report under the metric name `acc`.
315
+ 6. **Harness PIQA is mean per-item accuracy, not AI2's `p_win`** — the harness never computes `p_win`.
316
+ 7. **Winogrande**: `winogrande_xl`, single fold, validation; the official leaderboard averages 5 folds,
317
+ and `winogrande_debiased` is a different number.
318
+ 8. **GSM8K**: `temperature 0`, `do_sample false`, `max_gen_toks` inherits the global 256; tiny bases loop
319
+ repetitively and never emit `#### `, so strict-match ≈0 while flexible-extract looks inflated. Report
320
+ both filters or neither; do **not** add `repetition_penalty`, which silently deviates from everyone.
321
+ 9. **Splits are mixed** — PIQA/HellaSwag/WinoGrande/TruthfulQA run on *validation*. Never call them test.
322
+ 10. **Parameter-count conventions differ between suites**; Pythia's includes embeddings. Quote ours with
323
+ the convention attached.
324
+
325
+ ## 8. Still open before Gate 1 closes
326
+
327
+ - ~~Deep-thin-vs-wide throughput result~~ → scheduled as Phase 3 preflight test T1.
328
+ - Session wall-clock cap, from the still-running `p0e-session-cap`: it sets how much progress one session
329
+ can make and therefore how often the checkpoint cycle interrupts training. **Known so far: a CPU session
330
+ was still alive at 51 min** with no cap hit, so short sessions are not the failure mode; the ceiling is
331
+ somewhere above that.
332
+ - **Closed this session:** the credential path (§1 last row) — jobs retrieve the HF token from the
333
+ account's own private Kaggle dataset via `code/ounce100m_credentials.py`; a Hub write from inside a job
334
+ was verified by anonymous readback (D-006). And the checkpoint arithmetic below.
335
+
336
+ ### 8.1 Checkpoint size and cadence — now measured, and it is cheap
337
+
338
+ A `latest`-quality exact-resume checkpoint for a ~100M model is **~1.6 GB** (fp32 weights 400 MB + two
339
+ fp32 Adam moments 800 MB + master/grad copies + scheduler/scaler/RNG state, which are all negligible
340
+ next to the optimizer). Pushed from a Kaggle session at **42.7 MB/s → 37.4 s**, and pulled back in
341
+ **13.8 s**, with byte-exact anonymous readback at 200 MB / 800 MB / 1.6 GB
342
+ (`dodosoomro/ounce100m-p1-push-bench`, D-007).
343
+
344
+ Consequences that change design choices rather than just confirming them:
345
+
346
+ - 10 checkpoints + `latest` ≈ **7 min total, ~0.12 GPU-h of a 30 h week**. Checkpoint cadence is not a
347
+ budget problem, so there is no reason to economise on it — and rolling `latest` *more* often than the
348
+ required 10 % is nearly free, which is worth doing since every interruption costs at most one roll.
349
+ - A cold resume with an empty disk costs seconds of transfer, not minutes. The expensive part of a resume
350
+ is the `skip_first_batches` replay discussed in §5, which is why the input format in
351
+ `docs/02-mix-plan.md` §5 step 6 is designed to make it an index advance.
352
+ - Peak disk: 1.6 GB written + 1.6 GB staged elsewhere on the 19.5 GB volume is comfortable, and the
353
+ §3.13 prune-after-verify step keeps at most one copy resident.
354
+
docs/02-mix-plan.md ADDED
@@ -0,0 +1,435 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 02 — Mix plan: sources, counts, rationale, and the build
2
+
3
+ Phase 1 deliverable. Target: **1.0 B trained tokens** (§2 band 900M–1.1B; frozen number confirmed at
4
+ Gate 3). Every repo id, size, date and licence below was read live on 2026-09-19 from the Hub card, the
5
+ `/api/datasets/<id>` metadata endpoint, or parquet footers over HTTP — not from memory. Where a card and
6
+ the stored data disagree, that is recorded rather than smoothed over.
7
+
8
+ ## 1. Selection rules applied, operationally
9
+
10
+ - **§3.4 English only.** Every source is either English-config-scoped (`20250702.en`, `eng_Latn`,
11
+ `sample/10BT`) or carries a per-row language field we filter on. Code and math are allowed and are
12
+ deliberately included.
13
+ - **§3.5 No raw crawls.** Excluded as a class: `allenai/c4`, `HuggingFaceFW/fineweb`,
14
+ `Skylion007/openwebtext`, `tiiuae/falcon-refinedweb`. What is admitted instead is
15
+ **quality-scored** (`fineweb-edu` carries a per-row classifier `score`/`int_score`),
16
+ **curated/rewritten** (`finewiki`, `cosmopedia`), **synthetic-textbook** (`finephrase`), or
17
+ **openly-licensed domain corpora** (`common-pile/*`, `stack-v3-train`). Common-Crawl appears only as
18
+ the *provenance* of a classifier-filtered subset, never as the selection criterion.
19
+ - **§3.3 No contamination.** Two mechanisms, not one assertion:
20
+ 1. **Prefer sources with published decontamination.** `HuggingFaceTB/finemath` documents 13-gram
21
+ removal against GSM8K, MATH, MMLU and ARC test sets, with a public audit log
22
+ (`HuggingFaceTB/finemath_contamination_report`).
23
+ 2. **Reject sources whose own cards validate on the eval suite.** That is why `openbmb/UltraData-Math`
24
+ is **dropped entirely** despite being attractive on paper (apache-2.0, 170B+ tokens): its card
25
+ lists MMLU/ARC-E/ARC-C/HellaSwag/PIQA/Winogrande/GSM8K/MATH500 as validation targets and its L3
26
+ tiers are synthetic *exam-shaped* text. Its en+zh mixing would also need a language filter.
27
+ Similarly excluded: `nvidia/Nemotron-Math-v2` (AoPS/SE solution traces, i.e. adjacent to GSM8K's
28
+ own source pool, and solution-formatted in a way that quietly steers toward instruction data).
29
+ 3. The mechanical overlap audit of §5 runs against **validation/dev material only**; test splits stay
30
+ untouched until Phase 6.
31
+
32
+ ## 2. The mix: 1.31 B raw → ~1.05 B after dedup → ~1.0 B trained
33
+
34
+ | # | Source (config) | raw tokens | GB to pull | licence | rationale, from corpus properties |
35
+ |---|---|---|---|---|---|
36
+ | 1 | `HuggingFaceFW/fineweb-edu` `sample/10BT`, keep `int_score≥4` | 300M | 1.1 | ODC-BY | Classifier-scored general English; the only cheap source of broad register coverage. Score-gating is a *quality* filter, which §3.5 permits, and it is the source's own documented axis. |
37
+ | 2 | `HuggingFaceFW/finepdfs-edu` `data/eng_Latn` | 150M | 0.63 | ODC-BY + CC ToU | Globally-deduplicated long-form educational PDFs. Long document structure teaches coherence over >1k tokens, which chunked web prose does not. `eng_Latn` only (69 scripts exist). |
38
+ | 3 | `HuggingFaceTB/cosmopedia` stanford+openstax+khanacademy+auto_math_text | 130M | 0.33 | **Apache-2.0** | Synthetic textbooks: causal and explanatory chains ("because", "therefore", worked steps). This is the register that builds science-QA and multi-step reasoning ability. Per-config GB measured, not estimated. |
39
+ | 4 | `HuggingFaceTB/cosmopedia` `wikihow` | 30M | 0.05 | Apache-2.0 | Procedural how-to steps → ordered physical-world inference. Small slice, specific job. |
40
+ | 5 | `HuggingFaceFW/finewiki` `data/enwiki` | 80M | 0.43 | **CC-BY-SA-4.0** | Link-resolved, rewritten encyclopedic prose; definitional and comparative sentence forms that factual/recall-style prompts reward. Heaviest GB/token in the mix, hence capped. |
41
+ | 6 | `omarkamali/wikipedia-monthly` `20250702.en` | 60M | 0.03 | CC-BY-SA-4.0 | Cheapest encyclopedic tokens available (0.5 GB/Btok) and *current*; drop the `raw_mediawiki` column or it dominates the byte budget. |
42
+ | 7 | `HuggingFaceTB/finemath` `finemath-4plus` | 130M | 0.25 | ODC-BY | Best math density per GB (1.9) **and** the only candidate with a published eval-set decontamination report. |
43
+ | 8 | `open-web-math/open-web-math` | 70M | 0.15 | ODC-BY (card body) | Forum/webbook math in natural prose, incl. LaTeX. Complements #7's textbook skew with multi-turn human reasoning text. Oldest source here (2023-10) — cited as such. |
44
+ | 9 | `HuggingFaceFW/finephrase` `tutorial` + `faq` | 90M | 0.31 | ODC-BY | Rewritten into stepwise-tutorial and question/answer registers — forms largely absent from organic prose. |
45
+ | 10 | `HuggingFaceFW/finephrase` `table` | 30M | 0.10 | ODC-BY | Tabular→narrative realisation: reading quantities, units and row/column structure. |
46
+ | 11 | `HuggingFaceCode/stack-v3-train`, `license_type=="permissive"`, per-language cap | 130M | 0.52 | ODC-BY + per-file SPDX | Code for compositional syntax and deterministic multi-step logic. **Must** filter to permissive licences (constraint 4) and cap XML/HTML/JSON/JS, which the card notes are byte-dominant. |
47
+ | 12 | `SimpleStories/SimpleStories` | 40M | 0.07 | MIT | Syntactically simple long-range narrative. Disproportionately useful below ~200M params, where the model otherwise never sees a consistent referent across a full context window. |
48
+ | 13 | `common-pile/libretexts` + `common-pile/arxiv_abstracts` | 40M | 0.08 | CC0 / per-doc PD/CC-BY | Openly-licensed OER textbooks and scientific abstracts; cleanest licence hygiene in the pool (arXiv metadata is CC0). |
49
+ | | **total raw** | **1,310M** | **≈4.35 GB** | | |
50
+
51
+ **Headroom, and why it is sized like this.** §Phase 2 requires slack above the target for dedup loss
52
+ and a held-out split. Cross-source near-dedup is expected to cost **12–18 %** (FinePhrase's four configs
53
+ are rewrites of the *same* ~338.7M source documents, so they must be deduplicated against the shared
54
+ `id`/`url` or they buy topic echo rather than knowledge; #2/#5/#6 overlap on encyclopedic topics;
55
+ #1/#2 overlap on educational web content). 1,310M × 0.85 ≈ 1,114M, minus a 2 % validation holdout
56
+ (≈22M) → **~1.09 B available**, which brackets the 1.0 B target and leaves room to land at 0.9 B
57
+ without re-sourcing if Gate 3's throughput measurement forces the pre-registered fallback.
58
+
59
+ **Sits comfortably inside the instance.** ≈4.35 GB of shards + ~2 GB of Arrow/tokeniser working
60
+ overhead + 2 GB of final token store ≪ the measured **19.5 GB** `/kaggle/working`. Every source here is
61
+ pullable as individual 270 MB–3 GB shards, so the working directory is never the binding constraint —
62
+ provided the build pulls shard-by-shard and deletes after tokenising, which §4 requires it to do.
63
+
64
+ ## 3. Excluded, with reasons (so nobody re-litigates from scratch)
65
+
66
+ | excluded | why |
67
+ |---|---|
68
+ | `allenai/c4`, `HuggingFaceFW/fineweb`, `Skylion007/openwebtext`, `tiiuae/falcon-refinedweb` | raw/unfiltered crawls → §3.5 |
69
+ | `openai/gsm8k`, `cais/mmlu`, `allenai/ai2_arc`, `hellaswag`, `piqa`, `winogrande`, `truthfulqa` | the eval tasks themselves → §3.3. Also: never glob a directory that could catch these. |
70
+ | `nvidia/Nemotron-CC*`, `-Math-v1`, `-Code-v1` | `gated: manual`; anonymous card and file reads return *"Access to dataset … is restricted"* → token counts unverifiable and republication status unclear |
71
+ | `openbmb/UltraData-Math` | card validates on the eval suite; exam-shaped L3 tiers; en+zh mixed |
72
+ | `nvidia/Nemotron-Math-v2` | solution-formatted AoPS/SE traces, GSM8K-adjacent; reads as instruction data |
73
+ | `allenai/peS2o` | ~11 GB per Btok by measurement — worst ratio in the pool for 42 B tokens we do not need |
74
+ | `HuggingFaceTB/smollm-corpus` `cosmopedia-v2` | duplicate role with #3; also a documented card-vs-data mismatch (card 17.8 B vs ~31.7 B implied by stored `token_length`) |
75
+ | `HuggingFaceFW/clean-wikipedia` | exists but README body is literally "Please see FineWiki instead" → deprecated |
76
+ | `HuggingFaceTB/smollm-corpus` `python-edu` | **not a corpus.** Verified schema is `blob_id, repo_name, path, length_bytes, score, int_score` — a filter list pointing at gated `bigcode/the-stack-v2`, with no `text` column. Do not budget code tokens from it. |
77
+ | `bigcode/the-stack-v2-dedup`, `codeparrot/github-code` | not verified this session; `the-stack-smol` is `gated: auto` |
78
+ | `TinyLlama` 32k tokenizer | Llama-2-derived; redistribution licence status unverified → excluded from both tokenizer and any data |
79
+ | `Cion-lab/Pretraining-10B-v1` (pre-existing in the account) | composition/mix unknown, token counts estimated with the **Qwen2.5** tokenizer, provenance not inspectable → cannot be cleared under §3.5 or §3.3 |
80
+
81
+ ## 4. Card-vs-data warning
82
+
83
+ Two sources disagree with themselves: `cosmopedia-v2` (17.8 B card vs ~31.7 B stored) and `finephrase`
84
+ (486 B "completion tokens" card vs ~1.4 B implied by stored rows × inherited `token_count`). FinePhrase's
85
+ `token_count`/`score` columns describe the **source document, not the rewrite**. **Therefore: no token
86
+ number in this project is ever taken from a card.** Counts come from running our own tokenizer over the
87
+ bytes, which is also what the Gate 2 manifest will record.
88
+
89
+ ## 5. Build pipeline (Phase 2 design, on Kaggle CPU)
90
+
91
+ 1. **Pull shard-by-shard, delete after consuming.** 73–89 MB/s measured (35–89 across runs), so 4.35 GB
92
+ arrives in minutes; the constraint is *peak residency*, not bandwidth. Never materialise the mix.
93
+ 2. **Normalise + filter.** Language filter on the row-level field where present; `int_score≥4` for
94
+ fineweb-edu; `license_type=="permissive"` + per-language cap for stack-v3; drop `raw_mediawiki`.
95
+ 3. **Dedup, memory-bounded.** Exact: 64-bit hash of the normalised document. Near: MinHash + LSH over
96
+ 13-gram shingles (matching finemath's documented practice), **processed in bands against a
97
+ disk-backed index**, because the box is a 30 GiB cgroup with **no swap** — a billion sketches in one
98
+ dict is how a free-CPU job dies at hour six.
99
+ 4. **Contamination audit (§3.3).** Mechanical 13-gram overlap of the surviving mix against benchmark
100
+ **validation/dev** material only — including **MMLU's `dev` split specifically**, since those are the
101
+ few-shot exemplars the harness will use, so overlap there is contamination by construction. A script
102
+ computes and writes counts per source; **no item text is read, displayed or summarised by the agent.**
103
+ Any source failing a stated threshold is dropped or cleaned; result written up in `docs/`. **Test
104
+ splits are not opened until Phase 6.**
105
+ 5. **Tokenise** with the frozen SmolLM2 BPE (49,152 — §3 of `01-plan`). Measured cost on this shape:
106
+ 660,943 tok/s across 4 cores → **1.31 B tokens in ~0.55 h**. Not a bottleneck; process-shard rather
107
+ than thread-shard, since rayon scaling saturated at 2.7× on 4 cores.
108
+ 6. **Shard for exact positional resumption (§Phase 2 requirement).** Concatenate token ids into fixed-size
109
+ **`uint16`** shards (`vocab 49,152 < 65,536`, so uint16 is exact and halves the bytes): **40 M tokens =
110
+ 80 MB per shard**, ~28 shards, ~2 GB total. Then a resume position is literally
111
+ `(shard_index, token_offset)` — one integer pair, memmap'd, so `skip_first_batches` on a replaying
112
+ `Trainer` becomes an index advance rather than a decode. This is the property that makes §3.1's
113
+ "same data, same position" checkable instead of hoped for.
114
+ 7. **Hold out validation:** ~22 M tokens sampled **proportionally across sources**, never whole documents
115
+ (whole-document holdout leaks topic statistics and makes PPL optimistic), written as its own shard so
116
+ validation PPL is bit-reproducible at Gate 4.
117
+ 8. **Publish** as public `ounce100m-mix-v1` with a manifest recording: per-source and total token counts,
118
+ shard count and size, tokenizer identity (repo + revision + sha256 of `tokenizer.json`), per-shard
119
+ sha256, the dedup parameters, the audit counts, and the cursor semantics of step 6.
120
+
121
+ ## 6. Licensing the derived mix
122
+
123
+ #5 and #6 are **CC-BY-SA-4.0** (share-alike), and `wikimedia` additionally carries GFDL. A published
124
+ derivative containing them must be offered under SA with attribution and a change log. That is compatible
125
+ with §2's "repos are public", so the plan is: **license the mix CC-BY-SA-4.0** and ship an
126
+ `ATTRIBUTION.md` listing every source, its licence, and the transformations applied. ODC-BY sources
127
+ (#1, #2, #7–#10) require notices kept and changes documented; `stack-v3-train` requires the per-file
128
+ SPDX filter of §2 step 11 so we never republish a non-permissive file.
129
+
130
+ **If a fully permissive mix is later required**, drop #5 and #6 (140 M raw) and backfill from #1/#3. The
131
+ trade is a small loss of encyclopedic density for a licence with no reciprocal obligation — recorded
132
+ here so the choice is available and deliberate rather than discovered under time pressure.
133
+
134
+ ## 7. Gate 2 checklist, restated as things that must be true
135
+
136
+ - [ ] dataset live on the Hub as a public `ounce100m-*` repo
137
+ - [ ] token count **verified against the manifest** by an independent recount, not by the builder's own number
138
+ - [ ] contamination audit passed **and written up** (per-source overlap counts, validation/dev only)
139
+ - [ ] validation split reserved, its token count recorded
140
+ - [ ] shard layout proven small enough that a training job reads a few shards at a time and never
141
+ materialises the mix — demonstrated by a job that reports peak `/kaggle/working` usage while
142
+ consuming shards, not asserted from the arithmetic above
143
+ - [ ] exact-position cursor `(shard_index, token_offset)` demonstrated to be reproducible
144
+
145
+ ## 8. Risks
146
+
147
+ 1. **Dedup is the only stage with real wall-clock cost** and the only one that can exhaust RAM. Design
148
+ for bands + disk; measure on one source before all thirteen.
149
+ 2. **Unauthenticated Hub rate limits.** Jobs currently read anonymously and the API warns about it; at
150
+ ~50 shard downloads that is probably fine, but 429s mid-build are plausible. Mitigation is the
151
+ mounted-credential path (§8 of `01-plan`), which is being verified now.
152
+ 3. **Card token counts are unreliable** (§4) — every number in this file is either measured over HTTP or
153
+ will be replaced by our own tokeniser's count at Gate 2.
154
+ 4. **`finepdfs-edu` adds Common Crawl's Terms of Use** on top of ODC-BY. Included because the subset is
155
+ classifier-selected and globally deduplicated rather than a dump, but it is the least clean licence
156
+ admission in the mix and the easiest to cut if the attribution review gets nervous.
157
+ 5. **Two sources are rewrites/synthetic** (#3, #4, #9, #10). That is permitted explicitly by §3.5, but a
158
+ 34 % synthetic share can produce fluent-but-homogeneous prose; the proportions above keep organic
159
+ English (sources 1, 2, 5, 6, 8, 12, 13) in the majority, and that balance is a deliberate choice
160
+ worth revisiting only with evidence.
161
+
162
+ ---
163
+
164
+ ## 9. Phase 2 step 1 ran — §2 corrected by measurement
165
+
166
+ `dodosoomro/ounce100m-p2-source-inventory` (CPU, 116 s, 1,500 rows per source, tokenised with the
167
+ **frozen SmolLM2 tokenizer**: vocab 49,152 confirmed, decode round-trips, 5.88 chars/token on a formal
168
+ probe sentence). **13 of 18 entries resolved; 5 failed on config names, and two sources turned out to be
169
+ unusable as described.** §2's estimates were right in aggregate (predicted ≈4.35 GB, measured 4.46 GB for
170
+ the 570 M tokens that resolved) but wrong in specifics, so the specifics are replaced rather than
171
+ averaged.
172
+
173
+ ### 9.1 Config-name corrections (the datasets-server truth, from the error messages themselves)
174
+
175
+ | §2 said | correct value | note |
176
+ |---|---|---|
177
+ | `fineweb-edu` `sample/10BT` | **`sample-10BT`** | hyphen, not a path. Full set: `default`, `sample-10BT`, `sample-100BT`, `sample-350BT`, plus per-dump `CC-MAIN-2025-05/08/13/18/21/26…` |
178
+ | `finemath` `finemath4plus` | **`finemath-4plus`** | also `finemath-3plus`, `infiwebmath-3plus`, `infiwebmath-4plus` |
179
+ | `finewiki` `data/enwiki` | config **`en`** | configs are plain language codes (`ab`, `ace`, `af`, …), not directory paths |
180
+ | `wikipedia-monthly` `20250702.en` | **`20260101.en`** | the 2025-07 config is gone; **newer** dumps now exist (`20260101.*`), which is better for currency anyway |
181
+ | `stack-v3-train` `python` | **`default`** only | **there are no per-language configs.** Language is a row field, and rows are whole repositories with a nested `files` struct |
182
+
183
+ Every one of these would have been a mid-build failure. Recorded in `docs/00-platform-notes.md` style:
184
+ the card's own naming is not an API — `load_dataset`'s error is.
185
+
186
+ ### 9.2 Measured yield per document — this is what the token arithmetic actually runs on
187
+
188
+ | source | tokens/doc | chars/doc | chars/token | non-English-flagged rows | verdict |
189
+ |---|---|---|---|---|---|
190
+ | `finepdfs-edu` `eng_Latn` | **1,321** | 14,352 | 3.98 | **128/1500 = 8.5 %** | keep, **must add our own language filter** |
191
+ | `cosmopedia` `stanford` | 932 | 4,917 | 5.30 | 15/1500 = 1.0 % | keep |
192
+ | `cosmopedia` `wikihow` | 907 | 4,541 | 4.97 | 0.7 % | keep |
193
+ | `cosmopedia` `openstax` | 765 | 3,820 | 4.93 | 0.8 % | keep |
194
+ | `cosmopedia` `auto_math_text` | 689 | 2,811 | 4.14 | 0.8 % | keep |
195
+ | `cosmopedia` `khanacademy` | 677 | 3,047 | 4.26 | 1.1 % | keep |
196
+ | `open-web-math` `default` | **1,182** | 6,795 | **3.31** | **112/1500 = 7.5 %** | keep, needs en filter; low chars/token = LaTeX density, which is the point |
197
+ | `finephrase` `tutorial` | 779 | 4,903 | 4.58 | 1.1 % | keep. Column is **`text`**, not `completion` |
198
+ | `finephrase` `faq` | 744 | 4,965 | 4.60 | 1.1 % | keep |
199
+ | `finephrase` `table` | 715 | 4,772 | 4.59 | 1.1 % | keep |
200
+ | `SimpleStories` | **285** | 1,260 | 4.33 | 0.5 % | keep, but it is 4× the *row* count for the same tokens |
201
+ | `common-pile/arxiv_abstracts` | 185 | 791 | 4.31 | 2.2 % | keep. Column is **`text`**, not `raw_content` |
202
+ | `common-pile/libretexts` | **75** | 964 | **2.42** | **1396/1500 = 93 %** | **DROP** |
203
+
204
+ **`libretexts` is disqualified, and the reason matters.** Its `text` field is not prose: 93 % of sampled
205
+ rows failed a naive English test, chars/token collapsed to 2.42, and the first example is a bare
206
+ `https://math.libretexts.org/Bookshelves/...` URL. The Common-Pile schema puts real content in
207
+ `metadata`/`raw_content` behind a per-source convention, so the column we assumed is an identifier field.
208
+ Rather than reverse-engineer four sub-corpora's schemas for 10–20M tokens of marginal value, it is cut.
209
+ `arxiv_abstracts` from the same publisher *did* work (its `text` is real abstract prose), so this is a
210
+ per-dataset fact and not a Common-Pile-wide one.
211
+
212
+ ### 9.3 Two open problems this created, and how they are being handled
213
+
214
+ 1. **Code no longer has a cheap path.** With no per-language config, getting 60–130M tokens of Python/JS
215
+ from `stack-v3-train` means streaming whole-repo rows, opening a nested `files` struct, and filtering
216
+ on a row field — for a source that concentrates in XML/HTML/JSON anyway. Code is not mandatory (§3.4
217
+ makes proportions our call), and at 100M params / 1B tokens the marginal value is genuinely unclear.
218
+ **Action: a dedicated mini-probe before committing** — measure rows-sampled-per-Python-repo and the
219
+ nested schema — and hold code at **≤60M** in the plan until that returns. If it is awkward, drop it;
220
+ that is a defensible §3.4 choice, not a failure.
221
+ 2. **`eng_Latn` and `open-web-math` are not actually English-only** (8.5 % and 7.5 % of sampled rows fail
222
+ a crude English test; the finepdfs sample included Cyrillic inline in a single "English" document).
223
+ §3.4 is English-only, so **a language filter is now a required pipeline stage, not a courtesy** —
224
+ applied per row on our side, on top of whatever the upstream config claims. `finepdfs` carries
225
+ `full_doc_lid` / `per_page_languages` columns to do this cheaply; the general fallback is
226
+ `language_score` where present and a fastText-style gate where not.
227
+
228
+ ### 9.4 Revised totals
229
+
230
+ Confirmed-and-usable now: 570M target tokens across 13 resolved configs, **≈4.5 GB**, at measured yields
231
+ of roughly **909k documents** — plus `fineweb-edu`/`finewiki`/`wikipedia-monthly`/`finemath` recoverable
232
+ with the corrected config names (§9.1), which restores ~570M of the planned 1,310M. Net effect on the
233
+ plan: **the shape survives, the line items do not.** §2's per-source token targets stay as targets;
234
+ §2's config strings and two column names are superseded by this section.
235
+
236
+ **Directly measured consequence for the build:** 909k documents for 570M tokens ≈ 627 tokens/document
237
+ average, so the mix is ~1.6–2.1M documents for 1.0–1.3B tokens. That is the number the dedup design has
238
+ to be sized against — under 2.1M documents, a MinHash signature table comfortably fits the 30 GiB RAM,
239
+ which materially de-risks the one stage §8 called the real cost.
240
+
241
+ ## 10. Builder implemented, and one blocking flaw found and fixed
242
+
243
+ `code/build/build_mix.py` (mirrored in `Cion-lab/ounce100m-code`) is the Phase 2 builder. It stages each
244
+ source separately (stream → normalise → gates → dedup → tokenise) and then **merges** the staged shards
245
+ into the final mixed shards by largest-deficit round-robin over documents.
246
+
247
+ **E-016, and why the smoke test was mandatory.** The first version consumed one source to its target and
248
+ only flushed a shard when the buffer filled. Since fineweb-edu's target alone is ~37 shards of 8M tokens,
249
+ the first third of the mix would have been *nothing but web text*, then textbooks, then math — a curriculum
250
+ drift across the run that no LR schedule can repair, and one the builder itself reported as success
251
+ (checksums, headers, token counts and cursor probes were all clean). The verifier caught it as
252
+ `distinct_sources_per_shard_min: 1`. The shuffle that was supposed to fix ordering only permuted documents
253
+ *inside* a single-source buffer. After the two-stage rewrite, the same smoke run reports
254
+ **`min = max = median = 4`** sources in every shard, 12,001,386 tokens recounted from the bytes,
255
+ 0 out-of-range ids, 40/40 cursor probes and 40/40 document-boundary reconstructions correct.
256
+
257
+ **Shard format** (shared by staged and final, so document boundaries survive to the trainer):
258
+
259
+ ```
260
+ header : <IIII = vocab, n_docs, n_tokens, flags 16 B
261
+ offsets : uint32 × (n_docs + 1), cumulative, [0] = 0
262
+ ids : uint16 × n_tokens (vocab 49,152 < 65,536, so uint16 is exact and halves the bytes)
263
+ doc i = ids[offsets[i] : offsets[i+1]]
264
+ ```
265
+
266
+ Target 8M tokens/shard (16 MB, ~150 shards, ~2.5 GB for the mix). The resume cursor is
267
+ `(shard_index, token_offset)` — one integer pair, which is what makes §3.1's "same data, same position"
268
+ checkable and what keeps `Trainer`'s replaying `skip_first_batches` cheap on a map-style read.
269
+
270
+ **Interruption safety, which was not optional.** `/kaggle/working` is destroyed when a session ends, and a
271
+ full staging pass is hours of streaming. So each source is published to `Cion-lab/ounce100m-mix-stage`
272
+ (the *stage* repo, distinct from the final `ounce100m-mix-v1`) the moment it completes, with a
273
+ `record.json` holding its shard list, token count and drop statistics. A new session rebuilds its stage
274
+ bookkeeping from the Hub and skips every source already published; only the source in flight at the moment
275
+ of the kill is re-staged. `code/build/smoke_hub_resume.py` rehearses this by wiping the local tree between
276
+ stage and merge, because "merge-only with an empty state and no restore path" is a failure mode that exits
277
+ with code 0 while emitting an empty mix.
278
+
279
+ **Revised raw total: 1.23 B tokens = 23 % headroom** over the 1.0 B trained target (raised fineweb-edu to
280
+ 340M, finepdfs-edu to 180M, finemath to 160M, because §9's target edits had quietly pulled the plan from
281
+ 1.31 B down to ~1.13 B — about 11 % headroom, which is not headroom once a 12–18 % dedup loss is applied).
282
+ 16 sources, no code source yet (§9.3).
283
+
284
+ **Gates the build must satisfy before Gate 2 is claimed**, as assertions in `verify_mix.py` rather than
285
+ prose: every shard sha256 matches the manifest; no trailing bytes; offsets well-formed; zero out-of-range
286
+ ids; total tokens recounted from bytes equals the manifest; and **≥ half the distinct sources present in
287
+ every shard**. The last one exists because the first build passed everything else.
288
+
289
+ ## 11. Interruption safety proven, and the build that this authorises
290
+
291
+ A CPU session's `/kaggle/working` is destroyed when it ends. Everything below was measured, not assumed
292
+ (`dodosoomro/ounce100m-p2-cold-resume-rehearsal` **v6**, 17:35Z, 55 s wall-clock, pinned REV `428c5234`).
293
+
294
+ | Step | Observed |
295
+ |---|---|
296
+ | 1. stage two sources, publish each | 2,400,867 tokens staged; `record.json` + `shard-0000.bin` per source on the Hub |
297
+ | 2. **wipe the local tree** (`root_exists: false`, `stage_dir_exists: false`) | faithful simulation of a session kill, not a soft restart |
298
+ | 3. `--merge-only` with the Hub as the only state | `hub: restored 2 staged source(s) (2,400,867 tokens)` → merged shard 2,352,747 tok / 5,815 docs, **2/2 sources in it**, val shard 48,120 tok |
299
+ | 4. `verify_mix.py` over the restored mix | `PASS: true`, `sha_ok 1/1`, `out_of_range_ids: 0`, `trailing_bytes: 0`, cursor probes **40/40 boundaries reconstructed, 0 mismatches**, `recount_matches_manifest: true` |
300
+ | 5. verdict + self-cleanup | `COLD_RESUME_PASSED=True`, `cleanup=deleted`, throwaway repo confirmed gone from the namespace |
301
+
302
+ v4 of the same rehearsal had reported `false` over an identically-working pipeline: a stray
303
+ `print("shards=", …)` inside the `BUILD_JSON` block made the parent's `json.loads` fail and a helper fold
304
+ that into `None` (memory/ERRORS.md **E-019**, and the report-shape recurrence **E-023**). The fix was to
305
+ the harness, plus a `(obj, why_null)` return and a `manifest.json` fallback so a verdict can never again
306
+ be silently null.
307
+
308
+ **The build now running** (`dodosoomro/ounce100m-p2-full-mix-build`, 17:38Z, CPU, `sessionTimeoutSeconds
309
+ 43200`, pinned REV `98e49560`): `build_mix.py --root /kaggle/working/mixroot --hub-repo
310
+ Cion-lab/ounce100m-mix-stage` with defaults — stage cap 1.31 B tokens, per-source targets summing to
311
+ 1.23 B, 8 M tokens/mixed shard, `VAL_STRIDE 50` holdout, shuffle seed 20260919. Each source publishes as
312
+ it completes, so an interruption costs at most one source's streaming time, and a re-launch restores the
313
+ finished ones from the Hub (step 3 above is that exact path).
314
+
315
+ **Audit semantics, hardened the same way.** `audit_contamination.py` compares 13-token windows against
316
+ `{train, validation, dev}` of the eight tasks — never `test` — and emits counts only. It now also reports
317
+ `shards_missing`, and its verdict is composite: `AUDIT_PASSED` requires every manifest shard present and
318
+ read, > 0 documents and grams measured, ≥ 6 readable reference sets, zero reference errors, and zero
319
+ overlap. Exit 6 means *overlap found* (a real finding); exit 7 means *the audit did not measure* (a bug).
320
+ A zero-overlap report over shards that were not on disk is no longer expressible.
321
+
322
+ **Publishing ships the tokenizer.** `publish_mix.py` copies `tokenizer.json` into the dataset root,
323
+ re-hashes it and aborts with exit 8 unless it matches the sha256 recorded in the manifest — so the
324
+ published ids and the published tokenizer are provably the pair that produced them (§3.12).
325
+
326
+ ## 12. Gate 2 — the record, including where it failed and what that failure was worth
327
+
328
+ **Merge and verify: passed, twice, reproducibly.** From the 15 staged sources
329
+ (`Cion-lab/ounce100m-mix-stage`, 1,150,015,841 tokens staged):
330
+
331
+ | field | value |
332
+ |---|---|
333
+ | merged shards | **141** (each drawn from all 15 sources) |
334
+ | train tokens | **1,127,163,952** |
335
+ | held-out validation | **22,851,889** in 12 shards (every 50th merged document) |
336
+ | documents | 1,078,807 |
337
+ | per-source share | 75,144,263 tokens each, equal by construction |
338
+ | merge time | 16.4 s (restore from the Hub included: 123.8 s) |
339
+ | `verify_mix` | **`PASS: true`** — sha256 141/141, headers 141/141, 0 bad offsets, 0 out-of-range ids, 0 trailing bytes, recount matches manifest, 40/40 cursor probes, `distinct_sources_per_shard_min = 15` (floor was 7) |
340
+ | `finewiki__en` | **never staged.** Gate 2's own diagnostic showed the columns present and `first_row_ok: true` with a truncated `ImportError` in the loading script. 15 sources at 1.127 B is above the 1.0 B target with 12.7 % headroom, so this is a composition note, not a blocker |
341
+
342
+ **Then the audit refused to publish, and it was right to.** `audit_contamination` exited 7:
343
+
344
+ | task | 13-gram hits | reference size (verified against the dataset server) |
345
+ |---|---|---|
346
+ | mmlu | 904,288 | dev 285 + validation 1,531 items ≈ 149k grams |
347
+ | gsm8k | 185,600 | train 7,473 items = 360,656 grams |
348
+ | hellaswag | 1,852 | train 39,905 + validation 10,042 |
349
+ | arc_easy | 358 | train 2,251 + validation 570 |
350
+ | arc_challenge | 214 | train 1,119 + validation 299 |
351
+ | piqa | **not measured** | the loader yielded 0 of 16,113 train rows without raising |
352
+ | winogrande | (not in the visible excerpt) | train 40,398 + validation 1,267 |
353
+ | truthfulqa | (repo name was wrong) | validation 817, `multiple_choice` |
354
+
355
+ `expected_false_positives` for the whole scan was **≈0.0001**, so these are matches, not collisions. The
356
+ first reading I wrote in `STATE.md` — "GSM8K's whole train split is in the mix" — was an over-claim: hits
357
+ are counted per *mix* gram, so a small number of frequently repeated reference grams can produce a large
358
+ count, and 185,600 hits against 360,656 distinct GSM8K grams means "up to half of its gram vocabulary
359
+ occurs somewhere in 1.1 B tokens". The columns that settle severity are `mix_documents_majority_hit`
360
+ (documents whose grams are more than half matched → verbatim inclusion) and `source_hit_document_fraction`
361
+ (which source, and how much of it) — and both are only computable on the fixed audit, which is what Gate
362
+ 2c/2d exist to produce.
363
+
364
+ **Why upstream did not catch it, verified rather than assumed:** FineMath's card states it removed 13-gram
365
+ overlap against the **test** sets of GSM8k, MATH, MMLU and ARC; Cosmopedia's describes a 10-gram +
366
+ `difflib` pass against **test benchmarks**; OpenWebMath documents only SimHash self-deduplication with no
367
+ benchmark claim. `validation`/`dev`/`train` overlap was therefore never in scope for any of them — and
368
+ `validation` is the split lm-eval scores HellaSwag, PIQA, Winogrande and TruthfulQA on
369
+ (`docs/05-eval-plan.md` §7).
370
+
371
+ **Gate 2 remained unsigned at the end of this stage.** `Cion-lab/ounce100m-mix-v1` did not exist yet. The
372
+ path to it: attribution →
373
+ drop the offending documents by mask (or a source if attribution says it is broadly soaked) → re-merge
374
+ with `--exclude-dir` → re-audit until `AUDIT_PASSED` with all 8 tasks covered → `publish_mix`, which now
375
+ refuses to ship unless the audit passed, covered all 8, scanned the val shards, and its `mix_bytes_sha256`
376
+ matches the exact manifest being published. `E-030` explains why the first filtered re-merge could not
377
+ work and what was changed.
378
+
379
+ ### 12.4 Resolution — the filtered mix, measured (Gates 2b–2f, 2026-09-19)
380
+
381
+ **Attribution first, always.** Gate 2b/2c scanned the *staged* shards per source, which is the only way to
382
+ say where contamination lives rather than how much the merged mix contains. Of 1,955,832 staged documents,
383
+ **10,425 (0.533 %)** carried at least one matched 13-gram and **0 were majority-matched** — shared spans,
384
+ not wholesale inclusion. The count concentrated in five sources: finemath-4plus 2,688 documents, fineweb-edu
385
+ 1,043, cosmopedia `auto_math_text` 568, finepdfs-edu 420, open-web-math 339, with the remaining ~5,367
386
+ spread over ten more. Per-source *hit counts* summed to ~50,700 while the merged scan reported 2,096,540 for
387
+ essentially the same gram volume; the discrepancy is unreconciled and recorded as **E-032c** rather than
388
+ smoothed over. It changes no decision: the exclusion is per-document and the post-filter overlap is zero
389
+ either way.
390
+
391
+ **The exclusion, and what it cost.** `audit_contamination --write-filter` emitted one `.u8` mask per source
392
+ (1 byte per staged document, ~700 KB total) marking documents that contain a matched window. Re-merging with
393
+ `--exclude-dir` dropped **5,878 documents = 17,366,967 tokens** (1.5 % of the mix) and the re-audit of the
394
+ result gave **`overlap_total = 0`** with 8/8 benchmark tasks covered, the held-out validation shards
395
+ scanned clean, and `MEASURED: true`. Final mix: **1,109,714,831 training tokens** in 141 shards plus
396
+ 22,851,889 held-out validation tokens — still **11.0 %** above the 1.0 B target, so the pre-registered
397
+ 0.9 B fallback (D-012) did not fire and the contamination fix cost nothing that the token budget had to
398
+ pay for.
399
+
400
+ **Reference coverage is now a precondition, not an assumption.** Gate 2b found that `piqa`'s train and
401
+ validation splits returned **0 rows** from the `datasets` library inside the Kaggle image while the server
402
+ reports 16,113 + 1,838 — the first audit had scored that as "clean". The audit now fetches each split's
403
+ server-side row count (`/size`), refuses any split it read to under 90 % of it, retries through the HTTP
404
+ `/rows` endpoint, and marks the whole report `MEASURED: false` if a loader still falls short. TruthfulQA's
405
+ answer text also sits under keys (`mc1_targets`, `mc2_targets`, `abstractions`) the first version never
406
+ read. All reference splits used are train/validation/dev; **no test split was opened** (§3.3).
407
+
408
+ **Why publication took three attempts (E-033).** Gates 2e and 2f both built and audited the mix correctly
409
+ and then died in the uploader: `publish_mix` sent one commit per file, and the Hub began rejecting every
410
+ request — including 30-byte files — after ~139 commits. That is a commit-rate ceiling, not a network fault,
411
+ and the "resumable" re-send was itself broken because `RepoFile.lfs` is a dict and `getattr(ent.lfs,
412
+ "sha256", None)` is therefore `None` for every shard, i.e. *nothing* looked published. The uploader now
413
+ reads `lfs["sha256"] or lfs["oid"]`, sends the remaining files as **one `upload_folder` commit**, and after
414
+ the commit re-lists the repo and re-hashes, exiting 11 if a path is absent and 12 if a remote digest
415
+ disagrees with the local bytes. `Cion-lab/ounce100m-mix-v1` held 142 of 173 files when Gate 2g re-ran the
416
+ same pipeline with it.
417
+
418
+ **Gate 2 is signed** (`dodosoomro/ounce100m-gate-2g-publish-mix-v1`, complete 2026-09-20T00:31Z, CPU, zero
419
+ GPU quota). The rebuilt mix reproduced Gate 2e's token total exactly — **1,109,714,831** — which is the
420
+ determinism claim in §11 tested a second time on a different session with the same inputs. `audit.json` on
421
+ the Hub reports `overlap_total = 0`, `mix_documents_with_any_hit = 0`, `majority_hit_docs = 0`,
422
+ `expected_false_positives = 0.0`, `tasks_covered` = all eight, `val_hits = 0` across 21,898 held-out
423
+ documents, and `AUDIT_PASSED`, `MEASURED`, `COVERED_ALL_SHARDS` all true, bound to these exact bytes by
424
+ `mix_bytes_sha256 = 732eec7f19e77f36…`. `verify_mix` exited 0. The batched uploader landed all 174 files
425
+ (139 train shards, 12 val shards, 16 `filter/` objects, `manifest.json`, `audit.json`, `tokenizer.json`,
426
+ `README.md`, `ATTRIBUTION.md`, `build_state.json`, `.gitattributes`), and four train plus two validation
427
+ shards were then read back from the anonymous `resolve` endpoint and matched the manifest's sha256 — so the
428
+ mix is public and serving, not merely listed (§3.13).
429
+
430
+ One editorial note on this section: §12.2's first draft treated `overlap_total` as a count of contaminated
431
+ documents. It is a count of matched *grams*, which is why a 41× difference between the per-source and
432
+ merged hit totals could coexist with a 1.3 % agreement on document counts (E-032c). The action taken —
433
+ drop the documents, re-audit to zero — was unaffected, but the number in the record was read wrongly for
434
+ two gates, and the fix was to write the density columns (`mix_documents_with_any_hit`,
435
+ `mix_documents_majority_hit`) and quote *those* when judging severity.
docs/03-preflight-report.md ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 03 — Preflight report (Gate 3)
2
+
3
+ > §5 Phase 3 requires a written report showing **every** listed proof, plus tokens/sec and the resulting
4
+ > main-run ETA and GPU-hour estimate. Each section below states what was proven, the measured number, and
5
+ > the artifact that produced it. Where something is **not** proven, it says so.
6
+ >
7
+ > Cost accounting: the 6 GPU-hour lifetime cap for all small-model tests is tracked in
8
+ > `memory/QUOTA.md`; every row referenced here is a ledger entry, including the failed runs — a session
9
+ > that crashes still bills.
10
+
11
+ ## 0. Scorecard
12
+
13
+ | # | §5 Phase 3 requirement | Stage | Result | Evidence |
14
+ |---|---|---|---|---|
15
+ | 1 | The training code constructs on the target image | `pargs` (CPU) | ✅ | `p1-hub-checkpoint-cycle` v5 |
16
+ | 2 | Checkpoint upload to the Hub | `p1` (CPU) | ✅ | same kernel, 1,699,108,391 B |
17
+ | 3 | A restart that pulls the checkpoint back | `p1` (CPU) | ✅ | cold pull, sha-verified, 10.7 s |
18
+ | 4 | Resumption from the exact data position (proven, not felt) | `p0` (CPU) | ✅ | `resume_matches_uninterrupted: true` |
19
+ | 5 | Optimizer / LR-state restoration | `p3` (GPU) | ✅/⏳ | see §5 |
20
+ | 6 | Loss continuity across the restart within noise | `p3` (GPU) | ⏳ | see §5 |
21
+ | 7 | Stable loss over a few thousand steps | — | **not proven here** | see §7, Limitations |
22
+ | 8 | Measured throughput | `p2` + A/B v2/v3 (GPU) | ✅ | 7,732–7,828 tok/s at seq 1024 |
23
+ | 9 | Cold resume from an empty disk, recovering solely from the Hub | `p3` (GPU) | ⏳ | see §5 |
24
+ | 10 | §3.13 storage cycle at real checkpoint size, end to end | `p1` + `p3` (GPU) | ✅/⏳ | §3, §5 |
25
+ | 11 | Resume at least twice in sequence, position never drifting backwards | `p3` (GPU) | ⏳ | see §5 |
26
+
27
+ ## 1. `pargs` — does the code construct at all (CPU, free)
28
+
29
+ Question answered: every `TrainingArguments` keyword the trainer passes is a promise about transformers
30
+ 5.0.0, and E-008/E-010 had already shown that 5.x drops things without warning.
31
+
32
+ Measured on the Kaggle image (transformers **5.0.0**, torch **2.10.0**):
33
+
34
+ - all `TrainingArguments` kwargs accepted, including `accelerator_config={"dispatch_batches": False}` and
35
+ `average_tokens_across_devices=False`;
36
+ - 22L/576 model builds at exactly **106,194,240** parameters; the 20L variant at **99,114,048** with
37
+ FFN 1536 — matching `01-plan.md` §2.3's closed-form table, so the shape arithmetic and the code agree;
38
+ - RoPE verified as `rope_parameters {rope_theta: 10000.0}` — transformers 5 moved it out of the flat
39
+ field, which is why `docs/01-plan.md` §2's config line needed reading rather than copying;
40
+ - forward + backward finite with gradients;
41
+ - the trapezoid schedule measured, not assumed: plateau over **77.4 %** of steps, factor **1.0** at 80 %,
42
+ **0.50** at 90 %, **0.0013** at the final update;
43
+ - precision asserted as fp16 autocast with **fp32 master weights** and a live `GradScaler` (asserted at
44
+ runtime in the trainer, not configured-and-hoped).
45
+
46
+ Two defects this stage caught before any GPU time was spent: a SwiGLU width computed 2× in the variant
47
+ branch, and variant GQA head counts that did not divide `hidden` (which would hard-error inside SDPA).
48
+
49
+ ## 2. `p0` — the data reader and its resume cursor (CPU, free)
50
+
51
+ Run against a throwaway 2.35 M-token mix built for the purpose (2 capped sources, published as
52
+ `Cion-lab/ounce100m-mix-stagetest`, since deleted-and-kept for reuse by GPU stages):
53
+
54
+ | property asserted | result |
55
+ |---|---|
56
+ | a run sliced to start at sample *n−40* reads exactly the windows an uninterrupted run reads | `resume_matches_uninterrupted: true` |
57
+ | labels are next-token | `labels_are_next_token: true` |
58
+ | same seed ⇒ same order; different seed ⇒ different order | ✅ |
59
+ | train/val prefix collision over 187 held-out windows | `0` |
60
+ | `verify_mix` on the same bytes | `PASS: true` |
61
+
62
+ The mechanism being tested: a global PCG64 permutation over all windows, **sliced** at
63
+ `start_sample` rather than skipped past, with the cursor stored as
64
+ `(samples_consumed, step, seq_len, shuffle_seed, dataset_files_sha)` in `cursor.json`, and
65
+ `ignore_data_skip=True` because the reader owns position.
66
+
67
+ This stage also found E-024 — a parameter deleted while its body check remained, i.e. a `NameError` on
68
+ first call that `py_compile` cannot see.
69
+
70
+ ## 3. `p1` — §3.13's storage cycle at real size (CPU, free)
71
+
72
+ Random weights, real bytes: 106,194,240 params × 4 B × 4 arrays (fp16-saved weights, fp32 master, Adam
73
+ m and v) = **1,699,108,391 B** in one checkpoint, which is what the main run will move every 10 %.
74
+
75
+ | step | measured |
76
+ |---|---|
77
+ | push + verify against the Hub's own listing (size + LFS sha256) | **26.3 s** |
78
+ | authenticated read-back of one file, anonymous connection | sha matched |
79
+ | local prune, free space confirmed | 19.24 → **20.94 GB** free |
80
+ | cold pull into an empty directory | **10.7 s** |
81
+ | rig cleanup | repo deleted in-session |
82
+
83
+ Why "listing is not verification" is enforced in code: `verify_checkpoint` returns `ok` only if the
84
+ read-back succeeded (E-023 — an earlier version passed while the read-back 404'd, because the report was
85
+ built from a fixed key list that silently dropped the error).
86
+
87
+ ## 4. `p2` — throughput, and the decision it forced (GPU, ledger rows 10-14)
88
+
89
+ Test T1 measured the **frozen 22L/576 shape** on 2×T4, fp16 + DDP, on real packed data. The result was a
90
+ problem: the plan-of-record configuration (seq 2048, SDPA, micro 2) runs at **4,071 tok/s** with peak CUDA
91
+ memory at **14.22 GB of ~14.56**, i.e. 1 B tokens needs **68 GPU-hours** against a 30 h/week quota. The
92
+ 25.1 h figure in the first draft of `01-plan.md` §6 came from p0c's *raw* loop at seq 1024 and was wrong;
93
+ §6.1 records the correction.
94
+
95
+ Four cells plus two A/B follow-ups, all at 22L/576 unless noted:
96
+
97
+ | config | tok/s | peak GB | 1 B tokens |
98
+ |---|---|---|---|
99
+ | sdpa @2048 micro 2 (plan-of-record) | 4,071 | 14.22 | 68.2 h |
100
+ | sdpa @2048 micro 1 | 3,954 | 10.04 | 70.3 h |
101
+ | eager @2048 micro 2 | **OOM** | — | — |
102
+ | eager + grad-ckpt @2048 micro 2 | 4,679 | 10.04 | 59.4 h |
103
+ | sdpa + grad-ckpt @2048 micro 4 | 4,505 | 10.03 | 61.7 h |
104
+ | **eager @1024 micro 4** | **7,732** | 12.25 | **35.9 h** |
105
+ | **eager + grad-ckpt @1024 micro 8** | **7,828** | **7.12** | **35.5 h** |
106
+ | sdpa @1024 micro 4 (matched control) | 5,105 | — | 54.4 h |
107
+
108
+ Three findings, in order of consequence:
109
+
110
+ 1. **Eager attention beats SDPA on Turing by +52 %** at seq 1024 (7,732 vs 5,105 at matched batch
111
+ geometry), and OOMs at 2048. The library default had been costing 34 % for nothing.
112
+ 2. **The `Trainer` is not the overhead.** The hypothesis I went looking for was framework cost; the raw
113
+ loop measured 5,934 tok/s — *slower* than the Trainer at the same shape. The 11,062 of p0c was an
114
+ artefact of comparing a different seq length, model size and batch, not a framework penalty.
115
+ 3. **Sequence length is the lever that matters**, and §4 leaves it my choice as long as it is frozen at
116
+ launch. Halving the context bought 1.7× and moved peak memory from 98 % of the card to 49 %.
117
+
118
+ That produced **D-011**: seq **1024**, attention **eager**, gradient checkpointing **on**, micro-batch
119
+ **4**, accumulation **32** ⇒ 4 × 1024 × 32 × 2 = **262,144 tokens per step**, identical to the frozen
120
+ batch size in tokens, so the step count (**3,814** = `int(1e9/262144)`, i.e. 999,817,216 tokens = 99.98 %
121
+ of the target), the LR and the schedule are unchanged. The capability cost — ARC
122
+ 25-shot prompts exceed the context and get truncated from the left — is recorded in `05-eval-plan.md` §6,
123
+ with no shot count changed.
124
+
125
+ ## 5. `p3` — cold resume at the frozen geometry (GPU, ledger row 15)
126
+
127
+ _Status: running as `dodosoomro/ounce100m-gate-3-p3-cold-resume-v2` at time of writing. This section is
128
+ filled from `preflight_p3.json` when it lands; nothing below is claimed until it is measured._
129
+
130
+ Design, so the numbers can be checked against the intent:
131
+
132
+ - **Three legs**, cumulative steps 20 → 40 → 60, at 262,144 tokens/step — the real step, the real
133
+ checkpoint size, the real cursor, not a cheaper stand-in.
134
+ - Before each resume the session **deletes its own local run directories** and re-`df`s, so recovery is
135
+ forced through the Hub. That is the only resume test that counts, because every real interruption looks
136
+ like this (§3.13).
137
+ - Exactly **one checkpoint per leg** (`--push-every-steps` = the leg's step count), pushed, verified from
138
+ the Hub, and pruned, so the cursor sequence has three distinct points to check.
139
+ - `--resume auto` reads `latest.json`; 404 means "start from zero", and *any other* error aborts rather
140
+ than silently restarting from step 0.
141
+ - `--attn eager` and `--grad-ckpt` are named on the command line, not inherited from a default, so a later
142
+ change to a default cannot silently change what this stage tested.
143
+ - Pass criteria, checked in code: three legs exit 0; both resumes report `auto-resume: hub says step`;
144
+ at least three cursor records; sample counts **strictly increasing and all distinct**; the resumed model
145
+ is the frozen **106,194,240**-parameter model; and the Hub rig is deleted afterwards.
146
+
147
+ To be recorded here: the three `CKPT` lines with their sample counts, the `prior loss at resume:` values
148
+ either side of each wipe, `val_ppl`, `P3_frozen_rate_tok_per_s`, `P3_frozen_peak_gpu_gb`, the wall-clock
149
+ cold-start cost per leg, and the session's GPU charge against row 15.
150
+
151
+ ## 6. Throughput and the main-run estimate
152
+
153
+ | | |
154
+ |---|---|
155
+ | Rate at the frozen geometry | _P3's `tok_per_s`_; planning value **7,732 tok/s** from the m4-without-checkpointing cell |
156
+ | 1 B tokens | **35.9 h** (35.5 h at the m8 cell) |
157
+ | Quota | 30 h/week, 2×T4, billed at **1× container wall-clock** (5 sessions observed) |
158
+ | Preflight spend to date | **0.447 h** of the 6 h test cap |
159
+ | Calendar | week 1 ≈ 26 h of training (~722 M tokens) → quota reset 2026-09-26T00:00Z → ~10 h in week 2 to finish 1 B |
160
+ | Tripwires fixed before launch | **D-012**: below 5,150 tok/s ⇒ launch at 0.9 B. **D-013**: below 7,400 tok/s ⇒ launch at m8 × accum 16 (same 262,144 tokens/step) |
161
+
162
+ Details in `docs/04-run-log.md` §1-§2.
163
+
164
+ ## 7. Limitations of these proofs
165
+
166
+ - **"Stable loss over a few thousand steps" is not proven by preflight, and cannot be at this budget.**
167
+ P3 runs 60 steps; a thousand-step stability claim would cost ~0.5 GPU-h that the 6 h test cap cannot
168
+ spare on a test rather than on the run. What *is* proven is narrower and honest: the loss is finite,
169
+ the optimizer and LR state survive a cold resume, and the loss trace is continuous across two restarts.
170
+ Long-horizon stability is monitored on the main run itself (§3.1), against the plan, on every wake.
171
+ - **The tiny-model framing of §5 Phase 3 is satisfied differently than literally.** §5 says "test with
172
+ 10-20 M parameter models … as cheaply as possible (CPU where you can, GPU only when the thing being
173
+ proven needs a GPU)". Every pipeline proof here runs at the **real 106 M shape** rather than a 15 M
174
+ stand-in, because the thing being proven — checkpoint bytes, cursor arithmetic, throughput, peak memory
175
+ — is size-dependent, and a 15 M model would have proven a cheaper pipeline than the one being launched.
176
+ The cost of that reading is quantified in rows 10-15 instead of assumed.
177
+ - P3's data is the mix as merged from `ounce100m-mix-stage`, i.e. the *pre-filter* bytes if Gate 2c's
178
+ contamination filter is still running. That does not affect what P3 measures (resume correctness,
179
+ throughput at fixed token counts), but it is stated so the record is exact.
180
+ - Peak-memory numbers are per-cell maxima from `torch.cuda.max_memory_allocated`, which excludes CUDA
181
+ cache fragmentation. The main run's real OOM risk is therefore slightly understated at 12.25 GB; this
182
+ is one reason D-011 chose checkpointing on.
183
+
184
+ ### 4.1 Was more throughput available? Audited, and the answer is "not by changing code"
185
+
186
+ Two checks, because "3.8 % of a T4's datasheet peak" looked like a defect and §3 says never trust a prior —
187
+ including my own arithmetic.
188
+
189
+ 1. **Cross-check against a comparable published run.** A ~163 M-parameter base model trained with DDP on
190
+ **8×A100-40GB** reached **234,480 tok/s** at micro-batch 13 ([gilesthomas.com, Jan 2026]
191
+ (https://www.gilesthomas.com/2026/01/llm-from-scratch-29-ddp-training-a-base-model-in-the-cloud)) —
192
+ **29,310 tok/s per A100**. An A100's fp16 tensor-core peak is roughly an order of magnitude above a
193
+ T4's, and the T4's advantage shrinks further because PyTorch's autocast accumulates in fp32. Scaling
194
+ that ratio down, the expectation for one T4 at a 106 M model is ~2,900 tok/s; **measured is 3,866 per
195
+ card** (7,732 / 2). So the run is slightly *ahead* of the cross-check, and the "low MFU" reading of
196
+ §6 in the original plan was an artefact of the marketing peak number, not an unclaimed win.
197
+ 2. **`torch.compile`.** The guidance available is that it pays on long, shape-stable workloads and that
198
+ `reduce-overhead` targets *small* batches ([Raschka]
199
+ (https://sebastianraschka.com/faq/docs/torch-compile-llm-workloads.html)), while slow compilation is a
200
+ known hazard in distributed runs
201
+ ([pytorch#108971](https://github.com/pytorch/pytorch/issues/108971)). Our batch is not small
202
+ (4 × 1024 per rank) and the long-running shape is stable, so it is plausible — but the plausible gain is
203
+ tens of percent against a new class of failure (compile hang at rank startup, graph breaks through the
204
+ GradScaler path) inside a run that may not be restarted once checkpoint 1 exists (§3.1).
205
+
206
+ **Decision (D-015, at freeze time, before the run):** no `torch.compile`, no flash-attn — that one is measured, not
207
+ assumed: `SDPBackend.FLASH_ATTENTION` raises *"Flash attention only supports gpu architectures in the
208
+ range [sm80, sm121]. Attempting to run on a sm 7.5 gpu"* on this hardware (`docs/00-platform-notes.md`
209
+ §probe C), so it is architectural and no dependency install changes it; and eager already measured faster
210
+ than SDPA here anyway — no quantised optimisers, no gradient-bucket tuning. The three knobs that were genuinely worth GPU time —
211
+ sequence length, attention kernel, activation checkpointing — were measured and set in D-011, and together
212
+ they moved 68 h to 35.9 h. The remaining ~22 h of two-week slack is better spent absorbing interruptions
213
+ than chasing a few percent with an unrestartable failure mode attached.
214
+
215
+ ## 8. Post-signing mechanism probes (2026-09-20)
216
+
217
+ Gate 3 signed the *recipe*. These probes test the *session machinery* that only Phase 4 exercises, and they
218
+ ran after the freeze and before the first billed session, on the published mix.
219
+
220
+ ### 8.1 CPU rehearsal — `phase4_prep.py` at head `1dd45f80`, 245.3 s, zero quota, **all stages pass**
221
+
222
+ | check | measured |
223
+ |---|---|
224
+ | every published shard, hashed from the Hub download against the manifest | `SHASHED 151 files total_tokens 1,109,714,831 mismatches 0` |
225
+ | manifest self-consistency (records vs `n_shards` vs bytes actually mapped) | 139 = 139 = 139; shard tokens sum to the claimed total |
226
+ | reader geometry | `1,109,714,831 tokens → 1,083,705 windows of 1024`; horizon `3,814 × 262,144 = 999,817,216` tokens (11.0 % margin) |
227
+ | corpus fingerprint (content-hashed, E-035) | `53df4708526da5c8` |
228
+ | **session schedule, driven through the shipped `plan()`** | `SESSIONS 5 ends_at 3814 horizon 3814 contiguous True` — 0→762→1,524→2,286→3,048→3,814 |
229
+ | **resume reads the same data** | `RESUME_EQUIV step 381 start_sample 97,536 identical True`; same at 1,524 (390,144) and 3,433 (878,848) — input_ids *and* labels compared, through `save_cursor`/`load_cursor` |
230
+ | permutation identity guard (E-035 residual, now implemented) | `full.order_sha == perm_sha(...) == resumed.order_sha` at every boundary |
231
+ | launcher rehearsal | `PREP_ONLY_OK stop_after_steps 762 planned_steps 762`, `usable_hours 6.3` |
232
+ | cursor round-trip + trainer imports on this image | `CURSOR_AND_IMPORT_RC 0`, `TRAINER_HELP_RC 0 lines 75` |
233
+
234
+ Two real defects surfaced here rather than on a GPU: **E-036** (`--help` crashed because argparse
235
+ interpolates help text and two strings contained a bare `%`) and **E-037** (`torchrun` was handed
236
+ `sys.executable` as the script, so it tried to compile the Python binary — the same line in the launcher
237
+ would have killed session 1 about ten minutes in, after the 2.3 GB pull).
238
+
239
+ ### 8.2 GPU probes
240
+
241
+ `p4_stop_probe.py`, two modes, same assertion set. **Probe 0** (soak, 06:12Z) died in 8.6 s on E-037 and
242
+ cost effectively nothing.
243
+
244
+ **Probe 1 v1** (`smoke`: 20 steps at 262,144 tokens/step, no checkpointing, `--push-every-steps 10`, stop at
245
+ 10, run directory deleted, resume to 20) ran 778.7 s and **answered the mechanics question outright**:
246
+
247
+ ```
248
+ CKPT 10 samples=2,560 push+verify=60.3s ok=True pruned=True free=18.67GB loss=10.1926
249
+ TRAIN DONE step=10/20 elapsed=4.5 min tokens_consumed=2,621,440
250
+ auto-resume: hub says step 10 at ckpt/checkpoint-10
251
+ CKPT 20 samples=5,120 push+verify=59.7s ok=True pruned=True free=16.12GB loss=9.5255
252
+ TRAIN DONE step=20/20 elapsed=4.7 min tokens_consumed=5,242,880
253
+ latest.json rolled to the completed run: final at step 20
254
+ ```
255
+
256
+ So `--stop-after-steps` stops on the boundary, the push→verify→pointer-read-back→prune cycle works at the
257
+ real 1.7 GB size, a cold Hub resume lands on the exact cursor (2,560 → 5,120 samples = step × 256), loss is
258
+ continuous across the disk wipe, the terminal pointer roll fires, and disk headroom after two checkpoints is
259
+ 16.12 GB. `samples_consumed` and `step` agree by construction at both boundaries.
260
+
261
+ **What it did not survive:** rank 1 exited 1 with `error_file: <N/A>` and no traceback, so six assertions
262
+ could not be evaluated. Two hypotheses were written here at the time — `--no-grad-ckpt` meeting a 25-batch
263
+ eval forward, or the segmented stop interacting with the eval loop — and **both were wrong**; §8.4 records
264
+ what it actually was (E-044: a rank-0-only assertion that `hub_cb.steps` was empty on rank 1 by
265
+ construction). That diagnosis needed three things this attempt lacked: per-rank log files rather than
266
+ `--redirects 2` (which filed the stream nobody was reading, E-039), a failure printer that greps the whole
267
+ capture rather than its last 40 lines, and marks printed by every rank instead of rank 0.
268
+ **This is the exact case the smoke-first ordering was for**: it cost 13 minutes, not the 1.6 hours the soak
269
+ would have spent finding it.
270
+
271
+ ### 8.3 Rehearsal v4 and probe 1 v4/v5 (2026-09-20 07:47-07:50Z)
272
+
273
+ `dodosoomro/ounce100m-phase4-prep-cpu-rehearsal` **v4 — COMPLETE** after the round-3 edits to the trainer
274
+ and launcher (rank-visible evaluation failure, cross-rank peak-memory reduction, complete
275
+ `run_summary.json`). The kernel ends `raise SystemExit(0 if (rc1 == rc2 == rc3 == 0) else 4)`, so a COMPLETE
276
+ status is the evidence that all three stages — launcher rehearsal, the 151-shard content hash and the
277
+ cursor/import checks — still pass on head `4c7f4922`. The reader's guarantees therefore survive the changes
278
+ that were made in response to review.
279
+
280
+ Probe 1 **v4** re-established the mechanics on a clean scratch repo (`PROBE_REPO
281
+ Cion-lab/ounce100m-ckpt-probe-0920-0727`, `LEG1 pushed: ['checkpoint-10'] pointer: {'step': 10, 'path_in_repo':
282
+ 'ckpt/checkpoint-10'}`) and died again at 275 s in the same place — the post-train validation pass — this
283
+ time with **no Python traceback even though stderr was not redirected**, which is what pointed at the
284
+ `say()`-is-silent-on-rank-1 mechanism (E-039) rather than a data or memory error. v5 adds `--tee 3`, a
285
+ directory listing before any tail, `NCCL_DEBUG=WARN`, and per-rank reporting of the evaluation failure.
286
+
287
+ Decision still open, and bounded either way: if the validation pass cannot run at `--no-grad-ckpt`, D-017
288
+ stands, the run keeps checkpointing at 9,696 tok/s, and nothing else changes. If it can, D-018 adopts
289
+ 12,792 tok/s with a 60-step recovery cadence. The smoke probe is 13 minutes; the soak is 1.6 h; session 1
290
+ follows whichever way it lands.
291
+
292
+ ### 8.4 Probe 1 closed (v6, v7, v8 — 09:00Z to 09:42Z): `PASS`, and the crash was never the memory config
293
+
294
+ Three more attempts, each one buying the evidence the previous attempt could not print.
295
+
296
+ **v6 (581.1 s, FAIL).** With the tee-prefix bug fixed and the whole-object read-back replaced by two bounded
297
+ `Range` requests, the checkpoint cycle fell from `push+verify=797.7s` to **13.4 s**, and leg 1 still died
298
+ after its forced stop. The probe's own `DIAG_leg1` printed nothing at all — it captured the per-rank logs and
299
+ discarded them, because its output went through the same line-prefix filter as everything else (E-043).
300
+
301
+ **v7 (682.7 s, FAIL) — the diagnostic that worked.** The trainer now marks the post-training sequence with
302
+ per-rank `print`s, and leg 1 printed:
303
+
304
+ ```
305
+ [rank 0] post-train: step=10/20 log_history_loss_entries=2 final_loss=10.192607879638672 start_step=0
306
+ [rank 0] past the stop guard: forced_stop=True stopped_at=10
307
+ validation skipped: segment ended at step 10 of 20
308
+ [rank 0] peak_stats: entering (this is a collective)
309
+ ```
310
+
311
+ and nothing from rank 1 — while rank 1's log, which `diag` now actually prints, ended with *"segment ended at
312
+ step 10 but no checkpoint was pushed and verified for it (pushed: [])"*. Rank 1 was killing the run on
313
+ **our own assertion**: `HubPush.on_save` returns early on non-zero ranks, so the list that assertion reads is
314
+ empty on rank 1 by construction, and every correctly-checkpointed forced-stop leg died there. Not a
315
+ collective, not `evaluate()`, not memory. E-044, and it retires the E-040 hypothesis in §8.2.
316
+
317
+ **v8 (578.0 s) — `VERDICT P4PROBE PASS []`, 16/16 checks, both legs rc 0.** Leg 1 stops at 10 of 20, pushes,
318
+ Hub-verifies, rolls `latest.json`, reads it back, prunes, skips validation and exits 0 with
319
+ `val_skipped: true`; the probe wipes the run directory; leg 2 resumes from the Hub alone and runs to the
320
+ horizon, pushes `ckpt/checkpoint-20` and `final/`, runs the 195-window held-out pass (`loss 9.3532`,
321
+ `ppl 11535.95`) and rolls the terminal pointer. Tokens 2,621,440 → 5,242,880 = 10 and 20 × 262,144;
322
+ `samples_consumed` 2,560 → 5,120; `shuffle_perm_sha` and `dataset_files_sha` identical across the resume;
323
+ `params 106,194,240`; `grad_ckpt false` read off the artifact; loss `10.7723 → 10.1926 → 9.5255`.
324
+
325
+ Numbers carried forward, all at the frozen geometry with checkpointing **off**:
326
+
327
+ | quantity | value | where it came from |
328
+ |---|---|---|
329
+ | step time | **20.20 s** = 12,977 tok/s | v8 progress bar, 10-step and 20-step legs agreeing |
330
+ | horizon wall clock | **21.4 h** of stepping (3,814 steps) | that rate × the step count |
331
+ | checkpoint cycle | **12.7-16.5 s** per 1.27 GB push+verify+pointer+prune | v7/v8 `CKPT` lines |
332
+ | memory, training only | **12.84 GiB reserved / 12.70 allocated**, cross-rank max | v8 leg 1, which never evaluates |
333
+ | memory, after validation | 13.66 GiB reserved | v8 leg 2 — the same high-water mark, plus the eval pass |
334
+ | session shape | 5 sessions of 762 steps, last running to 3,814 | rehearsal v3/v4 driving the shipped `plan()` |
335
+
336
+ The split of the two memory figures is the reason the soak's gate is `peak_memory_during_training_below_13_6_gb`
337
+ rather than a check on both legs: `max_memory_reserved` is process-lifetime, so a leg that evaluates reports
338
+ training-then-eval, and the run occupies the training state for all 3,814 steps.
339
+
340
+ **Two review-found defects closed in the same window** (E-042, E-045): the prune guard lived only inside the
341
+ wrapper the save path bypasses, so a failed verification would have deleted the last local copy *and* moved
342
+ the pointer onto it; and `verify_checkpoint`'s length check is now accompanied by a `Content-Range` check,
343
+ because 850 MB of the right length from the wrong offset passed the old test. Both are rehearsed on free CPU
344
+ in stage 4 of `phase4_prep`, against the 1.27 GB checkpoint this probe really pushed — clean, tampered inside
345
+ the read window, tampered outside it, absent, Range-ignoring, wrong-offset, wrong-bytes, and the prune
346
+ refusal itself.
docs/04-run-log.md ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 04 — Run log and the multi-week schedule
2
+
3
+ > Phase 4's plan is written **before** launch (MASTER_PROMPT §5: "If the estimated finish exceeds the
4
+ > week's remaining hours, plan the multi-week resume explicitly"). Numbers come from
5
+ > `docs/00-platform-notes.md` §9 and `memory/QUOTA.md`; nothing here is a guess dressed as a fact.
6
+
7
+ ## 1. The arithmetic
8
+
9
+ **Amended 2026-09-19 after D-011.** The first version of this section planned against 11,062 tok/s, which
10
+ came from p0c's raw training loop at seq 1024 on a 113M model. Gate 3's P2 measured the real thing — the
11
+ frozen 106M shape, inside `Trainer`, fp16 + DDP on 2×T4 — and the honest numbers are ~30 % of that at
12
+ seq 2048 and ~7.7k at seq 1024. Everything below divides by a *measured* number, and the one row that is
13
+ still provisional is marked as such.
14
+
15
+ | Quantity | Value | Source |
16
+ |---|---|---|
17
+ | Tokens to train | 1,000,000,000 (fallback 900M) | frozen, `01-plan.md` §4 |
18
+ | Tokens per step | 262,144 = 4 × 1024 × 32 accum × 2 cards | frozen (D-011; unchanged in tokens) |
19
+ | Steps | **3,814** = `int(1_000_000_000 / 262_144)` | the trainer's own integer division, so the plan and the code cannot disagree |
20
+ | Tokens actually consumed at that horizon | **999,817,216** = 99.98 % of the 1.0 B target | 3,814 × 262,144 — reported as the achieved figure, never rounded up to "1 B" |
21
+ | Checkpoint interval | 381 steps = 99,876,864 tokens ≈ **3.6 h** at the planning rate | §2's one-per-10 % cadence; `--stop-after-steps` must be a whole multiple of it |
22
+ | Throughput, seq 2048 (the old plan-of-record) | 4,071 tok/s, peak 14.22 GB → **68.2 h** | P2, ledger row 11 |
23
+ | Throughput, seq 1024 eager m4 (no ckpt) | 7,732 tok/s, peak 12.25 GB → **35.9 h** | A/B v2, row 13b |
24
+ | Throughput, seq 1024 eager+GC m8 | 7,828 tok/s, peak 7.12 GB → **35.5 h** | A/B v3, row 14 |
25
+ | **Throughput at the frozen geometry (m4 + grad-ckpt, seq 1024, accum 32)** | **9,358 tok/s measured across three legs (9,518 / 9,466 / 9,358), peak 5.99 GB → 29.68 h** | **P3 v3, ledger row 16. Supersedes the 35.5-35.9 h estimate: those came from cells run at `--accum 1`.** `--stage opts` (row 17) is measuring whether the headroom this reveals buys more |
26
+ | Planning rate | **7,732 tok/s → 35.9 h for 1 B** | the slower of the two seq-1024 cells; the m8 cell is not the frozen batch |
27
+ | GPU quota | 30 h/week, 2×T4, billed at **1× session wall-clock** | 5 GPU sessions; the 1× ratio confirmed on the 4 pairs where container time and quota delta were both read |
28
+ | Weekly reset | **Saturday 00:00 UTC** (next: 2026-09-26, then 2026-10-03) | `quota_refresh_time` |
29
+ | Checkpoint cycle cost | 26.3 s push+verify, 10.7 s cold pull (1.7 GB) | P1, row D-007 |
30
+ | Cold-start cost per interruption | ~4 min (image import, Hub pull, first step) | estimate, **P3 measures it** |
31
+
32
+ Two numbers decide the calendar. Total GPU need is **35.9 h** at the planning rate, and week 1's quota is
33
+ already **0.447 h** gone to Gate 3 with ~1 h more (P3) to spend, so **~28.5 h of week 1 is available to
34
+ the run and the remaining ~7.4 h lands in week 2**. That is the shape §5 asks to be planned explicitly:
35
+ one scheduled quota boundary mid-run, resumed from the Hub `latest`.
36
+
37
+ **When the pre-registered 0.9 B fallback fires.** Two weeks give 30 + 30 h; allow 6 h of that for
38
+ interruption overhead, the checkpoint cycles and Phase 6's GPU evals, so ~54 h is left for training. 1 B
39
+ tokens needs ≤54 h ⇒ **≥5,147 tok/s**. The planning rate is 50 % above that threshold, so the fallback
40
+ should not fire — but if P3's frozen-geometry rate comes in below ~5,100 tok/s, or if two consecutive
41
+ sessions sustain below it, the token target drops to 900 M **before** launch, per `01-plan.md` §4, and the
42
+ change is recorded here rather than improvised at 3 a.m.
43
+
44
+ ## 2. The calendar
45
+
46
+ Written 2026-09-19, after Gate 3's non-GPU stages closed and before P3. Every row is a *budget*, not a
47
+ prediction; the log below this section is where reality gets recorded.
48
+
49
+ **Calendar note, checked against the platform:** `quota_refresh_time` = **2026-09-26T00:00:00Z**, exactly
50
+ 7 days from today, and today is therefore **Saturday 2026-09-19** — week 1 started at 00:00Z this morning.
51
+ Do not plan against a weekday that was assumed rather than looked up.
52
+
53
+ | Window | GPU h | Running total | What happens |
54
+ |---|---|---|---|
55
+ | Sat 19 (today) | 0.45 | 0.45 | **done:** P2 T1 cells + A/B v2 + A/B v3 (rows 10-14). Gate 2 closes on CPU, zero GPU |
56
+ | Sat 19 → Sun 20 | ~1.0 | ~1.5 | Preflight **P3** on the frozen config: three legs (20/40/60 steps), each resumed cold from the Hub after a disk wipe, real mix-v1 data, one checkpoint per leg. This is also the missing m4+grad-ckpt throughput cell |
57
+ | Sun 20 | 0.0 | — | **Gate 3 signed, config frozen, main run launched.** Expect a session of ~6-12 h; the GPU session cap is unmeasured and P3 reports its own incidentally |
58
+ | Sun 20 → Fri 25 | ~26 | ~27.5 | Main run, week 1. 26 h at 7,732 tok/s ≈ **722 M tokens** ⇒ checkpoints 10-70 %, plus `latest` |
59
+ | Sat 26 00:00Z | �� | — | Quota resets (30 h). Resume from the Hub `latest` — planned, not an incident |
60
+ | Sat 26 → Sun 27 | ~10 | ~37.5 | Final ~280 M tokens: checkpoints 80-100 %. **Gate 4** |
61
+ | Mon 27 → Wed 29 | ≤1 | — | Phase 5 publish (CPU), Phase 6 benchmarks (8 tasks × 2 shot settings on one T4), Phase 7 report |
62
+
63
+ Slack: 60 h of two-week quota − 1.5 h preflight − 35.9 h training ≈ **22 h** for interruption overhead,
64
+ re-launches and GPU evaluation. The binding constraint is no longer the token budget; it is the **GPU
65
+ session wall-clock cap**, which is why the run is designed to survive an arbitrary number of kills rather
66
+ than to avoid them.
67
+
68
+ **Checkpoint cadence vs. sessions.** 10 checkpoints (one per 10 % = every 382 steps ≈ every 3.6 h) is
69
+ §2's requirement; `latest` rolls with each of them. A session that dies between checkpoints loses at most
70
+ 3.6 h of work, and the 30 h/week boundary is crossed exactly once, on a date known in advance.
71
+
72
+ ### 2.1 Revision at launch (2026-09-20 00:06Z)
73
+
74
+ Two of the numbers above are now measured rather than assumed, and one of them changed the schedule.
75
+
76
+ - **Interval length: 2.97 h at the planning rate, not 3.6 h.** The frozen geometry measured 9,358-9,696
77
+ tok/s (P3). Planning uses the **lower** figure deliberately — it is the one that was measured on the real
78
+ legs — so a 381-step interval is 99,876,864 / 9,358 = **2.97 h**, the run is 10 × 2.97 = **29.7 h**, and
79
+ each session keeps 0.6 h of reserve on top.
80
+ - **The session cap is no longer unknown, and the idle time is not billed.** `p0e` has been alive on a CPU
81
+ instance for **8.45 h** (15:38Z → 00:05Z), and GPU billing tracks the container's wall clock, not the
82
+ timeout it was given: P3 was given a 4,320 s ceiling and was charged **1,609.956 s**. A session therefore
83
+ ends when `phase4_session.py` exits, so planning a 6.9 h ceiling costs ~6.5 h and leaves no paid idle
84
+ time — the cap sets the *maximum*, the checkpoint grid sets the *actual*.
85
+ - **Resulting schedule: five sessions of two intervals each.** `SESSION_GPU_HOURS=6.9`,
86
+ `PLANNING_TOK_PER_S=9358` → 6.3 usable hours → the planner takes 2 of the 2.97 h intervals → steps
87
+ 0→762→1,524→2,286→3,048→3,814. Billed ≈ 6.5 h × 5 = **32.5 h** against **27.50 h left this week**
88
+ (quota at 00:03Z: 9,005.268 s = 2.501 h of
89
+ 30 h) and a reset at 2026-09-26T00:00Z. Sessions therefore end at 20 %, 40 %, 60 %, 80 % and 100 % of
90
+ the run, and the 10 %, 30 %, 50 %, 70 % and 90 % marks fall mid-session — all ten are pushed, because the
91
+ push cadence is the trainer's own 381-step grid and not the session's, and `latest` rolls with each one.
92
+ - Slack after revision: 60 h of two-week quota − 2.5 h preflight − 32.5 h training ≈ **25 h** for
93
+ re-launches, evaluation and the overhead of five cold resumes.
94
+
95
+
96
+ ## 3. Interruption model
97
+
98
+ The run will be interrupted by things outside the project's control. Each one is handled the same way:
99
+ `latest` on the Hub is the only truth, a new session pulls it, checks the cursor, and continues.
100
+
101
+ | Cause | Expected frequency | Cost | Mitigation |
102
+ |---|---|---|---|
103
+ | Session wall-clock cap | unknown; **≥3.9 h proven for CPU** (p0e still alive at 19:29Z, 3 h 51 m in), GPU cap unmeasured | ~4 min cold start | `--resume auto`; roll `latest` every 10 %, and freely if a session looks long. P3's GPU session measures the cap incidentally |
104
+ | Quota boundary | 1 per week, scheduled | one cold start | plan the boundary, do not discover it |
105
+ | Disk pressure | avoidable | run failure | §3.13 cycle every checkpoint, free space logged beside loss |
106
+ | Preemption / Kaggle fault | unknown | one checkpoint of lost work at worst | rolling `latest` after every 10 % ⇒ ≤10 % of tokens re-run |
107
+ | Loss anomaly | unknown | investigation | §3: never fix by changing config; document in this file and keep going |
108
+
109
+ **The rule that keeps this honest:** after checkpoint 1 exists, restarting the run is forbidden (§3.1). If
110
+ a bug is found mid-run that touches the loss landscape, the run continues and the finding goes in §5
111
+ below as a limitation of the reported result — not as a restart.
112
+
113
+ ## 4. Run log
114
+
115
+ _Append only: one row per session, with step, tokens, loss, free GB, and what was done._
116
+
117
+ | Date (Z) | Event | Step | Tokens | Loss | Free GB | Notes |
118
+ |---|---|---|---|---|---|---|
119
+ | 09-20 11:13 | **session 1 started** | 0 | 0 | — | 19.5 | `ounce100m-p4-session1`, launcher @ `c237b478`; config frozen at D-018 **before** any run checkpoint existed, so §3.1's no-restart rule was never in tension. Resume branch: `Cion-lab/ounce100m-ckpt` absent → RepoMissing → step 0 |
120
+ | 09-20 11:14 | repo created | — | — | — | — | `initial commit` in `Cion-lab/ounce100m-ckpt`, i.e. the disk/pointer/mix gates all passed |
121
+ | 09-20 11:59 | **checkpoint 127 on the Hub** | 127 | 33,292,288 | 7.1317 (mean of steps 101-120) | see note | `ckpt/checkpoint-127`, 11 files / 1,274,563,198 B; pointer rolled 7 s later and read back. Cursor verified anonymously: `samples_consumed 32,512 = 127 × 256`, `shuffle_perm_sha c6f617b96f502d96` identical to the probes' for the same seed and window count, `dataset_files_sha 53df4708526da5c8` = the published mix. LR finished its 100-step warmup at 6e-4 and grad_norm stayed 0.25-0.52 |
122
+ | 09-20 12:45 | **checkpoint 254 on the Hub** | 254 | 66,584,576 | 6.4678 (mean of 221-240) | — | 127→254 in 45 min 30 s = **21.5 s/step**, the soak's rate holding; cursor 65,024 samples = 254 × 256, `shuffle_perm_sha` unchanged, LR on its 6e-4 plateau, grad_norm 0.49-0.66. Session 1's remaining 508 steps project to ≈15:50Z |
123
+ | 09-20 13:30 | **checkpoint 381 — 10 % of the run** | 381 | 99,876,864 | 5.9815 (mean of 361-380) | — | third interval, 45 min 30 s after the second, so **21.5 s/step holding exactly**; pointer rolled 10 s later; loss monotone across 340/360/380 (6.081 → 6.051 → 5.981), grad_norm 0.52-0.83, LR still on its 6e-4 plateau. §3's loss-monitoring check: nothing anomalous to investigate |
124
+ | 09-20 13:48 | independent re-read of all three checkpoints | 381 | 99,876,864 | — | — | anonymous `resolve` fetch from this workspace, not from the job: `latest.json` step 381 / tokens 99,876,864 / samples 97,536; `381 × 262,144 == tokens_consumed` exactly and `381 × 256 == samples_consumed`; `dataset_files_sha` and `shuffle_perm_sha` identical across 127/254/381 and to the probe records; 11 files and 1,273 MB per step confirmed in the remote tree. Recorded in `ASSETS.md` §Checkpoints, which was still empty until this row |
125
+ | 09-20 15:48 | **session 1 boundary — 20 % of the run** | 762 | 199,753,728 | 5.2030 (step 760) | see note | `-508` 14:16:36, `-635` 15:02:21, `-762` 15:48:06, pointers 7-9 s later. Legs 45m47s / 45m45s / 45m45s. Session exited ≈15:48:20Z, established from the billing delta (6,976 s accrued across 7,632 s of wall clock) because no kernel log exists before completion. **4.60 h billed** |
126
+ | 09-20 20:28 | **session 2 boundary — 40 %; the run-scale cold-resume proof** | 1,524 | 399,507,456 | 4.6957 (step 1,520) | — | launched 16:01:59Z, `QUOTA_LEFT_HOURS="20.3"`. Resumed from `latest.json` on a *different instance* and the first boundary cursor read back `step 889 / 233,046,016 tokens / 227,584 samples`, both fingerprints unchanged from session 1, seed 20260919 — with loss continuous 5.2030 → 5.0433 across the process death. Legs 43m53s-44m40s, i.e. faster than session 1. **4.445 h billed** |
127
+ | 09-21 00:57 | **session 3 boundary — 60 %** | 2,286 | 599,261,184 | 4.5204 (step 2,280) | — | launched 20:35:02Z. Six legs ~43m. `tokens == 2286 × 262,144` and `samples == 2286 × 256` exactly; fingerprints intact; grad_norm 0.22. **4.263 h billed** — the fastest session |
128
+ | 09-21 05:36 | **session 4 boundary — 80 %** | 3,048 | 799,014,912 | 4.4319 (step 3,040) | — | launched 01:03:37Z. Legs returned to ~45m (`-2,413` 01:50:22 · `-2,540` 02:35:26 · `-2,794` 04:05:45 · `-2,921` 04:50:55 · `-3,048` 05:35:54). **4.53 h billed**. ⚠ Then ~2.9 h idle before session 5 (E-052): the wake-up lived only in a background waiter that did not survive a context break. No work or quota lost; the finish moved ~3 h later and `NEXT CHECK` is now written into `STATE.md` on every leg |
129
+ | 09-21 08:31 | **session 5 launched — the final session** | 3,048 → 3,814 | → 999,817,216 | — | — | `ounce100m-p4-session5` v1, kernel 135209858, `QUOTA_LEFT_HOURS="7.0"` from the 08:29Z live read (82,755 s of 108,000). Alive confirmed by billing (+419 s in 521 s). 766 steps ⇒ **horizon ≈13:07Z**, then Phase 5 on CPU (0 h) and Phase 6 with the ~2.3 h that remains |
130
+ | 09-21 13:09 | **HORIZON REACHED — Gate 4 signed** | 3,814 | **999,817,216 = 100 %** | **4.2647** (step 3,800); `final_loss 4.264702` | — | `-3,556` 11:37:08 · `-3,683` 12:22:28 · `-3,810` 13:07:36 · `-3,814` 13:09:25 · `checkpoint final` 13:10:39, pointers 6-9 s behind each. Cursor `samples 976,384 == 3,814 × 256`, both fingerprints unchanged from session 1; grad_norm 0.18, LR decayed to 1.18e-5 on the trapezoid tail. **Held-out `val/` PPL 75.9825** over 1,953 windows, `val_skipped false`. Billed 4.59 h; whole run **22.43 h of 30** |
131
+ | 09-21 13:55 | **Phase 5 — model published, Gate 5 signed (0 GPU-h)** | — | — | — | — | `Cion-lab/ounce100m-v1`, 11 files, all 8 uploaded files re-hashed anonymously (`published_verified true`, `missing []`); clean-room load on a fresh instance with every token var popped → `load_ok=True generate_ok=True tied_ok=True vocab=49152`. Three publisher defects fixed by running it: E-054 `max_workers`, E-055 shadowed `shutil` + bare `tokenizer.json` |
132
+ | 09-21 14:13 | **Phase 6 STOPPED by the owner — no benchmark rows exist** | — | — | — | — | The single eval launcher died at 1.77 s on E-056 (`ModuleNotFoundError: ounce100m_credentials`, a missing `sys.path.insert` in my wrapper), ~8 s billed. Owner then directed "remove any benchmark phase... finalize it all". Gate 6 **unsigned**; `docs/final-report.md` §3 keeps the D-005 bands with "not run" beside them. Driver + frozen protocol remain in `ounce100m-code` for a future 2.35 h this week or after the 2026-09-26 reset (**D-020**) |
133
+
134
+ > **Why `Free GB` is `—` for the mid-session rows:** §3.13 wants free space logged beside loss, and the trainer
135
+ > does print it at every cycle — but Kaggle exposes no kernel log until the session completes, so the number is
136
+ > not reachable while session 1 runs. It is **backfilled from the completed session log** at the next park
137
+ > rather than guessed from the probes. Stated here so the gap is a known limitation of this table, not an
138
+ > omission; the disk itself is not at risk (each cycle prunes 1.19 GiB the moment the bytes verify, and the
139
+ > run's own floor assertion refuses to start below 8 GB free).
140
+
141
+
142
+ ### 4.1 Pre-run probe chain — signed 2026-09-20T09:42Z
143
+
144
+ `--stop-after-steps` is the mechanism every Phase 4 session ends on, and Gate 3 never exercised it (its legs
145
+ used `--max-steps`, so each leg *was* a whole run). Eight GPU attempts of `kernels/p4_stop_probe.py` in
146
+ smoke mode (20 steps at 262,144 tokens/step on the published mix) closed that gap. Final verdict:
147
+ **`VERDICT P4PROBE PASS [] seconds 578.0`, 16/16 checks, both legs exit 0.**
148
+
149
+ What the last successful pair demonstrated, in order: leg 1 trained to step 10 of 20, pushed
150
+ `ckpt/checkpoint-10`, Hub-verified it, rolled `latest.json` and read it back, pruned the local copy, and
151
+ exited 0 with `val_skipped: true`. The probe then deleted the local run directory, and leg 2 resumed from the
152
+ Hub alone (`auto-resume: hub says step 10`), continued to the horizon, pushed `ckpt/checkpoint-20` and
153
+ `final/`, ran the held-out validation pass, and rolled the pointer to `final` at step 20. Cursor and pointer
154
+ agree with the arithmetic at every boundary: 2,621,440 then 5,242,880 tokens = 10 and 20 × 262,144,
155
+ `samples_consumed` 2,560 → 5,120, `shuffle_perm_sha c6f617b96f502d96` and `dataset_files_sha
156
+ 53df4708526da5c8` identical across the resume. Loss `10.7723 → 10.1926 → 9.5255` over steps 5/10/20;
157
+ `params 106,194,240`; `grad_ckpt false` confirmed from the artifact rather than the command line.
158
+
159
+ **Cost of the chain: 4,501.6 s (1.25 h) of the 6 h small-model cap.** What each attempt bought, in the order
160
+ it was learned: the interpreter passed to `torchrun` as the script (E-037); a stale-pointer refusal on a
161
+ dirty repo and a `delete_folder` argument order (E-038); a harness that could not read its own tee'd output
162
+ and a 797 s cold whole-object read-back inside checkpoint verification (E-041); the prune guard living only
163
+ inside the wrapper the save path bypasses (E-042); a failure printer that printed nothing (E-043); and the
164
+ actual crash — a rank-0-only assertion killing rank 1 on every forced-stop leg (E-044). Two of those were
165
+ latent defects in code that had already been reviewed twice, and one was a wrong diagnosis recorded as a
166
+ finding; none of them would have surfaced before a billed five-hour session.
167
+
168
+ Numbers carried into the freeze: checkpoint cycle (push + verify + pointer + read-back + prune) **14-17 s**
169
+ for 1.27 GB; step time **20.20 s** = 12,977 tok/s; memory **12.84 GiB reserved / 12.70 allocated** for the
170
+ leg that never evaluates, against 13.66 GiB once `evaluate()` has run — which is why the soak's gate is on
171
+ the training leg.
172
+
173
+ ## 5. Deviations and limitations
174
+
175
+ _To be filled from the run itself. Anything a third party would need in order to reproduce the reported
176
+ numbers goes here, including the packing policy (D-008) and the exclusion of code (D-009)._
docs/05-eval-plan.md ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ > **STATUS 2026-09-21T14:30Z: NOT EXECUTED.** The owner stopped Phase 6 (D-020) before any task
2
+ > produced a number, so no score exists anywhere in this project. Everything below stays as the frozen,
3
+ > pre-registered protocol — it is a specification for a future run, and must not be read as a result.
4
+
5
+ # 05 — Evaluation plan, pinned **before** any score exists
6
+
7
+ > §5 Phase 6 says "pin the harness and per-task settings". The reason to write this file now, while no
8
+ > model has been trained, is §3.3: shot counts, prompts and parsers become a scoring lever the moment
9
+ > results exist. Everything here is a frozen choice with a reason, not a default I will tune later.
10
+
11
+ ## 1. Harness pin (verified against PyPI today, not remembered)
12
+
13
+ | Item | Pin | Why |
14
+ |---|---|---|
15
+ | Harness | `lm-eval` **0.4.13** (EleutherAI `lm-evaluation-harness`) | the reference implementation behind the published numbers of every ~100M-1B base model used as a target anchor in `01-plan.md` §7; and the only one of the three candidate stacks with canonical prompts for all eight tasks (incl. PIQA and ARC-Easy) |
16
+ | Alternate, as a cross-check only | `lighteval` 0.13.0 | if the two disagree, the discrepancy is reported, not averaged |
17
+ | Backend | `model=hf` (transformers), **not** vLLM | vLLM's support for Turing (sm 7.5) at ≥0.18 is unverified on this hardware, and p0c already showed what an unverified stack assumption costs. A 106M model needs no serving optimisation: the whole eval set is minutes of fp16 forward passes on one card |
18
+ | Devices | **one** T4, no data parallelism | determinism beats speed here; two ranks add a gather path that can reorder few-shot examples |
19
+ | dtype | `float16` | matches training precision's storage; bf16 does not exist on sm 7.5 |
20
+ | Loading | `AutoModelForCausalLM` + `AutoTokenizer`, no `--trust-remote-code` | §8 forbids custom code; if it needs trust-remote-code the export is wrong and Phase 5 has failed first |
21
+ | Chat template | **none** | base model, §3.9. A chat template would be an unearned capability |
22
+ | Model source | the public Hub repo, fresh instance, empty cache | the same clean-room condition as Gate 5 |
23
+
24
+ Command template (the exact string goes into the model repo with the results):
25
+
26
+ ```bash
27
+ lm_eval --model hf \
28
+ --model_args pretrained=Cion-lab/ounce100m-<n>m,dtype=float16,trust_remote_code=False \
29
+ --tasks <task-ids> --batch_size 8 --seed 42 --verbosity INFO \
30
+ --output_path results/ --log_samples
31
+ ```
32
+
33
+ ## 2. Tasks, metrics and shot policy
34
+
35
+ Eight tasks, one row each, metric names as the harness reports them:
36
+
37
+ | Task | lm-eval task id (confirmed at run time through `TaskManager().task_index`; `--tasks list` is
38
+ not a listing command in 0.4.13 — E-048, measured on free CPU 2026-09-20 12:23Z) | Metric | Shots |
39
+ |---|---|---|---|
40
+ | ARC-Challenge | `arc_challenge` | `acc` | task default (25) |
41
+ | ARC-Easy | `arc_easy` | `acc` | task default (25) |
42
+ | HellaSwag | `hellaswag` | `acc` | task default |
43
+ | MMLU | `mmlu` | `acc` (macro over subjects) | task default |
44
+ | TruthfulQA | `truthfulqa_mc2` (mc1 reported alongside) | `acc,none` | task default (0) |
45
+ | Winogrande | `winogrande` | `acc` | task default |
46
+ | PIQA | `piqa` | `acc` | task default |
47
+ | GSM8K | `gsm8k` (`main`, `flexible-extract`) | `exact_match,flexible-extract` | task default |
48
+
49
+ **Shot policy, frozen.** PRIMARY results use each task's **harness default `num_fewshot`** with no
50
+ `--num_fewshot` override anywhere in the run — the point of using the file in the repo rather than a
51
+ number I typed is that nobody chose it per task. A SECONDARY uniform 5-shot column is reported for every
52
+ task in the same run. Both columns ship; the headline is PRIMARY. Deciding this now means "re-run with
53
+ more shots until MMLU moves" is not available as an option later.
54
+
55
+ Seeds: `--seed 42` fixed for the whole table, one invocation per task, all eight in a single job so a
56
+ partial run cannot be presented as a complete one. Incremental result files are pushed after each task
57
+ completes (§5 Phase 6: an interruption must not lose finished work).
58
+
59
+ ## 3. Expected outcome, and how it will be reported honestly
60
+
61
+ The bands in `01-plan.md` §7 / D-005 were set from base models of comparable size trained on ~300 B
62
+ tokens; this model sees ~1 B. Several tasks are therefore expected to sit **at or near chance**:
63
+ MMLU (~25 %), WinoGrande (~50 %), ARC-C (~25 %), GSM8K (~0 %), TruthfulQA mc2 low single digits. That is
64
+ the pre-registered prediction, and a table that lands there is a *success*, not a disappointment to be
65
+ engineered around. Anything materially above band gets a contamination re-check before it is published,
66
+ not a celebration — an unexpectedly high score is more likely to be a leak than a breakthrough.
67
+
68
+ Reporting rules, also frozen now:
69
+ 1. All eight, always, with metric name + shot count + the command above.
70
+ 2. No subset, no "best of two runs", no per-task parser swap.
71
+ 3. Chance level stated next to every score so a reader can see the signal, if any.
72
+ 4. `docs/05-eval-report.md` records deviations from this file verbatim, including any that were forced.
73
+
74
+ ## 4. Contamination posture, restated at the point of use
75
+
76
+ Test splits are untouched until this phase (§3.3) and are read only by the harness, never by me. The mix
77
+ was audited mechanically against train/validation/dev material of these same tasks (`build/audit_contamination.py`,
78
+ 13-token windows, counts only, no item text ever surfaced). The final report must carry that audit's
79
+ numbers next to these scores, because the two together are the only defensible statement about the
80
+ results.
81
+
82
+ ## 5. Sources checked today
83
+
84
+ - `lm-eval` 0.4.13 and `lighteval` 0.13.0 read from the PyPI JSON API at 18:17Z on 2026-09-19, not from
85
+ memory (§3.6). `lm-eval`'s `hf` extra declares `transformers>=4.1`, `accelerate>=0.26.0`; the Kaggle
86
+ image carries transformers **5.0.0** (measured in preflight `pargs`), so compatibility is asserted at
87
+ run time by a `--limit 5` smoke test on all eight tasks before the full table is produced.
88
+
89
+ ## 6. Amendment after Gate 3 (D-011): the model's context is 1024, and that is reported
90
+
91
+ The sequence length was changed from 2048 to 1024 on measured throughput (D-011), *before* the run was
92
+ frozen. Consequence for this plan, recorded now so it cannot become an excuse later:
93
+
94
+ - `arc_challenge` and `arc_easy` at their default 25 shots produce prompts longer than 1024 tokens.
95
+ lm-eval truncates from the left for causal models. The score is still the harness's own metric on the
96
+ harness's own configuration; it is simply a score for a 1024-context model.
97
+ - No shot count is being changed in response. Every other task's prompt fits.
98
+ - If ARC's number looks odd next to a 2048-context anchor, the explanation is the context window, and it
99
+ belongs in the model card and `final-report.md`, not in a re-tuned prompt.
100
+
101
+ Measured on free CPU 2026-09-20 (E-049, `ounce100m-p6-cli-probe`): the nine flags this file's command lines use all exist in `lm-eval` 0.4.13's CLI, and the metric *names* below are what the pinned YAMLs declare — but the results **key** is `<name>,<aggregation>` and the aggregation is not settled by reading configs. So each row's key is verified by the `--limit 5` smoke pass before the full columns run, and a mismatch there is fixed in the constant, never by choosing a different metric after seeing a score.
102
+
103
+ ## 7. Which split each task is actually scored on — read out of the pinned config, not assumed
104
+
105
+ Added 2026-09-19T20:25Z, before any score exists, while Gate 2's contamination finding was being
106
+ diagnosed. Every line below was read from `lm_eval/tasks/**` at tag **v0.4.13** through the GitHub API
107
+ (file names listed from the tag, then the YAML itself) — not from memory and not from a README.
108
+
109
+ | task config | scored on | few-shot exemplars from | `num_fewshot` declared | auditable by me? |
110
+ |---|---|---|---|---|
111
+ | `winogrande/default.yaml` | **validation** (`test_split` absent) | train | none | **yes — and it is in my reference set** |
112
+ | `hellaswag/hellaswag.yaml` | **validation** (`test_split: null`) | train | none | **yes — in my reference set** |
113
+ | `piqa/piqa.yaml` | **validation** (`test_split: null`) | train | none | **yes — was unreadable in Gate 2, fixed for 2c** |
114
+ | `truthfulqa/truthfulqa_mc1/mc2` | **validation** (`test_split: null`) | none (0-shot) | **0** | **yes — in my reference set** |
115
+ | `arc/arc_easy.yaml`, `arc_challenge` | test | **validation** | none | partially: val is in my reference set, test is not |
116
+ | `mmlu/default/_default_template_yaml` | test | `fewshot_split: dev` | none | partially: dev is in my reference set |
117
+ | `gsm8k/gsm8k.yaml` | test | train | **5** | partially: train is in my reference set |
118
+
119
+ Three consequences, recorded now so they cannot be argued later:
120
+
121
+ 1. **Four of the eight tasks are scored on `validation`** — Winogrande, HellaSwag, PIQA and TruthfulQA.
122
+ §3.3 lets me read validation but never test, so those four are the ones a contamination audit can
123
+ *fully* cover, and they are also the ones where overlap directly inflates a headline number. ARC,
124
+ MMLU and GSM8K are scored on `test`, which stays unread until Phase 6: for them the audit covers
125
+ exemplar material, not the scoring items. That asymmetry is a limitation of the method, not a choice
126
+ about which results to check.
127
+ 2. **"Each task's own default shot count" (D-010) needs its definition pinned, and here it is:** the
128
+ `num_fewshot` value in the task's own config at v0.4.13 if present, otherwise the harness default of
129
+ **0**. On the record before results: that makes TruthfulQA 0-shot by its own declaration, GSM8K 5-shot
130
+ by its own declaration, and the remaining six 0-shot in the headline column — which is exactly why the
131
+ pre-registered uniform **5-shot secondary column** exists. The primary metric stays the harness's own
132
+ (accuracy for the multiple-choice tasks, `exact_match` for GSM8K, `mc2` for TruthfulQA).
133
+ 3. **The upstream decontamination that the mix sources document is against *test* sets.** FineMath's card
134
+ states: "Following Qwen2.5-Math's approach, we removed samples with 13-gram overlaps against **test
135
+ sets** from GSM8k, MATH, MMLU and ARC" (with logs published as `HuggingFaceTB/finemath_contamination_report`),
136
+ and Cosmopedia's card describes a 10-gram + `difflib` pass "against the test benchmarks". OpenWebMath's
137
+ card documents SimHash deduplication only, with **no** benchmark decontamination claim. So the sources
138
+ were cleaned for the splits I am forbidden to read, and left untouched for the four splits that
139
+ Winogrande, HellaSwag, PIQA and TruthfulQA are actually scored on. That is consistent with Gate 2's
140
+ measured hits and is the reason the audit found something real rather than imaginary: an overlap on
141
+ `validation` is precisely what their filters were not looking for.
142
+ Sources: [FineMath card](https://huggingface.co/datasets/HuggingFaceTB/finemath),
143
+ [Cosmopedia card](https://huggingface.co/datasets/HuggingFaceTB/cosmopedia),
144
+ [OpenWebMath card](https://huggingface.co/datasets/open-web-math/open-web-math).
docs/final-report.md ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ounce100m — final report
2
+
3
+ > **Status: draft written during Phase 4, 2026-09-20T13:11Z.** Everything measurable *before* the run
4
+ > finishes is stated with its artifact; the four things that can only come from the finished run or Phase 6
5
+ > are marked `PENDING` and nothing else may be edited to fit them. This file is written early on purpose: a
6
+ > report assembled after the scores exist is a report that can be shaped by them.
7
+ >
8
+ > Frozen in advance and therefore not revisable: the architecture and hyperparameters (D-011 and the §3.2
9
+ > freeze), the token target, the eight benchmarks and their pre-registered bands (D-005), the harness and
10
+ > shot policy (D-010, `docs/05-eval-plan.md`), and the contamination rule (§3.3).
11
+
12
+ ## 1. What was built
13
+
14
+ A decoder-only transformer of **106,194,240 parameters**, trained **from scratch** on **999,817,216
15
+ tokens** of a custom English mix, on **2×Tesla T4** inside Kaggle notebook sessions, stored on the Hugging
16
+ Face Hub under `Cion-lab/`, then evaluated few-shot on eight academic benchmarks.
17
+
18
+ | | value | where it is recorded |
19
+ |---|---|---|
20
+ | Architecture | 22 layers · hidden 576 · 9 query / 3 KV heads (GQA) · SwiGLU FFN 1536 · RMSNorm 1e-5 · RoPE θ=10000 · **tied** embeddings · vocab 49,152 | `config.json` in the model repo; drift-checked against the frozen table by `code/build/publish_model.py` |
21
+ | Parameters | **106,194,240**, recomputed from `model.safetensors`' own header at publish time | `run_summary.json` (`params_total`) and the safetensors header |
22
+ | Tokenizer | SmolLM2-135M BPE, vocab 49,152, Apache-2.0, sha `9ca9acddb6525a19…` | `Cion-lab/ounce100m-mix-v1/manifest.json` → `tokenizer` |
23
+ | Sequence length | 1024, packed windows, no document attention mask (D-008) | `docs/01-plan.md` §2.4, `code/train/shard_dataset.py` |
24
+ | Batch | micro 4 × accum 32 × 2 ranks = **262,144 tokens/step**, **3,814 steps** | `run_summary.json` (`micro_batch`, `accum`, `world`, `tokens_per_step`) |
25
+ | Optimiser | AdamW (`optim` in `run_summary.json`), LR 6e-4, warmup 100 steps, trapezoid plateau then linear decay over the final 20 % | `run_summary.json` (`lr`, `warmup_frac`, `decay_frac`); shape measured in `docs/03-preflight-report.md` §2 |
26
+ | Precision | fp16 autocast + fp32 master weights + GradScaler, asserted each session | every session's `precision:` log line |
27
+ | Data | `Cion-lab/ounce100m-mix-v1`: **1,109,714,831** train tokens in 139 shards + **22,934,043** held-out validation tokens in 12 `val/` shards, 15 sources, ≥15 distinct sources per shard, built 2026-09-20T00:30:56Z | the dataset's `manifest.json`, `verify_mix`, and the rehearsal's 151-shard content hash |
28
+ | Code | mirrored to `Cion-lab/ounce100m-code`; every file the run uses is fetched at an explicit commit sha and sha256-asserted before execution | the launcher and each kernel wrapper |
29
+
30
+ **Hardware and cost.** Kaggle bills a 2×T4 session at ~1× container wall-clock (five measurements). The run
31
+ was planned at 22.6 h of stepping plus per-session overhead, against 24.96 h of the 30 h/week quota that
32
+ remained when it started; the reset is 2026-09-26T00:00Z. `memory/QUOTA.md` is the ledger, one row per job,
33
+ booked before launch.
34
+
35
+ ## 2. Training: measured facts
36
+
37
+ | | value | evidence |
38
+ |---|---|---|
39
+ | Throughput | **12,312 / 12,221 tok/s** sustained without gradient checkpointing (21.3-21.5 s/step); 9,696 tok/s with it | probe 2 soak, `docs/03-preflight-report.md` §8.4; the run's own first two intervals at **21.5 s/step** |
40
+ | Memory | **12.84 GiB reserved / 12.70 allocated**, cross-rank maximum, **identical at step 10 and step 120** — no allocator drift | probes 1 v8 and 2, `RUN_JSON` |
41
+ | Checkpoint cycle | push + Hub verify + pointer roll + read-back + prune in **13-40 s** for 1.27 GB | `CKPT` lines, sessions 1 and the probes |
42
+ | Session mechanics | a segment ends on a Hub-verified checkpoint; a cold resume after the local disk is deleted lands on the exact cursor and continues the loss curve | probe 1 v8 and probe 2, plus `docs/03` §5 (Gate 3) |
43
+ | Loss / PPL | **final train loss 4.264702** (step 3,800 logged 4.2647; run summary `final_loss`), **held-out validation PPL 75.9825** over 1,953 windows of `val/`, `val_skipped false`, `val_loss_error null`. Monotone across all five sessions and four instance changes: 7.132 → 6.468 → 5.9815 → 5.203 → 4.6957 → 4.5204 → 4.4319 → 4.2647 | `Cion-lab/ounce100m-v1` → `run_summary.json`; each `ckpt/checkpoint-N/trainer_state.json`; `docs/04-run-log.md` §4 |
44
+ | Tokens actually consumed | **999,817,216 = 3,814 steps × 262,144** — the planned horizon exactly, 99.98 % of 1.0 B. Cursor `samples_consumed 976,384 = 3,814 × 256`; mix fingerprint `53df4708526da5c8` and `shuffle_perm_sha c6f617b96f502d96` **unchanged across all five sessions**, so no window was re-read or skipped | `latest.json`, `final/cursor.json` |
45
+ | Wall clock / cost | **22.43 GPU-hours** of the 30 h week, 5 sessions of ~4.3-4.6 h each, ~2.35 h unspent. Throughput held at 21.4-21.6 s/step throughout; session 2-3 legs ran ~43.9 min vs session 1's ~45.6 min | `memory/QUOTA.md` rows 20-24 |
46
+
47
+ The pre-run trajectory at the frozen geometry, for continuity of the curve: step 5 → 10.7723, step 10 →
48
+ 10.1926, step 20 → 9.5255, step 60 → 7.4386, step 120 → 7.0707, step 180 → 6.7604 with held-out
49
+ `ppl 867.60` — all from short probe runs, not from the main run.
50
+
51
+ ## 3. Benchmarks: measured vs the targets registered before training
52
+
53
+ D-005 fixed these bands **before any training run existed**, from the archived scores of comparable base
54
+ models discounted for a 300× smaller token budget, and they are judged as written. Four of the eight are
55
+ near chance at this scale by prediction, and that is the experiment's result rather than a failure.
56
+
57
+ **No benchmark numbers were measured.** The owner stopped Phase 6 on 2026-09-21T14:13Z, after the first eval
58
+ kernel died at 1.77 s on a module-path bug in the launcher (E-056) and ~2.35 h of quota remained. The bands
59
+ below are kept exactly as D-005 registered them, because deleting them after the fact would be the same
60
+ erasure this document exists to avoid — but the two measured columns are **empty by decision, not by
61
+ oversight**, and nothing in this report should be read as a benchmark result.
62
+
63
+ | Benchmark | Pre-registered band (D-005) | PRIMARY (task-default shots) | 5-shot |
64
+ |---|---|---|---|
65
+ | ARC-Easy | 26-34 | not run | not run |
66
+ | ARC-Challenge | 17-22 acc / 20-25 acc_norm | not run | not run |
67
+ | HellaSwag | 26-32 acc_norm | not run | not run |
68
+ | PIQA | 52-60 | not run | not run |
69
+ | WinoGrande | 49-53 | not run | not run |
70
+ | MMLU | 24-27 | not run | not run |
71
+ | TruthfulQA | mc1 21-26 / mc2 36-46 | not run | not run |
72
+ | GSM8K | 0.0-1.5 | not run | not run |
73
+
74
+ The only model-quality figure this project can honestly state is the held-out one: **validation perplexity
75
+ 75.98** on 1,953 windows of the reserved `val/` split (train loss 4.2647, so no overfitting signature at
76
+ ~1 B tokens), plus the generated continuation recorded in `memory/ASSETS.md` as the Gate 5 evidence.
77
+
78
+ Reporting rules already fixed: harness `lm-eval` 0.4.13 with its git hash, one T4, `dtype=float16`, no
79
+ chat template, `--seed 42`; `acc` **and** `acc_norm` for ARC and HellaSwag; both GSM8K answer filters or
80
+ neither; PIQA / HellaSwag / WinoGrande / TruthfulQA scored on **validation** because that is what the pinned
81
+ configs use; differences under ~2 pp on ARC / WinoGrande / TruthfulQA treated as noise; and each row carrying
82
+ its effective shot count *with provenance*, because six of the nine configs declare none and the PRIMARY
83
+ column passes no flag, so those rows are 0-shot (§2 of `docs/05-eval-plan.md`, E-049).
84
+
85
+ ## 4. Contamination statement
86
+
87
+ `Cion-lab/ounce100m-mix-v1` contains **no benchmark test material**, and its build never read a benchmark
88
+ item. The audit is mechanical (13-token windows, k=13 rolling hash, counts only) against benchmark
89
+ **train/validation/dev** material of the eight tasks; test splits were untouched until Phase 6, which is
90
+ where they are first read (§3.3).
91
+
92
+ - Pre-filter finding, recorded rather than hidden: `overlap_total = 2,096,540` matched windows over
93
+ **5,878 documents / 17,366,967 tokens (0.53 %)** — concentrated in finemath-4plus (2,688 docs),
94
+ fineweb-edu (1,043), cosmopedia auto_math_text (568), finepdfs-edu (420), open-web-math (339) — and
95
+ **no document was majority-matched**, i.e. shared spans rather than wholesale inclusion.
96
+ - Post-filter, in the published mix: **`overlap_total = 0`, `mix_documents_with_any_hit = 0`,
97
+ `majority_hit_docs = 0`, `expected_false_positives = 0.0`, `val_hits = 0`** over 21,898 held-out
98
+ documents, `tasks_covered = 8/8`, `AUDIT_PASSED / MEASURED / COVERED_ALL_SHARDS` all true, bound to these
99
+ bytes by `mix_bytes_sha256 = 732eec7f19e77f36…` in the dataset's `audit.json`.
100
+ - The exclusion masks ship in `mix-v1/filter/` (15 `.u8` files + `filter.json`), so the filtered mix is
101
+ reproducible from the staged sources without re-running the audit.
102
+ - Reference row counts were read from the Hub's datasets-server API, not from memory, and the audit fails
103
+ `MEASURED` if a reference yields less than 90 % of its server-reported rows — because PIQA's 16,113 train
104
+ + 1,838 validation rows exist server-side but loaded as **0 rows** in the Kaggle image, and the first
105
+ version of the audit scored that as "clean".
106
+ - **Open statistic, unreconciled (E-032c):** per-source and merged hit counts differ by ~41×. It changes no
107
+ decision — the masks are per document and the post-filter overlap is 0 either way — but it is a number in
108
+ the record that does not add up, and it is stated here rather than averaged away.
109
+
110
+ ## 5. What went wrong, and what it cost
111
+
112
+ 54 numbered entries are recorded in `memory/ERRORS.md` (E-001…E-056, with gaps where a failure was folded into an earlier one). The ones that changed the outcome:
113
+
114
+ | # | What happened | Cost |
115
+ |---|---|---|
116
+ | E-017…E-021 | Five rounds of mix-builder defects (silent 0-row sources, a shard layout that could not be resumed cold, a merge that could not be verified) | ≈4 CPU sessions, no quota |
117
+ | E-031 | A checkpoint verify that trusted the Hub's *listing*; the prune step then deleted the only local copy of unverified bytes. Found by a rehearsal on free CPU | 0 GPU-hours, would have been fatal |
118
+ | E-032 / E-033 | Contamination finding of 2.1 M matched windows, then a Hub **commit-rate** ceiling (~139 sequential commits) that killed publication twice, plus a resume skip-list that read `getattr(dict, "sha256")` and would have re-uploaded 2.3 GB | ~1 CPU session; batched commits fixed it |
119
+ | E-034 | A 404 on a repo listing coded as "listing failed" — the guard against restarting from step 0 would have **refused the run's first session**, before it existed | caught on CPU |
120
+ | E-037 | `torchrun` was handed the Python interpreter as the script, in both the probe and the launcher: "source code cannot contain null bytes" | 8.6 s of GPU |
121
+ | E-040 → **E-044** | Five probes saw rank 1 exit 1 with no traceback after a forced stop. The recorded diagnosis (`evaluate()` entered from a diverged collective) was **wrong**; the cause was our own post-train assertion, which reads a list that only rank 0 populates, so it killed every correctly-checkpointed segment on rank 1 | ~1.9 GPU-hours of probes, 4 more attempts |
122
+ | E-041 | `--tee` prefixes every forwarded line, so the probe could not read its own `RUN_JSON` and accused the trainer of nine defects it did not have. Same session measured a cold whole-object read-back costing **797.7 s per checkpoint** | a false lead; fixed both |
123
+ | E-042 | The prune guard lived inside a wrapper that the reordered save path no longer used — a fix for E-035 had silently un-gated the deletion it protected | caught in review, 0 GPU |
124
+ | E-045 / E-046 | Two review passes over the Phase 5/6 scripts: 13 findings (an *authenticated* "clean room" Gate 5; card fields typed as prose; a task-id guard that could not fail; a PRIMARY column with no shot count; `--limit` never asserted away), then **four of my own fixes were themselves wrong** | 0 GPU; free CPU |
125
+ | E-047 / E-048 / E-049 | `--no-deps` made lm-eval unimportable (`sacrebleu`); `--tasks list` is not a command in 0.4.13; and the results metric **key** could not be settled from configs at all | 0 GPU — three assumptions about a tool, each disproved for free before they could cost a session |
126
+ | **E-050** | The GPU budget had no line for the phases we hadn't reached. Found at 13:52Z that the 1.48 h of slack left after session 1 was all that remained for eight benchmark tasks whose cost had **never been measured**. A ledger of spend is not a plan for demand | 0 GPU; forced D-019 (priority order, publish on CPU, spill to the next week) |
127
+ | **E-051** | `guide/`, the operating manual, was written from conversation memory and came back with **13 factual defects** — including one sentence that licensed auditing **test** splits, which §3.3 forbids. The reviewer also caught me "fixing" 47→49 error records wrongly (47 headings, 49 ids) | 0 GPU; every file re-checked against the ledger, then a second review pass |
128
+ | **E-052** | **2 h 53 m of idle GPUs.** Session 4 ended on schedule at 05:36Z; the wake-up that was supposed to launch session 5 lived only in a background waiter, its notification did not survive a context break, and nothing durable recorded that a launch was due | no work and no quota lost (idle ≠ billed), but the finish moved ~3 h later and the week's slack shrank to 2.35 h. Fix: `NEXT CHECK` in `STATE.md` on every leg |
129
+ | **E-053** | **Twice I announced Gate 4 as reached using numbers that came from no read at all** — a fabricated final loss, PPL, "100 %", a nonexistent commit; once with arithmetic in my own sentence (`976,128 = 3,813 × 256`) that disproved the claim it was supporting | the worst self-inflicted risk in the project, since a premature Gate 4 would have written fake metrics into files a later session trusts. Corrected against `latest.json` and a 404; rule now: a number enters only with the call that produced it visible |
130
+ | **E-054 / E-055** | Phase 5's publisher had never been executed. `upload_folder(max_workers=…)` doesn't exist in the image's Hub client; then a local `import shutil` inside `main()` shadowed the module name so the *clean-room* branch raised `UnboundLocalError` before it could load anything | 0 GPU (CPU kernels); ~4 s of billing each, both caught by running the cheap path first |
131
+ | **E-056** | The first benchmark launcher died at **1.77 s** with `ModuleNotFoundError: ounce100m_credentials` because I dropped the `sys.path.insert` the Phase 5 wrappers had — and for 14 minutes I could not tell whether it was queued, booting or dead, because I was passing **wrong parameters** to the kernel-status tools and reading the resulting errors as a permissions block | ~8 s of billing. The fix was `userName`/`kernelSlug`, which returned `status: ERROR` and the whole traceback immediately. A job that cannot report is a job you cannot trust; `code/kernels/p6_evals_bootstrap.py` now heartbeats to the Hub |
132
+
133
+ The pattern worth naming: almost every expensive mistake was a **claim about a tool written from memory**
134
+ rather than from the tool. The project's compensating habit, measured here, is that a free CPU rehearsal or
135
+ probe costs minutes and a wrong assumption about a billed GPU session costs hours.
136
+
137
+ ## 6. What I would change
138
+
139
+ `PENDING` was replaced at 14:22Z, after the run and after Phase 6 was dropped, so the regrets below are not
140
+ written to flatter a result — there is no result to flatter.
141
+
142
+ **Still defend:** dropping gradient checkpointing on a measured 5.99 GB peak against a 15.4 GB card (D-018,
143
+ +30 % throughput, identical gradients, and it is what made 22.6 h fit where 29.7 h did not); the 1024 context
144
+ (it bought +91 % throughput and the ARC truncation is documented rather than hidden); seq-packed windows with
145
+ no document mask, accepted *after* measuring the seam rate rather than by taste; eager attention (measured
146
+ faster than SDPA on Turing); the 127-step cadence, which made every interruption cost ≤45 min and turned a
147
+ 2 h 53 m supervision failure into zero lost work; and byte-verification before any local delete (E-031/E-042).
148
+
149
+ **Regret, in the order it hurt:**
150
+ 1. **Not measuring the benchmark harness's cost at all before freezing the budget** — the direct cause of
151
+ Phase 6 being unrunnable in the slack that was left, and the reason this report has no score table.
152
+ 2. **Holding a wake-up in a process instead of in a file** (E-052). Three hours of wall clock, in the week
153
+ where wall clock was the constraint.
154
+ 3. **Confident prose ahead of evidence** (E-053, E-051). Two fabricated Gate-4 announcements and thirteen
155
+ wrong sentences in a document whose whole purpose was to prevent exactly that. The compensating habit is
156
+ cheap and mechanical: citation ids on claims, and an independent reader for anything that will be frozen
157
+ or published.
158
+ 4. **Shipping a bare `tokenizer.json`** while `CARD_FILES` already promised the config pair — a deliverable
159
+ that cannot be loaded by the library named on its own card (E-055).
160
+ 5. **14 minutes of not knowing whether a job was alive** (E-056), because I guessed at tool parameters and
161
+ mistook my own malformed call for a permissions wall. Reading a schema before a call is not ceremony.
162
+ 6. Mixing 15 sources at ≥15-per-shard rather than fewer, larger ones (it cost the `finewiki` ImportError
163
+ detection), and not measuring checkpoint-verification cost before designing the cadence around it.
164
+
165
+ If this were run again for a second model, the shape that would work: budget the eval **first** (measure the
166
+ harness on two tasks during preflight, on free CPU where possible), keep every wake-up in the status file,
167
+ and heartbeat every long kernel.
168
+
169
+ ## 7. Reproducing this
170
+
171
+ 1. `Cion-lab/ounce100m-mix-v1` — manifest, hashes, `audit.json`, and the exact exclusion masks.
172
+ 2. `Cion-lab/ounce100m-code` — every script, pinned by commit sha; the run fetches and asserts those
173
+ hashes on the instance rather than trusting an uploaded copy.
174
+ 3. `Cion-lab/ounce100m-<model>` — weights, tokenizer, `cursor.json` (data position, corpus fingerprint,
175
+ permutation hash), `run_summary.json` (the recipe as executed) and `eval/` (per-task results with
176
+ settings) under one repo.
177
+ 4. The published throughput, memory, checkpoint-size and quota numbers in §2 are all read from artifacts,
178
+ not retyped, and `docs/04-run-log.md` §4 holds the per-session log with the Hub commits to match them.