Bridge+Memory leak fix+More functions#19
Merged
maderix merged 1 commit intomaderix:mainfrom Mar 3, 2026
Merged
Conversation
maderix
approved these changes
Mar 3, 2026
Owner
maderix
left a comment
There was a problem hiding this comment.
Review & Benchmark Report
Thoroughly reviewed and benchmarked this PR. Great contribution — thanks for putting this together!
Benchmark Results (Stories110M, 30 steps)
| Metric | Baseline (train_large) |
This PR (train_large_ane) |
Improvement |
|---|---|---|---|
| ms/step (train) | 108.6 | 91.1 | -16% (17.5ms saved) |
| Compiles per restart | 72 | 99 | +27 more kernels |
| Compile time | 3.7s | 4.1s | +400ms |
| Loss trajectory | 10.39→9.78 | 10.39→9.78 | Identical ✅ |
Where the gains come from
- Classifier forward: 1.3ms ANE vs ~9.3ms CPU cblas — ~8ms saved
- Softmax: 2.7ms ANE vs ~75ms CPU — ~7ms saved
- RMSNorm backward: 0.12ms/eval on ANE — marginal gain but good to have
Tests
test_rmsnorm_bwd: PASS ✅ (max error 0.009, well within 0.05 threshold)test_classifier: All 4 subtests PASS ✅ (rmsnorm, classifier fwd, softmax, classifier bwd)
Correctness
Loss trajectories match baseline exactly — the ANE-offloaded ops produce numerically equivalent results.
Notes for follow-up
- Compile budget is tight (99/~100 limit) — may want to optimize
gen_classifier_bwd()is unused (CPU cblas is faster for that shape) — could remove or document as experimental- The bridge library is a nice abstraction for Python/ctypes consumers
Thanks for the contribution! 🎉
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.
Added Bridge APIs
Added temp workaround for 119 ANE compile limit
Offloaded the Classifier & Softmax to the ANE