Skip to content

#874: guard the provenance transfer's opening reads; range-check _resolve_parents - #1216

Merged
lmoresi merged 4 commits into
developmentfrom
bugfix/provenance-opening-reads-874
Nov 16, 2026
Merged

lmoresi merged 4 commits into
developmentfrom
bugfix/provenance-opening-reads-874

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Addresses #874: the follow-ups from the #1201 review, H1's review of this PR, and point (B) of the #1206 review. Review: H1 (review and parallel test runs on a 96-thread Linux workstation).

The rule

Every rank-local step of these builders that can raise sits inside a guard. The guard turns the failure into the same error on every rank before the next collective call:

  • a CollectiveBuildError in the transfers and the rotations;
  • the RuntimeError of addon_partition's own checks there.

A step that is itself collective (a basis DM built by _cell_node_indices, the move check, a node lookup that evaluates collectively) is read on every rank before the guard.

Sites

site was now
fault_mg.provenance_transfer_parallel, opening level tables read unguarded before the first allreduce under one guard; node tables read first, collectively
fault_mg.provenance_transfer_parallel, after the star forest the got reshapes, Xw and reference_vertices unguarded under the weight guard, which every rank enters
fault_mg.cell_located_transfer_parallel, opening level tables unguarded as for the provenance transfer
fault_mg.level_pair_rotation caught only RuntimeError and ValueError; CSR build unguarded catches any exception, and covers the CSR build ahead of createAIJ
fault_mg.level_wall_rotation per-node blocks (an offset and an SVD each) and CSR build unguarded guarded
addon_partition._resolve_parents two star forests built from unchecked old addresses both records checked on every rank: length, rank and cell
addon_partition.inherit_provenance parent[cell] after the allreduce, unchecked the host's record checked and indexed inside the guard
addon_partition._base_parent_addresses cell tables read before the guard; record[cell] on return both inside the guard, with the record checked
addon_partition._carried_reference table read unguarded before its allreduce a failure counts as a mismatch, refused on every rank

Point (B) of the #1206 review: the parallel fault-copy repair now counts copy nodes, identified by their global columns, as the serial transfer does. Before, it counted node × component columns, twice the serial count in 2-D.

Test

tests/parallel/test_0874_provenance_and_parent_collective_parallel.py, now 24 cases. Each new case forces one failure on the last rank and asserts that every rank raises the same message and class:

  • the transfer's opening read;
  • the read after the parent fetch;
  • the cell-located transfer's opening read;
  • the old-address records of _resolve_parents, short, naming no such rank, or naming no such cell, for both records (H1's nit);
  • a short host record in the inheritance;
  • a short record in the base parent addresses;
  • the carried-reference read;
  • the pair rotation and the wall rotation. These are captured from a split-fault solve with a rotated free-slip wall, with the CSR build forced to fail.

tests/parallel/test_1120_split_transfer_fault_copies_parallel.py gains test_the_weak_copies_are_counted_as_nodes_as_in_serial. It checks the repair's count against the copy nodes whose located column is weak.

Results on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH):

  • Development's fault_mg.py and addon_partition.py, np 2: every new case fails. The record cases on the parent addresses: a hang, a short record passing silently, and an MPI abort. Every other case hangs (exit 124), except the two rotations, which abort (exit 142).
  • This branch: the file gives 24 passed at np 2, 3, 4 and 5. test_1120 parallel gives 2 passed at np 2 and 3; serial gives 8 passed.
  • Neighbours at np 2: 66 passed, 2 skipped. Files: test_0874_fault_mg_collective_failures, test_0874_mirrored_mesh_cut, test_0874_nested_transfer_verdict, test_1089, test_1096, test_1097_place_sheet, test_1099, test_1173, test_1176, test_1111, test_1101, test_1131, test_1064.
  • Serial neighbours: 63 passed.
  • scripts/check_test_coverage.py: OK.

Not in this PR

An inventory of the three files lists 45 functions with an unguarded step ahead of a collective. The rest is triaged in the #874 comment:

H1's three nits on #1212's _seam_points (the no-overlap assumption, height-1 only, one exterior label compared vertex by vertex) follow once #1212 merges.

Underworld development team with AI support from Claude Code

