ukint-vs commited on
Commit
1b9108d
·
verified ·
1 Parent(s): 3b3cb45

Add dataset card

Browse files
Files changed (1) hide show
  1. README.md +24 -149
README.md CHANGED
@@ -1,149 +1,24 @@
1
- # LoopBench
2
-
3
- A length-generalization study of **looped transformers** on algorithmic tasks,
4
- run entirely on a single Apple Silicon machine (M4 Max, PyTorch/MPS). Tiny
5
- decoder-only models (~0.8–3M params) are trained on seeded algorithmic
6
- generators and evaluated for out-of-distribution (OOD) length extrapolation.
7
-
8
- The confirmed R=8 result: **the depth-scaling exponent `p` improves held-out
9
- Dyck-1 length extrapolation without materially changing ID accuracy**. An
10
- independent, predeclared 15-pair replication improved far-OOD exact match from
11
- .403 to .614 (+.211, paired t=2.734, 95% CI [.046, .377]); its class-balanced
12
- sensitivity check also replicated. Addition remains at 0% OOD and parity
13
- returns to chance despite better ID training. The completed five-task R=8 sweep
14
- also finds that p=.5 strongly improves prefix-sum ID trainability (.649→.953;
15
- exploratory paired t=2.816) and removes a copy seed failure, but both tasks stay
16
- at effectively 0% OOD: better optimization is not algorithmic extrapolation.
17
- An exploratory inference-depth probe finds that the Dyck advantage is already
18
- present at R=1 and peaks at R=4, so it does not support a simple mechanism where
19
- `p` merely prevents degradation in later loop iterations.
20
-
21
- ## Method in one screen
22
-
23
- - **Model** (`loopbench/model.py`): decoder-only, RMSNorm, RoPE (base 10000),
24
- SwiGLU. Two block styles:
25
- - `preln` — standard pre-norm residual block (the control).
26
- - `loopdeepnorm` — [DeepLoop's](https://arxiv.org/abs/2607.13491) hybrid
27
- sandwich, `α = (2N)^p` on the residual, `β = (8N)^(−p)` applied once at
28
- init to the output projections, `N = K · R_ref`. `p = 0` ⇒ `α = β = 1`
29
- (unscaled).
30
- - **Loop**: `K` physical blocks applied `R` times; optional Bansal-style input
31
- injection (`recall = add`). Truncated backprop keeps grad for the last
32
- `backprop_window = 8` iterations. This gives full gradient coverage at R=8;
33
- fixed k=8 is **not** comparable at larger R.
34
- - **Schedules** (`loopbench/schedules.py`): `fixed`, `uniform`,
35
- `poisson_lognormal`; `n_ref ∈ {max, mean, per_batch}` sets the `N` behind
36
- `α/β` (research question RQ2).
37
- - **Tasks** (`loopbench/tasks/`): binary addition, parity, copy, Dyck-1,
38
- prefix-sums (mod 7). Pure-Python, seeded, emitting `[runs, batch, seq]`
39
- tensors directly. **Full-answer prediction (FAP)**: the model reads
40
- `<question> EOQ` and predicts the whole `<answer> EOS`; loss is masked to the
41
- answer span; the metric is exact match over that span.
42
-
43
- ## Throughput levers (built in from day one)
44
-
45
- Tiny models on MPS are overhead-bound, so the grid's wall-clock is attacked by:
46
-
47
- 1. **Run-stacking** (`loopbench/stacking.py`) — all seeds of a cell train as one
48
- `vmap`-ed model (`stack_module_state` + `functional_call` + `vmap`). One
49
- process, N runs, ~one run's wall time. bf16 is applied by explicit casting,
50
- not `torch.autocast` (which does not compose under `vmap` on MPS).
51
- Memory-heavy copy/prefix cells use deterministic seed shards `(0,1)`, `(2,3)`,
52
- `(4)` and merge their logs; this changes parallelism, not experiment factors.
53
- 2. **No hidden syncs** — metrics accumulate on-device; host transfer every
54
- `log_every` steps; divergence is a device-side check.
55
- 3. **Truncated backprop** through the loop (in the model).
56
- 4. **Early stopping** with a token ledger.
57
- 5. **On-device pregenerated data** (`loopbench/data.py`) — one pool tensor,
58
- moved to the device once, indexed per step. No DataLoader.
59
-
60
- Per-run divergence is masked out so one diverging seed cannot poison its
61
- stack-mates.
62
-
63
- ## Quickstart
64
-
65
- ```bash
66
- uv sync --frozen
67
- uv run pytest # unit tests (tasks, model, stacking, schedules)
68
-
69
- # Stage 0 bring-up + divergence probe (the gate before the grid)
70
- uv run python scripts/stage0.py
71
-
72
- # A single stacked job
73
- uv run python -m loopbench.train --task addition --seeds 0,1,2,3,4 \
74
- --k-layers 2 --R 8 --recall add --device mps
75
-
76
- # Rebuild the committed Stage-1a summary and hero figure
77
- uv run python scripts/analyze_stage1a.py
78
-
79
- # Rebuild the exploratory Dyck inference-depth probe
80
- uv run python scripts/analyze_iteration_dynamics.py
81
- ```
82
-
83
- Outputs: per-job JSON in `runs/<name>.json` (config, per-seed training curves,
84
- ID/OOD exact-match by eval length × inference-R, per-iteration activation norms,
85
- per-block grad norms, divergence flags, token ledger, tokens/sec) and per-seed
86
- checkpoints in `checkpoints/<name>/seed_<s>.pt` for full reevaluation.
87
- The committed CSV/JSON/SVG evidence can be regenerated without the raw training
88
- runs. Full reevaluation requires the separately distributed checkpoint bundle.
89
-
90
- ## Comparability pins (read this before comparing numbers)
91
-
92
- Results here are **internally comparable at R=8 and only qualitatively comparable
93
- to prior papers**. The pins for the confirmed R=8 study are:
94
-
95
- - **Tokenizer**: task-specific symbol vocabularies (< 50 symbols), shared
96
- special tokens (`PAD=0`, `EOS=1`, `EOQ=2`).
97
- - **Supervision**: full-answer prediction (FAP), matching Fan et al. Next-token
98
- variants are out of scope.
99
- - **Positions**: RoPE, base 10000 (NoPE available as a flag but PE ablations are
100
- out of scope).
101
- - **Optimizer**: Muon on attention/MLP matrices (muon_lr 0.01) + AdamW
102
- β=(0.9, 0.95), lr 3e-4 on embeddings/head/norms; cosine schedule, warmup, and
103
- grad clip 1.0. These LoopDeepNorm values were frozen for Stage 1a. Embeddings
104
- use init std 0.02 to remove the cold-start logit spike.
105
- - **Precision**: bf16 on MPS (fp32 fallback off-device). Seeds control
106
- data + init; run-level numeric noise on MPS is reported as part of the
107
- seed variance.
108
- - **Checkpoint/evaluation**: weights are selected only by ID validation seed
109
- 4242, then reloaded and evaluated on shared held-out seed 20260721.
110
- - **Causal scope**: `p` changes residual scaling and output-projection
111
- initialization together. Without a non-recurrent model trained under the same
112
- α/β values, the Dyck result is not evidence that the benefit is specific to
113
- weight tying or recurrence.
114
- - **Gradient coverage**: k=8 covers all R=8 iterations. The aborted R=32 gate had
115
- only 25% coverage, so it is documented as a blocked method extension rather
116
- than evidence about high-recurrence capacity.
117
-
118
- ## What this contributes
119
-
120
- - A small Apple-Silicon research harness for stacked independent runs,
121
- per-seed early stopping, best-checkpoint capture, and memory-safe evaluation.
122
- - A reproducible separation between improved ID optimization and genuine length
123
- extrapolation across five tasks, with checkpoint hashes and generated evidence
124
- artifacts. Prefix-sum is the sharp negative control: large ID gain, zero OOD.
125
- - A methodological warning for recurrent-depth studies: fixed truncated-BPTT
126
- windows change credit coverage as R changes.
127
- - A bounded practical result: a separate one-seed HDFS short-to-long anomaly
128
- gate did not validate a loop-model advantage; the matched Transformer won on
129
- far-OOD AUPRC (.699 versus .509), so the transfer study stopped at its gate.
130
-
131
- Stage 1a is consolidated in [STAGE1A_RESULTS.md](STAGE1A_RESULTS.md). The R=32
132
- extension is deferred until k/R gradient comparability is solved.
133
-
134
- ## Documentation
135
-
136
- - [STAGE1A_RESULTS.md](STAGE1A_RESULTS.md) — final metrics, statistical tests,
137
- limitations, and evidence inventory.
138
- - [DYCK_REPLICATION_PLAN.md](DYCK_REPLICATION_PLAN.md) — frozen independent
139
- replication protocol, committed before seeds 15–29 were trained.
140
- - [RESEARCH_NOTES.md](RESEARCH_NOTES.md) — RASP-L framing and practical-transfer
141
- rationale.
142
- - [STAGE1_PLAN.md](STAGE1_PLAN.md) — frozen experiment contract.
143
-
144
- ## Citation / license / contact
145
-
146
- Citation metadata is in [CITATION.cff](CITATION.cff).
147
- LoopBench is available under the [Apache License 2.0](LICENSE).
148
-
149
- Vadim Smirnov · `ukint-vs@proton.me`
 
1
+ ---
2
+ license: apache-2.0
3
+ pretty_name: LoopBench Checkpoints and Evidence
4
+ tags:
5
+ - transformers
6
+ - length-generalization
7
+ - looped-transformers
8
+ ---
9
+
10
+ # LoopBench checkpoints and evidence
11
+
12
+ This repository contains the separately distributed artifacts for
13
+ [LoopBench](https://github.com/ukint-vs/loopbench) v0.1.0.
14
+
15
+ - `checkpoints/` 125 selected PyTorch checkpoints.
16
+ - `runs/` raw training JSON logs.
17
+ - `artifacts/` derived CSV/JSON evidence, checkpoint SHA-256 hashes, and the
18
+ summary figure.
19
+
20
+ The code, experiment contracts, results, and reproduction commands live in the
21
+ LoopBench GitHub repository. All 125 checkpoint hashes were verified against
22
+ `artifacts/stage1a_metrics.csv` before publication.
23
+
24
+ Licensed under Apache-2.0.