Repository navigation
#907: a cold rotated solve whose first linear solve fails raises - #916
Merged
Merged
Conversation
The rotated route runs its own Krylov loop and warned and went on when the outer linear solve failed. With a preconditioner failing at iteration 0 (KSP_DIVERGED_PC_FAILED, -11), it returned with the velocity at zero. The failure is forced by a coarse-level python PC that reports a failure at every application, so it fails the same way on any build. (#901's singular coarse case under plain LU stops failing once #901's double-setup fix lands.) - test_1115 (serial): the solve raises, naming the reason. With solver.tolerate_linear_failure = True it keeps the last iterate and records the reason. - test_1116 (np >= 2): every rank raises. On development the raise tests fail ("DID NOT RAISE"), and the tolerate case passes, since that is development's behaviour. test_1115 joins CI batch 4. Underworld development team with AI support from Claude Code
… raises On a hard failure of the outer linear solve (fieldsplit-Schur, vector or direct LU), the rotated Newton loop used to warn and go on: a preconditioner that failed, a breakdown, a NaN, a residual that grew. On the first step that left the fields at the initial guess, and with a preconditioner failing at iteration 0 the velocity stayed at zero. Now such a failure raises on every rank, naming the KSP reason, when no Newton step has been accepted yet. solver.tolerate_linear_failure = True keeps the old behaviour: warn and keep the guess. The decision reads the KSP's converged reason and the line-search record, which every rank holds alike. After an accepted step the fields hold that iterate. The line search rejects a failed increment and the loop's convergence warning stands, so a hard failure only warns there. test_0022's fixture is that case: its power-law TI tangent is driven to 1e-11, and the sixth linear solve fails at round-off (a NaN in the GAMG velocity sub-solve) with Newton already at 2.45e-10 of the reference. A first version raised there and broke it. An iteration cap (KSP_DIVERGED_ITS) and the velocity sub-solve's own reason only warn, as before. test_1115 and test_1116 pass (serial, np 2 and 3), as does test_0022. All 341 serial tests and 27 tests/parallel tests at np 2 that touch the rotated path or fault contact pass. rotated-freeslip.md states the rule. Underworld development team with AI support from Claude Code
From the adversarial review of 52d1789: - A warm re-solve of a state at round-off raised. On test_0022's fixture at tolerance 1e-11, 12 of 12 warm re-solves raised: on a warm start the guess is the caller's own state. The raise is now for a cold start (a zero initial guess) with no step accepted. A warm start warns and keeps its state. The reviewer's probe now warns on all 12. - The raise skipped the loop's teardown and records. A caught raise left _rotated_freeslip_info and the SNES reason reading success, and an uncached solve leaked its objects. Now: - the loop records the failure, destroys the iteration's temporaries and leaves through the normal teardown, with SNES reason -3 (DIVERGED_LINEAR_SOLVE), without writing the fields; - the solver raises after recording the result and the convergence status. - With the opt-out, a cold datum lift applied a failed (NaN) increment. The lift is no longer taken from a failed solve. - tolerate_linear_failure is declared with the solver's other options. - The message uses solve_report.ksp_reason_string. That names -11 KSP_DIVERGED_PCSETUP_FAILED, as everywhere else, where a duplicate table had called it KSP_DIVERGED_PC_FAILED. - A hard failure is judged by the caller. The loop raises or warns, and the adjoint warns, so no "proceeding with the last iterate" warning prints before a raise. - test_1115 checks three things: - after a caught raise the records read failure and the fields are not written; - the opt-out writes the zero guess; - a warm start whose first step fails keeps its state, to 1e-8 (the write-back re-applies the rotation gauge, 3e-10). test_1116 fails rank 0 only: PETSc reduces the PC's failed reason, and every rank raises. Its timeout statement is corrected. - rotated-freeslip.md and the faults guide's status row describe the behaviour. All 342 serial tests and 27 tests/parallel tests at np 2 that touch the rotated path or fault contact pass. test_1116 passes at np 2 and 3. Underworld development team with AI support from Claude Code
…ot cached From the second adversarial review (of 4d57036): - fault_contact.solve_with_fault, and FaultNetwork.solve through it, call the loop directly and never raised. Since 4d57036 they left the fields unwritten with no warning, and the result's U was zero. They now raise the same message after recording the result. - A caught raise poisoned the cached workspace. PCMG and PCREDUNDANT never reset a failed preconditioner's reason at set-up, so every later solve on the solver failed at iteration 0, even with the cause removed. This was pre-existing for any hard failure on a cached solver. A workspace whose KSP failed hard is no longer cached; it is destroyed. - Two warnings before the raise contradicted it: the unconverged-exit warning, and the velocity sub-solve's. The first is skipped when the raise follows; the second prints only when the outer solve did not fail hard. rotated-freeslip.md no longer says an unconverged exit always leaves the last iterate. - The cold start is read before the warm path imposes the datum. A warm request on zero fields with a datum is a cold start. - On the raise path the result's rotation_gauge is None, not the previous solve's record. The Returns list documents linear_failure. - The getattr guard on the declared opt-out is gone. test_1115 gains four tests: a solve after a caught raise converges, solve_with_fault raises (a NaN forcing on test_0846's split box, reason -9), a warm request on zero fields with a datum raises, and a tolerated cold failure with a datum leaves finite fields. The first three fail on 4d57036. The last fails with round 1's lift guard removed. All 346 serial tests and 27 tests/parallel tests at np 2 that touch the rotated path or fault contact pass. test_1116 passes at np 2 and 3. Underworld development team with AI support from Claude Code
From the third adversarial review (of eac2c90): - The drop of a workspace that failed hard on a warm start, or after an accepted step, was untested: every new test reached it through the cold raise. test_1115's warm case now solves once more with the cause removed, and must converge. It fails when the drop is limited to the raise. - The tolerated cold failure with a datum leaves the fields exactly zero. The test asserted only that they were finite, which a datum snap after the failed lift would also satisfy. - rotated-freeslip.md gives the drop its own paragraph. It covers raised and warned failures alike, and states the cost: a full KSP set-up, 38.7 s to 76.5 s on a 39k-dof FMG fixture, paid every step by a time loop driven past round-off (#911). It also says the velocity sub-solve's warning gives way to the outer failure. - ROTATED_FREESLIP_LINEAR_REUSE.md lists a hard failure under Invalidation. - solve_with_fault and FaultNetwork.solve say they raise. split-node-faults.md says the rate-and-state loop's cold starts raise on a first-step failure. - adapt-on-top-faults.md no longer names solve_rotated_freeslip_nonlinear or a nonlinearity-probe dispatch; neither exists. Left open: #910 (a warm solve on the fast path fails at iteration 0 with no cause) and #911 (a solve past round-off fails its last linear solve; since this branch, a time loop rebuilds its KSP every step). test_1115 (7) and test_0846 pass. Underworld development team with AI support from Claude Code
Member
Author
Adversarial review, round 1 (bugfix/rotated-solve-raises-on-failure at 52d1789)Reviewed by a separate agent against Findings and what was done
Observed, not changed: after one forced failure on a cached solver, later solves kept failing at iteration 0 even with the cause removed. It looks like the failed reason stays latched on the cached KSP's PC. It was not shown for a failure PETSc raises itself. Issue verdicts
Adversarial review, round 2 (bugfix/rotated-solve-raises-on-failure at 4d57036)Reviewed by a separate agent, at np <= 3. Each new regression test was run on 4d57036 first and failed there. The datum-lift test was shown to fail with round 1's guard removed. Findings and what was done
Issue verdicts
Checked and sound
Adversarial review, round 3 (bugfix/rotated-solve-raises-on-failure at eac2c90)A narrow review of the round-2 commit by a separate agent, serial, in the worktree environment. Findings and what was done
Issue verdicts
Checked and sound
Underworld development team with AI support from Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A rotated free-slip solve whose first linear solve failed used to write its zero initial guess into the fields as if it were a solution, and only warned. This PR makes a cold start whose first linear solve fails raise, on every rank.
Closes #907
What was wrong
The rotated route runs its own Newton loop, and an outer linear solve that failed hard (a preconditioner that failed, a breakdown, a NaN) only warned. On a cold start, a failure at iteration 0 left the velocity at zero. A caller that did not read
_rotated_freeslip_info["converged"]took the zeros for a solution. Found with a singular multigrid coarse level under plain LU (#901).A second defect was found in the review. PCMG and PCREDUNDANT never reset a failed preconditioner's reason at set-up, so a cached workspace whose KSP failed hard failed every later solve on that solver at iteration 0, even after the cause was gone. That was already true on development.
The fix
solve_report.ksp_reason_string.converged = False, the KSP reason and a negative SNES reason.Stokes.solve, the vector solver,fault_contact.solve_with_faultandFaultNetwork.solve. The adjoint warns.solver.tolerate_linear_failure = True(declared on the solver base class) warns and continues, as before. The fields then hold the zero guess, and a failed datum lift is not applied.The standard SNES path is unchanged: it only warns on divergence.
Tests
solve_with_faultraises on test_0846's split box (reason -9) and keeps the fields.The rotated and fault-contact set passes: 346 serial and 27 parallel at np 2.
Docs
rotated-freeslip.mdstates the convergence contract, the opt-out and the cost of dropping a failed workspace.ROTATED_FREESLIP_LINEAR_REUSE.mdlists a hard failure under Invalidation.split-node-faults.mdsays the rate-and-state loop's cold starts raise.solve_with_faultandFaultNetwork.solvesay they raise.Review
Three rounds of adversarial review are in the first comment.
Issues
scripts/test.shconflicts withbugfix/rotated-fmg-coarse-solve(Rotated free-slip annulus: the FMG coarse level is a dense SVD on one rank, so more ranks make the solve slower (caps kaiju at np 16) #901): both add to batch 4.rotated_bc.pymerges cleanly.Underworld development team with AI support from Claude Code