Skip to content

Fix MPI submesh injection across parent ownership boundaries (completes #858) - #1095

Merged
lmoresi merged 5 commits into
developmentfrom
bugfix/submesh-injection-858
Nov 12, 2026
Merged

lmoresi merged 5 commits into
developmentfrom
bugfix/submesh-injection-858

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member

Supersedes #858 (gthyagi's "Fix MPI submesh injection across parent ownership boundaries"). His three commits are kept, merged, not squashed; this branch adds development and the review follow-up. Fixes #1087.

What changed and why

The defect (from #858). Mesh.prolongate, and copy_into from a submesh to its parent, mapped DOFs rank by rank, wrote matched rows, then synced. That keeps each DOF's owner's value. A parent DOF on the region's edge can be owned by a rank with no child cell there; that rank had no copy to write, so the DOF kept its old value. Separately, an extracted region on one rank was redistributed by the Mesh constructor, which broke its parent map.

#858's fix:

  • Every rank's copy of an injected value reaches the parent owner through the field DM's section SF. Copies must agree (rtol 1e-12, atol 1e-14) or every rank raises; the owner takes their mean.
  • Region and surface extraction keep the parent's partition.

Review follow-up (H1, 2026-11-06), in b09e3dc:

  • Test partition: the region is on rank 0 with its neighbour on the last rank, so orphan DOFs exist, and the test asserts they do. The old body fails it at np 2 and np 3.
  • Memory: the section SF is released. That was 1098 kB per call at 23.6k DOF rows, now 0.
  • Code: the reduction is a helper, _reduce_injection, using MPI.DOUBLE.
  • Labels: extract_surface checks hasLabel (a missing label raised a PETSc abort; it now raises ValueError) and no longer adds labels to the parent.
  • New tests: agreeing shared copies are injected; the rejection tolerance on both sides plus NaN; a missing label.
  • Mesh.prolongate from a submesh loses values at parent DOFs owned by a rank outside the region (fails at np 3) #1087's regression: tests/test_0858_submesh_injection_odd_ranks.py runs the annulus at np 3 and np 5 from serial CI, starting from sevens, and asserts orphan DOFs exist.
  • Design note: its paragraph is moved below the flavours table.

The full list, finding by finding, is on #858.

Tests

  • tests/parallel/test_1087_submesh_prolongation_ownership.py: 20/20 at np 2, 3 and 4.
  • Mutants (overlays): each is caught.
    • The old body: 10 failures at np 2 and 3.
    • No division by the multiplicity: caught at np 2.
    • Dropped old values: caught by both files.
    • A loose tolerance, and no finiteness check: caught by the tolerance test.
  • Submesh files: 81 passed serially; 54–56 passed at np 2, 3 and 4. test_0770 now passes at np 3.
  • Memory: 0.0 kB growth per call at np 2 over 200 calls, against 1098 kB without the release.

Follow-up

#856 (boundary names across ranks) lands straight after this, as #858 says; it covers H1's finding 5.

Checklist (UW3 Style Charter)

  • I have read the Style Charter and followed it over the surrounding code (S2)
  • No drive-by refactors (S9). The helper extraction was a review request.
  • 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). The injection copies raw nondimensional values: S7's variable-to-variable exception.
  • Parallel safety considered: np 2, 3, 4 and 5 checked; every raise is collective (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 5 commits October 24, 2026 18:28
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>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 05:34

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 705de47 into development Nov 12, 2026
10 checks passed
lmoresi added a commit that referenced this pull request Nov 12, 2026
…names-856

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

lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

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

Verdict: READY at b09e3dc. The injection is correct under every attack we ran. Each of H1's 2026-11-06 merge conditions on #858 is met, and each new test fails on the bug it names.

Reviewed head b09e3dc3 against development f8c60140 (its ancestor). Hyperion, PETSc int32, MPICH; runs supervised. Logs are in runs/2026-11-12-h3review/1095/logs/.

Findings

None blocking.

  1. Low. Two mutants are caught only as a hang or an abort, not as an assertion:

    • the disagreement check raising rank-locally (if int(invalid):) hangs at np 3 (exit 124);
    • the emptiness check in extract_surface made rank-local (if local_faces == 0:) aborts at np 3 (exit 134).

    Both are caught, so this is not a defect. A failure message would be kinder than a supervisor timeout.

  2. Low. test_the_rejection_tolerance[5e-13-True] asserts that the call does not raise, but not the injected value. The agreeing-copies test covers the value.

Attacks that failed

  • The defect, on development (test_0858, which launches np 3 and np 5 itself): replace error 8.0 and add error 1.0, with 2 orphan DOFs present; 2 failed. Head: 2 passed.

  • The in-process injection test on development, np 3: 4 of 8 cases fail, all in the single-rank-region partition. Head: 20/20.

  • The PR's parallel file at the head: 20 passed on every rank at np 2, 3, 4 and 5. At np 1, 11 passed and 9 skipped (the mpi-marked tests).

  • Mutants, each caught by the PR's own tests at np 3:

    mutant result
    old body (per-rank write) 10 failed, including all 4 single-rank-region injection cases
    no division by multiplicity 6 failed at np 3, and 2 failed at np 2 (the agreeing-copies test)
    rtol 1e-9 the 5e-11 rejection case fails
    finiteness check removed the NaN case fails
    section-SF reduction skipped 5 failed
    rank-local raise hang, exit 124
    rank-local empty-surface check abort, exit 134
  • Memory, np 2, 65,139 parent rows, 100 calls after 20 warm-up: head 0.00 kB per call. With overlap.destroy() removed: 3041 kB per call.

  • Collectives behind rank-local guards (from reading _reduce_injection and extract_surface):

    • createSubDM, both section-SF reductions and both allreduce calls run on every rank;
    • the only branch is on uw.mpi.size;
    • the raise follows a global allreduce;
    • extract_surface reads hasLabel per rank, and its emptiness decision is global.
  • Neighbours:

    • 9 serial submesh files: 81 passed, 1 skipped;
    • 8 parallel submesh files (0768, 0770, 0773, 0775, 0779, 0782, 0783, 0785): pass on every rank at np 2, 3, 4 and 5, with 38 to 40 passed per rank (the skips vary by rank count).
  • CI at b09e3dc: green on every shard.

H1's 2026-11-06 merge conditions on #858

Issues

Not tested

np above 5; Open MPI; 3-D regions; periodic parents; the Gadi np 16 workflow.

Underworld development team with AI support from Claude Code

gthyagi pushed a commit to gthyagi/underworld3 that referenced this pull request Nov 13, 2026
…evelopment f8c6014) into underworldcode#856

underworldcode#856 must land after underworldcode#858: its collective _surviving_labels needs underworldcode#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>
gthyagi pushed a commit to gthyagi/underworld3 that referenced this pull request Nov 13, 2026
The test launched np 3 and np 5 and required some parent DOF on the
region's edge to be owned by a rank with no child copy of it. On macOS the
default partitioner left none, so the test failed its precondition before
testing anything (W1, on wombat). A shell partition now puts the region's
cells (r < 1) on rank 0 and deals the rest to ranks 1 to n-1 by angle;
PETSc gives a shared point to the highest rank sharing it, so the edge at
r = 1 is owned by ranks with no child cell, on any platform. Measured:
104 such DOFs at np 3 and 5; the transfer exact. On the code before underworldcode#1095
the replace error is 8.0 and the add error 1.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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