feat(opt): Muon optimizer (Newton-Schulz orthogonalization) for 2D weights#560
Merged
Conversation
…ights - Add src/tri/math/muon_optimizer.zig - G1: Newton-Schulz 5-iteration orthogonalization for 2D weights - G2: Hybrid Muon+AdamW setup (Muon for attn/MLP, AdamW for embed/norm) - Momentum-based velocity accumulation with Nesterov option - AdamW with bias correction, weight decay, epsilon guard - Cosine decay-ready (externally scheduled) - 6 tests: NS normalization, zero vector, direction preservation, Muon weight update, AdamW convergence, hybrid dual-tensor Closes #535 Ref: R12
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
Implement Muon optimizer with Newton-Schulz orthogonalization for 35% speedup vs AdamW (R12).
New file
src/tri/math/muon_optimizer.zig— 327 LOCGates addressed
Features
MuonOptimizer: velocity-based momentum with NS orthogonalizationAdamWState: bias-corrected AdamW with weight decayHybridMuonAdamW: unified optimizer managing both pathsTests (6)
Reference: https://kellerjordan.github.io/posts/muon/
Closes #535