Skip to content

feat(pretrain): task #124 — regime-aware INV-TRAIN-005 epoch-zero cap#936

Merged
noahgift merged 1 commit into
mainfrom
feat/task-124-inv-train-005-from-scratch
Apr 20, 2026
Merged

feat(pretrain): task #124 — regime-aware INV-TRAIN-005 epoch-zero cap#936
noahgift merged 1 commit into
mainfrom
feat/task-124-inv-train-005-from-scratch

Conversation

@noahgift

Copy link
Copy Markdown
Contributor

Summary

  • Contract training-loop-pretrain-v1 v1.1.0 → v1.2.0: INV-TRAIN-005 / GATE-TRAIN-005 epoch-zero cap is now regime-dependent (finetune keeps the MODEL-1 literal 10.0; from_scratch uses 2.0 × ln(vocab_size) ≈ 21.64 for vocab=50257). pv validate green.
  • New TrainingRegime enum threaded through check_non_divergence, PretrainConfig, run_epoch, test_config, and all 4 existing call sites. Default Finetune.
  • 3 new falsifier tests lock the from-scratch regime: near-random baseline passes, >2·ln(vocab) aborts, formula is 2.0 × ln(vocab_size).
  • CLI apr pretrain defaults regime: Finetune; task Integrate trueno-rag for enhanced text/document ML #125 will wire --mode {finetune|from-scratch} to flip regime alongside LR / warmup / target_val_loss.

Why

The hardcoded val_loss[0] ≤ 10.0 cap was calibrated for MODEL-1 finetuning. Any from-scratch pretrain starts at uniform-random cross-entropy = ln(vocab_size) ≈ 10.82 for vocab=50257, so every legitimate cold start trips the divergence abort. This is a blocker for task #119-onwards real-compute pretrain dispatches.

Test plan

  • pv validate contracts/training-loop-pretrain-v1.yaml — 0 errors, 0 warnings
  • cargo test -p aprender-contracts --lib — 1371 pass
  • cargo test -p aprender-train --lib pretrain:: — 22 pass (incl. 3 new)
  • cargo test -p apr-cli --lib pretrain — 3 pass
  • cargo clippy -p aprender-train --lib --no-deps -- -D warnings — clean
  • cargo fmt --all -- --check — clean
  • CI ci / gate + workspace-test green
  • Auto-merge fires on green checks

Closes #124

🤖 Generated with Claude Code

The hardcoded val_loss[0] ≤ 10.0 cap was calibrated for MODEL-1 finetuning,
but any from-scratch pretraining starts at ln(vocab_size) ≈ 10.82 for
vocab=50257 — every legitimate cold-start would trip the divergence abort.

Contract training-loop-pretrain-v1 v1.1.0 → v1.2.0:
- INV-TRAIN-005 / GATE-TRAIN-005 cap becomes regime-dependent:
  * finetune: literal 10.0 (MODEL-1 lesson preserved)
  * from_scratch: 2.0 × ln(vocab_size) (permits near-random baseline)
- GATE-TRAIN-005.evidence_discharged_by lists 4 Rust tests
- `pv validate` green (0 errors)

Rust:
- New TrainingRegime enum { Finetune, FromScratch { vocab_size } }
  serde-tagged "kind" for YAML/JSON interop; default Finetune.
- epoch_zero_val_loss_limit() returns regime-dependent cap.
- check_non_divergence(epoch, history, &regime) threaded through
  PretrainConfig, run_epoch, test_config, 4 existing call sites.
- 3 new falsifier tests:
  * from_scratch permits near-random baseline (val_loss[0]=18, vocab=50257)
  * from_scratch aborts above 2·ln(vocab) (val_loss[0]=25)
  * regime cap formula lock (2.0 × ln(vocab_size))

CLI:
- apr pretrain PretrainConfig literal defaults to Finetune;
  task #125 will wire --mode {finetune|from-scratch} to flip regime
  alongside LR / warmup / target_val_loss.

Gates: 22/22 pretrain tests PASS, 3/3 CLI tests PASS, 1371 contract
tests PASS, clippy+fmt clean.

Closes: #124

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@noahgift noahgift enabled auto-merge (squash) April 20, 2026 14:14
@noahgift noahgift merged commit 38b44da into main Apr 20, 2026
11 checks passed
@noahgift noahgift deleted the feat/task-124-inv-train-005-from-scratch branch April 20, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate trueno-viz for training visualization

1 participant