fix: correctness and safety improvements for training#31
Merged
maderix merged 1 commit intomaderix:mainfrom Mar 4, 2026
Merged
fix: correctness and safety improvements for training#31maderix merged 1 commit intomaderix:mainfrom
maderix merged 1 commit intomaderix:mainfrom
Conversation
- Validate all fread() return values in model_load_weights (model.h) - Check ane_eval() return values in ane_conv_eval (forward.h) and ane_eval_k (tiny_train.m) - Log error details on ANE eval failure (ane_runtime.h) - Thread-safe RMSNorm: replace global g_rms_tmp with local allocation (stories_cpu_ops.h) - Bounds-check token indices in cross_entropy_loss, embed_lookup, embed_backward - Atomic checkpoint writes via tmp+rename pattern (tiny_train.m) - Non-destructive recompile: compile new kernels first, swap only on success (model.h) - Validate fread() in load_checkpoint (tiny_train.m)
Author
Benchmark ResultsHardware: Apple M3 Ultra (28-core CPU, 96 GB RAM, 31.6 TFLOPS peak ANE dual-die)
No performance regression. Safety and correctness fixes have zero measurable overhead. |
Owner
|
Good stuff — non-destructive recompile, atomic checkpoints, fread validation, and thread-safe RMSNorm are all real improvements. Merging now. We'll swap the assert() calls on token bounds to non-fatal logging (uint16_t is always >= 0 anyway, and a bad token should skip, not abort). Thanks! |
maderix
pushed a commit
that referenced
this pull request
Mar 4, 2026
Follow-up to PR #31 — assert() aborts on bad tokens, which is too harsh for training. Skip bad tokens with a warning instead.
Author
|
Your welcome! I think we should thank Claude ;-) under some nice stress prompts :D |
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.
Fixes 7 correctness and safety issues identified during M3 Ultra benchmarking and code review.
Changes:
Both make train and make train_large compile cleanly on macOS.