Add SpecializingFactorizations.jl package extension#1005
Conversation
|
This should also get an opt-out #1023 |
Wraps SpecializingFactorizations.jl as two opt-in LinearSolve algorithms: - SpecializedLUFactorization: type-stable, structure-detecting dense LU-style solver for square systems (diagonal/bidiagonal/tridiagonal/ banded/triangular/symmetric specializations behind one workspace type). - SpecializedQRFactorization: rank-revealing, never-throwing dense QR least-squares solver for rectangular / rank-deficient systems (minimum-norm least-squares == pinv(A)*b). Both are AbstractDenseFactorization subtypes gated behind a weakdep extension (ext/LinearSolveSpecializingFactorizationsExt.jl), implementing init_cacheval + SciMLBase.solve! with cache reuse via specializinglu!/ specializingqr!. Added a focused test set (extension load + solve + caching across LU/QR, structured, complex, float32, overdetermined, and rank-deficient cases) wired into the Core test group. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
16310f0 to
a81d68d
Compare
|
Rebased onto current main (was conflicting after the test-suite restructure in #1022 and the test-target slimming). Conflict resolution:
Verified locally on Julia 1.12: the |
Per review on SciML#1005 (matching SciML#1023): SpecializingFactorizations has generic-element fallbacks, so SpecializedLUFactorization and SpecializedQRFactorization solve Dual-number problems directly via _use_direct_dual_solve instead of the primal/partials splitting path. The split-path math is square-only, so this also makes the QR least-squares solver correct for Dual rectangular systems. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
|
Rebased on main and added the ForwardDiff opt-out per the review comment (same pattern as #1023):
Ran locally on the rebased branch: Note for whichever of this and #1023 merges second: both touch the same line of |
Rename the Float32 test variable solf (flagged by typos as a misspelling of solve) to sol32, and add SpecializedLUFactorization / SpecializedQRFactorization to the docs solver list so the Documenter missing-docs check covers them. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
resolve.jl enumerates every AbstractDenseFactorization subtype, so the new SpecializedLU/QRFactorization hit the generic do_factorization fallback when their extension is not loaded. Load the package (already a test dep) so both algorithms go through the extension and get re-solve coverage. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
|
CI status on Remaining red is not from this PR:
|
Please ignore until reviewed by @ChrisRackauckas.
Adds an opt-in package extension wrapping SpecializingFactorizations.jl as two LinearSolve algorithms. This is a weakdep extension only — no hard dependency and no change to any default algorithm.
What SpecializingFactorizations.jl provides
It exposes two type-stable, single-workspace dense factorizations that detect the property a matrix actually has and dispatch to the specialized solve, all behind one concrete workspace type (the structure/rank choice is a runtime enum field, not a Julia type, so the pipeline infers and the warm path is allocation-free):
specializinglu/SpecializedLU— a square solver that cheaply scansAfor structure (diagonal, bidiagonal, tridiagonal, banded, triangular, symmetric PD, symmetric/Hermitian indefinite) and uses the matching specialized factorization instead of a generalO(n^3)LU.specializingqr/SpecializedQR— a rectangular / rank-deficient least-squares solver. Column-pivoted rank-revealing QR (geqp3) that returns the least-squares / minimum-norm solution for any shape including singular/rank-deficient, never throwing.Wrapped algorithms
SpecializedLUFactorization— wrapsspecializinglu; for square systems.SpecializedQRFactorization— wrapsspecializingqr; for rectangular / rank-deficient least-squares.Both wrapped because they cover complementary problem classes (square structured solves vs. rectangular/rank-deficient least-squares) and both expose the
ldiv!+ in-place re-factor (specializinglu!/specializingqr!) interface theLinearCachewarm-solve path wants.Implementation
src/extension_algs.jl: twoAbstractDenseFactorizationstructs with docstrings + examples; exported fromsrc/LinearSolve.jl.ext/LinearSolveSpecializingFactorizationsExt.jl:init_cachevalbuilds the factorization;SciMLBase.solve!re-factors in place oncache.isfresh(reusing the workspace viaspecializing*!), guardsissuccess, and returnsbuild_linear_solutionwith the appropriateReturnCode.Project.toml:SpecializingFactorizationsadded to[weakdeps],[extensions],[compat]("0.1"),[extras], and thetesttarget. NoSparseArraystrigger — it operates on dense matrices only.test/specializing_factorizations.jl: focused test set (extension load, square/structured/complex/float32 LU, overdetermined and rank-deficient QR, cache reuse across re-factor for both), wired into the Core test group.Registration
SpecializingFactorizations.jl is registered in the General registry (v0.1.0).
Caveats
SpecializedLUFactorizationis square-only by construction; rectangular systems should useSpecializedQRFactorization.!iszero), not numerical/tolerant.specializing*!).🤖 Generated with Claude Code