Skip to content

The coarse levels of a refined hierarchy move with the finest level - #1244

Merged
lmoresi merged 7 commits into
developmentfrom
feature/coarse-levels-move-with-the-fine
Nov 20, 2026
Merged

lmoresi merged 7 commits into
developmentfrom
feature/coarse-levels-move-with-the-fine

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

The coarse levels of a refined hierarchy now move with the finest level. This is stage 1, for meshes built with refinement=. The add-on and split fault levels follow in a second PR.

Louis Moresi, 2026-11-19, ruling on the design note for this change:

"They should move, really, even if, in the FMG, we don't know their coordinates. If we extract a coarse level as a submesh, I think it should be an injection of the fine-level coordinates."

What changes

On development. A move of a refined mesh (mesh.deform, a mover) changed the finest level only, and the coarse levels stayed where they were made. Quadrilateral and hexahedral transfers are built from where the levels stand, so after a move they paired an unmoved coarse level with a moved fine one, and the multigrid degraded as the mesh moved.

Now. Each coarse vertex takes the displacement of the finest vertex it is under the refinement.

  • The map is the refinement's own. A new Cython wrapper, _plex_topology.inherited_vertices, reads it from DMPlexTransformGetTargetPoint. It is exact and topological: no search and no coordinate match. The inherited vertices come first on triangles and tetrahedra, and after the new cell-centre vertices on quadrilaterals and hexahedra, so no fixed offset is assumed.
  • The displacement, not the position. A coarse vertex takes its finest vertex's displacement since the mesh was made, so a level that a refinement callback snapped onto a curved wall stays where it was made at rest.
  • Lazily. The levels move at the next read: in clone_dm_hierarchy for a solver, in _coarse_level_meshes for the custom multigrid, and in the requested-FMG route. The trigger is _geometry_version, which every coordinate change bumps. So a snapshot restore or an ephemeral_coords round trip puts the levels back with the finest. _move_version, which counts committed moves only, would have left them moved.
  • Both copies of a level move: the hierarchy DM and its cached wrap. A wrap keeps its record of where it was made.

