Skip to content

Reload a refined mesh's checkpoint correctly on any rank count (#690) - #1063

Merged
lmoresi merged 3 commits into
developmentfrom
bugfix/refined-reload-690
Nov 11, 2026
Merged

lmoresi merged 3 commits into
developmentfrom
bugfix/refined-reload-690

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

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_sidecar paired the saved fine coordinates with a serial refinement of the sidecar by array index, which holds only for a serial write. Two things followed:

  • A mesh written on 2+ ranks reloaded on every rank count with cells joined to the wrong vertices. ∫1 came back negative: a box at refinement 2 gave −0.023, and an annulus gave −0.478 against 2.356. That includes a serial reload, so saved runs couldn't be viewed in house either.
  • The mesh SF was sf0 ∘ (coarse distribute SF), which doesn't map the file's points to the rebuilt DM. read_checkpoint therefore failed on more ranks than wrote ("0 dofs for point").

The fix:

  • Matching. _match_file_points matches 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.
  • Reference coordinates. Mesh.write now 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.
  • Older files. A file written before this change falls back to its saved coordinates. If the match doesn't close, the reload warns and loads the fine mesh without its hierarchy, which is always correct. The decision is collective. A corrupt mesh is never returned.
  • Design note. docs/developer/design/fmg-checkpoint-hierarchy.md is updated, replacing its superseded Simple-partitioner section.

Evidence

  • Reduction matrix: box and annulus, refinement 0–2, written at np 1 and 4, read at np 1, 2 and 4, through both write_timestep/read_timestep and write_checkpoint/read_checkpoint. ∫1 is exact and a P2 T = x comes back exact.
  • H2's production snapshots:
    • step4850 (written at np 4) and step3900 reload with ∫1 = 2.356194 and the hierarchy restored.
    • mmpde5 step3550 (np 12, a moved mesh, old format) reloads flat, with a warning, and is correct.
    • The step3900 restart with FMG on the velocity block now solves: vrms 825.3722 against 825.3717 on a fresh mesh, where development hung.
  • Adversarial review (H1): 228 reads, all exact. They cover 2D and 3D; triangles, tets, quads and hexes; P1–P3, vector and DG fields; np 1, 2 and 4. The SF is equivalent to sf0.compose(sf1). H1's review record follows as a comment.

Tests (fail on development, pass here)

  • tests/test_0690_refined_checkpoint_cross_np.py writes 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:
    • a moved mesh with a working FMG Poisson solve;
    • the old-file fallback, with the hierarchy restored when the mesh is unmoved and flat when it is moved;
    • a match that fails on some ranks only, which must reload flat on all ranks. A rank-local fallback mutant hangs here (H1's merge condition F1).
  • Neighbours pass: test_0004, test_0003, test_0074, test_1016*, test_0005*, test_1012, ptest_0004 at np 2, 3 and 4, ptest_1020 and ptest_0864. check_test_coverage.py reports 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)

  • I have read the Style Charter and followed it over the surrounding code (S2)
  • No drive-by refactors, renames, or "while I was here" cleanups (S9)
  • Bug fixes ship the regression test, written first, with level_* and tier_* markers (S8)
  • No hedging names and no commented-out code (S3, S4)
  • Every exception swallow states its sanctioned failure mode in a comment (S4)
  • New data access uses .array / mesh.X.coords (S7). No new field access.
  • Parallel safety considered: np 2 and np 4 checked, every fallback decision collective (S11)
  • No pixi.toml / pixi.lock or other dependency changes
  • AI-assisted work carries the attribution line below

Underworld development team with AI support from Claude Code

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>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 12:23

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.

@lmoresi

lmoresi commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

H1's adversarial review of ec4ac3c (the record from $HYPERION_WORK/runs/2026-11-11-690/review/690-review.md, posted by H5). Merge condition F1 is addressed in 9d7cb62, together with F3 and F4. F2 is filed as its own issue.

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

  • Builds.
    • Branch: wt-690r at ec4ac3c, as installed. I checked that the installed discretisation_mesh.py is byte-identical to git show ec4ac3c0:....
    • Development base: wt-910 (activate.sh 910 r690b). I used it instead of a runtime module swap. Its installed discretisation_mesh.py and discretisation_mesh_variables.py are byte-identical to 8417977. Only rotated_bc.py differs, and checkpoint reload does not use it. Both builds run PETSc 3.25.3.
    • Throughout this record, "dev" means that build.
  • Mutants. Each is a copy of the installed branch package under review/scratch/ov-M*, with one edit made by probes/mutate.py, put first on PYTHONPATH. Every run asserted that the mutant was the module actually imported. These are package copies, not builds.
  • How tests ran.
    • From a git archive of ec4ac3c (scratch/arch-ec4), with PYTHONDONTWRITEBYTECODE=1 and -p no:cacheprovider.
    • All MPI ran under scripts/mpi_supervisor.py.
    • TMPDIR pointed into review/scratch/tmp.
    • ptest_0004 hardcodes /tmp/_ptest_0004…. In the archive copy only, I changed that path to review/scratch/pt0004.
  • Cores.
    • The limit was 2 until the coordinator raised it to 6 partway through.
    • np-4 jobs then ran one at a time, beside at most one 2-core job.
    • The serial pytest that spawns the cross-np workers sits idle while they run. I did not count it as a core.
  • Files written. Only under review/. H2's snapshots and H5's runs/h5-690 files were read in place, read-only. No git or GitHub writes, no builds.
  • Probes, all in review/probes/:
    • fields_rw.py writes a refined mesh carrying analytic fields, with both write_checkpoint and write_timestep.
      • Fields: P1, P2 and P3 scalars, a P2 vector, DG0 and DG1. The values are the nodal values of a non-polynomial f, or f at the cell centroid for DG0.
      • On reload it records the integral of 1, and whether the set of cells, each keyed by its sorted vertex coordinates, equals the written set.
      • It also records the fine-vertex coordinate set difference, the per-level vertex set difference against the written hierarchy, and the pointwise field error through both readers.
    • sf_check.py checks the matched SF point by point.
    • coll_prep.py and coll_read.py build and run the one-rank-failure cases.
    • misc_rw.py covers named meshes, adapt children and coarsening.
    • chain.py does a restart of a restart.
    • scale.py measures reload cost.
    • stokes_fmg.py runs the restart Stokes solve.
  • Labels. Statements marked [read] come from reading the code and were not measured. Everything else was measured; the logs are in review/logs/.

Check 1: Reproduction

H5's new tests

test branch development
test_0690_refined_checkpoint_cross_np.py (serial pytest; 2→1, 1→2, 2→2) 3 passed 2→1 and 2→2 fail (ts_box integral of 1 = −0.0927); 1→2 passes
tests/parallel/test_0690_…_parallel.py, np 2 3 passed aborts ("stack smashing detected", signal 6)
same, np 4 3 passed not run

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

  • Cases:
    • box2: simplex box, cellSize 0.25, refinement 2, 672 cells.
    • moved2: box2 moved by up to 0.06, about one finest cell.
    • ann2: annulus, refinement 2.
    • tet1 and tet2: 3D tet box, refinement 1 and 2.
    • quad1 and quad2: quad box, refinement 1 and 2.
    • hex1: hex box, refinement 1.
  • Coverage:
    • Written on each build at np 1 and 2, and on the branch at np 4.
    • Read by each build at np 1, 2 and 4. Development's np-4 reads cover only box2 and hex1.
    • Both readers in every case.

A row counts as correct when all of these hold:

  • the integral of 1 equals the written value to a relative 1e-12;
  • the cell sets are identical;
  • the fine vertex sets are identical;
  • every field error is below 1e-13.
written read rows correct flat (warned) max field error box2 integral of 1 incorrect cases
branch np1 branch np1, np2, np4 48 48 0 1.3e-15 1.000000 -
branch np2 branch np1, np2, np4 48 48 0 1.8e-15 1.000000 -
branch np4 branch np1, np2, np4 36 36 0 1.3e-15 1.000000 -
dev np1 branch np1, np2, np4 48 48 6 (moved2) 1.3e-15 1.000000 -
dev np2 branch np1, np2, np4 48 48 6 (moved2) 1.8e-15 1.000000 -
branch np1 dev np1 / np2 16 / 14 all 0 1.3e-15 1.000000 hex1 at np 2 hangs (PETSc error in DMPlexSectionLoad on one rank)
dev np1 dev np1 / np2 / np4 16 / 14 / 0 all that ran 0 1.3e-15 1.000000 hex1 at np 2 hangs; box2 and hex1 at np 4 hang
branch np2 dev np1 / np2 10 / 10 0 0 3.1 −0.092678 ann2, box2, moved2, quad1, quad2; tet and hex runs error or hang
dev np2 dev np1 / np2 10 / 10 0 0 3.2 −0.092678 the same
branch np4 dev np1 / np2 / np4 10 / 8 / 4 0 0 3.3 −0.022923 the same; others error or hang

The full per-row table is in logs/matrix_table.md.

  • The branch is exact on every one of its 228 reads: 2D, 3D, quad, hex and annulus, both readers, written at np 1, 2 and 4, read at np 1, 2 and 4.
  • It restores the hierarchy in every case except development-written files of moved2. Those are old files of a moved mesh, and they correctly fall back to flat, with a warning, and stay exact.
  • Development reproduces the issue's numbers:
    • box r2 written at np 4: −0.0229 (issue: −0.023);
    • annulus r2 written at np 4: −0.478 (issue: −0.478);
    • box written at np 2: −0.0927, as in H5's test;
    • quad, hex and tet are corrupt too, or error out.

H5's files and H2's snapshots

These were read in place with H5's own read.py and snap.py.

input branch np1 branch np2 dev np1 dev np2
out4 (branch, np 4), box/annulus r0–2 all exact, levels restored all exact box r1 −0.421, box r2 −0.0229, ann r1 0.0569, ann r2 −0.478 same
dev-out4 (development, np 4) all exact (via fallback match) all exact same corruption same
out1 (np 1), read at np 2 - all exact - all exact
H2 fixed/step4850 levels 3, integral of 1 2.356194 2.356194 −0.698332 −0.698332
H2 first/step3900 levels 3, 2.356194 2.356194 −0.393793 −0.393793
H2 mmpde5/step3550 levels 1 (flat, warned), 2.356200 2.356200 0.374348 0.374348

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

  • What PETSc documents (DMPlexTopologyLoad, DMPlexSectionLoad and DMPlexGlobalVectorLoad manual pages, 3.26):
    • The topology SF "pushes points in [0, N) to the associated points in the loaded DMPLEX".
    • DMPlexSectionLoad uses the saved global point numbers in [0, NX) and the SF "associates each topology point in dm with a global number in [0, NX)".
    • The pages say nothing about which leaves are required, or about composing with a distribution SF.
  • What the code builds [read]:
    • _match_file_points takes the roots from sf0's graph. Root (rank, index) is the chunked file layout of the file's point numbering, the same layout DMPlexSectionLoad uses for the field file's "order" dataset.
    • Its leaves are arange(chart) of the rebuilt DM.
    • That is the contract sf0.compose(sf1) has after a distribute:
      • every local point, shared ones included, is a leaf of the root for its file point;
      • shared points give a root several leaves.
  • Measured (sf_check.py): data is carried from the loaded DM to the roots through sf0, then to the rebuilt DM through the new SF, and compared with the same data computed on the rebuilt DM. This covers each point's closure-vertex centroid and its ordered cone as file ids, which captures edge direction and cell cone rotation.
file np 1 np 2 np 4
box2 (written np 4), tet1 (np 4), hex1 (np 4), ann2 (np 1), quad2 (np 2), tet2 (np 1) leaves = chart; centroid mismatch 0.0 and cone-order mismatches 0 at every depth same same
  • Root degree: 1 at np 1. Up to np at np > 1 for both sf0 and the new SF; these are the shared points.
  • Conclusion: the new SF is equivalent to sf0.compose(sf1) as sectionLoad uses it.
  • Fields, with values on every refined level of the fine mesh:
    • P1, P2, P3, P2 vector, DG0 and DG1 all reload pointwise to ≤ 1.8e-15 at np 1, 2 and 4 (check 1 matrix, ck rows).
    • P3 (two dofs per edge) and DG1 (cell closure order) would expose any orientation mismatch; there was none.
    • DG fields are supported by both writers.

Check 3: Collective safety

Code [read]:

  • _load_reference_coordinates decides on rank 0 and broadcasts.
  • In _match_file_points:
    • exact is an allreduce;
    • every allgather comes before any rank-local decision;
    • the closure loop's break is local and makes no collectives;
    • the single decision point is allreduce(ok, LAND).
  • The fallback is return False on every rank, after the coarsest-level distribute and refines that every rank has already done. Then comes the ordinary unrefined path.
  • The deferred stamp raises a RuntimeError rank-locally if the coordinates changed between the match and the stamp. That cannot happen in this flow, but the raise is not collective (F4).

Measured. Inputs were made from a branch-written np-2 box2 (copies in scratch/coll/):

  • refpert: reference coordinates of the 122 vertices with x < 0.3 shifted by 1e-3, so only those ranks fail the exact match.
  • oldlocal: reference coordinates removed and the saved geometry moved by a bump of up to 0.045 (more than half the 0.0625 spacing) in x < 0.3 only. The match fails only where the bump is.
input branch np 2 branch np 4 mutant M4 (rank-local fallback) np 2 M4 np 4
refpert flat on every rank [1, 1], warned once, integral of 1 1.000000000000, P2 exact flat [1, 1, 1, 1], exact hangs (supervisor: stuck in nuke_coords_and_rebuild) MPI abort (Allreduce message truncated: mismatched collectives)
oldlocal flat [1, 1], integral of 1 1.000000000000 flat on all 4 hangs MPI abort

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

  • Moves. MMPDE-style deform before writing (moved2, nearly one fine cell) restores exactly, with the hierarchy, written at np 1, 2 and 4 and read at np 1, 2 and 4.
  • Refinement callback. The annulus callback snaps the boundary; ann2 restores exactly. [read] _view_reference_coordinates refines dm_hierarchy[0] the way the reload does, and the coarse levels are never moved by deform, so the written references and the reload's rebuild are the same geometry.
  • Restart of a restart. An np-4 file was reloaded at np 2, re-written, then read at np 1 and 4 (chain.py). moved2, ann2, tet1 and quad1 are all exact, with the hierarchy, cells identical and fields ≤ 9e-16.
  • adapt(). The child of a refined box (max_levels=1) has a single-level hierarchy. So it writes no sidecar and no reference coordinates, and it reloads flat and exact at np 1 and 2 on both builds.
  • Coarsening and remesh. Not testable: this PETSc has no mmg or parmmg (Mesh(coarsening=1) raises; test_1016_mesh_multigrid_levels skips for the same reason).
    • [read] The chart check compares only stratum sizes.
    • A hierarchy whose fine level has the same sizes as refine(coarsest) but a different numbering would write wrong references. This is unlikely; remesh() leaves dm_hierarchy stale, which is pre-existing.
    • The reload's closure check would then fail and fall back flat. The outcome is safe but loses FMG (F6).
  • DM rename to uw_mesh during write:
    • The name is restored (uw_foo before and after, measured).
    • A named, moved, refined mesh written by write_timestep and by write_checkpoint at np 2 reloads exactly, with the hierarchy, at np 1 and 2 on the branch.
    • On development the same file is corrupt (−0.112). That is the pre-existing reader bug, not the rename.
    • The extra topologies/uw_mesh/dms/uw_reference_coordinates group is ignored by development. [read] The only other code that walks dms groups (_petsc_payload_name) does so in field files, not mesh files.
  • Both directions:
    • Development-written files on the branch:
      • all correct;
      • unmoved ones keep their hierarchy (matched by saved coordinates);
      • moved ones fall back flat with a warning.
    • Branch-written files on development behave exactly as development-written files do there:
      • correct when written at np 1 (except hex1 at np 2, which hangs, as development does on its own files);
      • corrupt when written at np ≥ 2.
    • No new incompatibility.

Check 5: The cKDTree stamp and tolerance

[read] Neither cKDTree query crosses ranks.

  • The stamp's query: each rank queries its own rebuilt vertices, as stored at match time, against its own coordinate array. A match in another rank's portion cannot arise.
  • The match's query: it is against the allgathered table, so ghost and shared vertices find their file vertex wherever it was loaded.

Measured:

  • Shared vertices: across all the np 2 and np 4 reads, no vertex mismatch (sf_check depth 0, centroid mismatch 0).
  • Tolerance: exact match within 1e-8·max(extent, 1).
    • Measured on a 1e-6-wide and a 1e6-wide refined box, written at np 2 and read at np 1. Both are exact, with the hierarchy.
    • The same files with their references removed (old-file path) also restore.
    • The references are bit-identical by construction, so in practice the tolerance only has to absorb nothing.
  • Old-file path: no distance bound at all. Nearest neighbour, a local uniqueness check, then the closure check (F5). The oldlocal case shows a partly wrong vertex match is caught by the closure check and falls back.
  • Periodic meshes [read]: no refined periodic mesh is built in uw3 here; not tested.
  • Duplicate-coordinate meshes, such as split faults [read]: the vertex uniqueness check fails, so they would reload flat.

Check 6: Scaling

Unit box at refinement 2, written at np 4, reloaded on the branch (scale.py). "Gathered" is the size of everything _match_file_points allgathers, as held on each rank.

cells np Mesh() of which match gathered per rank Python peak in match per rank RSS peak per rank
38,400 1 / 2 / 4 8.8 / 5.2 / 2.6 s 7.7 / 4.5 / 2.2 s 3.3 MB 35 / 19 / 11 MB 426 / 382 / 366 MB
152,224 1 / 2 / 4 30.9 / 15.7 / 8.3 s 27.1 / 13.8 / 7.1 s 12.8 MB 134 / 69 / 38 MB 768 / 561 / 450 MB
607,488 1 / 2 / 4 121.6 / 63.2 / 32.6 s 105 / 55 / 28 s 51 MB 527 / 271 / 147 MB 2099 / 1244 / 800 MB
152,224, development 1 4.4 s (and wrong) - - - 630 MB
  • Time: the match costs about 0.18 ms per cell per rank, serial, and halves with each doubling of ranks. It is dominated by the per-point Python closure loop.
  • Against development: the reload is about 7 times slower serially (30.9 s against 4.4 s at 152k cells).
  • Memory: the gathered tables are about 85 bytes per 2D triangle cell, replicated on every rank whatever the np.
  • Projections [projection, not measured]:
    • 10 M triangles: about 0.85 GB per rank in tables, and 30 min serially, or about 30 s at np 64 for the local loop. The global per-key sort then runs over the whole table on every rank.
    • A 3D tet mesh has about 1.5 times as many vertices, edges and faces per cell, with wider keys. Estimate about 3 to 4 times the bytes per cell: some 3 GB per rank at 10 M tets. At 64 ranks per node that is not feasible.
  • Silence: a serial 607k-cell reload is silent for over 2 minutes. The supervisor's 120 s silence watchdog killed it just after it finished.
  • Assessment: H2's 372k-cell case (28 s serial per H5) is fine. A distributed match is needed before meshes of order 10 M cells (F2).

Check 7: 3D, quads and annulus refinement 2

Covered in the check 1 matrix and in sf_check:

  • tet refinement 1 and 2;
  • quad refinement 1 and 2;
  • hex refinement 1;
  • annulus refinement 2.

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 restart

H2's first/step3900 was written at np 4, at refinement 2. The velocity block uses Stokes FMG, mg/full with 3 levels, as in H5's stokes_snap.py. T is read by read_timestep in both runs.

run np 2 np 4
branch reload levels 3; velocity PC built 3 MG levels; vrms 825.371755; 4 velocity KSP iterations; 5.1 s 3 levels; vrms 825.372164; 4 iterations; 2.0 s
branch fresh Annulus(cellSize 1/8, refinement 2) 3 levels; vrms 825.372159; 4 iterations; 2.9 s 825.371736; 4 iterations
development reload hangs (stuck in a collective; killed after 90 s of silence) hangs
development fresh 825.372159 825.371736
  • Agreement: reload and fresh agree to 5e-7 relative. That is the same spread as fresh at np 2 against fresh at np 4, so it is solver tolerance (1e-5).
  • FMG is used: the velocity PC has 3 MG levels and the same iteration count as the fresh mesh.
  • Coarse levels:
    • The reloaded L0 is identical to the written L0, and the fine level is identical.
    • The reloaded intermediate L1 on the annulus is a plain refine of L0, not callback-snapped, so its boundary midpoints sit up to 0.0125 inside the circle. On the live mesh they are snapped.
    • This is the same on development (pre-existing) and has no measurable effect on FMG here (F7).
    • The box and the moved box have identical levels.

Check 9: Regressions and mutants

suite branch development
serial: test_0003_save_load, test_0004_checkpoint_fmg_hierarchy, test_0005_* (7 files), test_0074, test_1012, test_1016_* (4 files) 88 passed, 1 skipped (mmg) 88 passed, 1 skipped
ptest_0004 at np 2 OK: 3 levels, FMG in 2 iterations OK
ptest_1020 at np 2 PASS PASS
ptest_0864 (split checkpoint and seam ligament) at np 2 7 passed 7 passed
test_0690 parallel at np 4 3 passed not run
ptest_0004 at np 3 / np 4 OK: 3 levels, FMG in 2 / 3 iterations not run

Mutants:

mutant cross-np test parallel test, np 2 review collective probe caught?
M1: saved coordinates paired by index 3 failed hang (exit 124) - yes
M2: SF not rebuilt (sf stays file→loaded) 2→1 and 2→2 failed 2 failed - yes
M3: no reference coordinates written 3 failed aborts - yes
M4: rank-local fallback 3 passed 3 passed hangs at np 2, aborts at np 4 not by H5's tests (F1)

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:

  • written on 1, 2 or 4 ranks;
  • read on 1, 2 or 4 ranks;
  • box and annulus, plus 3D, quad and hex.

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:

  • unmoved ones keep the hierarchy;
  • moved ones reload flat with a warning.

Findings

Medium

  • F1. The collective fallback is untested.
    • Making the fallback rank-local (M4) passes every test the branch adds, and every neighbour test.
    • With M4, a file whose match fails on one rank hangs at np 2 and aborts at np 4.
    • Add a parallel test that perturbs the stored reference coordinates over part of the domain, as probes/coll_prep.py refpert does. Assert a uniform flat reload with no hang.
  • F2. Reload cost and memory scale with the global mesh on every rank.
    • Serial reload is about 7 times development's.
    • The cost is 0.18 ms per cell per rank in a Python closure loop, plus about 85 bytes per cell (2D) of tables allgathered to every rank.
    • Fine for current runs (607k cells: 32 s at np 4). Not viable at 10 M cells, especially in 3D.
    • Not a merge blocker; the design doc already names a distributed match as follow-up. File an issue with these numbers. A vectorised closure (cone arrays instead of per-point getTransitiveClosure) would cut the time well before that.

Low

  • F3. The tests do not separate the builds as well as they could.
    • The cross-np 1→2 case passes on development, because development's 1→N failure on triangles needs np 4 (or hex at np 2).
    • On development the parallel file aborts ("stack smashing detected") instead of failing cleanly. _drop_reference_coordinates raises KeyError on rank 0 only when the group is absent, so the ranks diverge.
    • Suggested fixes: add a hex or quad case to the 1→2 parametrisation, and broadcast a presence flag before deleting.
  • F4. [read] The deferred-stamp RuntimeError is raised rank-locally. It is unreachable in the current flow. If it is ever reachable, it should be decided collectively.
  • F5. [read] The old-file match has no distance bound. It relies on local uniqueness plus the closure check, which held in every case tried (oldlocal, moved2 development files). Consider rejecting nearest distances above, say, a quarter of the local edge length, to fail fast and explain why.
  • F6. [read] The write-side chart check compares stratum sizes only. The closure check at reload backstops it, so the failure mode is a flat reload, not corruption. It could not be exercised here: no mmg, so no coarsening or remesh.

Informational

  • F7. On the annulus, the reloaded intermediate multigrid levels are not callback-snapped (up to 0.0125 off the live L1). This is pre-existing on development, and has no measured effect on the FMG iterations.
  • F8. Branch-written refined files written at np ≥ 2 remain corrupt when read by a development build, exactly as development's own files are. No new incompatibility, but restarts and visualisation must use a build that contains this fix.

Merge conditions

  1. Add the one-rank-failure parallel test (F1). It must hang or fail with the M4 mutant and pass on the branch.
  2. Optional but cheap: the F3 test fixes.
  3. File a follow-up issue for the distributed or vectorised match, with the scaling table above (F2).

Queued for np 4

Nothing remains queued. The coordinator raised the limit to 6 cores during the review, and every np-4 item in review/queue_np4.sh was run, one np-4 job at a time:

  • the np-4 writes and reads;
  • the np-4 sf_check;
  • the collective probes with and without M4;
  • Stokes at np 4;
  • scaling at np 4;
  • test_0690 parallel at np 4.

The file is kept, annotated, as the record. ptest_0004 at np 3 and 4 was run last, by hand.

Not tested

  • Coarsening, remesh() and the MMPDE fault add-on cycle: this PETSc has no mmg or parmmg.
  • Refined periodic meshes: none available.
  • Meshes with duplicated vertices, such as split faults, at refinement > 0.
  • Rank counts above 4, and meshes above 607k cells: the large-scale behaviour is a projection only.
  • Hex at refinement 2.
  • Development reads at np 4 of the other np-1-written cases: box2 and hex1 hang there, the rest were not run.
  • A full development read matrix at np 4: development's np-4 hangs cost 90 s each, so only representative cases were run.

Records

  • Logs: review/logs/. The matrix table is logs/matrix_table.md.
  • Probes: review/probes/.
  • Scratch files: review/scratch/.

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>
@lmoresi

lmoresi commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

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

@lmoresi
lmoresi merged commit ef4ed89 into development Nov 11, 2026
10 checks passed
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.

3 participants