Skip to content

Check the add-on record on every rank before the provenance transfer reads it (#874) - #1201

Merged
lmoresi merged 1 commit into
developmentfrom
bugfix/provenance-record-check-874
Nov 16, 2026
Merged

lmoresi merged 1 commit into
developmentfrom
bugfix/provenance-record-check-874

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 16, 2026

Copy link
Copy Markdown
Member

Addresses #874: finding 4 of the #1165 review. Review: H1 (review and parallel test runs on a 96-thread Linux workstation).

The defect

fault_mg.provenance_transfer_parallel read pre._addon_parent[pcell] and packed the coarse cells for the star forest between two collective calls, with no check. A damaged record on one rank failed there alone, and the other ranks waited:

Damage on one rank What happened at np 2
short record IndexError on that rank
a rank that doesn't exist PETSc error 98 in the star forest set-up on that rank, then a hang
a cell that doesn't exist MPI abort

addon_partition._parent_cells_local also read its cell tables just before its guard.

The fix

The record is checked before the star forest is built on it.

  • It must have one entry per cell of pre.
  • Each entry must be a (rank, local cell) that exists. The coarse cell counts are allgathered once for this.

The check and the packing sit under one guard. A failure is a CollectiveBuildError on every rank together, the class of the checks beside it, so the hierarchy build degrades on all ranks. _parent_cells_local now reads its cell tables inside its guard as well.

The statement after the weight verdict, gcols = cols_u[inv], needs no guard: inv comes from np.unique over the same rows, so it can't index out of range.

Test

Four cases are added to tests/parallel/test_0874_provenance_and_parent_collective_parallel.py. Each damages the last rank only, and asserts that every rank raises the same message:

  • the record short;
  • every entry naming a rank that doesn't exist;
  • every entry naming a cell that doesn't exist;
  • a cell-table failure ahead of the parent location.

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

  • Development's two files, np 2: each of the four fails. The short record is an IndexError on one rank. A bad rank is a PETSc error on one rank and then a hang (supervisor exit 124). A bad cell is an MPI abort. The cell-table failure hangs.
  • This branch: 10 pass at np 2, 3, 4 and 5 (the six earlier cases and the four new ones).
  • Neighbouring files at np 2: 22 pass (test_1096, test_1089, test_1173, test_1097, test_1099).
  • Serial test_1173: 12 pass.
  • scripts/check_test_coverage.py: OK.

#874 stays open: add_fault's split is still to be guarded, and findings 5 and 6(b, c) of the #1165 review are still open.

Underworld development team with AI support from Claude Code

…reads it (#874)

Finding 4 of the #1165 review. provenance_transfer_parallel read
pre._addon_parent[pcell] and packed the coarse cells between two collective
calls, unchecked. On one rank, a short record raised an IndexError and an
address out of range gave a PETSc error or an MPI abort, while the other
ranks waited (np 2).

The record is now checked before the star forest is built on it: one entry
per cell of pre, each a (rank, local cell) that exists (the coarse cell
counts are allgathered). The check and the packing are under one guard, and
a failure is a CollectiveBuildError on every rank. addon_partition.
_parent_cells_local now reads its cell tables inside its guard as well.

Tests (in test_0874_provenance_and_parent_collective_parallel.py): the
record damaged on the last rank only (short, a rank that does not exist, a
cell that does not exist), and a cell-table failure before the parent
location. On development each fails at np 2: IndexError on one rank, a
PETSc error on one rank and a hang, an MPI abort, a hang. Branch: 10 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 00:44

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 0292449: ready to merge on green from this review (a comment, not a GitHub approval). Finding 4 is fixed. A short, out-of-range or wrong-rank record on one rank is now the same CollectiveBuildError on every rank. The earlier probe, which failed on development, now passes at np 2 and 4. One minor finding below: the same class of failure remains in the transfer's unguarded opening lines. We suggest closing it here or under #874, which stays open.

How it was run

The two changed modules were laid over a development install (176958a). Two Python files from fafbecb, the PR's base, were added too (discretisation_mesh.py, meshing/smoothing/graph.py). The underworld3 import was checked to load from that overlay. The tests are this branch's.

Findings

No blocking findings.

Minor

  1. A rank-local failure before the first allreduce in provenance_transfer_parallel still hangs.

    • Where: the opening lines read the node and cell tables with no guard, and then reach m4.allreduce(int((owner < 0).sum())). These are _cell_node_indices x2, _cell_vertex_table for coarse, fine and pre, the l2g reshapes and _fine_cell_of_node.
    • Failure case (np 2): we used the captured provenance call of test_0874_provenance_and_parent_collective_parallel.py, as the PR's own tests do. fault_mg._cell_vertex_table was made to raise IndexError on the last rank, for pre only. Rank 1 raised alone. Rank 0 waited in that allreduce until the supervisor stopped the run (exit 124). The supervisor's native stacks show rank 0 in MPI_Allreduce inside provenance_transfer_parallel.
    • Same pattern after the SF: a few statements between the bcast and the weight guard are also outside a guard: the got reshapes into cols_u / Xn_u / V_u, and reference_vertices(pre, coarse). A rank that fails there leaves the others in the weight verdict's allgather.
    • Likelihood: low. These read the rank's own DM. Still, it is the same thing the PR fixes in _parent_cells_local by moving its cell tables under the guard. Doing the same here (one try around the opening table reads, followed by _collective_raise(..., error=CollectiveBuildError)) would close the transfer completely. If you'd rather not grow this PR, a line under Fault-split multigrid: rank-local raises before collectives in the cell-located transfer and the line cut's orientation vote #874 is enough.
  2. addon_partition._resolve_parents builds two star forests from the record with no range check. sf_dir is built from _addon_self_old and sf_get from _addon_parent_old. A damaged address there would fail the same way finding 4 did on development:

    • a rank that does not exist gave PETSc error 98 and then a hang;
    • a cell that does not exist gave a segmentation violation and an MPI abort.

    The record is built internally, just before, so this is a follow-up for Fault-split multigrid: rank-local raises before collectives in the cell-located transfer and the line cut's orientation vote #874, not a defect in this PR.

  3. split_tail_levels: its comment still describes a hang. A rank-local raise inside add_fault, before the split's own collectives, leaves the raising rank in the verdict and the others in the split. The comment is accurate, and this PR doesn't touch it. The PR text says add_fault's split is still to be guarded and that Fault-split multigrid: rank-local raises before collectives in the cell-located transfer and the line cut's orientation vote #874 stays open, which matches.

Confirmed correct

  • The record check: the shape must be (cells of pre, 2). The rank must be in [0, size). The cell must be in [0, coarse cells on that rank), against the allgathered counts. Those are exactly the conditions under which the SF graph is valid. The packing of root is under the same guard.
  • coarse_cells is gathered outside the try, on every rank, so the guard adds no collective that one rank could skip.
  • A rank that owns no fine node (mine.size == 0) still checks the record's length, so a short record there is caught too.
  • gcols = cols_u[inv] needs no guard, as the PR says: inv comes from np.unique over the same rows.
  • _parent_cells_local's cell tables are now inside the guard. The defaults (n_f = n_c = 0, an empty cell) keep the allreduce that follows well-defined on a rank that failed.
  • The earlier finding-4 probe cuts the record to one entry on the last rank only. On this branch every rank raises the same CollectiveBuildError: fault_mg: the add-on record of the level holds (1, 2) entries for N cells; it does not describe this mesh. That held at np 2 (N = 628) and np 4 (N = 377), and every rank reached the end of the probe. On development the same probe raised IndexError on the last rank while rank 0 waited.

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

case development
short record IndexError: index 534 is out of bounds for axis 0 with size 314 on one rank, then an MPI abort in the next allreduce
no such rank petsc4py.PETSc.Error: error code 98 on one rank, then a hang (supervisor exit 124)
no such cell segmentation violation in PETSc, then an MPI abort
cell-table failure IndexError on one rank, then a hang (supervisor exit 124)

What was run (this branch)

file np 2 np 4
test_0874_provenance_and_parent_collective_parallel.py 10 passed 10 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
finding-4 probe (record cut short on the last rank) same CollectiveBuildError on every rank same, on every rank

In total:

  • 40 passed, 0 failed.
  • Two probe runs, plus the prelude probe of finding 1 (np 2, hangs as described).
  • The four new cases run against development at np 2, all failing as tabled.

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

Not run:

  • np 3 and 5. The author reports np 2 to 5. Our core budget on a shared machine allows at most 4 processes.
  • The neighbouring files the author lists (test_1096, test_1089, test_1173, test_1097, test_1099).
  • macOS.

Logs kept by the reviewer.

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi merged commit 0df40fe into development Nov 16, 2026
10 checks passed
jcgraciosa pushed a commit to jcgraciosa/underworld3 that referenced this pull request Nov 17, 2026
…nge-check _resolve_parents

The two follow-ups from the underworldcode#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
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