Add Newton Schultz via Polar Express as a retraction for Iso optimizer - #294
Add Newton Schultz via Polar Express as a retraction for Iso optimizer#294kogolobo wants to merge 7 commits into
Conversation
Signed-off-by: Konstantin Golobokov <kogolobo@uw.edu>
Greptile SummaryThis PR adds a Newton-Schulz approximation of the polar retraction to the Iso optimizer.
Confidence Score: 5/5The PR appears safe to merge, with no outstanding correctness or repository-rule issues. No new actionable failures were identified in the changes since the previous review. All previous findings were manually resolved, including the CPU SYRK concern and the benchmark synchronization policy threads. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
Iso[Iso optimizer step] --> Factors[Update Stiefel factors U and V]
Factors --> Choice{Retraction}
Choice --> QR[QR]
Choice --> Polar[SVD polar]
Choice --> Cayley[Cayley transform]
Choice --> NS[Newton-Schulz]
NS --> PE[Polar Express polynomial<br/>8 iterations]
QR --> Result[Retracted factors]
Polar --> Result
Cayley --> Result
PE --> Result
Result --> Recompose[Recompose parameter<br/>U S Vᵀ]
Reviews (7): Last reviewed commit: "Add retraction dosctrings" | Re-trigger Greptile |
Signed-off-by: Konstantin Golobokov <kogolobo@uw.edu>
581648e to
12888d2
Compare
Signed-off-by: Konstantin Golobokov <kogolobo@uw.edu>
|
Thank you for contribution! It looks like the retractions are becoming big. Could you move this entire block into a RetractionT = Literal["qr", "polar", "cayley", "newton_schulz"] |
Signed-off-by: Konstantin Golobokov <kogolobo@uw.edu>
Done, thanks! |
Signed-off-by: Konstantin Golobokov <kogolobo@uw.edu>
| ("polar_wide", "polar", (5, 8)), | ||
| ("cayley_tall", "cayley", (8, 5)), | ||
| ("cayley_wide", "cayley", (5, 8)), | ||
| ("newton_shultz_tall", "newton_schulz", (8, 5)), |
There was a problem hiding this comment.
nit: typo in new schultz
There was a problem hiding this comment.
typo is not nit and should be fixed.
There was a problem hiding this comment.
Fixed, thanks for noticing this!
|
/claude review |
| ("polar_wide", "polar", (5, 8)), | ||
| ("cayley_tall", "cayley", (8, 5)), | ||
| ("cayley_wide", "cayley", (5, 8)), | ||
| ("newton_shultz_tall", "newton_schulz", (8, 5)), |
There was a problem hiding this comment.
typo is not nit and should be fixed.
Signed-off-by: Konstantin Golobokov <kogolobo@uw.edu>
Signed-off-by: Konstantin Golobokov <kogolobo@uw.edu>
|
/ok to test fea8a69 |
|
/claude review |
Summary
Contributes to #28.
This PR adds a Newton-Schulz matrix-sign retraction (
retraction="newton_schulz") to theIso(isospectral) optimizer. This allows to approximate the polar retraction without usingtorch.linalg.svd. This is an incremental step toward #28, exploring iterative matrix polynomial retractions for Stiefel factors.Key Changes
_newton_schulz_retractionleveragingmuon_utils.newton_schulz(defaults tosteps=8withpolar_expresscoefficients).tests/riemannian_optimizers/test_isospectral.pywith parameterization fornewton_schulz, validating singular value preservation and Stiefel factor orthogonality (becnmarks/benchmark_isospectral_retraction.pywhich usestriton.testing.do_benchto measure combined retraction time for both Stiefel factorsBenchmark: Retraction Latency & Manifold Precision
Benchmarked on NVIDIA GeForce RTX 4090 using with TF32 enabled (
fp32_matmul_prec="high"):polar(SVD)qrcayleynewton_schulz(steps=8)Observations:
newton_schulz(polar_express) track the analytical SVD polar factor withinnewton_schulz(21.53 ms) is 2.66x faster than Cayley (57.25 ms) and faster than QR (26.81 ms), avoiding thenum_ns_steps=8as the necessary default for numerical stability.Testing
pre-commit run --all-filespasses cleanly.pytest tests/riemannian_optimizers/test_isospectral.pypasses on CPU and CUDA.