feat(inner): add GlobalNystrom preconditioner (sketch once, mask per free block) - #62
Merged
Merged
Conversation
Nystrom resketches A[F, F] from scratch on every outer step. GlobalNystrom instead sketches the full operator once (restricting a rank-r factorisation to a principal submatrix is exact) and reuses that basis across every free block via the general Sherman-Morrison-Woodbury update, so repeated solves of the same operator (parameter sweeps, warm-started re-solves) amortise the sketch cost instead of paying it every outer step. Wired in as the "global_nystrom" inner-solver shortcut alongside cg/jacobi/ nystrom/exact, with unit tests (preconditioner-level and solver-level, bound and equality-constrained), a README update, and a new marimo notebook comparing all four inner solvers head to head. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
GlobalNystrom, a newInnerSolverthat sketches the full operatorAonce and reuses that basis across every free block the active-set loop visits, instead of resketchingA[F, F]from scratch on every outer step (whatNystromdoes). Restricting a rank-rfactorisation to a principal submatrix is exact, so masking rows of the one global basis is a valid free-block preconditioner — applied via the general Sherman-Morrison-Woodbury identity, since the masked basis is no longer orthonormal."global_nystrom"string shortcut alongsidecg/jacobi/nystrom/exact, and exports it from the package root.Exact's conditioning memo), so a solve with many outer steps — or several solves reusing the same operator (parameter sweeps, warm-started re-solves) — pays the expensive sketch (matrix-free products, QR, Cholesky, SVD) once instead of once per step/solve.book/marimo/notebooks/04_solver_comparison.py) comparingCG,Jacobi,Nystrom, andGlobalNystromhead to head on a planted-optimum problem with a spectral gap, including a repeated-solve experiment showing whereGlobalNystrom's pay-once sketch pulls ahead.Test plan
make fmt— lint/format cleanmake typecheck— ty + mypy strict cleanmake test— 112 passed, 100% coverage maintainedmake deptry— no dependency issuestests/test_nncg/test_inner.py), solver-level planted-optimum + trajectory-equivalence + sketch-memoisation tests for both the bound-only and equality-constrained solves (tests/test_nncg/test_solver.py), and the"global_nystrom"API shortcut (tests/test_nncg/test_api.py)marimo export html(all four solvers reportconverged: True, both figures render)🤖 Generated with Claude Code