Skip to content

Nested-transfer verdicts over all ranks; a repaired adapt keeps no parent map on any rank (#961, #807) - #970

Merged
lmoresi merged 4 commits into
developmentfrom
bugfix/nested-transfer-collective-961
Nov 7, 2026
Merged

lmoresi merged 4 commits into
developmentfrom
bugfix/nested-transfer-collective-961

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 6, 2026

Copy link
Copy Markdown
Member

The nested-transfer helpers decide over all ranks, and an adapt that repaired cells keeps no cell-parent map on any rank (#961, #807).

The bug

ptest_0844_reconnect_parallel.py::test_adapt_with_repair_runs_in_parallel failed on some ranks and not others, then hung, at np 2 and 4 (#961, #807). After mesh.adapt(engine="edge_split", repair=True), one rank kept a cell-parent map and another did not, and the ranks then went down different transfer builders. There were three causes:

  • The subsampler derived maps through repaired passes. _subsample_mg_levels derived each retained span's cell-parent map from the composed vertex transfer, whether or not a repair had flipped cells in the span. nvb.nested_cell_parents returned None when any local cell lacked a unique parent. So a rank whose flips happened not to straddle two coarse cells kept a map, and the others did not.
  • The helpers decided rank-locally. nested_cell_parents and nested_prolongation_from_dms decided None on their own rank's cells. Both callers, the subsampler and custom_mg (the any-degree transfer), then take a fallback that is collective.
  • The test's asserts stopped one rank ahead of a collective. So a failure on one rank read as a hang on the others.

The change

  • The engine records repaired passes. It notes which passes a repair actually changed; n_flips is a global count. No span through such a pass gets a cell-parent map.
  • Both helpers' verdicts are reduced over all ranks. A rank that owns no cell returns an empty transfer, so it does not veto the others.
  • Coordinates are read before any early return. _nested_prolongation_local reads both DMs' coordinates first, because the first read is collective. Hyperion found this in review, on the new empty-rank return.
  • ptest_0844 reduces before asserting. Its asserts that stood ahead of a collective now reduce the fact over all ranks first.

Tests

tests/test_0874_repair_drops_parent_maps.py (serial, tier B):

  • A repair that reports flips but moves nothing leaves no map. Development derives one there.
  • The same adapt without repair keeps its maps.

tests/parallel/test_0874_nested_transfer_verdict_parallel.py (tier B), on hyperion:

  • A transfer spoiled on rank 0 only gives None on every rank. On development the ranks disagree: [True, False] at np 2 and [True, False, False, False] at np 4. On this branch it passes.
  • A rank that owns no cell does not veto the transfer. The two-triangle box gives cells per rank [0, 2] already at np 2. On development this hangs (rc 124), and the CI supervisor fails the job. On this branch it passes.
  • Results on this branch: 2 passed at np 2, 3, 4 and 8. With the early return restored, it hangs at np 2.

ptest_0844_reconnect_parallel.py, the whole file: 7 passed at np 2 and 4 on this branch, in 15 s and 9 s; on development it hung for 840 s. It is not yet in CI; #958 lists it as deferred, and it can move once this merges.

The 59 serial files that use adapt, edge_split, custom_mg or add_fault give 501 passed and 4 skipped on this branch (macOS).

This new parallel file shifts the later MPI batches by one.

Issues

Hyperion's review follows as a comment.

Underworld development team with AI support from Claude Code

… pass keeps no parent map

ptest_0844_reconnect hung at np 2 and 4: after adapt(engine="edge_split",
repair=True) one rank kept a cell-parent map and another did not, and the
ranks went down different transfer builders. Two causes:

- The subsampler derived each retained span's parent map from the composed
  vertex transfer, whether or not a repair had flipped cells in the span. It
  kept the map wherever every local cell had a unique parent, which held on a
  rank whose flips happened not to straddle two coarse cells. The engine now
  records which passes a repair changed (n_flips is global), and no span
  through such a pass gets a map.
- nvb.nested_cell_parents and nvb.nested_prolongation_from_dms returned None
  on a rank-local verdict; both callers then take a collective fallback.
  Their verdict is now reduced over all ranks. A rank that owns no fine
  vertices returns an empty transfer, so it does not veto the others.

Tests:
- test_0874 (serial): a repair that reports flips but moves nothing leaves no
  map; on development the subsampler derives one. The same adapt without
  repair keeps maps.
- tests/parallel/test_0874: a transfer spoiled on rank 0 only gives None on
  every rank; a regular refinement's transfer and map are found; an empty
  rank returns an empty transfer. This new parallel file shifts the later MPI
  batches by one.

Underworld development team with AI support from Claude Code
On the 0.2 box every rank owns vertices at np 2 and 4, so the empty-rank check
never reached the branch it was for (hyperion's run). A box of two triangles
leaves a rank with no cell at np 3 and more; the test asserts that premise
there, and that every rank recovers the transfer.

Underworld development team with AI support from Claude Code
getCoordinatesLocal is collective the first time a DM's coordinates are
read. The new empty-rank return in _nested_prolongation_local came before
the fine DM's read, so at np 3 and 4 the empty rank went on to the verdict's
reduction while its peers waited in that read: PETSc error 98 and "Message
truncated" at np 3, rc 142 at np 2 and 4 (hyperion, on b34c01c). Both
vectors are now read first. With hyperion's overlay of this change the
parallel file gave 2 passed at np 2, 3, 4 and 8.

Underworld development team with AI support from Claude Code
…mpty-rank premise holds at np 2

From hyperion's review of df84634:
- #961's second defect: four asserts in ptest_0844_reconnect checked a
  rank-local fact ahead of a collective (the chart in
  test_geometry_and_conformity_survive; the prolongation and both parent-map
  arms in test_adapt_with_repair_runs_in_parallel). A failure on one rank left
  the others waiting, and read as a hang. They now reduce the fact over all
  ranks first. Asserts with no collective after them are left as they were.
- The two-triangle box leaves a rank with no cell already at np 2 (cells per
  rank [0, 2]), so the premise is asserted at every rank count and the comment
  says so.

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

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

Copy link
Copy Markdown
Member Author

Adversarial review of #970

Verdict: mergeable once the PR text narrows what it closes. We found no defect in the fix at df84634. Its test of an empty rank did find one earlier, now fixed: at b34c01c the early return skipped a collective getCoordinatesLocal(). #961's second defect, the ptest_0844 asserts, is not addressed. Base eddab70.

Findings

  1. Merge condition on the PR text, not a code must-fix: ptest_0844_reconnect hangs in parallel: a rank-dependent assert leaves its peers in a collective #961 defect 2 is untouched. ptest_0844_reconnect_parallel.py is not in the diff, and these asserts are still rank-local ahead of a collective: in test_geometry_and_conformity_survive, assert out.getChart() == chart before _global(...); in test_adapt_with_repair_runs_in_parallel, assert child._adapt_prolongation and all(...) before four adapt calls, and assert any(pc...) and assert all(pc is None...) before the final _global(...). After the fix these agree on every rank (8 configurations at np 2 and 4), by accident of the fix, not by construction, so the next failure there reads as a hang again. Compute a local flag, reduce it, and assert once after the collectives.
  2. Should-fix, test text. The premise assert in test_a_rank_that_owns_nothing_does_not_veto_the_transfer is gated to size >= 3 for no reason. Cells per rank on the two-triangle box: np 2 [0, 2], np 3 [0, 2, 0], np 4 [0, 0, 0, 2]. So rank 0 is empty at np 2, which is what CI runs. With the empty-rank branch removed, the test fails at np 2, 3, 4. "At np 2 every rank owns one, the case is not exercised" is wrong. Assert any(empty) at every size, and fix the comment.
  3. Low. The empty-rank test checks only all(found), not nested_cell_parents with an empty rank, nor the empty transfer's shape. A probe at np 3 gave transfer 49/49/0 and parents 36/36/0, no hang.
  4. Low. nested_prolongation_from_dms is public and now collective, but its docstring has no Parameters or Returns; the long text sits on the private _nested_prolongation_local (Charter section 6).

Attacks that failed

  • _on_every_rank reached on only some ranks: every caller of the two helpers is rank-uniform. custom_mg.py:520 sits in the serial branch of if parallel:. In _subsample_mg_levels, its guards are global now.
  • n_flips global and recorded on every pass: an allreduce SUM in flip_to_reduce_max_angle, and _repaired_passes is appended in both arms, so it lines up with level_dms. Adapts of adapts are refused already.
  • Config matrix at cellSize 0.2, refinement 1, max_levels 1 and 2. Base: disagreement between ranks with repair at np 2, ratio 1.0, and at np 4, ratios 1.0 and 2.0. Branch: agreement at np 2 and 4 everywhere, all maps None with repair, kept without. Tail sizes unchanged. Vertex transfers were never None on either build.
  • A mesh losing a transfer: not found. _adapt_parent_cells has no consumer in src, and the solver uses the vertex P, which is unchanged. In theory a repaired span whose flips never straddle a coarse cell used to keep a valid map and now drops it; we saw no such case, and nothing reads the map. We did not measure solve iteration counts.
  • Serial, no repair: unchanged.
  • Each new test fails for its reason on a mutant through an overlay: repaired condition removed, serial test_a_repaired_pass_leaves_no_parent_map fails; verdict reduction removed, the spoiled-transfer test fails at np 2; empty-rank branch removed, its test fails at np 2, 3, 4; early-return order restored, np 2 hangs into the supervisor, which is an acceptable failure mode.
  • Runs at df84634: tests/parallel/test_0874 2 passed at np 2, 3, 4, 8; ptest_0844_reconnect 7 passed at np 2 and 4, where it hung for 840 s on eddab70; serial test_0874 2 passed. On eddab70 the empty-rank proof is a hang (rc=124), and the spoiled-transfer test fails with [True, False].

CI placement

The new file is index 33, in batch 5, so every later file shifts one place. Harmless: it adds seconds, and #963 was not caused by batch order. A flake in a later batch near this merge should still be read with that in mind. The serial file falls in the test_08* batch, about 5 s.

Issues

Merge conditions

  • Narrow the close claims as above.
  • Remove the size >= 3 gate and correct the comment.
  • Optional: make the ptest_0844 asserts collective, which lets Closes #961 stand.

Could not test

Adapt with a rank that owns no cells (only the helpers were exercised on an empty rank, np 3); 3-D (flip_to_reduce_max_angle is 2-D only); solve accuracy and iteration counts on adapt tests; the shifted CI batches.

Status at aba71f0

Reviewed at df84634. The PR's tip answers finding 1 (the asserts ahead of a collective in ptest_0844 now reduce first) and finding 2 (the premise is asserted at every np). Rerun at np 2 on the tip: test_0874 and ptest_0844_reconnect, results below in the PR's thread. These test-only changes were not re-reviewed.

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Rerun at aba71f0, np 2, hyperion: tests/parallel/test_0874_nested_transfer_verdict_parallel.py 2 passed; ptest_0844_reconnect_parallel.py 7 passed. No library change since df84634.

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi merged commit 37aa2a1 into development Nov 7, 2026
8 checks passed
lmoresi pushed a commit that referenced this pull request Nov 7, 2026
…961)

It passes 7 of 7 at np 2 and np 4 on this base, where it hung for 840 s before
#970.

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