Skip to content

feat(inner): add GlobalNystrom preconditioner (sketch once, mask per free block) - #62

Merged
tschm merged 1 commit into
mainfrom
add-global-nystrom-preconditioner
Jul 19, 2026
Merged

feat(inner): add GlobalNystrom preconditioner (sketch once, mask per free block)#62
tschm merged 1 commit into
mainfrom
add-global-nystrom-preconditioner

Conversation

@mstoll1602

Copy link
Copy Markdown
Collaborator

Summary

  • Adds GlobalNystrom, a new InnerSolver that sketches the full operator A once and reuses that basis across every free block the active-set loop visits, instead of resketching A[F, F] from scratch on every outer step (what Nystrom does). Restricting a rank-r factorisation 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.
  • Wires it in as the "global_nystrom" string shortcut alongside cg/jacobi/nystrom/exact, and exports it from the package root.
  • The sketch is memoised on operator identity (mirroring 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.
  • Adds a marimo notebook (book/marimo/notebooks/04_solver_comparison.py) comparing CG, Jacobi, Nystrom, and GlobalNystrom head to head on a planted-optimum problem with a spectral gap, including a repeated-solve experiment showing where GlobalNystrom's pay-once sketch pulls ahead.

Test plan

  • make fmt — lint/format clean
  • make typecheck — ty + mypy strict clean
  • make test — 112 passed, 100% coverage maintained
  • make deptry — no dependency issues
  • New tests: preconditioner-level correctness/rejection tests (tests/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)
  • Notebook verified end-to-end via marimo export html (all four solvers report converged: True, both figures render)

🤖 Generated with Claude Code

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>
@tschm
tschm merged commit 98c26e5 into main Jul 19, 2026
53 checks passed
@tschm
tschm deleted the add-global-nystrom-preconditioner branch July 19, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants