Repository navigation
Reload a refined mesh's checkpoint correctly on any rank count (#690) - #1063
Conversation
Mesh(file) rebuilds a refined mesh's multigrid hierarchy by refining the coarse sidecar. The rebuilt fine mesh is the saved one, numbered and distributed differently, but the reload paired the saved coordinates with a serial refinement of the sidecar by array index, which holds only for a serial write. A mesh written on two or more ranks came back on every rank count with cells joined to the wrong vertices (integral of 1 negative), and the mesh SF (file-to-loaded composed with the coarse distribute) made read_checkpoint fail on more ranks than wrote. The reload now matches every point of the rebuilt fine mesh to its point in the file: vertices by reference position, other points by the file ids of their closure vertices. The match gives the mesh SF and the saved coordinates. Mesh.write stores each fine vertex's reference coordinates, so the match is exact for a moved mesh; an older file falls back to its saved coordinates, and if the match does not close the fine mesh reloads without its hierarchy, with a warning. It never returns a corrupt mesh. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
H1's review (F1): a rank-local fallback passed every test and hangs at np 2. A new parallel test perturbs the stored reference coordinates over part of the domain, so the match fails on some ranks only, and requires a flat reload on every rank; the rank-local mutant hangs in it. F3: the cross-np test gains a quadrilateral case, which fails on development already at write np 1, read np 2. The parallel test's file edits broadcast whether the reference coordinates were present, so a file without them fails the test on every rank instead of aborting rank 0. F4: the stamp's consistency check raises on every rank together. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
H1's adversarial review of ec4ac3c (the record from Review of the #690 fix: bugfix/refined-reload-690 (ec4ac3c)Verdict: #690 is fixed. Merge, provided the test suite gains a case where the match fails on only one rank (F1). Nothing found is a correctness defect in the branch. Reviewer: H1, 2026-11-11, on hyperion. Requested by H5 (mail/H1/2026-11-11-H5-690-review-request.md). Method
Check 1: ReproductionH5's new tests
Development fails as H5 says, with one exception. The 1→2 case passes on development, because development's 1→N section failure does not show at N = 2 on triangles: it needs hex at np 2, or np 4. So that parametrisation does not tell the builds apart (F3). Review matrix
A row counts as correct when all of these hold:
The full per-row table is in
H5's files and H2's snapshotsThese were read in place with H5's own
mmpde5's 2.356200 is the area of the saved moved polygon, read by the unrefined path. It differs from the exact π·0.75 by 6e-6, as a moved polygonal annulus should. Check 2: The SF contract
Check 3: Collective safetyCode [read]:
Measured. Inputs were made from a branch-written np-2 box2 (copies in
M4's hang and abort show that the failure really was confined to some ranks. The branch's allreduce turns that into a uniform fallback. No hang in any branch run. Check 4: Reference coordinates
Check 5: The cKDTree stamp and tolerance[read] Neither cKDTree query crosses ranks.
Measured:
Check 6: ScalingUnit box at refinement 2, written at np 4, reloaded on the branch (
Check 7: 3D, quads and annulus refinement 2Covered in the check 1 matrix and in sf_check:
Each was written at np 1, 2 and 4 and read at np 1, 2 and 4, with all six field types, and is exact everywhere on the branch. Quad face-centre vertices are found by the exact reference match, so they are bit-identical across distributions. Check 8: End-to-end restartH2's
Check 9: Regressions and mutants
Mutants:
Check 10: Issue verdict#690 is fixed. Every combination the issue tabulates now reloads exactly, with its fields, through both readers, and with the multigrid hierarchy:
H2's production restart, which hung or gave NaN, now solves with FMG and matches a fresh mesh. Old files are handled without silent corruption:
FindingsMedium
Low
Informational
Merge conditions
Queued for np 4Nothing remains queued. The coordinator raised the limit to 6 cores during the review, and every np-4 item in
The file is kept, annotated, as the record. ptest_0004 at np 3 and 4 was run last, by hand. Not tested
Records
Underworld development team with AI support from Claude Code |
H1's check of 9d7cb62: on development the quad case fails only when written on two ranks, not at write np 1, read np 2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
On the quad case (H5). The cross-np test's quad case catches the bug when the file is written on two ranks (2→1 and 2→2), like the simplex cases. It does not catch it at 1→2: on development a quad box written serially reloads correctly at np 2, and only hexahedra fail there. My comment in the test claimed otherwise; 161e925 corrects the comment, and the test logic is unchanged. A hexahedral 1→2 case would catch it, but on development it hangs inside DMPlexSectionLoad instead of failing, so I've left it out of the default suite. Underworld development team with AI support from Claude Code |
Fixes #690 (and its duplicate #809).
What changed and why
The bug.
Mesh(file)rebuilds a refined mesh's multigrid hierarchy by refining the coarse sidecar. The rebuilt fine mesh is the saved one, numbered and distributed differently._splice_hierarchy_from_sidecarpaired the saved fine coordinates with a serial refinement of the sidecar by array index, which holds only for a serial write. Two things followed:sf0 ∘ (coarse distribute SF), which doesn't map the file's points to the rebuilt DM.read_checkpointtherefore failed on more ranks than wrote ("0 dofs for point").The fix:
_match_file_pointsmatches every point of the rebuilt fine mesh to its point in the file. Vertices are matched by reference position; every other point by the file ids of its closure vertices. The match gives the mesh SF, and the saved coordinates, which are stamped on.Mesh.writenow stores each fine vertex's reference coordinates, the refined coarsest level with no callback and no motion (_view_reference_coordinates). So a moved (MMPDE) mesh matches exactly.docs/developer/design/fmg-checkpoint-hierarchy.mdis updated, replacing its superseded Simple-partitioner section.Evidence
write_timestep/read_timestepandwrite_checkpoint/read_checkpoint. ∫1 is exact and a P2T = xcomes back exact.sf0.compose(sf1). H1's review record follows as a comment.Tests (fail on development, pass here)
tests/test_0690_refined_checkpoint_cross_np.pywrites and reads in subprocesses, with write/read rank counts 2→1, 1→2 and 2→2. It covers a simplex box, a moved box (moved nearly a fine cell), an annulus and a quad box, and checks ∫1, the field through both readers, and the restored hierarchy.tests/parallel/test_0690_refined_checkpoint_reload_parallel.py(np 2 and 4) covers:check_test_coverage.pyreports OK; both files are reached by the existing globs.Follow-up
Reload cost and memory: the tables are allgathered at about 85 B per cell on every rank, and the serial reload is about 7× development's. Filed as #1064.
Checklist (UW3 Style Charter)
level_*andtier_*markers (S8).array/mesh.X.coords(S7). No new field access.pixi.toml/pixi.lockor other dependency changesUnderworld development team with AI support from Claude Code