fix(mps): harden SRC adaptive stopping rule at extreme scale - #486
Conversation
…sors Publicize the accumulator behind scale_safe_norm so consumers can keep the (scale, sumsq) representation across an accumulation instead of finishing each step: the pair stays representable past the point where the finished norm saturates to inf, which stopping rules comparing against a running norm need at extreme scales.
A panel column whose true norm exceeds the real type's range comes back from the backend QR with an infinite diagonal even when every element is finite (measured: finite Q with an -inf diagonal for a single overflow column, NaN alongside non-finite Q for mixed blocks). The rank test read that as exact rank deficiency (inf <= inf tolerance), and NaN passed as full rank; both hand a degenerated factor to consumers as a certified outcome. Scan the candidate diagonal first and report QrAppendOutcome::NonFinite, terminating the factorization and suppressing the inverse update.
… at extreme scale Three regimes let the adaptive sweep report an uncertified state as converged: a saturated accumulated sketch norm made err <= cutoff * inf hold at the first round; overflowed R^-1 row norms collapsed the leave-one-out estimate to zero through recip(); and a panel norm overflow degenerated the QR factor into a false rank-deficiency stop. Keep the accumulated norm in the scale-safe (scale, sumsq) form with component-wise pushes (a complex modulus can overflow with finite components), evaluate the stopping comparison in an association order whose only overflow implies the decision is correct, treat an uninformative estimator (non-finite row norms or a saturated estimate) as not converged, and surface a degenerated QR factor as ApplyError::NonFinite instead of a bond-stuck Ok.
…overflow-proof Review hardening of the stopping-rule fix. Evaluate the convergence comparison in the log domain over the accumulator's (scale, sumsq) representation: no association order of the direct product survives every representable cutoff-times-extreme-scale combination without an intermediate saturating in one direction, while the log form keeps every operand finite. Carry the degenerated QR diagonal out of IncrementalQr as a payload on QrAppendOutcome::NonFinite so the error diagnostic names the quantity observed at the detection site instead of being re-inferred from the panel norm. Move the component-wise accumulation into NormAccumulator::push_scalar (the modulus-overflow subtlety lives with the representation), demote the consumerless finish() from the public surface, add Debug/Clone, cover fixed mode driving through a degenerated factor, and extract the scaled-state test helper.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThe changes expose ChangesSRC numerical robustness
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Apply as apply_successive_randomized_dense
participant Norm as NormAccumulator
participant QR as IncrementalQr
participant Result as ApplyError
Apply->>Norm: accumulate panel scalars
Apply->>QR: append panel
QR-->>Apply: QR outcome and inverse-row norms
Apply->>Norm: read scale and sumsq
Apply->>Apply: evaluate adaptive convergence
Apply-->>Result: report NonFinite when QR certification degenerates
Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
The adaptive stopping rule of successive randomized compression (SRC) degraded toward false convergence at representational extremes: a saturated accumulated sketch norm made
err <= cutoff * infaccept any finite estimate at the first round, overflowedR^-1row norms collapsed the leave-one-out estimate to zero throughrecip(), and a panel column norm pastf64::MAXproduced a non-finite QR diagonal that the rank test misread as exact rank deficiency (inf <= inftolerance) — each returning a finite but uncertified state as a success. This PR hardens all three regimes so every degradation now points toward growth, a correct convergence, or an explicit error. Closes #483.Changes
ariadnetor-core: the scale-safe accumulator behindscale_safe_normis now public (NormAccumulatorwithpush/push_scalar/scale/sumsq), exposing thedlassq-style(scale, sumsq)representation that stays exact past the point where the finished norm saturates.push_scalarenters elements component-wise, because a complex modulus can overflow with finite components.ariadnetor-linalg:IncrementalQr::appendscans the candidate diagonal before the rank test and reports a new terminatingQrAppendOutcome::NonFinite { diagnostic }instead of lettinginfmasquerade as rank deficiency or NaN as full rank; the inverse update is suppressed andinto_orthonormal_q's guarantee is scoped accordingly.ariadnetor-mps: the sweep accumulates the sketch norm in the(scale, sumsq)form, evaluates the stopping comparison in the log domain (withpthe current sketch width, no product of cutoff, scale, andsqrt(sumsq / p)is ever formed, so no operand ordering can saturate an intermediate), treats an uninformative estimator — non-finite row norms or a saturated reciprocal norm — as "not converged" (leave_one_out_estimatenow returnsOption), and surfaces a degenerated QR factor in adaptive mode asApplyError::NonFinitecarrying the observed diagonal.Impact
apply_successive_randomized_dense: adaptive-path behavior only; public signature and dispatch unchanged. Fixed mode never claims the cutoff guarantee, ignores the append outcome as before, and stays covered by the elementwise result-boundary scans (check_finiteon panels and assembled sites).QrAppendOutcomegains a variant and dropsEq(the diagnostic payload isf64); the workspace has no exhaustive matches.scale_safe_norm/combine_normsare behaviorally unchanged.Test plan
f64::MAXwhile every per-round panel norm stays representable; bond selection must match the unit-scale run (fails before the fix with the bond stuck at the saturating round).ApplyError::NonFiniteinstead of a bond-stuckOk; fixed mode driven through the same degenerated factor is tolerated and the overflowed weight is caught by thecheck_finitescan over the assembled sites — the test asserts the detection site, which distinguishes the documented tolerance (error at the assembled-site scan) from a hypothetical fixed-mode error at the append itself.NormAccumulatorrepresentation identity, saturation, and modulus-overflow survival;leave_one_out_estimateOptioncontract including the all-finite-but-saturated reciprocal case;IncrementalQrnon-finite outcomes for a first-append overflow column and a projected overflow block, with termination and inverse-state hygiene.cargo test --workspace,cargo clippy --workspace --all-targets(warnings denied), andcargo doc --no-depson the touched crates: all clean.Notes
R_iiinside[rank tolerance, 1/MAX)) is covered at theOption-contract unit level; an end-to-end fixture proved unreachable for the existing integration fixtures without magic RNG-tied magnitudes.NonFinitehandling inapply_successive_randomized_dense— tracked by SRC fixed mode keeps a right-orthogonality label a degenerated QR factor may violate #485.Summary by CodeRabbit
New Features
Bug Fixes
Documentation