Skip to content

fix(lsmr): keep MGK's ⟨v, Mv⟩ in range at extreme ‖A‖ - #404

Merged
schroedk merged 7 commits into
mainfrom
fix/lsmr-metric-range
Sep 24, 2026
Merged

schroedk merged 7 commits into
mainfrom
fix/lsmr-metric-range

Conversation

@schroedk

@schroedk schroedk commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Stack 4/5 (extreme scales), on main after #403.

  • MGK normalizes u in place once β leaves 1e±64, since Aᵀu scales with ‖A‖β; inside that band the stream is unchanged.
  • alpha_from_vp lets a NaN ⟨v, Mv⟩ (∞ − ∞ from finite terms) reach its re-sum, which scales both norms to 2^500 so a cosine below 2^-1074 survives; a subnormal negative ⟨v, Mv⟩ takes the re-sum's sign.
  • A non-finite solution x fails with InvalidInput. Past Krylov exhaustion at tol = 0, h̄ overflows and x became NaN, which budget stops returned as Ok (plain lsmr on main too; mlsmr once this PR recovered the overflowing dot).

Preconditioned solves are exact up to raw ‖A‖ ≈ 1e244 with ‖M⁻¹‖‖A‖ finite; past it they can fail with InvalidInput. The power-of-two scaling sweep gains an mlsmr arm.

Mutants: never normalizing u fails the sweep and the overflowing-dot test; always normalizing fails the headroom pin; the old re-sum fails both alpha_from_vp unit tests; is_finite for is_normal fails the subnormal-pair test; dropping the finite-x guard fails both exhaustion cases.

@schroedk
schroedk added this pull request to stack #402 September 23, 2026 17:07
@schroedk
schroedk force-pushed the fix/lsmr-metric-range branch from b6d8886 to 7797589 Compare September 23, 2026 17:32
@schroedk
schroedk force-pushed the fix/lsmr-metric-range branch from 7797589 to 94a8b48 Compare September 24, 2026 09:48
@schroedk
schroedk removed this pull request from stack #402 September 24, 2026 09:48
@schroedk
schroedk added this pull request to stack #407 September 24, 2026 09:48
@schroedk
schroedk force-pushed the fix/lsmr-metric-range branch from 94a8b48 to aa1fd8f Compare September 24, 2026 11:31
@schroedk
schroedk force-pushed the fix/lsmr-metric-range branch 2 times, most recently from 099cd97 to 317b1f7 Compare September 24, 2026 12:56
Base automatically changed from fix/lsmr-normalize to main September 24, 2026 12:57
MGK normalizes `u` in place once β leaves 1e±64, since `Aᵀu` scales
with ‖A‖β; inside that band the stream is unchanged. `alpha_from_vp`
lets a NaN ⟨v, Mv⟩ (∞ − ∞ from finite terms) reach its re-sum, which
now scales both norms to 2⁵⁰⁰ so a cosine below 2⁻¹⁰⁷⁴ survives.

The power-of-two scaling sweep now covers the preconditioned solve,
exact up to raw ‖A‖ ≈ 1e244 with ‖M⁻¹‖‖A‖ finite; past it the solve
fails with InvalidInput.
@schroedk
schroedk force-pushed the fix/lsmr-metric-range branch from 317b1f7 to c56a756 Compare September 24, 2026 12:57
Bitwise-identical: to_f64 on 2M random m·2^e plus a sweep, alpha_from_vp's
tail on 200k random pairs. Drops the never-read breakdown store of u_norm_inv
and restores pow2's doc reason.
A vp whose terms round to subnormals can land below zero for a positive
pair; the finite-vp clamp returned α = 0 there, reported as an exact solve.
Only a normal vp is trusted over the scaled re-sum.
Run past Krylov exhaustion at extreme anisotropy with tol = 0, h̄ grows by
~1/ε a step until it overflows, and x += t_x·h̄ becomes 0·∞. Only tolerance
stops measured x, so a budget stop returned the NaN as Ok. Plain lsmr did
this on main; mlsmr started to once #404 recovered overflowing ⟨v, Mv⟩.
schroedk added a commit that referenced this pull request Sep 24, 2026
Run past Krylov exhaustion at extreme anisotropy with tol = 0, h̄ grows by
~1/ε a step until it overflows, and x += t_x·h̄ becomes 0·∞. Only tolerance
stops measured x, so a budget stop returned the NaN as Ok. Plain lsmr did
this on main; mlsmr started to once #404 recovered overflowing ⟨v, Mv⟩.

Co-Authored-By: Claude <noreply@anthropic.com>
Replaces the target-minus-exponent pair and its parity fix-up; bitwise
identical on 400k random pairs, 222k of them through the fallback.
@schroedk
schroedk force-pushed the fix/lsmr-metric-range branch from 17eb85f to 1570aab Compare September 24, 2026 14:07
@schroedk
schroedk merged commit 06b7fc3 into main Sep 24, 2026
5 checks passed
@schroedk
schroedk deleted the fix/lsmr-metric-range branch September 26, 2026 06:58
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.

1 participant