…olve_parents

The two follow-ups from the #1201 review.

- provenance_transfer_parallel read its level tables (vertex tables, the
  layout reshapes, the node-to-cell map) unguarded before its first
  allreduce. They are now read under one guard, raised on every rank as a
  CollectiveBuildError. The node tables build a basis DM, which is
  collective, so they are read on every rank first (they are cached).
- addon_partition._resolve_parents built two star forests from the recorded
  old addresses with no check. Each record is now checked on every rank
  first: one entry per cell (the level below's cells, and the fine level's),
  each a (rank, old local cell) that exists, against the allgathered old
  cell counts. A failure raises the same RuntimeError on every rank.

Tests (test_0874_provenance_and_parent_collective_parallel.py): an opening
read failing on the last rank; the old parent addresses short, naming a
rank that does not exist, or a cell that does not exist, on the last rank.
Development at np 2: a hang; a short record passing silently; a hang; an
MPI abort. Branch: 14 passed at np 2 to 5.

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

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 16, 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 on e0d9d04: changes requested. One small change is needed.

How it was run

Builds:

  • The PR's merge base is development at eccae6d. It carries compiled changes beyond the build used for Check the add-on record on every rank before the provenance transfer reads it (#874) #1201, so these runs use a build whose compiled code matches eccae6d.
  • That build was made from a commit whose only difference from eccae6d is in Python files; it has no .pyx, .pxd or .h changes.
  • Over its install we laid every .py file of the package: e0d9d04's for this branch, eccae6d's for development. The two overlays differ only in addon_partition.py and fault_mg.py.
  • The underworld3 import was checked to load from each overlay. The tests are this branch's.

Probes run the real meshes of the test file's captured calls, with one failure forced on the last rank only. That is the same method the PR's tests use.

Findings

Blocking

  1. A failure after the star-forest exchange in provenance_transfer_parallel still hangs.
    • Where: between sf.bcastEnd(...) and the weight _collective_raise. The statements there are the got reshapes into cols_u / Xn_u / V_u, cn_u / cv_u, Xw = Xf[mine], and reference = reference_vertices(pre, coarse). All of them are outside any guard.
    • Failure case (np 2): fault_mg.reference_vertices was made to raise IndexError on the last rank, for its call from provenance_transfer_parallel.
      • Rank 1 raised alone. Rank 0 waited in _collective_raise until the supervisor stopped the run (exit 124).
      • The supervisor's stacks: rank 0 is in _collective_raise(), rank 1 is past the call.
    • Fix: put those statements in a try that every rank enters, not only ranks with mine.size. Reuse the existing problem and _collective_raise(problem, error=CollectiveBuildError). For example, open the weight block's try before cols_u = ... and leave only the weighting under if mine.size.
    • Likelihood: low, as before. But this PR is the follow-up that closes the transfer, and its failure contract should hold end to end.

Should fix here, or note under #874

  1. cell_located_transfer_parallel has the same unguarded opening this PR fixes in the provenance transfer.
    • Where: _cell_vertex_table(coarse/fine), the l2g reshapes, _fine_cell_of_node and fcent are read before the first _collective_raise.
    • Failure case (np 2): we used the captured call of test_0874_fault_mg_collective_failures_parallel.py, with _cell_vertex_table raising on the last rank from that function. Rank 1 raised alone; rank 0 waited in _collective_raise until the supervisor stopped the run (exit 124).
    • Fix: the change is the one this PR makes. Read cn / fn first, collectively, then put the rest under one guard. Doing it here would keep the two transfers alike.

