Repository navigation
A capped fieldsplit sub-solve says so, and a diverged solve warns (#585, #625, #1059) - #1062
Conversation
…625) PETSc does not count a sub-KSP that stops at its cap (DIVERGED_ITS) as a failure, so a Stokes solve can report convergence while its velocity or pressure block never solved. The Schur operator is applied through the velocity solve, and a capped velocity block hands the pressure Krylov an operator that moves between applications. The count was recorded (solve_report.sub[name].capped, and the transcript's t.capped()), but nothing said so at solve time. _warn_on_divergence, which every solver calls after its solve, now first warns once per capped block. The warning names the solver, the block and its cap, and points at the report's count and the two remedies. It does not fire during a bounded difficulty probe, where the caps are the point. The message carries no counts, so Python's warning filter shows it once per block in a time loop. Rank 0 warns; nothing collective. No cap value changes. Measured on the level_1 tier_a suite (1483 passed), the warning fired in four places: - test_0205's two deliberately capped solves; - the pressure block of a Stokes solve in test_0010 (200); - block 1 of the block-constrained Stokes path in test_1019 and test_1065 (200), named "field-1" since that path splits by field index. test_1160 (new, tier B): a velocity block capped at 2 warns exactly once, naming the block, while the solve still reports convergence; a solve within its caps is quiet. On development the first fails: the cap is recorded and nothing is said. Underworld development team with AI support from Claude Code
hyperion's review of 5bd1481: - F1: the cap warning is attributed to the caller's solve() line (_warn_from_caller); stacklevel=3 landed on memprobe's wrapper, so the filter showed it once per process, not per call site. The Stokes GAMG-fallback warning had the same fixed stacklevel and gets the same fix. - F5: the advice says a higher ksp_max_it helps only a block that converges slowly; a digit-named block is named by its DM fields (a constrained solve's field-1 is the pressure and its multipliers). - F6: the warnings come after _record_convergence_status, so under -W error rank 0 raises only after every rank has recorded the solve. - F2, F3: test_1160 counts the velocity block's warning, asserts the cap value, the attribution, one warning over a loop of solves whose counts differ, quiet under estimate_difficulty, and nothing off rank 0. Counts in the message, no probe exclusion, the outer KSP's cap and the old attribution each fail it. #1059: a solve that diverges warns (RuntimeWarning, rank 0, after the record), naming the reason and whether the fields hold the initial guess or the last iterate; the bounded difficulty probe's DIVERGED_MAX_IT does not. test_1161 (tier B) diverges by construction (ksp_divtol 1e-30) and fails without the warning. Underworld development team with AI support from Claude Code
… GAMG warning on rank 0 hyperion's review of 9bc93f7: - N1: test_1161 asserts that estimate_difficulty(1) on a nonlinear box stops at DIVERGED_MAX_IT without a divergence warning; removing the probe exemption fails it (it survived every test before). - N3: the Stokes GAMG-fallback warning is issued on rank 0 only, as the solve's other warnings; it printed once per rank. Underworld development team with AI support from Claude Code
Review record, round 1 of 2: 5bd1481 (pre-PR)9bc93f7 answers F1, F2, F3, F5 and F6 (partly); round 2 follows. Paths under Bundle D review: the sub-solve cap warning (#585, #625)Branch Verdict: the mechanism is sound (rank-uniform, no stale reports, the probe exclusion works, no regressions in the sample), but do not merge as is. The warning points at Method
Check 1: np 2, rank 0 only, rank uniformity
Check 2: the rotated pathThe probe is a rotated free-slip SolCx box (16x16, tolerance 1e-9,
Check 3: stacklevel and "once"
Time loop, default filters (
Check 4: stale reports
There are no stale reports, and the probe exclusion works. One note: a warm re-solve from a converged state runs no sub-applications, so Check 5: noiseW1's four files, level_1 tier_a selection, serial:
Serial sample of 29 files, level_1: Darcy x3, Poisson, Stokes Cart/Sph/nullspace/multigrid/SolCx, VE, VEP, NS SUPG, advection-diffusion, constrained x3, Nitsche, rotated free-slip, solve_report, guard, penalty, homotopy, Newton cold start, transcript, gauge, rate-strengthening and pc-fallback.
np 2, parallel solver files: 0780 VE Stokes, 1062 and 1063 constrained, 1077 advection-diffusion SUPG, 1078 NS SUPG, 1064 rotated.
Is the constrained field-1 cap genuine? I measured it with
Check 6: test_1160 and mutants
Check 7: regressions and warning filters
Check 8: issue verdicts
Findings
Merge conditions
Queued for np 4
Not tested
Addendum: tests that diverge on purpose (for W1's #1059 divergence warning)W1's next change makes How I built this list:
Tests where a warning would interact with a filter:
Verdict for W1: no test that diverges on purpose runs under an error filter. The new warning breaks nothing in this list.
Underworld development team with AI support from Claude Code |
Review record, round 2 of 2: 9bc93f79ebb02c answers N1 (the probe-exemption test), N3 (the GAMG fallback under rank 0) and F7 (issue keywords; the rotated-path gap is kept in #625). A check of 9ebb02c follows. Paths under Bundle D review, round 2 (9bc93f7)Branch Verdict: mergeable with two small conditions.
Method
Check 1: mutants
The exemption is live but untested. With the no-exemption mutant, test_1058's Check 2: test_1160 and test_1161 at np 1, 2 and 4
F2 is fixed: the np 2 failure from round 1 is gone, and np 4 passes too. Check 3: attributionPlain script (
Check 4: the GAMG-fallback warning at np 2
Check 5: F5 wording, and F6 under
|
| case | rank 0 | rank 1 | has_solution after (r0 / r1) | next collective | outcome |
|---|---|---|---|---|---|
| cap, solve in try/except | raises the cap warning | returns | True / True | integral ok; second solve ok | clean, rc 0 |
| divergence, in try/except | raises the divergence warning | returns | False / False | integral ok | clean, rc 0 |
| cap, uncaught | exception escapes; at exit stuck in MPI_Allreduce |
enters Integral.evaluate and is stuck in MPI_Allgather |
n/a | deadlock | the supervisor found no output for 90 s, reported the ranks in different collectives and killed the job (rc 124) |
- Every rank now reaches
_record_convergence_statusbefore the raise. That part of F6 is fixed:has_solutionagrees across ranks. - Rank 0 still raises while the others return. When the exception is uncaught, an np 2 job hangs rather than aborting (N2).
- The same applies inside pytest under
-W error: rank 0 fails the test at the solve, while rank 1 carries on to the test's later collectives. - Rank-0-only output and rank-symmetric control flow cannot both hold under an error filter. Warning on every rank would make the raise uniform, but it repeats the text N times (the GAMG fallback already does that).
- I recommend documenting this limitation rather than blocking the merge.
-W erroris opt-in.
Check 6: #1059 noise and accuracy
New divergence warnings issued (capcount counts them before any filter):
| run | divergence warnings | where | diverges on purpose? | accurate? |
|---|---|---|---|---|
| serial sample (31 files, 109 tests) | 6 | test_0203 x4 (guard cut: DIVERGED_LINEAR_SOLVE, "initial guess"); test_0017 x2 (SNES_Poisson DIVERGED_LINEAR_SOLVE, "initial guess"; the test sets simplefilter("ignore"), so neither is shown) |
yes, all six | yes. A cut or failed first linear solve leaves gvec at the guess. |
| test_1057 homotopy rescue (level_2, run separately) | 1 | the deliberate cold solve at line 286: DIVERGED_MAX_IT, "last iterate" | yes | yes. The homotopy march that follows, which converges in the end, issued none. |
| np 2 parallel files (6) | 0 | none | n/a | n/a |
| test_1058 bounded probes | 0 (6 under the no-exemption mutant) | none | (exempt) | n/a |
- Continuation and Picard tests in the sample (1068, 1071, 1067, 1052) issued none.
- No retry or homotopy path warned for an attempt it later recovered from. The noise is acceptable.
- Not covered, as before: the rotated path. Its failures still return before these calls (pyx 8235, 12822), and the docstring now says it covers the native path only.
Check 7: regressions
| run | branch 9bc93f7 | base |
|---|---|---|
| serial sample, level_1 (31 files: Darcy, Poisson, Stokes, VE/VEP, NS, advection-diffusion, constrained, Nitsche, rotated, solve_report, guard, penalty, homotopy, Newton, Picard, transcript x2, gauge, rate-strengthening, pc-fallback, 0205) | 109 passed, 63 warnings | 109 passed, 37 warnings |
| np 2: 0780, 1062, 1063, 1077, 1078, 1064 | 13 passed, 3 skipped (both ranks) | 13 passed, 3 skipped |
The branch has 26 more pytest summary entries than the base. 11 of the issued warnings are new: 6 divergence and 5 cap. The GAMG fallback was issued 64 times on each build. On the base those were attributed to memprobe.py:269, and on the branch they are attributed to each test's own line. I did not break the summary delta down entry by entry. No regressions.
Status of the round-1 findings
| finding | status | evidence |
|---|---|---|
| F1 attribution / once per process | fixed | user file:line in every context; case B shown |
| F2 test_1160 at np 2 | fixed | 6 passed at np 2 and np 4 |
| F3 test_1160 weak | fixed | all five cap mutants caught (every-rank at np 2) |
| F4 rotated path silent | open (follow-up) | unchanged; the docstring now scopes it out and points at #625. File it as its own issue. |
| F5 constrained advice and name | fixed | wording above |
F6 rank-divergent raise under -W error |
partly fixed | status recorded on every rank; uncaught raise at np 2 still deadlocks (N2) |
| F7 commit message accuracy and issue keywords | open, trivial | 9bc93f7 has no Fixes/Refs keywords and does not correct 5bd1481's firing list. The PR body should carry "Fixes #585 (native path), Refs #625, Fixes #1059", plus the rotated follow-up. |
New findings
- N1 (low, merge condition): test_1161 does not cover the -5 difficulty-probe exemption. The no-exemption mutant passes 1160, 1161 and 1058. Add one probe case asserting no "the solve diverged" warning.
- N2 (low, document): under
-W error::RuntimeWarningat np 2, an uncaught rank-0 cap or divergence warning deadlocks the job: rank 0 in Allreduce at exit, rank 1 in the next collective. This was measured and killed by the supervisor. It is inherent to rank-0-only warnings. - N3 (minor): the GAMG-fallback warning is shown once per rank (N copies at np N), unlike the cap and divergence warnings.
- N4 (info): the constrained block label lists every multiplier field (up to
multiplier_3here), which grows long with many constraints. It is accurate.
Issue verdicts
- Stokes velocity KSP truncates silently at its default 200-iteration cap #585: fixed on the native path. The rotated path remains (F4 follow-up).
- Stokes pressure sub-solve runs at its 200-iteration cap — the inner Schur solve is silently unconverged and dominates solve time #625: not fixed. Use Refs.
- Stokes at viscosity >= 1e11 (PETSc frame): the velocity sub-solve returns NaN at iteration 0 and the solve returns u = 0 #1059: fixed for native solves. A diverged solve now warns, accurately, once per reason and call site, on rank 0. The rotated path is not covered.
Not tested
- Jupyter display.
- The GAMG fallback attribution with memprobe or timing on alone (both on and both off were measured).
-W errorat np 4.- Stokes at viscosity >= 1e11 (PETSc frame): the velocity sub-solve returns NaN at iteration 0 and the solve returns u = 0 #1059's actual viscosity ≥ 1e11 case (test_1161 uses the ksp_divtol fixture).
Underworld development team with AI support from Claude Code
Underworld development team with AI support from Claude Code
Check of 9ebb02c (head now 189ca99, a merge of development)189ca99 merges development into 9ebb02c. Against its merge-base with development, the branch still touches only D's five files: the .pyx, solvers.py, test_1160, test_1161 and test.sh. So this check of 9ebb02c covers the code. Bundle D (PR #1062), check of 9ebb02cThe change from 9bc93f7 is in Verdict: N1 and N3 are closed, and nothing regressed. From this check's side, 9ebb02c is fine to merge. F4 (the rotated path) and N2 (a rank-0-only raise under
On the solvers.py diff: the message's inputs ( Underworld development team with AI support from Claude Code |
The finite-difference test builds each SNES with a solve stopped at 0 iterations, which since #1062 warns that the solve diverged. The test now expects that warning, so it runs clean under -W error::RuntimeWarning. Underworld development team with AI support from Claude Code
A sub-solve stopped at its cap. PETSc does not count a fieldsplit sub-KSP that stops at its iteration cap (
DIVERGED_ITS) as a failure. The outer solve can then converge while a block never solved: the Schur operator is applied through a velocity solve that is inexact and varies between applications. The count was recorded (solve_report.sub[name].capped), but nothing said so at solve time._warn_on_capped_sub_solvesissues one RuntimeWarning per capped block, after the solve has recorded its status, on rank 0:field-1 (pressure + multiplier_0 + ...)is the pressure and its multipliers, solved as one Schur block.ksp_max_ithelps only a block that converges slowly, and one that stagnates needs a better preconditioner. On the constrained parallel tests, a cap of 5000 still caps, at 11 times the wall time.solve()line (_warn_from_caller), so the default filter shows it once per block and call site in a time loop.estimate_difficulty, whose caps are the point.A diverged solve. A solve that diverges printed a notice and returned, so a script carried on with whatever the fields held. At a viscosity of 1e11 or more in PETSc's frame that is u = 0 (#1059).
_warn_on_diverged_solveadds a RuntimeWarning, after the record and on rank 0. It names the reason and whether the fields hold the initial guess or the last iterate. The bounded difficulty probe'sDIVERGED_MAX_ITis exempt.The Stokes GAMG-fallback warning used a fixed
stacklevelthat landed on memprobe's wrapper, and it printed on every rank. It now goes through_warn_from_calleron rank 0.Where it fires
In the test suite, the cap warning fires in:
The divergence warning fires in test_0203 (×4, a deadline on purpose) and test_0017 (×2, filtered). A converging homotopy run issues none.
Tests
tests/test_1160_a_capped_sub_solve_says_so.py(new, tier B). A velocity cap of 2 warns once, on rank 0 only. The message has the cap value and is attributed to the test file. A loop of solves whose capped counts differ shows it once.estimate_difficultyis quiet, and a solve within its caps is quiet. These mutants each fail it: counts in the message, no probe exclusion, the outer KSP's cap, the old attribution, and warning on every rank (np 2).tests/test_1161_a_diverged_solve_warns.py(new, tier B). A solve that diverges by construction (ksp_divtol 1e-30, so independent of Stokes at viscosity >= 1e11 (PETSc frame): the velocity sub-solve returns NaN at iteration 0 and the solve returns u = 0 #1059's cause) warns once on rank 0, with the reason and "initial guess". A converged solve and a bounded probe'sDIVERGED_MAX_ITdo not warn.Limits
-W error::RuntimeWarningin parallel. Only rank 0 warns, so only rank 0 raises. Uncaught, its exception leaves while the other ranks enter the next collective, and the run hangs. Both warnings are issued after every rank has recorded the solve, sohas_solutionagrees across ranks. Caught in a try/except, it is clean.Issues
Underworld development team with AI support from Claude Code