18 Commits
Author SHA1 Message Date
rzen 921069c5db Add degradation analysis + backing artifacts
- reports/degradation-analysis.md: interpretation of the one-parameter-at-a-time
  ablations (ctx/short/small/data vs v1), grounded in val loss + sample text.
  Key findings: held-out loss tracks quality for generalizing models; different
  degradations give qualitatively different failure text; data-starvation
  overfits (train ppl 1.1 / val ppl 322) with samples that hide the damage.
- reports/compare.md: side-by-side samples across all configs
- reports/loss-{small,short,ctx,data}.csv: variant training curves
2026-07-12 18:28:43 -04:00
rzen 9fd56b6063 Add degradation experiments: one-parameter-at-a-time ablations
Controlled study of how the model degrades. Four variants, each = v1 with a
single field replaced (dataclasses.replace), so differences are attributable:
- small: capacity down (2L/64d, ~0.38M params)
- short: training time down (max_iters 20k->2k)
- ctx:   context window down (256->64)
- data:  data quantity down (max_train_tokens->1M; new TrainConfig knob + train.py slice)

- scripts/compare.py: sample same prompt across all trained configs with a
  shared seed, print side by side, write reports/compare.md
- tests/test_configs.py: enforces one-parameter-at-a-time (only intended fields
  differ from v1) + small param count (3 tests). Full suite: 29 passing.
2026-07-12 12:58:48 -04:00
rzen 84c41bc612 Phase 5: v1 sample gallery — iteration 1 complete
- reports/samples-v1.md: 5 story-opening prompts sampled at temp 0.8 / top-k 200.
  Grammatical, coherent story arcs; expected sub-sweet-spot wobbles (plot logic,
  entity drift). All iteration-1 definition-of-done items now checked off.
2026-07-12 12:44:10 -04:00
rzen 116e1f61a3 Mark full training run item done (val loss 1.52) 2026-07-12 12:36:03 -04:00
rzen ba73c8a7e8 Phase 4: v1 training run results (val loss 1.52, ppl ~4.6)
- reports/loss-v1.csv: full train/val loss log over 20k steps
- reports/loss-v1.txt: ASCII loss curve (steep descent then flattening tail)
Training ran ~58 min on M1 MPS at 5.7 it/s. No overfitting (train~=val).
2026-07-12 12:35:47 -04:00
rzen 72595e274b Mark overfit sanity check + documented-commands items done 2026-07-12 11:34:55 -04:00
rzen 8915d274f5 Phase 5: autoregressive sampler (temperature + top-k)
- src/sample.py: load checkpoint + tokenizer, generate token-by-token with
  temperature/top-k (or greedy), stop at <|endoftext|>, crop to context window.
  --suite samples a fixed prompt suite into reports/samples-<config>.md.
- tests/test_sample.py: length, context-window safety, early stop, greedy
  determinism, str output (5 tests, tiny untrained model)
2026-07-12 11:34:45 -04:00
rzen 4947556c02 Phase 4: dependency-free ASCII loss-curve plotter
- scripts/plot_loss.py: reads reports/loss-<config>.csv, renders train/val
  loss as a terminal ASCII chart, saves it to reports/loss-<config>.txt.
  Verified on a synthetic curve. Keeps deps at torch + numpy.
- README: documented plotting choice and the Phase 4 run commands.
2026-07-12 11:32:34 -04:00
rzen 234a37f8fd Phase 4: training loop (code only — for user to run)
- src/train.py: AdamW (decay on matrices only), cosine LR w/ warmup, grad
  clipping, periodic train/val loss, CSV logging, resumable checkpoints.
  --overfit mode runs the overfit-one-batch sanity check. MPS, fp32.
- configs/v1.py: TrainConfig (batch 64, peak LR 6e-4, 20k iters, etc.)
- tests/test_train.py: LR schedule + optimizer grouping (3 tests, no run)
2026-07-12 10:51:58 -04:00
rzen 7b25fc89f6 Mark Phase 2 encoding + Phase 3 model items done 2026-07-12 10:49:06 -04:00
rzen e708a5b886 Phase 3: decoder-only transformer (~4.3M params)
- src/model.py: GPT written module by module — RMSNorm, explicit causal
  self-attention (scores/mask/softmax/weighted-sum), GELU MLP, pre-norm
  residual blocks, learned positions, weight-tied head. GPT-2 style init.
- configs/v1.py: frozen ModelConfig dataclass (4L/256d/4h/256ctx/4096vocab)
- tests/test_model.py: exact param count (4,262,144), forward shapes, init
  loss ~= ln(vocab), weight tying, causal-masking check (5 tests, forward-only)
- Verified forward pass runs on MPS.
2026-07-12 10:48:55 -04:00
rzen c202bada6a Phase 2: token dataset + corpus encoder (code only, not yet run)
- src/dataset.py: memmap uint16 token loader + random-crop batch sampler
  (x, y shifted-by-one, reproducible via generator)
- scripts/encode_corpus.py: stream stories -> encode -> uint16 .bin, one EOT
  token appended per story, flat memory. encode_file() factored out for testing.
- tests/test_dataset.py: batch shapes/shift/bounds/reproducibility +
  encoder round-trip/separators/uint16 on synthetic data (5 tests)
2026-07-12 10:38:20 -04:00
rzen 6111aac459 Mark Phase 1 tokenizer item done 2026-07-12 10:33:33 -04:00
rzen 3a489fef0a Phase 1: trained 4096-vocab tokenizer + per-word encode cache
- artifacts/tokenizer.json: 3839 merges, trained on 50MB sample in 87s.
  3.97 bytes/token on held-out text.
- encode() caches word->ids so encoding the full corpus is mostly dict
  lookups (TinyStories has a small vocabulary).
2026-07-12 10:33:24 -04:00
rzen 2c5fc29592 Phase 1: from-scratch byte-level BPE tokenizer
- src/tokenizer.py: byte-level BPE with GPT-2-style word pre-tokenization,
  protected <|endoftext|> special token, save/load as inspectable JSON.
  Simple recount-per-merge trainer over unique words.
- tests/test_tokenizer.py: round-trip, special-token integrity, unicode,
  lossless pre-tokenization, save/load, determinism (8 tests, no pytest dep)
- scripts/train_tokenizer.py: train on a corpus sample, report bytes/token
2026-07-12 10:31:16 -04:00
rzen e760c00043 Mark Phase 0 environment + dataset item done 2026-07-12 10:26:03 -04:00
rzen 0c26cd1f1f Record canonical TinyStoriesV2 SHA-256 hashes for reproducibility 2026-07-12 10:25:53 -04:00
rzen 5a7f2177bc Phase 0: project plan, pinned environment, data download + MPS smoke test
- README with full pipeline plan (tokenizer -> data -> model -> training -> eval)
- pip/venv setup pinned to torch 2.13.0, numpy 2.5.1 (Python 3.13)
- scripts/download_data.py: one-time TinyStoriesV2 fetch with SHA-256 recording
- scripts/check_mps.py: verifies MPS backend, backward pass, GPU speedup
2026-07-12 10:24:52 -04:00