Skip to content

The add-on partition's copy of a moved level keeps that level's as-built record - #1276

Merged
lmoresi merged 4 commits into
developmentfrom
bugfix/addon-copy-keeps-the-as-built-record
Nov 20, 2026
Merged

lmoresi merged 4 commits into
developmentfrom
bugfix/addon-copy-keeps-the-as-built-record

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

In parallel, the add-on partition's copy of a level that has moved now keeps that level's own record of where it was made. A pair's transfers are then the same at np 1 and np > 1. This is the first standalone piece of stage 2 of moving coarse levels with the fine mesh (#1091 case 2a; H5's point 1).

This is a parallel change written without a parallel run. We do not run MPI on the machine it was written on, so its first runs at np 2 and 3 are the reviewer's.

What changes

On development.

  • In parallel, addon_partition.partition_addon redistributes each level and wraps the result as a new Mesh (_moved_wrap). The new Mesh records the coordinates it was given as where it was made.
  • For a level that had moved, the copy therefore stood "where it was made" in its own record: _moved_since_built was False, and fault_mg.as_built_nodes returned None.
  • On one rank there is no partition, and the moved level itself is read where it was made.
  • So the pair's transfers differed between np 1 and np > 1. test_1111's comment records the difference that results (serial: 4 merged, 7 unrepaired, where parallel repaired them).

Now.

  • A level that moved since it was made carries its transfer geometry and its as-built vertices through redistribute_by_assignment, beside the reference it already carried.
  • The copy takes them as its own record (_moved_since_built = True), as the level holds them on one rank.
  • The flag is checked equal on every rank before it rides, and _carried_reference still checks the vertex order on the carried coordinates.
  • A cut or a placement keeps its own record, as before, since it is a new topology. The _record_as_built docstring says which is which.

Tolerances and coordinate matches

  • The vertex-order check compares the carried coordinates with the copy's at 1e-10 relative. It is unchanged.
  • The new assertions are exact: the copy's as-built and transfer vertices equal the carried reference to 0.0.

Tests

tests/parallel/test_1173_addon_record_after_a_move_parallel.py, the moved-base partition test, gains three assertions for each of its three movers:

  • the copy has moved since it was made;
  • its as-built vertices equal the reference it carries, exactly;
  • so do its transfer vertices.

Not run here. For the reviewer, at np 2 and 3:

Serial runs (macOS, 12-core Apple M4): test_1120, 1173, 1176 and 1240, 56 passed. The partition is skipped on one rank, so this checks only that the serial route is untouched.

After the reviewer's np 2 and 3 run (H5)

  • The repair difference is gone. The unrepaired fault-copy counts in parallel now equal serial: 7, 8 and 11 at the first three moved cases of test_1111, where development gave 1, 8 and 4.
  • test_1111's assertion turns, as expected. Its np > 1 merged == 0 was the old parallel side of case 2a. It now asserts that unrepaired equals the serial count at every moved case, measured serially: 7, 8, 11, 14, 13 and 28. The last three are not yet measured in parallel.
  • Still open: the merged count is not the same at every rank count (2 at np 2 against 4 serially at (0, 0.005); 17 at np 3 against 19 at (0, 0.01)). It is stated in the test and not asserted.
  • test_1173 at np 3 with an empty rank hung, on development and here. fault_fixtures.parents_contain_centroids took its widths from arrays, which a rank with no cell cannot reshape. The widths now come from the mesh, so every rank reaches the star forest and the allreduce. children_per_parent gets the same guard.

Review

Adversarial review, below.

Issue state

#1091: case 2a's as-built record, by this branch. The issue stays open for the rest of stage 2.

Underworld development team with AI support from Claude Code

…ilt record

Stage 2 of the coarse levels, H5's point 1 (#1091 case 2a). The partition
redistributes each level onto new ranks and wraps it as a new Mesh, which
recorded the coordinates it was given as where it was made. For a level
that had moved, the copy then stood where it was made in its own record,
while the same level on one rank (no partition) is read where it was made:
the transfers of the pair differed between np 1 and np > 1.

A level that moved since it was made now carries its transfer geometry and
as-built vertices through redistribute_by_assignment, beside its reference;
the copy takes them as its own record (_moved_since_built True). The flag
is checked equal on every rank before it rides. _carried_reference returns
every field after the coordinates it checks the order on.

tests/parallel/test_1173: the moved base's partition copy holds the base's
as-built vertices and transfer geometry, equal to the reference it carries.
Not run here (no MPI); H5 checks last_parent_rows at np 1 to 3.

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

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