Follow-ups for #874 (not this PR)

  1. addon_partition still indexes a record by a located cell with no check, and the result reaches later collectives:

    A short host record on one rank is an IndexError there alone. This is the same failure as finding 4 of the Raise the provenance transfer's and the parent relation's rank-local failures on every rank (#874) #1165 review, at two more sites.

  2. _carried_reference reads _cell_vertex_table(moved) before its allreduce, unguarded.

  3. fault_mg.level_pair_rotation's guard catches only (RuntimeError, ValueError). An IndexError or KeyError from getOffset / _fault_pair_nodes_on on one rank escapes it and leaves the others in _collective_raise. The other guards in the file catch Exception.

  4. fault_mg.level_wall_rotation builds its blocks rank-locally, with getOffset and an SVD per node, before the collective createAIJ. There is no guard.

  5. split_tail_levels: its comment is still accurate. A rank-local raise inside add_fault, before the split's own collectives, hangs. The PR doesn't touch it, and the add_fault guard is still outstanding under Fault-split multigrid: rank-local raises before collectives in the cell-located transfer and the line cut's orientation vote #874.

Nit

  1. The new _resolve_parents test damages only _addon_parent_old. The check also covers _addon_self_old, the other star forest's record, and our probes confirm it is refused (below). Parametrizing the test over both records would keep that half covered.

Confirmed correct

  • Opening reads of provenance_transfer_parallel: _cell_vertex_table was forced to raise on the last rank, for pre. That is the probe from the Check the add-on record on every rank before the provenance transfer reads it (#874) #1201 review, which hung on development. At np 2 every rank now raises the same CollectiveBuildError: fault_mg: the provenance transfer failed to read the level tables: IndexError: ..., and every rank finishes. The node tables are read outside the guard, first. That is right: the PR says _cell_node_indices builds a basis DM, which is collective.

  • _resolve_parents: we damaged each of the two records on the last rank only, at np 2:

    record damage development this branch
    _addon_parent_old short returns silently on both ranks RuntimeError ... the parents have shape (314, 2) on every rank
    _addon_parent_old no such rank PETSc error 98 on rank 1, rank 0 hangs (exit 124) ... name a rank or a cell that does not exist on every rank
    _addon_parent_old no such cell segmentation violation, MPI abort (exit 59) same refusal on every rank
    _addon_self_old short caught late, by the "parent was not found after the move" check ... the cells of the level below have shape (314, 2) on every rank
    _addon_self_old no such rank PETSc error 98 on rank 1, rank 0 hangs (exit 124) refused on every rank
    _addon_self_old no such cell segmentation violation, MPI abort (exit 59) refused on every rank

    The checks are the right ones for the two star forests. Each record must have one row per leaf (cells of below now; cells of lev). Each entry's rank must be in [0, size) and its cell in [0, old cell count on that rank), against the allgathered _addon_n_cells_old. The allgather sits outside the try, so no rank can skip it. It runs after the self_old is None return, which every rank takes alike. The refusal is a RuntimeError, as addon_partition's other checks are.

Development fails the new cases (np 2, run here)

case development
opening-read failure in the transfer fails; IndexError on one rank, then a hang (exit 124)
damaged old address, short fails: AssertionError: [None, None], the record accepted silently
damaged old address, no such rank hang (exit 124)
damaged old address, no such cell MPI abort (exit 59)

What was run (this branch)

file np 2 np 3 np 4
test_0874_provenance_and_parent_collective_parallel.py 14 passed 14 passed 14 passed
test_0874_fault_mg_collective_failures_parallel.py 5 passed 5 passed
test_0874_mirrored_mesh_cut_parallel.py 3 passed 3 passed
test_0874_nested_transfer_verdict_parallel.py 2 passed 2 passed
test_1089_fault_split_multigrid_parallel.py 6 passed 6 passed
test_1096_addon_partition_parallel.py 3 passed 3 passed
test_1097_outcropping_ribbon_partitioned_parallel.py 2 skipped (needs 4 ranks) 2 passed
test_1097_place_sheet_partitioned_addon_parallel.py 4 passed 4 passed
test_1099_band_placement_partitioned_parallel.py 2 passed 2 passed
test_1173_addon_record_after_a_move_parallel.py 7 passed 7 passed
test_1176_custom_mg_transfer_after_a_move_parallel.py 3 passed 3 passed
test_1176_facet_restore_agrees_across_ranks_parallel.py 3 passed 3 passed
test_1176_rank0_generators_parallel.py 3 passed 3 passed

In total: 126 passed, 0 failed, and 2 skipped by design at np 2.

Probes:

  • At np 2 on this branch: opening reads (raised on every rank); post-exchange (hang, finding 1); cell-located opening (hang, finding 2); six _resolve_parents damages (refused on every rank).
  • At np 2 on development: the same six damages, and the opening reads.

Every parallel run was under the MPI supervisor with a timeout, pinned to four cores.

Not run:

Logs kept by the reviewer.

Underworld development team with AI support from Claude Code

Underworld development team with AI support from Claude Code
…t as nodes

H1's review of #1216 and point (B) of the #1206 review.

- provenance_transfer_parallel: every statement from the fetched parents to
  the weights (the reshapes, Xw, reference_vertices) is under one guard that
  every rank enters, a rank with no owned node too.
- cell_located_transfer_parallel: the opening reads under one guard, the
  node tables (collective) read first, as in the provenance transfer.
- level_pair_rotation: the guard catches any exception (an IndexError from an
  offset escaped it) and covers the CSR build ahead of createAIJ.
- level_wall_rotation: the per-node blocks and the CSR build are guarded.
- inherit_provenance and _base_parent_addresses: the host's record is checked
  (one entry per cell) and indexed under the guard, before the collectives.
- _carried_reference: a failure reading the table refuses on every rank.
- The parallel fault-copy repair counts copy NODES (by their global columns),
  as serial does, not node x component columns.
Every guard raises a CollectiveBuildError on every rank (addon_partition's
RuntimeError where its checks raise one).

Tests: a forced failure on the last rank at each site
(test_0874_provenance_and_parent_collective_parallel.py, now 24 cases, the
_resolve_parents ones over both records), and the node count checked against
the located transfer (test_1120 parallel). Development hangs or aborts on
every new case at np 2.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 16, 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 on f060cb0: ready to merge on green from this review.

How it was run

Build:

Probes: each probe forces one failure on one rank, through the real meshes of the test file's captured calls. Every run was under the MPI supervisor with a timeout, pinned to four cores. After every timeout we checked for leftover ranks; none were left.

Item by item (np 2 probes)

# site forced failure development (rows 1-5 from the previous rounds' runs; rows 6-10 at 0189b21) this branch
1 provenance_transfer_parallel, opening _cell_vertex_table raises for pre hang (exit 124) CollectiveBuildError ... failed to read the level tables on every rank
2 provenance_transfer_parallel, after the star forest (last round's blocking item) reference_vertices raises hang (exit 124) CollectiveBuildError ... failed to weight the fine nodes on every rank
3 cell_located_transfer_parallel, opening _cell_vertex_table raises hang (exit 124) CollectiveBuildError ... failed to read the level tables on every rank
4 _resolve_parents, _addon_parent_old short / no such rank / no such cell passes silently / PETSc error 98 + hang / segmentation violation refused on every rank, all three
5 _resolve_parents, _addon_self_old short / no such rank / no such cell caught late / PETSc error 98 + hang / segmentation violation refused on every rank, all three
6 level_pair_rotation IndexError from _fault_pair_nodes_on (the old guard caught only RuntimeError/ValueError) hang (exit 124) CollectiveBuildError ... the pair rotation failed: IndexError on every rank
7 level_wall_rotation a malformed second normal on every wall node of one rank, so np.array(nrms) raises ValueError in the block loop ValueError on rank 0 alone; rank 1 waits (exit 124) CollectiveBuildError ... the wall rotation failed: ValueError on every rank
8 inherit_provenance host record short / host record 1-D short: IndexError on one rank alone, the other returns; 1-D: accepted silently on both ranks RuntimeError ... the host's record holds (314, 2) entries for 628 cells / holds (628,) entries on every rank
9 _base_parent_addresses _cell_centroids raises inside it hang (exit 124) RuntimeError ... locating the cells ... failed: IndexError on every rank
10 _carried_reference a carried pair that cannot be unpacked, on one rank hang (exit 124) RuntimeError ... not in the order ... (TypeError: ...) on every rank
B parallel unrepaired_fault_copies units — twice the serial count (see below) the same as serial

Error classes:

  • The transfers and the rotations raise CollectiveBuildError.
  • The four addon_partition sites raise the module's RuntimeError, as its other checks do.
  • In every case the message is identical on every rank.

On item 7: our first probe for it used a point that is not in the level DM. That ends in a segmentation fault inside getOffset on both builds. A memory fault is not a Python exception, and no guard can turn it into one. The malformed-normal probe in the table is the Python-level failure the guard is for.

Point (B): serial and parallel count the same thing

We used the fixture of tests/test_1120_split_transfer_fault_copies.py, with the finest split pair's last_parent_rows read from a shear solve:

case serial (np 1) development np 2 / 4 this branch np 2 / 4
at rest: weak copies 4 8 / 8 4 / 4
at rest: remaining 0 0 / 0 0 / 0
finest only moved 0.015: weak copies 13 26 / 26 13 / 13
finest only moved 0.015: remaining (unrepaired_fault_copies) 13 4 / 4 2 / 2
  • Weak copies: these are now counted in nodes in parallel, exactly the serial count. Development counted node-by-component columns, twice the serial count in 2-D.
  • Remaining: the development figures (4) were columns; on this branch they are nodes (2).
  • The new test: test_the_weak_copies_are_counted_as_nodes_as_in_serial fails on development (weak_copies: 8 against 4 expected) and passes on this branch at np 2 and 4.

Observation for #1120, not this PR: in the moved case, serial and parallel do not repair the same rows.

Spot-check of the "agreed arithmetic" triage

  • _route: its only callers are in _dependent_columns, which computes dest by searchsorted over the matrix's own getOwnershipRangesColumn(). So dest is always a valid rank. argsort/searchsorted cannot raise on it, and nothing rank-local precedes the alltoall. The triage holds.
  • _fold_rows: fold comes from the allgathered decisions of _dependent_columns, so it is the same on every rank. It holds columns of T itself. createAIJ comes first and is collective. The setValue loop touches only owned rows with indices from T. The triage holds.
  • _assemble_owned_rows: the inputs (Wall, Call) come out of guarded builders whose verdicts every rank has passed. The columns are layout global indices. The triage holds, with one caveat: sp.csr_matrix runs after the allreduce and before the collective createAIJ. An out-of-range column there (impossible from a valid layout, but not checked) would raise on one rank before a collective.

Still open, as the PR says: custom_mg.build and the FAC helpers, partition_addon, _dependent_columns, rotated_split_transfers, and add_fault's split. split_tail_levels's comment about that hang is still accurate. We also note that level_wall_rotation collects node_normals before its allreduce, outside the new guard. Those calls may themselves be collective, so they belong with the open list rather than inside this guard.

Tests (this branch)

file np 2 np 3 np 4
test_0874_provenance_and_parent_collective_parallel.py 24 passed 24 passed 24 passed
test_0874_fault_mg_collective_failures_parallel.py 5 passed 5 passed
test_0874_mirrored_mesh_cut_parallel.py 3 passed 3 passed
test_0874_nested_transfer_verdict_parallel.py 2 passed 2 passed
test_1089_fault_split_multigrid_parallel.py 6 passed 6 passed
test_1096_addon_partition_parallel.py 3 passed 3 passed
test_1097_outcropping_ribbon_partitioned_parallel.py 2 skipped (needs 4 ranks) 2 passed
test_1097_place_sheet_partitioned_addon_parallel.py 4 passed 4 passed
test_1099_band_placement_partitioned_parallel.py 2 passed 2 passed
test_1111_custom_mg_cut_of_a_moved_child_parallel.py 7 passed 7 passed
test_1120_split_transfer_fault_copies_parallel.py 2 passed 2 passed
test_1173_addon_record_after_a_move_parallel.py 7 passed 7 passed
test_1176_*_parallel.py (three files) 9 passed 9 passed

Serial: test_1120_split_transfer_fault_copies.py and test_1111_rotated_fmg_coarse_shifted_lu.py give 10 passed, 1 skipped.

In total: 184 passed (74 at np 2, 24 at np 3, 76 at np 4, 10 serial), 0 failed; 2 skipped by design at np 2, and 1 serial skip.

On development:

  • The new _resolve_parents case hangs on its first parametrization (exit 124).
  • The new test_1120 node-count test fails as shown above.
  • The other new cases are covered by the development column of the probe table.

Not run:

  • np 5. The author reports np 2 to 5; our core budget on a shared machine allows at most 4 processes.
  • test_1101, test_1131, test_1064 in parallel.
  • scripts/check_test_coverage.py.
  • macOS.

Logs kept by the reviewer.

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.

3 participants