Skip to content

Keep extracted boundary names consistent across MPI ranks (completes #856; after #1095) - #1098

Merged
lmoresi merged 8 commits into
developmentfrom
bugfix/submesh-boundary-names-856
Nov 12, 2026
Merged

lmoresi merged 8 commits into
developmentfrom
bugfix/submesh-boundary-names-856

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member

Supersedes #856 (gthyagi's "Keep extracted boundary names consistent across MPI ranks"). His commit is kept, merged, not squashed.

Merge after #1095. This branch contains #1095 (#858, completed), because it needs #858's collective extraction guards. Until #1095 merges, this PR's diff includes #1095's changes as well; after that it shows only #856's own.

What changed and why

The defect. extract_region built each rank's boundary enum from the label strata it held, so a rank with no points on a boundary left that name out. A boundary condition on it then raised KeyError on that rank, while the others waited in collective solver setup. On development a natural condition on Top hung at np 2, 4 and 8. A checkpoint written by such a rank also lost the names.

The fix (#856). _surviving_labels takes the union over ranks (an allgather), so every rank's enum holds every name that survives anywhere.

The review follow-up (H1, 2026-11-06), in 2333f8f:

  • Source: no label creation. Every rank already has the label, and the branch never fired outside a synthetic test.
  • The helper test:
    • it uses the reachable state (the label everywhere, points on rank 0);
    • it checks collectively, using hasLabel;
    • it destroys its DM in finally.
  • The public contract: the enum is pinned exactly, for the default partition and for a region held by one rank.
  • New: the symptom. A natural condition on Top for a region only rank 0 holds, solved to u = y.
  • New: surface extraction on that region.
  • Collective checks. Every test checks rank agreement collectively before a call that would raise on some ranks only, so the old code fails cleanly instead of hanging.

The finding-by-finding list is on #856.

Tests

  • tests/parallel/test_1085_submesh_boundary_names.py: 5/5 at np 2, 3 and 4.
  • On the old code (an overlay): 5 failed at np 2 and np 4, exit 1, no hang.
  • A rank-0 broadcast instead of the union: caught.
  • Submesh files: 81 serial; 59–61 at np 2, 3 and 4.

Checklist (UW3 Style Charter)

  • I have read the Style Charter and followed it over the surrounding code (S2)
  • No drive-by refactors (S9)
  • Bug fixes ship the regression test, shown to fail without the fix, with level_* and tier_* markers (S8)
  • No hedging names and no commented-out code (S3, S4)
  • Every exception swallow states its sanctioned failure mode in a comment (S4): none added
  • New data access uses .array / mesh.X.coords (S7)
  • Parallel safety considered: np 2, 3 and 4 checked; collective checks come before any rank-local raise (S11)
  • No pixi.toml / pixi.lock or other dependency changes
  • AI-assisted work carries the attribution line below

Underworld development team with AI support from Claude Code

gthyagi and others added 8 commits October 23, 2026 17:48
Region filtering previously selected boundary enum members from rank-local strata. A coarse extracted annulus lost Upper on some ranks, causing KeyError in natural Stokes boundary registration while peers entered collectives. Union label presence over the DM communicator and create empty labels where globally retained boundaries have no local points. Preserve candidate order and exclude globally absent labels.

Validation: two focused regressions pass serial and on each of two MPI ranks, including actual region extraction. No equations, coordinates, partitioning or finite-element values change. Next validate the existing int32 Gadi installation gates and rerun only the four affected coarse Poisson models.
Reduce source values and multiplicities through the parent field DM before owner synchronisation. This preserves spatial injection without global coordinate gathering, including add mode and untouched exterior values. A parent owner may retain no extracted-region cells even when another rank has the corresponding source node.

Add independent P1/P2 vector replace/add regressions. Reproducer: annulus 2h buffers at h=1/32 on 16 ranks lose four inner-wall source values despite correct saved submesh topography. Static compilation and diff checks pass; matching versioned int32 installation, serial/MPI regression gates and affected scientific reruns remain pending on Gadi.
Avoid implicit child redistribution when a filtered region or surface occupies only one MPI rank. Preserve the parent-derived point/DOF mappings and retain the existing parent-owner reduction. Make surface emptiness validation collective so ranks outside a valid surface do not fail before PETSc extraction.

Add deterministic P1/P2 replace/add coverage with the region concentrated on one parent rank, plus empty-rank re-extraction/cell-size and surface-label tests. The four new transfer cases fail on the original PR with errors 5.0/4.0 before this change.

Validation on an isolated rebuilt Mac PETSc 3.25 int32/Open MPI runtime: 20 serial passed, one existing expected failure; 23 passed on each of two ranks; 10 passed on each of four ranks. Python parsing, Black test formatting, deprecated-pattern gate, CI test reachability and diff checks pass. Shared runtime and benchmark results unchanged. Next: verify the fresh Linux/MPICH CI run.

Underworld development team with AI support from Claude Code
Reduce component minima and maxima in the parent field section SF before changing any target values. Preserve raw nondimensional transfer and document collective surface extraction and its persistent empty labels.

Underworld development team with AI support from Claude Code
#858's base was 7222caf, over 370 commits behind. Merged, not rebased,
to keep gthyagi's commits and authorship.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sts pinned

H1's review of f93cadb (2026-11-06), with development merged.

- The injection test now puts the extracted region on rank 0 and its
  neighbour on the last rank, split at the interface (y = 0.85). Parent
  DOFs owned there by a rank with no child copy now exist, and the test
  asserts that they do; the old prolongate body fails it (10 tests at
  np 2 and 3), where before it passed.
- The section SF taken in prolongate is released: it grew memory by
  1098 kB per call at 23.6k DOF rows on rank 0 at np 2; now 0.
- The shared-value reduction is a helper, _reduce_injection, with the
  public MPI.DOUBLE.
- extract_surface asks hasLabel before reading a label (getLabel gives a
  null handle, and getValueIS on it aborted PETSc), and no longer adds
  empty labels to the parent: every rank already has the label.
- New tests: agreeing shared copies are injected (a missing division by
  the multiplicity now fails at np 2); the rejection tolerance on both
  sides and non-finite values; a missing label raises ValueError. The
  MPI-only tests carry mpi(min_size=2).
- tests/test_0858_submesh_injection_odd_ranks.py runs the annulus
  injection at np 3 and 5 from serial CI (#1087), from a field of sevens
  so dropped old values show, and asserts orphan DOFs exist.
- The design note's paragraph moves below the flavours table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#856 must land after #858: its collective _surviving_labels needs #858's
collective extraction guards. Merged, not rebased, to keep gthyagi's
commits and authorship.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n the contract

H1's review of 9bf307d (2026-11-06).

- _surviving_labels keeps the allgathered union (the fix) and no longer
  creates labels: a filtered DM carries the parent's label list on every
  rank, and the branch never fired outside the synthetic test.
- The helper test builds the reachable state (the label on every rank,
  points on rank 0 only), checks agreement on every rank, uses hasLabel,
  and destroys its DM in a finally, so a failure cannot hang the batch.
- The enum is pinned exactly, for the default partition and for the
  region on one rank.
- New: the symptom itself, a natural condition on Top for a region held
  by rank 0 alone, solved to u = y; and extract_surface on that region.
- level, tier and mpi(min_size=2) markers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 06:52

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 merged commit 552ff44 into development Nov 12, 2026
10 checks passed
@lmoresi

lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

Adversarial review of #1098 (H3, second review desk)

Verdict: READY at 2333f8f, merged after #1095 and on green CI. CI was still running when we finished: shards 5 and 6 had passed. The union of surviving names is correct, and the symptom test catches the defect on development.

Reviewed head 2333f8f9 (stacked on #1095 at b09e3dc) against development f8c60140. Supervised runs; logs are in runs/2026-11-12-h3review/1098/logs/.

Findings

None.

The symptom, checked as asked

  • The real symptom on development, np 2: a copy of test_a_natural_condition_on_a_boundary_some_ranks_lack with the two pre-checks removed. One rank raises KeyError: 'Top' in BC registration while its peer waits in solver setup: exit 124 (hang). The same with only the union line removed at the head: KeyError: 'Top', exit 124. At the head it passes.
  • The PR's own file on development, np 2: 5 of 5 fail on both ranks, exit 1, no hang. The enums disagree (_agree(['All_Boundaries']), _agree([('All_Boundaries', 1001)])). The collective pre-checks turn the hang into a clean failure, as intended.

Attacks that failed

  • The PR's file at the head: 5 passed on every rank at np 2, 3, 4 and 5. At np 1, 5 skipped (module mpi(min_size=2)).
  • Mutants at np 2:
    • union removed: 5 failed per rank;
    • a rank-0 broadcast in place of the union: 1 failed per rank (test_surviving_labels_use_global_presence).
  • Collectives (from reading): the new allgather sits in _surviving_labels, which every rank reaches from extract_region and extract_surface. There is no rank-local branch before it.
  • Neighbours at the head, with Fix MPI submesh injection across parent ownership boundaries (completes #858) #1095's files included:
    • 35 serial submesh and units-model files: 314 passed, 3 skipped;
    • 8 parallel files (0768, 0770, 0773, 0779, 0783, 0785, 1085, 1087): 56 to 58 passed per rank at np 2, 3, 4 and 5.

Issues

Not tested

np above 5; Open MPI; 3-D regions; a checkpoint written by a rank without the name (named in the PR body); nested extraction.

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.

4 participants