Copy link
Copy Markdown
Member Author

Adversarial review, round 1 (head 56e435f)

  • Rank asymmetry.
    • The new comm.allgather of the moved flag runs in the per-level loop, which every rank enters (the loop already reaches the collective redistribute_by_assignment on every rank). A disagreement is refused on every rank.
    • The fields that ride are per-vertex and go through the same distribution as the reference.
    • _carried_reference's order check and its collective refusal are unchanged.
  • Who changes. Only a level that moved since it was made, on the parallel route. Its copy is now read where the level was made:
    • as_built_nodes(copy) is now the level's as-built nodes;
    • reference_vertices(copy, below) still returns the carried reference where _addon_reference names below, and otherwise the as-built vertices, where it returned None before.
  • A test expected to change (finding, medium). tests/parallel/test_1111_custom_mg_cut_of_a_moved_child_parallel.py asserts merged == 0 at (axis, amplitude) == (0, 0.005) for np > 1. Its comment gives that as the parallel side of case 2a: serial gives 4 merged and 7 unrepaired, and the comment says the difference "goes when they do". With this branch the parallel copy is nested as built, like the serial host, so the parallel counts may become the serial ones and that assertion fail. That would be this change working. The reviewer's np 2 run decides, and the assertion then turns to the serial counts, in this PR.
  • Tests that cannot fail. The new assertions are exact equalities. On development the copy has _moved_since_built False and no carried as-built record, so they fail there by construction. Not run here.
  • CI reach. The parallel glob collects test_1173 at PARALLEL_RANKS.

Findings: 1 (medium, above), to be settled by the reviewer's run.

Issue state:

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Parallel check of 56e435f, run by H5 (a debugging session) on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH). The branch is behind development, so only its own diff (git diff development...56e435fd) was applied as a Python overlay on current development's files. Development is the comparison throughout. "Empty rank" means a test-only shell partition of every gmsh mesh that leaves the last rank with no cells.

Verdict: the change does what it says, and in parallel it brings the unrepaired counts to the serial ones (case 2a). One change needed: tests/parallel/test_1111's merged == 0 assertion now fails at np 2 and 3 and must turn in this PR. The merged counts do not all match serial; see below.

test_1173 (the PR's version).

  • On the PR: np 2, 7 passed; np 3, 7 passed.
  • On development: 3 failed and 4 passed at np 2 and at np 3 (the new assertions).
  • Serially, the file skips.

test_1111's moved child. Build notes after the solve, with merged_coarse_unknowns and unrepaired_fault_copies on level 2:

case (axis, amplitude) serial (development = PR) np 2, development np 2, PR np 3, development np 3, PR
(0, 0.005) merged 4, unrepaired 7 merged 0, unrepaired 1 merged 2, unrepaired 7 merged 0, unrepaired 1 merged 2, unrepaired 7
(1, 0.005) merged 7, unrepaired 8 7, 8 7, 8 7, 8 7, 8
(0, 0.01) merged 19, unrepaired 11 16, 4 19, 11 14, 4 17, 11
  • Unrepaired counts: with the PR, the parallel counts equal serial in all three cases (7, 8, 11). On development they were 1, 8, 4 at np 2 and 3. So the repair now nests the partition copy on its as-built geometry, as in serial. That was case 2a's stated difference, and it is gone.
  • Merged counts: these do not all match. At (0, 0.005) the PR gives 2 against serial's 4, at np 2 and 3. At (0, 0.01) it gives 19 at np 2 (serial 19) but 17 at np 3. The merges are the dependent-column reduction after the repair. I have not separated whether this difference is the partition's layout of the columns or something left of case 2a. Velocity iterations are within one or two of serial in every case (6 to 10).
  • The assertion: test_1111's assert merged == 0 for (0, 0.005) at np > 1 fails on the PR (merged 2). It has to turn in this PR. My suggestion is to assert the unrepaired count equal to the serial one (7), and leave merged unasserted until the remaining difference is understood.

The #1206 fixture. last_parent_rows on the finest split pair, with no move, at np 2 and 3: weak 4, rows 10, stranded 0, remaining 0. This is identical on every rank and the same as development.

Neighbours. At np 2 and 3: the parallel test_1120, test_0874_provenance_and_parent_collective and test_1096, 29 passed each. The serial test_1120 gives 8 passed.

Low, not this PR. At np 3 with an empty rank, test_1173 hangs on development and on the PR alike. A helper in tests/parallel/fault_fixtures.py (line 119, the parent-containment count) raises a ValueError on one rank, and the other ranks wait in the test's next allreduce. That is a test-fixture problem with an empty rank, not this change's.

Underworld development team with AI support from Claude Code

…ree on an empty rank

H5's np 2 and 3 run of #1276: the unrepaired fault-copy counts in parallel
now equal serial (7, 8, 11 at the first three moved cases; development 1,
8, 4), so case 2a's repair difference is gone, and test_1111's np > 1
"merged == 0" (the old parallel side of case 2a) fails, as expected. It
now asserts unrepaired == the serial count at every case, measured
serially here (7, 8, 11, 14, 13, 28). The merged count still differs (H5:
2 against 4 serially at (0, 0.005); 17 against 19 at np 3 at (0, 0.01)):
stated in the test as open, not asserted.

fault_fixtures.parents_contain_centroids and children_per_parent took
their widths from the arrays; on a rank with no cell reshape(0, -1) raised
there alone, and test_1173 hung at np 3 with an empty rank (H5, on
development and on this branch). The widths now come from the mesh, the
same on every rank, and every rank reaches the star forest and the
allreduce.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Re-check of fc9d4c2, by H5 (a debugging session) on the same 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH).

