feat: async double-buffered ANE training (eliminates 88% compile bottleneck)#23
Open
mgkcloud wants to merge 4 commits intomaderix:mainfrom
Open
feat: async double-buffered ANE training (eliminates 88% compile bottleneck)#23mgkcloud wants to merge 4 commits intomaderix:mainfrom
mgkcloud wants to merge 4 commits intomaderix:mainfrom
Conversation
Key discovery: compile and eval can run in parallel via GCD. 119 foreground evals completed during a 26.8ms background compile. Architecture: - Two kernel sets (A/B) alternate active/pending - Background GCD thread compiles pending kernels while active runs - Atomic swap at batch boundary - Eliminates 88% compilation bottleneck Includes: - train_double_buffer.m: modified train_large.m with async compilation - PROBE_RESULTS.md: full benchmark data from M4 probe - Updated Makefile
dev-erik
added a commit
to dev-erik/ANE
that referenced
this pull request
Mar 3, 2026
…timized training (train_opt), double-buffered async ANE training (train_double_buffer), Qwen2.5-0.5B LLM inference (inference/). Added get_path() env var support and SEC_FLAGS to all new targets. Skipped PR maderix#22 (binary blob risk).
dev-erik
added a commit
to dev-erik/ANE
that referenced
this pull request
Mar 3, 2026
…timized training (train_opt), double-buffered async ANE training (train_double_buffer), Qwen2.5-0.5B LLM inference (inference/). Added get_path() env var support and SEC_FLAGS to all new targets. Skipped PR maderix#22 (binary blob risk).
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.
Problem
Training on ANE is bottlenecked by recompilation, not compute. Because weights are baked at compile time, every weight update requires a full ANE recompile. On M4:
Solution
Async double-buffered compilation using GCD (Grand Central Dispatch).
Two kernel sets (A/B) alternate between active and pending:
Results (M4, 10 cores, 32GB)
Verified over 50 training steps with 5 batches each. Every batch achieved
compile_stall=0ms. Kernel swap confirmed at step boundaries.Key findings (PROBE_RESULTS.md)
exec()restart is required.unload+loadafter file overwrite does NOT update weights._ANEChainingRequestsupports loopback execution for potential kernel fusion.Files
training/train_double_buffer.m— Modifiedtrain_large.mwith async compilationPROBE_RESULTS.md— Full benchmark data from M4 probe experimentstraining/Makefile— Updated withtrain_double_buffertargetUsage
cd training make train_double_buffer ./train_double_bufferTested on Apple M4 (macOS 26.3). Should work on any Apple Silicon with ANE.