How the transfers read the moved levels:

  • Simplex pairs are read where they were made, as development already reads a moved simplex fine level (fault_mg.as_built_nodes). The coarse side is now read the same way when it moved with the fine side, so simplex transfers are development's.
  • Quadrilateral and hexahedral pairs are read where they stand, both moved.
  • The rule for the coarse side. A coarse level is read as built only when the fine level of the pair is, and only if it moved with the finest. A level that a mesh was made on after it moved (an adapt child's parent) is read where it stands, as before.
  • Lookups that locate one level in another (add-on parents, provenance, the cell-located transfers) read an injected level's cells and nodes as built together, under the same rule (_cell_vertex_table(..., as_built=...)). The argument defaults to False, which reads a level where it stands, as development does; only these lookups pass True, and they do so only for a level that moved with the finest.

Checkpoints. A checkpoint saves the coarsest level where it was made, whether or not a solve moved it before the write. Its reference coordinates are refined from that level as well.

Not in this PR:

  • the add-on and split fault levels (stage 2, with the review points from H5, the session that maintains the split-level transfers);
  • adapt intermediates (an adapt child has no refined hierarchy of its own);
  • coarsened hierarchies, whose levels are not nested;
  • periodic meshes, which hold their coordinates cell by cell.

Those keep their levels where they are.

Measured

Serial, on macOS (12-core Apple M4). A box whose top wall rises by 2.5 % of the depth times sin πx each step, with the interior stretched; Stokes with the custom FMG on the velocity block. The table gives velocity-block iterations at steps 0 / 1 / 5 / 10 / 15 / 20; every solve converged.

cells development 246d6ce this branch
triangles 3 3 3 3 4 5 3 3 3 3 4 5
quadrilaterals 3 4 6 8 9 11 3 4 4 4 5 5
hexahedra 3 4 4 5 6 7 3 4 4 4 4 5
  • An adapt of a base whose top wall was raised three times beforehand (test_1176): 2 Poisson iterations against 4 on development, the same as at rest.
  • Cost per move, the time to move every coarse level (median of 3):
cells vertices per level cost per move one Stokes solve
triangles 340 / 1293 / 5041 26 ms 4.5 s
quadrilaterals 289 / 1089 / 4225 19 ms 4.6 s
hexahedra 125 / 729 / 4913 31 ms 159 s

Agreement across ranks.

  • In the provenance transfer, whether the coarse side is read as built depends on whether it follows the finest. That is the same on every rank: a collective move stamps the level on every rank, and the add-on partition sets the fine level's record on every rank together.
  • The collective move check is still entered by every rank when any rank's coarse side follows the finest. This is defensive: we know of no case where the ranks differ, so no test covers one.
  • A failure reading that record on one rank is raised on every rank.

Tolerances and coordinate matches

  • None in the library. A coarse vertex is paired with its finest vertex by the refinement's map.
  • The tests compare coordinates bit for bit: a coarse vertex against its finest vertex, and a level put back against where it was made.
  • The iteration test asserts 4 velocity iterations after ten rises serially and 5 at np 2 and 3, the measured values, and at most 5 above np 3. Development gives 8 serially.

Tests

tests/test_1240_coarse_levels_move_with_the_finest.py, level 2, tier B:

  • The map at rest: each coarse vertex coincides with its finest vertex bit for bit (triangles, quadrilaterals).
  • After a move: each coarse vertex, in both the hierarchy DM and the wrap, stands on its finest vertex, and the wrap keeps where it was made. This fails on development.
  • A move put back puts the coarse levels back bit for bit.
  • A level a refinement callback snapped (the annulus) stays where it was made at rest.
  • Iterations: quadrilateral multigrid after ten rises takes 4 iterations serially (5 at np 2 and 3). On development it takes 8, so the test fails there.

tests/parallel/test_0874_agreed_custom_mg_build_parallel.py gains a case where a failure on one rank at the coarse side's move check must be raised on every rank.

The two put-back and snapped-level tests pass on development too: they guard against wrong motion, not missing motion.

Changed tests. Two existing tests asserted the old contract:

  • test_0764: "its coarse levels keep the originals" now checks that the coarse level stands on its finest vertices.
  • test_1176: "the tail has not moved" now checks that the tail moves with the base when the base moved. The raised-wall adapt now gives 2 iterations instead of 4.
  • test_1173: the cut-on-a-moved-mesh case applies the transfer to the level's as-built nodes, the position a node was built at.
  • test_1173, parallel: a moved base's partition now has each cell inside its parent where both stand (it asserted some were outside). Cells where they were made are tested against the parents where those were made (parents_contain_centroids(..., as_built=True) in fault_fixtures).
  • test_1172, serial and parallel: "the coarse levels keep their geometry" passed only because the move waits for the next read. It now reads the hierarchy and asserts that the coarsest level stretched with the finest, to 1e-14.

Serial runs: the 118 multigrid, refinement and moving-mesh test files plus test_1240 (-n 6):

  • On the reviewed head: 1079 passed, 8 skipped, 1 xpassed. Two failed:
    • test_1176's at-rest adapt case: a mesh that never moved no longer stamps its levels, so that assertion now depends on the raise.
    • test_1173's cut-on-a-moved-mesh case: it applied the transfer to the coarse level's current nodes, where the transfer is read on the as-built ones.
  • After updating those two tests: test_1173, test_1176, test_1240 and test_0764's adapt cases gave 52 passed.

The three files in that slice that start mpirun themselves (test_0690, test_0791, test_1086) were left out. We do not run MPI on this machine.

scripts/test.sh gains decade lines for test_120* to test_129*; check_test_coverage.py passes.

Not run: any parallel case. The new collectives are reasoned in the review below, not run; the reviewer runs np 2 and 3.

Docs

  • guides/fault-multigrid.md: the FAC-patch passage now says that a faulted mesh's registered levels still do not move.
  • Docstrings in discretisation_mesh.py, fault_mg.py, custom_mg.py and addon_partition.py that said coarse levels never move are updated.

Review

One round of adversarial review (posted below); its findings are fixed in this head.

Issue state

No issue is open for this. The design note and Louis's ruling are in the planning thread.

Underworld development team with AI support from Claude Code

Louis's ruling, 2026-11-19: the coarse levels move, by injection of the
fine-level coordinates. A move of a refined mesh changed its finest level
only, and quadrilateral and hexahedral transfers paired an unmoved coarse
level with a moved fine one: on a rising wall the velocity solve went from 3
to 11 iterations (quadrilaterals) and 3 to 7 (hexahedra) in 20 steps.

Each coarse vertex now takes the displacement of the finest vertex it is
under the refinement, read from the refinement transform
(_plex_topology.inherited_vertices, DMPlexTransformGetTargetPoint): exact and
topological. Lazily, at the next read of the levels, keyed on
_geometry_version, so a restore puts them back. Both the hierarchy DMs and
the cached wraps move; a wrap keeps where it was made.

A simplex pair, and every lookup that locates one level in another, read a
level that moved with the finest where it was made, cells and nodes together,
when the fine level is read there: simplex transfers are development's.
Quadrilateral and hexahedral pairs are read where they stand. The same
iterations are now 3 to 5 for both. A checkpoint saves the coarsest level
where it was made.

Two tests that asserted the old contract are updated (test_0764, test_1176);
an adapt of a raised base now takes 2 iterations, not 4.

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

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 19, 2026

Copy link
Copy Markdown
Member Author

Adversarial review, round 1 (before the PR), and what was done

A fresh review session read the diff against development, ran serial probes, and checked the guide's list. Findings, and the fix in this head:

  1. High: a wrap's moved flag could differ between ranks.
    • The defect: a wrap made after a move was stamped with _moved_since_built from this rank's vertices alone. Under a move that touches part of the mesh, ranks could disagree, and as_built_nodes returns before its allreduce where the flag is False, so the ranks would part. It was confirmed in serial that the flag depends on local data; it was not run under MPI.
    • Fixed: the stamp sets the flag True on every rank, and the collective _moved_off_transfer_geometry decides.
  2. Medium: the cell table and the node coordinates of a moved level could come from two geometries.
    • The defect: _cell_vertex_table read a moved level as built for every caller. The provenance and cell-located routes still passed its current nodes, so nodes were pulled back through cells of another geometry. Measured in serial: a weight difference up to 8 and a reproduction error 0.5 to 1.2.
    • Fixed: the table is read as built only on request (as_built=), under one rule: a level that moved with the finest is read as built where the fine level of the pair is, cells and nodes together. In the provenance route that is decided from reference_vertices before the guarded block, and the coarse nodes are swapped for their as-built ones there. The probe's mixed and consistent readings now give the same transfer.
  3. Low-medium: the coarse coordinates were written into a vector that earlier clones share.
    • Fixed: the new coordinates go into a new vector. A clone taken before a move keeps its geometry (probe).
  4. Low: the checkpoint content depended on whether a solve came before the write.
    • Fixed: the sidecar, and the reference coordinates refined from it, hold the coarsest level where it was made. Probe: the sidecar equals the as-built coarsest with and without a solve before the write.
  5. Low: the version was recorded before the work.
    • Fixed: it is recorded after the levels move.
  6. Low: a remesh that gives the finest another topology left stale maps.
    • Fixed: the move is skipped, on every rank together, when the finest no longer matches the hierarchy.
  7. Low: cost.
    • Fixed: a mesh that has never moved does nothing on its first read.
    • Not changed: a moved mesh pays one _deform_mesh per cached wrap per changed geometry, measured at 19–31 ms per move.
  8. Low: tests.
    • Added: an independent check that, at rest, each coarse vertex coincides with its finest vertex bit for bit.
    • Changed: the iteration bound is now == 4, the measured value.
    • Noted: the put-back and snapped-level tests cannot detect missing motion; they guard wrong motion.
  9. Low: stale text that said coarse levels never move.
    • Updated: discretisation_mesh.py, fault_mg.reference_vertices, addon_partition._parent_cells_local, and scripts/test.sh (decade lines 120 to 129, not a century line).
    • Kept as true: the FAC warning (a faulted mesh's levels still do not move) and the relaxation doc (it is about relaxing a child where it was made).
  10. Low (Charter): the docstring opened with a quote.
    • Fixed: it now opens with what the method does, and names the ruling.

Checked and found sound by the reviewer:

  • the refinement map for every cell type at refinement 2 and 3;
  • self.dm numbering against dm_hierarchy[-1] on the build and reload paths;
  • the early returns, which use rank-identical values;
  • coarse ghost vertices;
  • the collective followed decision in custom_mg;
  • coarse wall rotation, which reads the moved geometry;
  • the reload splice;
  • CI reach.

Not run: any parallel case. The parallel review is with the reviewer of our parallel runs (H1, the session that runs them on a Linux workstation).

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Review from the Underworld development team with AI support from Claude Code (H1: review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH))
(H1 is the session that reviews pull requests and runs the parallel tests.)

Verdict at c7d7eda: ready to merge on green from this review.

  • What holds in parallel: the coarse levels move with the finest exactly (to 0.0) on every rank. Every rank takes the same decision under a move that reaches only some ranks. Checkpoints round-trip across rank counts. The quadrilateral and hexahedral multigrid now holds as the wall rises.
  • What needs action: finding 1 must be handled by whichever of this PR and custom_mg.build agrees on failure: the set-up phase and the per-level loop body (#874) #1225 merges second. Without it, the two together hang on a one-rank failure in the new coarse-side loop.

What I ran

item result
Localized move (only cells above y = 0.8 move) followed by set_custom_fmg(mesh.multigrid_levels[:-1]) and a Stokes solve. Run with the levels taken before or after the move, triangles and quadrilaterals, at np 2 and 3, plus triangles at np 3 with an empty rank (the empty-band layout: 0 cells on rank 2). No hang in any of the 10 runs. On every rank, each wrap reports moved since built True, moves with the finest True, and the collective "off its record" check True, including on ranks that moved nothing locally and on the empty rank. Velocity iterations are equal on every rank. On development, the same runs report False everywhere and also complete.
Injection exactness, after the localized move and after 20 wall rises: the maximum over ranks of the gap between each coarse vertex and its finest vertex, paired through inherited_vertices 0.0 on every level, at np 2 and 3, with the empty rank, and for triangles, quadrilaterals and hexahedra.
Checkpoint round trip. A triangle box and a quadrilateral box at refinement 2, the top wall raised ten times, a custom-FMG Stokes solve (which moves the coarse levels), then write_checkpoint. Written at np 2 and read at np 3 and 1; written at np 1 and read at np 2 and 3. All four combinations, both meshes: 3 levels restored, the integral of 1 equal to round-off, the written velocity read back with the same energy (to 1e-16 relative). A fresh solve on the reloaded mesh agrees with the written solution to about 1e-7 relative (solve tolerance 1e-6), with the same iterations as the write at that rank count. On reload, the coarse levels start where they were made (offset 0.28 from the injected positions) and move with the finest at the first solve (0.0).
Moving wall at np 2: the PR's benchmark, velocity iterations at steps 0 / 1 / 5 / 10 / 15 / 20 Quadrilaterals (16×16, refinement 2): development 3 7 12 19 27 37; branch 3 5 5 5 6 6. Hexahedra (4×4×4, refinement 2): development 4 5 7 8 10 12; branch 4 5 5 5 5 5. Triangles: 3 3 4 4 6 7 on both, unchanged. The PR's serial claim (quadrilaterals 11 → 5, hexahedra 7 → 5, triangles unchanged) reproduces in direction. At np 2, development degrades more than in serial (37 and 12 at step 20), and the branch stays at 6 and 5. Every solve converged.
Named tests, serially (their intended mode: test_1240, test_1176, test_1173, test_0764's TestEngineLessAdapt) 52 passed.
Named tests at np 2 and 3 test_0764's adapt cases: 4 passed on both the branch and development. test_1240: 6 passed and 1 failed at np 2 and 3. The iteration test, calibrated serially, gets 5 against 4; see finding 2. test_1176 and test_1173 are serial tests: at np 2 and 3 they fail broadly on development as well (13 failures on each tree in test_1176, and the same cut case in test_1173). A rank-local assertion then parts the ranks and the file hangs, on both trees. These are not regressions.
The updated tests They tighten the contract rather than loosening it. test_0764: it asserted the coarse level kept its original coordinates; it now asserts the coarse level changed and equals the finest vertices it is under. test_1176 (wall-raised): it asserted 4 iterations, now 2, the same as at rest; "no tail level moved" became "every tail level moves with the finest exactly when the base was raised". test_1173: the transfer is now applied to the level's as-built nodes rather than its current ones, which matches the new contract that a moved simplex pair is read as built.
The custom_mg build path with #1225 (not yet merged), tested by merging its head d651d32 into this PR, which merges cleanly test_0874_agreed_custom_mg_build passes 12/12 at np 2 and 3. test_0052 passes (9). See finding 1.
Neighbours at np 2: 20 custom_mg/FAC/fault-MG parallel files plus test_0690's parallel reload 190 passed and 4 skipped on both the branch and development.

Findings

  1. Medium (integration with custom_mg.build agrees on failure: the set-up phase and the per-level loop body (#874) #1225): the new coarse-side loop in build calls fault_mg.as_built_nodes with no agreement point in front.
    • Why it matters. as_built_nodes is collective: it runs _moved_off_transfer_geometry, an allreduce. In custom_mg.build agrees on failure: the set-up phase and the per-level loop body (#874) #1225's agreed build, the loop that reads the fine side has agree() before the same call; this PR's new coarse-side loop does not.
    • Measured on the merge of the two. On a moved simplex hierarchy at np 2, I forced a failure on the last rank after the first coarse-side as_built_nodes. It hangs: the failed rank is in the context's exit agreement, and the other rank is in _moved_off_transfer_geometry.
    • Why the scan misses it. test_0052's agreed-build rule sees direct mpi4py calls only, so it passes on the merge.
    • Fix. Add agree() before that as_built_nodes call, as the fine-side loop has, in whichever PR lands second.
  2. Low: test_1240's iteration test is calibrated serially. It asserts exactly 4 velocity iterations, and at np 2 and 3 the count is 5. The file lives in tests/ and runs serially in the suite, so CI is unaffected. If it should hold in parallel too, a bound (≤ 5) would be safer, still well below development's 8 in serial and 19 at np 2.
  3. Low: a docstring states the wrong collectiveness. The _plex_topology module docstring says every function there is rank-local and calls no collective. inherited_vertices creates and sets up a DMPlexTransform on the DM's communicator, which PETSc documents as collective. It is only called inside _move_coarse_levels_with_the_finest, behind guards that are the same on every rank, so no hang follows; the docstring should say it is collective.

Build

_plex_topology.pyx changes, so I built the head fresh in a new worktree on cores 0 to 3. The _plex_topology shared object is dated 10:26, after the head's commit at 10:18, and inherited_vertices imports. For the baseline, the merge base 246d6ce has the same compiled sources as an existing build at 116b0a0, with 246d6ce's Python overlaid. Every parallel run used at most 3 ranks, on cores 0 to 3. Not run: np 4 and above, and the adapt-intermediate and stage-2 cases, which are out of scope.

Logs kept by the reviewer.

Underworld development team with AI support from Claude Code

Underworld development team with AI support from Claude Code
The coarse-side loop in custom_mg.build calls the collective
fault_mg.as_built_nodes once per level whose coarse side moved with the
finest. It now has an agreement point in front, as the fine-side loop has
since #1225: a failure on one rank after a coarse-side check is raised on
every rank at the next level's agreement point, where it hung the others.

- test_0874_agreed_custom_mg_build_parallel: a refined triangle box whose
  top wall has risen (two fine-side and two coarse-side checks per build,
  probed serially); the failure is forced on the last rank at the first
  coarse-side check, and must be the same CollectiveBuildError on every
  rank with the agreement calls paired.
- test_1240: the iteration count is 4 serially and 5 at np 2 and 3
  (measured by the reviewer); above np 3 it is bounded by 5.
- _plex_topology: inherited_vertices is collective on the DM's
  communicator (it creates a DMPlexTransform there); the module docstring
  said every function was rank-local.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Integration with #1225, head 6d7b167

The reviewer's parallel pass (comment 7027279982) found one item and two lows. All three are addressed in this head.

  • Merge. Development c902390 (custom_mg.build agrees on failure: the set-up phase and the per-level loop body (#874) #1225 and An SLCN history record takes one route on every rank, an empty rank included #1237) is merged in, with no conflicts.
  • The coarse side's move check agrees on failure. The loop that reads each pair's coarse side as built calls the collective fault_mg.as_built_nodes. On development plus this branch it had no agreement point in front, so a failure on one rank after a check hung the others at the next level's check. It now has agree() at each level, as the fine-side loop has.
  • A test that forces the failure. test_a_failure_after_a_coarse_side_move_check in tests/parallel/test_0874_agreed_custom_mg_build_parallel.py:
    • The fixture is a refined triangle box whose top wall has risen, solved with the custom FMG. A serial probe gives 2 fine-side and 2 coarse-side checks per build.
    • The test first asserts that the build reads the coarse side at all (more checks than fine levels).
    • It then forces the failure on the last rank at the first coarse-side check. It asserts the same CollectiveBuildError on every rank, with the agreement calls per rank paired.
  • test_1240's iteration count. The test asserts 4 serially and 5 at np 2 and 3, as the reviewer measured. Above np 3, where no count was measured, it bounds the count by 5. Development gives 8 serially.
  • _plex_topology. inherited_vertices is now documented as collective on the DM's communicator, since it creates a DMPlexTransform there.

Serial runs on the merged head (macOS, 12-core Apple M4): 839 passed, 4 skipped and 1 xpassed across 85 multigrid, refinement and fault test files; test_0052 passes. The new parallel case has not been run here; it goes to the reviewer at np 2.

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Review from the Underworld development team with AI support from Claude Code (H1: review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH))
(H1 is the session that reviews pull requests and runs the parallel tests.)

Verdict at 6d7b167: ready to merge on green from this review. All three findings from my review of c7d7eda are addressed.

item result
Finding 1: the new agree() before the coarse-side as_built_nodes The new case test_a_failure_after_a_coarse_side_move_check passes at np 2 and np 3. I then removed that one agree() in a local copy of the installed package and changed nothing else. The case hangs at np 2 and at np 3: the supervisor stopped it after 90 s of silence, with the healthy rank in _moved_off_transfer_geometry and the failed rank in the exit agreement. The test catches the missing point.
Finding 2: test_1240 7 passed at np 2 and np 3. The iteration test is now exact at np ≤ 3 (4 serially, 5 at np 2 and 3), and becomes a ≤ bound above that.
Finding 3: the _plex_topology docstring It now says the function is collective.
test_0874_agreed_custom_mg_build (#1225 is now in) 13 passed at np 2 and np 3, the new case included.
Localized move, then set_custom_fmg Triangles and quadrilaterals at np 2 and 3, and triangles at np 3 with an empty rank (0 cells on rank 2). No hang. Every rank, including ranks that moved nothing locally and the empty rank, reports the same flags (moved since built, moves with the finest, and the collective check: all True), and the velocity iterations are the same on every rank.
Injection exactness 0.0 on every coarse level, over all ranks, in every run above.
Moving wall, quadrilaterals, np 2 3 5 5 5 6 6 at steps 0 / 1 / 5 / 10 / 15 / 20, the same as at c7d7eda. Development gave 3 7 12 19 27 37.
test_0052 9 passed.

Build. The merge of development brings compiled changes (petsc_generic_snes_solvers.pyx, _plex_topology.pyx). I moved the build worktree to 6d7b167, touched the .pyx files, and rebuilt on cores 0 to 3. The shared objects are dated 12:34, after the head's commit at 12:19. Every parallel run used at most 3 ranks, on cores 0 to 3.

Logs kept by the reviewer.

Underworld development team with AI support from Claude Code

… it follows

- test_1173 (parallel): a moved base's partition. The level below moved
  with the finest, so each cell lies inside its parent where both stand now
  (asserted == 0, where the move used to put 920 or 51 cells outside); the
  cells where they were made are tested against the parents where those
  were made (parents_contain_centroids(..., as_built=True)).
- fault_fixtures.parents_contain_centroids: an as_built argument, reading
  the parents through fault_mg._cell_vertex_table(as_built=).
- test_1172 (serial and parallel): "the coarse levels keep their geometry"
  passed only because the move is lazy. It now reads the hierarchy and
  asserts the coarsest level stretched with the finest (x -> 1.5 x) to
  1e-14.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Review from the Underworld development team with AI support from Claude Code (H1: review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH))
(H1 is the session that reviews pull requests and runs the parallel tests.)

57635a3: ready to merge on green from this review. The head has since moved to 590a51c, a merge of development that brings only PRs already merged there (#1232, #1233, #1236, #1243, #1245); the PR's own files are unchanged by it, so these runs stand.

The push changes tests only: fault_fixtures.py, the serial and parallel test_1172, and the parallel test_1173. Nothing under src/ and no compiled sources changed, so the library is the one reviewed at 6d7b167.

Runs at 57635a3 against the 6d7b167 build (identical library):

file np 2 np 3
tests/parallel/test_1173_addon_record_after_a_move_parallel.py 7 passed 7 passed
tests/parallel/test_1172_moved_refined_mesh_solves_on_moved_geometry_parallel.py 13 passed, 2 skipped 13 passed, 2 skipped
tests/parallel/test_1176_custom_mg_transfer_after_a_move_parallel.py 3 passed 3 passed
tests/parallel/test_0874_agreed_custom_mg_build_parallel.py 13 passed 13 passed
  • Serial: test_1172 13 passed, 2 skipped; test_1173 12 passed.
  • The skips are the existing "geometric multigrid needs a hierarchy" cases.

as_built= in fault_mg._cell_vertex_table. The argument was added in c7d7eda, already part of the reviewed head. This push only forwards it from the test helper parents_contain_centroids.

When the argument is not passed, the function behaves as on development. The one new block is guarded by as_built and ..., so it is skipped and (vxy, cv) comes back as before.

These library callers pass it:

  • cell_located_prolongation, cell_located_transfer_parallel and provenance_transfer_parallel in fault_mg;
  • _parent_cells_local in addon_partition, through _cell_centroids.

All other callers use the default.

CI checks.

  • scripts/check_test_coverage.py passes: all 491 test files are reachable from scripts/test.sh.
  • No new files, and no changes to test.sh or the workflow files.
  • git diff --check is clean.

Underworld development team with AI support from Claude Code

Stage 1 moved provenance_transfer_parallel's reference_vertices call to the
top, to decide whether the coarse side is read as built, and left it
outside every guard. A failure there on one rank raised out of the
function at once while the other ranks waited at the level tables'
agreement point: test_0874's forced failure hung at np 2 on CI.

The reference is now read under a guard raised on every rank, and the
collective move check is entered by every rank when any rank's coarse side
follows the finest. The later read in the weighting reuses it. The test that
forces the failure is renamed for where the read now is.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

A hang at np 2 in test_0874_provenance_and_parent_collective_parallel, fixed in b4e9cf7

test_a_failure_after_the_parent_fetch_is_raised_on_every_rank hung at np 2 on CI at 6d7b167 and 590a51c. The branch introduced it.

  • Cause. This branch moved provenance_transfer_parallel's call to reference_vertices to the top of the function, to decide whether the coarse side is read as built. The call sat outside every guard. The test forces that function to fail on the last rank, so that rank raised out of the function at once. The other ranks waited at the level tables' agreement point.
  • Fix.
    • The early read is now guarded, and a failure is raised on every rank as a CollectiveBuildError.
    • The collective move check (as_built_nodes) is entered by every rank when any rank's coarse side follows the finest.
    • The later read in the weighting reuses the early value.
  • Test. It is renamed test_a_failure_reading_the_reference_vertices_is_raised_on_every_rank, since the read is no longer after the parent fetch.

Serial, after rebuilding: 100 passed and 2 skipped (test_0052, 1172, 1173, 1176, 1240, 1120*, 1096*). The np 2 and 3 runs go to the reviewer.

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Review from the Underworld development team with AI support from Claude Code (H1: review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH))
(H1 is the session that reviews pull requests and runs the parallel tests.)

Verdict at b4e9cf7: changes requested (one test stub). The hang is fixed.

The cause and the fix

I reproduced the CI hang at 590a51c, np 2. The forced reference-vertex failure left the last rank unwrapped (LinAlgError), while rank 0 waited in the agreement. That confirms the cause: the early reference_vertices read sat outside every guard. At b4e9cf7 that read is guarded and agreed, and the move check is entered on an allreduced OR.

Results at b4e9cf7

np 2 and np 3, under the MPI supervisor with an outer timeout:

file np 2 np 3
test_0874_agreed_build_parallel pass pass
test_0874_agreed_custom_mg_build_parallel (incl. the coarse-side case) pass pass
test_0874_fault_mg_collective_failures_parallel pass pass
test_0874_mirrored_mesh_cut_parallel pass pass
test_0874_nested_transfer_verdict_parallel pass pass
test_0874_provenance_and_parent_collective_parallel 1 fail, 23 pass, no hang 1 fail, 23 pass, no hang
test_1172 / test_1173 / test_1176 (×3) parallel files pass pass

The remaining failure

test_a_cell_table_failure_before_the_parent_location_is_raised_on_every_rank stubs addon_partition._cell_centroids with failing(mesh). This PR now calls it with as_built=, so on rank 0 the stub raises TypeError ("unexpected keyword argument 'as_built'"). The agreed error then carries rank 0's TypeError instead of the forced "cell table" message. In CI this test ran before the hanging one, so the failure was hidden behind the hang.

With this change the file passes 24/24 at np 2 and np 3:

--- a/tests/parallel/test_0874_provenance_and_parent_collective_parallel.py
+++ b/tests/parallel/test_0874_provenance_and_parent_collective_parallel.py
@@ -239,10 +239,10 @@ def test_a_cell_table_failure_before_the_parent_location_is_raised_on_every_rank():
     original = ap._cell_centroids
 
-    def failing(mesh):
+    def failing(mesh, **kwargs):
         if uw.mpi.rank == uw.mpi.size - 1:
             raise IndexError("cell table (forced on one rank)")
-        return original(mesh)
+        return original(mesh, **kwargs)

Coverage after the rename

  • The early read is covered by the renamed test.
  • The region after the parent fetch is the weighting guard, up to its agreement. It is still covered by test_provenance_weight_failure_is_raised_on_every_rank, which forces _node_weights to fail on the last rank. _node_weights runs only on ranks that own fine nodes, so I measured that test's fixture. Every rank owns some: 1260 and 1268 at np 2; 785, 836 and 907 at np 3. The forced failure therefore fires on the last rank, and the test passes. A _barycentric injection sits in the same branch and would add nothing.

The logical-OR entry into as_built_nodes

In the add-on fault fixture, at rest and moved, no rank's coarse side follows the finest, so the OR is False everywhere. Fault solves are bitwise identical to 590a51c at np 2 and 3: per-rank hashes of velocity and pressure, slip, and iterations. A rank that does not follow but enters for another rank discards the result, so its coordinates cannot change.

Underworld development team with AI support from Claude Code

addon_partition._cell_centroids takes as_built= since this branch, and
_parent_cells_local passes it; the stub took one argument, so the call
raised TypeError instead of the forced failure. Verified by the reviewer at
np 2 and 3 (24 of 24).

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