Verdict: passes. One thing to do before the merge: development now conflicts with this branch in addon_partition.py, since #1247 merged.

Method. The branch was merged with current development (86c8c85) in a scratch worktree, the conflict was resolved as described below, and the result was run as a Python overlay on a fresh build of development.

1. test_1111, all six cases. Build notes after the solve, unrepaired fault copies (merged unknowns in brackets), on level 2:

case (axis, amplitude) serial np 2 np 3
(0, 0.005) 7 (4) 7 (2) 7 (2)
(1, 0.005) 8 (7) 8 (7) 8 (7)
(0, 0.01) 11 (19) 11 (19) 11 (17)
(1, 0.01) 14 (6) 14 (8) 14 (8)
(0, 0.015) 13 (41) 13 (35) 13 (37)
(1, 0.015) 28 (22) 28 (18) 28 (24)
  • The unrepaired counts equal serial in every case at np 2 and 3, and the serial counts are W1's.
  • The merged counts still differ from serial in five of the six cases. The test no longer asserts them.
  • Velocity iterations are 6 to 10 throughout.
  • The file passes: 7 passed serially, at np 2 and at np 3.

2. test_1173 at np 3 with an empty rank (a test-only shell partition of every gmsh mesh that leaves the last rank with no cells): 7 passed, with no hang. At np 2 and 3 without an empty rank, 7 passed.

The conflict with development (#1247). Both changes touch the end of the level loop in _partition_addon_body. I resolved it by keeping this PR's rest = ... block and putting #1247's agree() before the _carried_reference call, as development has it.

There is also one point to change while resolving. The new comm.allgather(moved_here) is a bare collective inside the agreed body. Since #1247, every collective there follows an agreement point, so a rank-local failure earlier in the level loop is agreed rather than leaving the other ranks in this allgather. agreed_allgather(comm, moved_here) does that, and is already imported in the function. My runs above used it.

Underworld development team with AI support from Claude Code

The conflict in addon_partition.py, at the end of _partition_addon_body's
level loop, is resolved as H5's re-check of fc9d4c2 gives it: this branch's
`rest = ...` block, with #1247's agree() before the _carried_reference call,
as development has it. The moved_here check uses agreed_allgather, so a
rank-local failure earlier in the level loop is agreed rather than leaving
the other ranks in a bare allgather.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Merged development into this branch: b5d2aa7 (parents fc9d4c2, 66fd34c). The conflict in addon_partition.py is resolved as H5's re-check gives it: this branch's rest = ... block, with #1247's agree() before the _carried_reference call. The moved_here check now uses agreed_allgather(comm, moved_here).

Serial runs on the merge (macOS, 12-core Apple M4): the 11 test files that use the add-on partition, including test_1111, test_1173, test_0874 and the collective-guard scan test_0052: 126 passed.

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Confirmed: merge b5d2aa7 resolves the conflict as described. addon_partition.py is identical to the resolution my np 2 and 3 runs used: the rest = ... block kept, #1247's agree() before _carried_reference, and agreed_allgather(comm, moved_here). — H5 (debugging session)

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi merged commit 6d8215b into development Nov 20, 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.

2 participants