Repository navigation
Boxz: train an 8.1M model, audit the torch engine, and gate the first Kaggle run - #1
Open
nachikethsr1 wants to merge 3 commits into
Open
nachikethsr1 wants to merge 3 commits into
nachikethsr1 wants to merge 3 commits into
Conversation
…ering questions Model run (measured, reproducible): * base: 8,115,200 params, 1.64M train tokens, 2000 steps -> val loss 3.9330 (ppl 51.1) * SFT: 350 steps over 218 examples, best held-out loss 2.3619 * fixed 20-prompt suite: 15% requirement-met, 70% own-turn stop, 122 tok/s * reports/LIVE_5M.md, reports/live_5m.json, tools/live_eval_5m.py, configs/boxz-live-5m.json, checkpoints/registry.json entries * weights packed into backups/live-sft5m (3 shards, 86 MB) so they survive a wipe Bug: English questions were claimed by the coding template router -- 'explain css grid' matched the snake template and 'what is the main idea behind flexbox' was answered with a menu of projects, so the model never spoke. Question framing now routes to the model unless a build verb follows it. Regression tests in tests/test_coding_selection.py. Bug: .gitignore ignored backups/**/*.bin, the exact files the comment above it promised to commit -- a packed backup could never be pushed. Fixed, with a test that asks git itself. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
… inference Audit finding: the brief assumed Boxz had no PyTorch engine. It already has one (boxz/torch_engine, 1778 lines) and it is numerically faithful -- verified directly on the 8.1M checkpoint: worst logit diff 1.86e-05 vs NumPy, argmax agreement 1.000, 76/76 tensors bitwise identical. Building a second PyTorch implementation would have been the rewrite the brief forbids, so this fixes what was actually wrong and adds what was actually missing. BUG (data loss): TorchTrainer.find_latest returned the newest step_* directory without opening it. A truncated checkpoint left by a killed session was picked over a valid older one and resume died with UnpicklingError. Added verify_checkpoint() (files present, non-empty, parseable, model+optimizer present, format version readable) and made find_latest skip failures newest-first. 6 tests, 2 of which fail without the fix. NEW: boxz/torch_engine/generate.py -- PyTorch inference with a verified KV cache. PyTorch was training-only before this; every chat path ran NumPy. The sampler is imported from the NumPy side so identical logits give identical tokens. Also fixes a bug in my own first version: cache.length was never advanced, so each step overwrote position 0 (max logit diff 12.3 -> 1e-5). 7 tests, 4 of which fail if the cursor advance is removed. Measured (CPU, same checkpoint, same sampler): NumPy + KV cache 146.1 tok/s 1.00x PyTorch + KV cache 196.5 tok/s 1.34x PyTorch no cache 82.4 tok/s 0.56x CLI: 'boxz torch sample' and 'boxz torch infer-bench'. Docs: docs/MIGRATION_AUDIT.md, reports/MIGRATION_REPORT.md with explicit VERIFIED/BLOCKED labels -- CUDA, AMP, torch.compile and Rust are BLOCKED in this sandbox and are not claimed. Full suite: 778 passed, 56 skipped (was 727 passed). Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…reflight Found while preparing the first Kaggle run, worst first: 1. TOKENIZER COULD BE SILENTLY RETRAINED (would invalidate every weight). configs/boxz-live-8m.json shipped tokenizer_path=null and no tokenizer is committed, so prepare_dataset retrains a 2048-token BPE on a fresh clone. Measured: same vocab size, DIFFERENT ids (sha a75f6d73 vs bc28e7e4; 3/3 probes differ). Fixed by committing data/tokenizers/live-2048/ with a pinned-sha manifest, pointing all live configs at it, and making tools/train_gpu.py refuse to start without one (verified: exit 1). 2. SILENT PROGRESS RESET. A bare TorchTrainer(cfg, checkpoint_dir=...) on an existing run started at step 0 and overwrote it. Resuming is now the default; resume='none' is required to start over and logs what it discards. Also: resume='latest' on an empty dir now starts a fresh run instead of raising (that would have failed the first Kaggle session); an explicit missing path still refuses. The old test encoding the previous contract was rewritten deliberately into 3 tests; the safety is preserved. Added: configs/kaggle-8m.json session-sized config, ckpt dir /kaggle/working tools/preflight_kaggle.py 12 checks -> GO/NO-GO, and kaggle-dataset builder data/corpus_manifest.json corpus + tokenizer provenance with sha256 reports/PRETRAIN_READINESS.md audit, benchmark, status table, GO/NO-GO Dataset audit (read-only): 5,558,271 bytes, sha 7f761dfd, 37,185 docs (29,408 unique), 1,643,060 train / 50,817 val tokens -- exact match to the run. No leakage: 40/40 val chunks absent from train; 0.84% 13-gram overlap is cross-source boilerplate; longest shared run 36 tokens. Bounded benchmark (measured, 2 vCPU, FP32, 8.1M params): 100 steps 1,592.1 tok/s | 200 steps 1,623.9 tok/s | NumPy baseline 1,168.8 => torch is 1.39x NumPy for training on CPU. Tests: 786 passed, 56 skipped, 0 failed (was 778). No production checkpoint touched (model.npz sha unchanged), no dataset downloaded, no full training started, no history rewritten. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
Three commits that take Boxz from "a NumPy transformer with a zip in git" to an 8.1 M-parameter model trained end to end, with the PyTorch engine audited, a real inference path added, and the Kaggle run made safe to start.
Most of the work was finding and fixing defects that would have silently invalidated a training run, not adding features.
Commits
add455c14bd9aetorch_engine, fixed corrupt-checkpoint resume, added PyTorch inference + verified KV cache460dcb5Bugs fixed (each verified by a test that fails without the fix)
boxz-live-8m.jsonhadtokenizer_path: nulland no tokenizer was committed. A fresh clone retrains a 2048-token BPE with different ids (a75f6d73vsbc28e7e4). Every weight would train on the wrong token space. Now committed + pinned by sha, andtrain_gpu.pyrefuses to start without one.find_latestsorted directory names and never opened them. A truncatedstep_000300beat a validstep_000200and resume died withUnpicklingError. That is the exact Kaggle kill-mid-write scenario.TorchTrainer()on an existing run restarted at step 0 and overwrote it. Resuming is now the default.explain css gridmatched the snake template, so the model never spoke..gitignoreignoredbackups/**/*.bin— the exact files the comment above it promised to commit, defeating the backup-on-wipe design.Measured results
Dataset audit (read-only, nothing modified)
5,558,271 B · sha
7f761dfd· 37,185 docs (29,408 unique) · 1,643,060 / 50,817 tokens, exact match to the run. No leakage: 40/40 val chunks absent from train, 0.84 % 13-gram overlap is URL/CSS boilerplate, longest shared run 36 tokens.What is not claimed
torch.compileare BLOCKED, not verified.Next steps (documented in
reports/PRETRAIN_READINESS.md)GO for the first Kaggle run, conditioned on three manual actions: upload the corpus as a Dataset (
python tools/preflight_kaggle.py kaggle-dataset), run cell 5a to proveGPU VERIFIED, and confirm the 8.1 M architecture is the intended run #1.Docs
docs/MIGRATION_AUDIT.md·reports/MIGRATION_REPORT.md·reports/PRETRAIN_READINESS.md·reports/LIVE_5M.md·reports/live_5m.json