Skip to content

Reject non-finite LM and Schur trials with exact rollback - #50

Open
cola1917 wants to merge 1 commit into
pypose:releasefrom
cola1917:fix-lm-nonfinite-trials
Open

cola1917 wants to merge 1 commit into
pypose:releasefrom
cola1917:fix-lm-nonfinite-trials

Conversation

@cola1917

Copy link
Copy Markdown

Problem and change

BAE's LM.step() and Schur.step() override PyPose's implementation, so they do not inherit the fix in pypose/pypose#442. This companion change follows the request in pypose/pypose#442 (comment).

A finite step can produce a NaN loss (sqrt outside its domain) or an infinite loss (exp overflow). The existing comparison accepts NaN and retains infinity when the rejection budget is exhausted. Subtracting a non-finite update also cannot restore the original parameters.

Both optimizers now reject non-finite trial losses even at the retry limit and restore trainable parameters from an exact pre-trial snapshot. This applies to explicit and matrix-free normal equations. Strategy updates, damping, linear solvers, and finite-loss acceptance rules remain unchanged: a finite uphill trial is still accepted when the existing rejection budget is exhausted. The maximum number of attempts remains reject + 1.

The implementation is self-contained and does not require pypose/pypose#442 to merge first. Snapshot storage costs O(P) additional memory. Model buffers/forward side effects are outside rollback, and the starting loss/Jacobian must be valid.

Validation

RTX 4080 SUPER, Python 3.10.12, PyTorch 2.7.0+cu128, Warp 1.13.0+cu12; CUDA extensions built with CUDA 12.8 and USE_CUDSS=0.

  • pytest tests/test_lm_nonfinite.py tests/test_normal_operator.py -q: 37 passed, using either PyPose #442 or unmodified PyPose main 9345958.
  • The 32 new regression cases cover LM/Schur, explicit/matrix-free paths, actual sqrt/exp non-finite trials, retry budgets 0/2, repeated steps, exact state/loss restoration, and finite downhill/uphill controls. LM additionally tests a solver returning NaN updates.
  • On unmodified BAE afad40e, the same new test file gives 20 failures and 12 passing finite controls; with this patch all 32 pass.
  • git diff --check passes.

A broader pytest tests -q attempt was interrupted after 191 seconds: 25 passed and 15 failed, including compile/Jacobian tests. The two compiled-indexed-residual and two unused-parameter-position failures were separately reproduced on unmodified BAE afad40e. The remaining broad-suite failures have not all been baseline-checked; this is not a claim of a clean full suite. No existing assertions, skips, or CI configuration were changed.

This branch has not been deployed

No deployments
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