Save pre-eval checkpoint to prevent training loss on eval crash#107
Open
sunilp wants to merge 1 commit intokarpathy:masterfrom
Open
Save pre-eval checkpoint to prevent training loss on eval crash#107sunilp wants to merge 1 commit intokarpathy:masterfrom
sunilp wants to merge 1 commit intokarpathy:masterfrom
Conversation
After the training loop completes and before evaluation begins, save a lightweight checkpoint (model state dict). If evaluation crashes (e.g. OOM when the agent has increased model size), the checkpoint survives for inspection or metric recovery. On successful eval, the checkpoint is cleaned up automatically. Fixes karpathy#7
sunnypatneedi
added a commit
to sunnypatneedi/autoresearch-muon
that referenced
this pull request
Mar 10, 2026
Fixes adopted from karpathy/autoresearch PRs: - karpathy#84: NaN loss bypasses fast-fail (IEEE 754: NaN > 100 is False). Fix: `not x <= 100`. Applied to both train.py and train_mlx.py. - karpathy#83: ParquetFile handles never closed, causing FD exhaustion on multi-epoch training. Fix: try/finally with pf.close(). - karpathy#107: Save pre-eval checkpoint so eval OOM/crash doesn't lose the entire training run. Removed on successful eval. - karpathy#93: MFU off-by-one: warmup skips 11 steps (0-10), not 10. - karpathy#70: Loss only reported last microstep, not average across grad accumulation. Fix: accumulate loss += detach() / grad_accum_steps. - karpathy#53: Debug checkpoint on loss explosion with step/loss metadata for post-mortem analysis (train.py only, merged into karpathy#84 fix). - karpathy#62: Input validation for --num-shards and --download-workers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
sunnypatneedi
added a commit
to sunnypatneedi/autoresearch-muon
that referenced
this pull request
Mar 10, 2026
Fixes adopted from karpathy/autoresearch PRs: - karpathy#84: NaN loss bypasses fast-fail (IEEE 754: NaN > 100 is False). Fix: `not x <= 100`. Applied to both train.py and train_mlx.py. - karpathy#83: ParquetFile handles never closed, causing FD exhaustion on multi-epoch training. Fix: try/finally with pf.close(). - karpathy#107: Save pre-eval checkpoint so eval OOM/crash doesn't lose the entire training run. Removed on successful eval. - karpathy#93: MFU off-by-one: warmup skips 11 steps (0-10), not 10. - karpathy#70: Loss only reported last microstep, not average across grad accumulation. Fix: accumulate loss += detach() / grad_accum_steps. - karpathy#53: Debug checkpoint on loss explosion with step/loss metadata for post-mortem analysis (train.py only, merged into karpathy#84 fix). - karpathy#62: Input validation for --num-shards and --download-workers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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.
Summary
Saves a lightweight checkpoint (model state dict) after the training loop completes and before
evaluate_bpb()runs. If evaluation crashes (OOM, CUDA error), the trained weights survive for inspection or metric recovery. On successful eval, the checkpoint is cleaned up automatically.torch.save(model.state_dict(), "pre_eval_checkpoint.pt")between training and evalFixes #7