Repository navigation
Fix MPI submesh injection across parent ownership boundaries - #858
Conversation
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
Adversarial review1. The average conceals rank disagreement. injected = values.array.reshape(new_data.shape)[matched] / multiplicity[matched]is correct only while every contributing rank holds the same submesh value for The guard is cheap: reduce min and max alongside the sum and raise when they 2. 3. Discharged on inspection. We expected the We also traced |
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
|
Thanks @lmoresi. Addressed in Shared contributions now undergo per-component minimum/maximum reductions through the parent field's PETSc section SF. Disagreement beyond The regression deliberately corrupts local shared copies, covers both vector components and both transfer modes, and checks that rejection leaves the target unchanged. The inconsistency reproducer failed before the fix. After rebuilding locally, the complete file passes: serial 10 passed/4 MPI-only skipped; MPI2 and MPI3 each pass all 14 tests on every rank. I also documented collective surface extraction and the intentional persistence of empty parent labels. #858 must merge before #856. |
Adversarial review of #858Verdict: ready with listed changes. The production injection is correct under every attack we ran. The regression test does not exercise the defect the PR is named for, and the new code leaks memory on every call in parallel. Reviewed head f93cadb. Its base 7222caf is 344 commits behind development eddab70. The textual merge is clean. The last CI run (2026-10-29) predates that base, so it says nothing about the merged state. Findings
Attacks that failed
Issues
Merge conditions
Not testedOpen MPI and np above 8; CI's own partition at np 2; periodic parents and meshes after Underworld development team with AI support from Claude Code |
|
Finishing this PR (H5, at Louis's and C1's direction): a superseding PR from What changed, against H1's review of f93cadb (2026-11-06):
Mutants (overlays): the old body, no division, dropped old values, a loose tolerance and no finiteness check are each caught. Results: the file passes 20/20 at np 2, 3 and 4. The submesh files pass serially (81) and at np 2, 3 and 4 (54–56 each). test_0770 now passes at np 3. Finding 5 (enum agreement on nested children) is #856's. That follows next, the same way. Underworld development team with AI support from Claude Code |
…-858 Fix MPI submesh injection across parent ownership boundaries (completes #858)
…, hasLabel, tests 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 (underworldcode#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>
…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>
Submesh injection can lose shared-node values when a parent DOF owner retains no extracted-region cells. Local copies reach another rank's parent ghosts, then owner synchronization overwrites them with untouched values. In the annulus workflow this zeroed four inner-wall topography values before gravity assembly.
Reduce matched values and their multiplicities through the parent field DM before synchronizing owners. Averaging shared contributions preserves replace/add semantics and leaves unmatched parent values unchanged. Production transfer uses distributed PETSc vectors without gathering global coordinates.
The original CI failure exposed a second cause: if an extracted region initially occupies one MPI rank, the filtered DM reports
isDistributed() == False. The Mesh constructor then redistributed the child, invalidating rank-local parent matches. Preserve the parent-derived partition when constructing region and surface submeshes; ordinary mesh distribution is unchanged. Surface extraction now checks for a globally empty face stratum, allowing legitimate empty ranks while still rejecting missing/empty surfaces. Independent child repartitioning remains outside coordinate-coincidence injection.Validation of the updated branch on an isolated Mac PETSc 3.25.0 int32/Open MPI 5.0.10 build:
Earlier Gadi validation applies to the unchanged owner-reduction implementation in feature commit
86cb3cf1, before the partition-preservation follow-up:Underworld development team with AI support from Claude Code
Review follow-up (29 October 2026)
The shared-DOF injection now reduces per-component minima/maxima through the parent field's PETSc section SF and raises collectively on disagreement (rtol 1e-12, atol 1e-14) before touching the target. Sum/multiplicity injection and raw nondimensional values are retained. Extraction documents its collective contract and deliberately persistent empty parent labels.
A deliberately corrupted local-copy regression failed before the fix. The final regression uses a whole-domain extracted child to guarantee shared nodes at MPI2 and MPI3, checks both vector components and both transfer modes, and verifies unchanged targets on failure. An isolated native Mac rebuild passes the complete file: serial 10 passed/4 MPI-only skipped; MPI2 and MPI3 each pass all 14 tests on every rank. Source/target meshes are not repartitioned by this change.
Merge this PR before #856: its globally surviving-label collective requires the collective extraction guards supplied here.
Underworld development team with AI support from Claude Code