Skip to content

test_0858: build the partition instead of relying on the platform's partitioner - #1113

Merged
lmoresi merged 1 commit into
developmentfrom
bugfix/0858-test-deterministic-partition
Nov 12, 2026
Merged

lmoresi merged 1 commit into
developmentfrom
bugfix/0858-test-deterministic-partition

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member

What and why

tests/test_0858_submesh_injection_odd_ranks.py (from #1095) launches np 3 and np 5 runs. As its precondition, it requires some parent DOF on the extracted region's edge to be owned by a rank with no child copy of it. On macOS (W1, on wombat, development 613ed1e) the default partitioner left no such DOF: {'add': 0.0, 'orphans': 0, 'replace': 0.0}. Both cases failed the precondition before testing anything.

The partition is now built, not left to the partitioner:

  • a shell partition puts the region's cells (r < 1) on rank 0;
  • it deals the rest to ranks 1 to n-1 by angle;
  • PETSc gives a point shared between ranks to the highest of them, so the edge at r = 1 is owned by ranks with no child cell there, on any platform.

The test asserts both the layout (child cells only on rank 0) and the precondition, so it can't pass vacuously.

Tests

np 3 np 5
this branch 104 such DOFs; replace and add exact 104 such DOFs; replace and add exact
the code before #1095 replace error 8.0, add error 1.0 the same

The code before #1095 also ignores the built layout (its child cells end up on every rank), which fails the layout assert as well.

Only the test changes.

Checklist

  • Style Charter followed (S2)
  • No drive-by changes (S9)
  • Test markers kept (S8)
  • No hedging names or commented-out code (S3, S4)
  • No exception swallows
  • No new data access
  • Parallel: np 3 and 5 (S11)
  • No dependency changes
  • AI attribution below

Underworld development team with AI support from Claude Code

🤖 Generated with Claude Code

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 #1095
the replace error is 8.0 and the add error 1.0.

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

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 closed this Nov 12, 2026
@lmoresi lmoresi reopened this Nov 12, 2026
@lmoresi

lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

Review of #1113 (test_0858 builds its own partition)

Verdict: READY at c78bf26. One non-blocking finding: this file no longer catches the no-division mutant. test_1087 at np 2 still catches it, and a one-line change, tested below, restores the catch here.

Reviewed head c78bf26c against development (merge-base 613ed1e0). The diff is test-only: tests/test_0858_submesh_injection_odd_ranks.py, +50/−6.

Build: wt-dev01b (01b06c9). It contains #1095 (705de47 is an ancestor). The installed discretisation_mesh.py is identical to the worktree source, and Mesh._reduce_injection is present. Hyperion, MPICH, everything pinned to 2 cores (taskset -c 40,41; np 3 and np 5 oversubscribe those 2 cores).

Tests ran from git archive refs/h1/pr1113 tests scripts/mpi_supervisor.py copies, with PYTHONDONTWRITEBYTECODE=1 and -p no:cacheprovider. Logs are in runs/2026-11-13-1113/logs/, and the per-run errors.json files are in runs/2026-11-13-1113/bt/.

Mutants in the workers

test_0858 runs its check in mpirun subprocesses, so a pytest plugin in the parent process never reaches them. I put H3's #1095 mutant table (runs/2026-11-12-h3review/1095/mut/mut1095.py) into hook/sitecustomize.py, on PYTHONPATH. It rewrites the method when discretisation_mesh is imported in any process. Every worker logs [MUT <name> applied pid …], and the run logs confirm the rewrite reached every rank.

I also added rev1095, which replaces all of Mesh.prolongate with the version from before #1095 (f8c6014). This is the library fix reverted.

H5's runs/h5-858/ov-* overlays are full package copies of the older h5-858 tree, so I did not use them on dev01b.

1. The test passes serially

  • 2 passed (np 3, np 5), in 15 s.
  • A second run gave the same result.
  • A third run with PETSC_OPTIONS=-petscpartitioner_type simple also gave 2 passed.

2. The partition it builds

errors.json for the plain run:

  • np 3: child_cells [406, 0, 0], orphans 104, replace 0.0, add 0.0
  • np 5: child_cells [406, 0, 0, 0, 0], orphans 104, replace 0.0, add 0.0

A probe (probe.py, which imports the test's own _region_on_rank_0) gave this at np 3:

rank cells before (parmetis) cells after inside r=1 outside child cells orphans owned
0 351 406 406 0 406 0
1 360 328 0 328 0 51
2 351 328 0 328 0 53
  • Total cells are 1062 before and after, so no cell is lost or duplicated.
  • At np 5, rank 0 keeps the same 406 cells and the outer cells are dealt across ranks 1 to 4.
  • All 104 parent P2 nodes on r = 1 are orphans: owned by an outer rank, with no child copy there. The default-partition test on development had only 2.
  • The odd-rank layout and the orphan condition both hold. The new child_cells assertion pins the layout.

3. The test still guards the fix

mutant PR test (c78bf26) development test
rev1095 (pre-#1095 prolongate) 2 failed: replace 8.0, add 1.0 (H3: fails, 8.0 / 1.0)
oldbody (per-rank write) 2 failed: replace 8.0, add 1.0 fails
nodiv (no division by multiplicity) 2 passed (not caught) 2 failed: replace 1.0, add 1.0
noreduce (section-SF min/max reduction skipped) passed passed
loosetol, nofinite, localraise, localempty, nodestroy passed passed
  • The library fix reverted: caught at np 3 and np 5, with the same errors H3 recorded for development.
  • noreduce, loosetol, nofinite, localraise, localempty and nodestroy only weaken the consistency checks, the empty-surface check or the SF release. Agreeing copies never exercise them. Neither version of this file catches them, and the parallel test_1087 file does (H3's table). So this PR loses no coverage there.

Findings

  1. Medium, non-blocking: this file no longer catches the nodiv mutant.
    • Cause: the whole region sits on rank 0, so no parent DOF has more than one child copy and the multiplicity is always 1. Under the old platform partition the region straddled ranks, and nodiv gave error 1.0.
    • Other cover: parallel/test_1087_submesh_prolongation_ownership.py (agreeing-copies tests) at np 2 with --with-mpi: 10 passed with no mutant, and 2 failed under nodiv. The cover is in CI's parallel tests, not lost.
    • Suggested fix, tested in runs/2026-11-13-1113/variant/: split the region's cells between ranks 0 and 1 by angle, and deal the outside cells to ranks 2 to n-1. Then change the assertion to all(child_cells[:2]) and not any(child_cells[2:]).
      • The variant passes: child_cells [203, 203, 0], then [203, 203, 0, 0, 0], orphans 104, errors 0.
      • nodiv fails, with errors 1.0 / 1.0.
      • oldbody and rev1095 fail, with errors 8.0 / 1.0.
      • np 3 then has a single outer rank, which still gives the orphan case.
  2. Low. _region_on_rank_0 only works for uw.mpi.size >= 2. At np 1, size - 2 = -1, so dest would be −1 and bincount raises. The worker only ever runs at np 3 and np 5, so this cannot be reached from the test.
  3. Nit. Region membership is read from the cell centroid (hypot < 1.0), not from the "Inner" label. This is exact here, because the internal boundary is meshed conformally. Using the label would tie it to the same definition extract_region uses.
  4. Nit. The PETSc partitioner option has no effect on the parent: UW builds it with its own default (parmetis on hyperion) and ignores -petscpartitioner_type. That is why item 4 below uses explicit repartitioning.

4. Platform independence and determinism

  • Two plain runs: the per-rank layout fingerprint is identical (md5 of sorted cell centroids).
    • np 3: ffd7af0f85 9f91253f04 85a731546e
    • np 5: ffd7af0f85 d97383e778 922f14dd32 f5aca99abc c322adf999
  • -petscpartitioner_type simple|ptscotch|chaco in PETSC_OPTIONS: the parent still came out of parmetis (351/360/351), so these runs check nothing.
  • A different starting partition, forced: I repartitioned the parent with simple or ptscotch before calling _region_on_rank_0. The starting layouts were 354/354/354 and 352/355/355 at np 3, and 213/213/212/212/212 and 212/212/212/213/213 at np 5.
    • The built layout matched the parmetis start on every rank.
    • The orphan count was 104 in every case.
  • So the built partition does not depend on the partitioner. The ownership of shared r = 1 points went to the outer ranks every time, which matches the docstring's "highest rank" statement.
  • macOS was not tested.

5. Rest of the diff

  • The shell-partition idiom is the one the library already uses in fault_split.py, custom_mg.py and place_surface.py.
  • migration is destroyed. Mesh(dm, …) does not redistribute an already-distributed DM. regions is copied across.
  • The docstring is accurate. It drops the "CI runs np 2, np 4" remark, which is fine.

CI at c78bf26

  • An earlier run (43220237178) failed shard 3/6 on parallel/test_1152_fac_zone_survives_a_mover_parallel.py::test_a_kept_zone_patch_matches_a_fresh_registration[zone] (NaN pressure). That file is unrelated to this diff.
  • A rerun (43290806515) was pending at review time. Only shard 6/6 and the style gates had finished, and both passed.

Not tested

macOS; Open MPI; np other than 3 and 5 for the test itself.

Underworld development team with AI support from Claude Code

@lmoresi lmoresi closed this Nov 12, 2026
@lmoresi lmoresi reopened this Nov 12, 2026
@lmoresi
lmoresi merged commit b0a426d into development Nov 12, 2026
26 of 30 checks passed
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