Skip to content

test_1152: a failed assertion says how the solves ended and what the move left - #1096

Merged
lmoresi merged 4 commits into
developmentfrom
bugfix/test-1152-failure-record
Nov 12, 2026
Merged

lmoresi merged 4 commits into
developmentfrom
bugfix/test-1152-failure-record

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member

tests/parallel/test_1152_fac_zone_survives_a_mover_parallel.py[zone] failed once in a parallel run and has passed since. The assertion message held only the numbers it compared, so the red run could not be explained afterwards.

Each assertion in the test now carries a record of the move it failed on:

  • for the solve with the patch kept and for the one registered again: the solve's reason, the outer KSP's reason, the first and the last residual norm (from solver.solve_report, and from the rotated solve's record on the split level);
  • the velocity iteration counts of both;
  • the lowest cell quality the move left (mesh.quality()["q_min"]).

No assertion or bound is changed, and no library code.

What the record reads on a passing serial run (macOS), first two moves:

case move velocity its, kept / fresh q_min reasons first residual
zone 1 8 / 7 0.455 CONVERGED_FNORM_ABS, KSP_CONVERGED_ATOL (both) 13.757
zone 2 8 / 7 0.427 same 13.725
split level 1 17 / 16 0.433 KSP_CONVERGED_ATOL (both) 14.453
split level 2 17 / 17 0.364 same 13.921

The test's bound is "kept takes at most one velocity iteration more than fresh". On this host the zone case sits on that bound at both moves, so one more iteration on the kept side is a failure. These counts were taken on a build of the #1091 branch (PR #1094), which changes nothing a serial solve reads; they have not been taken on a build of development itself. The test file's comment gives 6 and 6, and 13 and 13, at np 1.

Serial: 2 passed in 134 s. Not run in parallel here.

Review, by the author (a test-only change; no second reviewer was used): every value in the record is the same on all ranks (q_min is reduced over ranks in mesh.quality, the reasons and norms come from collective solver state), so the assertion message does not differ between ranks; mesh.quality() reads coordinates only and is called between the two solves' set-ups, not inside one; the record is built whether or not an assertion fails, so a pass exercises the code that a failure would print. No open issue is in this change's territory.

Underworld development team with AI support from Claude Code

…move left

The zone case failed once in a parallel run and the message held only the
numbers compared. Each assertion now carries, for the solve with the patch
kept and the one registered again: the solve's reason, the outer KSP's
reason, the first and last residual norms; and beside them the velocity
iteration counts and the lowest cell quality after the move.

No assertion or bound is changed.

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings November 12, 2026 05:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…rs under it

The first red CI run that carried the record had it cut by pytest's
truncation of the assertion message, and the linear solvers' reasons were the
part cut. A move that fails a bound now prints its record before the assert,
past the capture, one key a line: the errors, the mesh quality, how each SNES
ended, and one line for the outer KSP and each solver under it (the
fieldsplit's velocity and pressure solves, every multigrid level, the FAC
smoother's SOR and ASM and the ASM's blocks) with its reason, its iteration
count, its preconditioner's failed reason and the norm of its operator. The
lines of the ranks are set side by side where they differ.

That separates the three readings of a linear solve that fails at its first
step on a healthy mesh: a factorisation that failed (DIVERGED_PC_FAILED, a
zero pivot on one block, SUBPC_ERROR above it), a NaN in the operator (a NaN
norm), and a sub-solve that diverged by itself (its own reason, no failed
preconditioner).

The iteration counts in the comments were stale. Measured on development
f8c6014 at np 1: kept and fresh 8 and 7 on the zone, 17 and 16 to 17 on the
split level; with no patch 10 to 13 and 17 to 19. The bound is unchanged.

Underworld development team with AI support from Claude Code
The record took each operator's norm with Mat.norm, which is collective, in a
walk of the solver tree that a rank leaves early where its preconditioner
never set up. Ranks would then make different numbers of collective calls and
hang. Each rank now reads its own rows of an operator (the sum of squares and
the count of entries that are not finite), the ranks' lines are matched by key
after one allgather, and the norm and the count are added up there. A line a
rank does not hold is said to be absent on that many ranks.

Underworld development team with AI support from Claude Code
…dist

The record of a failed move was printed past pytest's capture only. CI runs
this file serially under pytest-xdist, whose workers' own output does not
reach the controller, so the red run on df4bd01 showed the truncated
assertion and none of the record. It is now printed into the capture as well,
where pytest reports it under "Captured stdout call", and past it as before
for the runs under mpirun.

Checked with the failure forced in a copy of the test, under
`-n 1 --dist loadfile`: the whole record is in the report.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

PR #1096 at 149bd53, test_1152 failure record (H1, hyperion, 2026-11-12)

Verdict: READY at 149bd53.

Setup: library build development f8c6014 (wt-devf8c), with the test file from 149bd53 (a test-only change). A read-only plugin (plug/rec1096.py) wrote each move's record per rank and compared it across ranks with an allgather.

  • Both cases pass at np 1, 2 and 4.
  • The record (told, iterations and errors) is identical on every rank at every np.

Velocity iterations, kept/fresh, by move:

np zone 1 zone 2 zone 3 split 1 split 2 split 3
1 8/7 8/7 8/7 17/17 17/17 17/17
2 9/8 8/7 8/7 19/20 19/19 20/19
4 9/8 8/8 8/7 19/19 19/19 20/20
  • On development f8c6014 the zone case sits on the kept <= fresh + 1 bound in 8 of 9 moves.
  • The file's comment says 6/6 at np 1 for zone and 13/13 for split. That is stale for this development build.
  • Every solve ends converged: zone with CONVERGED_FNORM_ABS, split with KSP_CONVERGED_ATOL.
  • The kept-against-fresh velocity error is 1e-10 to 7e-9.
  • q_min is 0.33–0.50.

Wall time: np 1 536 s, np 2 356 s, np 4 266 s.

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

PR #1096 at df4bd01: the failure record at np 2

The record prints only when a move fails. To reach it, I forced the failure path with a read-only plugin that adds 100 to the kept solve's reported velocity iterations; the solver itself was untouched. I ran [zone] at np 2 on a development f8c6014 build, with df4bd01's test file.

  • The whole record printed once, and failed cleanly in 62 s (1 failed): no hang, and no "on other ranks" or "absent" lines.
  • Every solver line is present, from the outer ksp down to level3.pc1.blocks.
  • The summed operator norms are consistent: the outer ksp is 1083.4867 against split0's 1083.4860, and level3 equals split0. not_finite=0 throughout.
  • (My first attempt set TOLERANCE to 1e-30. That is also the solver's tolerance, so the solve never finished and the supervisor stopped it. That was my probe's fault, not the PR's.)

Log: df4/ff_np2.log.

Underworld development team with AI support from Claude Code

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.

2 participants