Skip to content

Fix collective evaluation of prescribed rotated wall data (supersedes #855) - #1097

Merged
lmoresi merged 9 commits into
developmentfrom
bugfix/rotated-datum-collectives-855
Nov 12, 2026
Merged

lmoresi merged 9 commits into
developmentfrom
bugfix/rotated-datum-collectives-855

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

This supersedes #855. It is @gthyagi's branch at 1d2297b8 with his two commits kept, development merged in, and the corrections our review of 2026-11-06 listed as merge conditions.

The fix (gthyagi, unchanged)

When an FE field prescribes the wall-normal velocity on a rotated free-slip wall, ranks that own nodes of different walls evaluated that data a different number of times. FE evaluation is collective, so the solve hung before its first Stokes iteration. _datum_batches now schedules the evaluations by registered boundary on every rank, including ranks with no nodes on a wall.

What we changed, and why

  • Merged development (93e66ee, then f8c6014). One conflict in build_rotation, where Rotated free slip: a mesh whose walls mix given and default normals keeps a rigid rotation in its answer #968 added given_dofs beside the changed datum_nodes list; both are kept.
  • Kept the sheet datum on fault pairs (one line in rotated_bc.py). The schedule filters rows by boundary name; development's fault-pair rows carried the datum expression in that slot, so after the merge the sheet's prescribed normal velocity was dropped without an error. The row now carries SHEET_TANGENCY. test_1092::test_fault_reaction_is_the_membrane_resultant is the regression test: on the merge commit it fails with a maximum error of 0.0474 against a limit of 0.00096; it passes on development and on this head.
  • A test that reaches the repaired call site. test_build_rotation_evaluates_fe_data_on_every_rank_in_registration_order puts FE data on two walls of a 1 x 4 box and solves. The data prescribe uniform flow, whose energy is exactly 4/100. The box is tall so that at three ranks one rank owns no wall node (independent review: on a unit box, a build_rotation that evaluates only on ranks holding datum nodes passed the test, and hangs on this one). On development this test hangs at three ranks (supervisor exit 124, ranks waiting in allreduce); it passes in serial there. It gathers each rank's schedule before asserting.
  • The schedule test gathers before asserting, so a rank-asymmetric schedule fails with a message instead of hanging.
  • Removed lines that did nothing: an assertion that could not fail, and a guard in _datum_batches that repeated its only caller's.

Not done: renaming node_dspec (it now holds a boundary name). The variable is development's, and this PR leaves development's lines in rotated_bc.py alone apart from the one sheet-datum row.

Verification (hyperion, PETSc int32, MPICH 5.0.1, head 009e96e)

check result
tests/parallel/test_1084 at np 1, 2, 3, 4, 5 4 passed on every rank
new build_rotation test on development, np 3 hangs, exit 124 (measured on the unit-box version; the independent review measured the tall box hanging under the gate mutant)
test_1092, all four tests including Maxwell pass (run at 09e3682 and d35ff07; library unchanged since)
test_1092 fault reaction on the merge before the fix fails, 0.0474 against 0.00096
parallel/test_1066_rotated_datum_parallel at np 2, 3, 5 (09e3682) pass
seven neighbouring rotated parallel files at np 3 (d35ff07) 33 passed, 4 skipped per rank; the skips are accuracy anchors not recorded for this host's gmsh
serial test_1018_rotated_freeslip, 1066, 1085, 1131, 0846, 1077 (d35ff07) 70 passed
scripts/check_test_coverage.py all 427 test files reachable

Not run: anything above np 5; the full suite (left to CI).

Issues

No open issue names this hang. #883, #939, #941, #348 and #878 are untouched by this change.

Checklist (UW3 Style Charter — docs/developer/UW3_STYLE_CHARTER.md)

  • I have read the Style Charter and followed it over the surrounding code (S2)
  • No drive-by refactors, renames, or "while I was here" cleanups (S9)
  • Bug fixes ship the regression test, written first, with level_* and tier_* markers (S8)
  • No hedging names (maybe_ / try_ / do_) and no commented-out code (S3, S4)
  • Every exception swallow states its sanctioned failure mode in a comment (S4)
  • New data access uses .array / mesh.X.coords — no with ....access(...), no mesh.data (S7)
  • Parallel safety considered — np2/np4 checked where swarm/mesh/solver dispatch is touched (S11)
  • No pixi.toml / pixi.lock or other dependency changes riding in an unrelated PR
  • AI-assisted work carries the attribution line below

Underworld development team with AI support from Claude Code

gthyagi and others added 7 commits October 23, 2026 15:16
Schedule FE-valued normal data in globally registered boundary order, including empty (0,dim) coordinate batches on ranks without constrained nodes. Local node/spec grouping could enter mesh local-vector collectives in different orders and hang before Stokes iteration. Preserve boundary attribution and SVD signs for each owned datum row.

Validation: two focused annulus component checks pass serial and on both MPI2 ranks, covering ranks with missing local boundary groups and FE evaluation of empty batches. No native or mathematical discretization change. Next: validate a fresh Gadi int32 installation on MPI16 and rerun the case2 h32 reproducer before primary-workflow acceptance.
State boundary registration order explicitly, mark the MPI regressions, and correct the datum-node payload comment.

Underworld development team with AI support from Claude Code
One conflict, in build_rotation: development added given_dofs (#968) beside
the datum_nodes list whose payload this branch changed to carry the boundary
name. Both are kept. No other change is made in this merge; the fault-pair
sheet datum that the name filter now drops is fixed in the next commit.

Underworld development team with AI support from Claude Code
…fore asserting

Review of #855 (2026-11-06), findings 2 to 4.

A third test puts FE data on two walls of a box and solves, so the repaired
call site in build_rotation is the code under test. The data prescribe uniform
flow, whose energy is exactly 1/100. On the old schedule this solve hangs at
three ranks before its first Stokes iteration.

The schedule test now gathers every rank's schedule before asserting on it, so
a rank-asymmetric schedule fails with a message instead of hanging in a
collective. The assertion that could not fail and the Open MPI variable that
does nothing under MPICH are removed.

Underworld development team with AI support from Claude Code
The datum schedule filters rows by boundary name. Development's fault-pair
rows carried the datum expression in that slot, so after the merge no row
matched the sheet and its prescribed normal velocity was dropped without an
error. The row now carries the sheet's registered name.

test_1092::test_fault_reaction_is_the_membrane_resultant is the regression
test: on the merge commit it fails with a maximum error of 0.0474 against a
limit of 0.00096, and it passes on development.

Underworld development team with AI support from Claude Code
No conflicts.

Underworld development team with AI support from Claude Code
build_rotation enters the datum schedule only when datum_specs is given, so the
helper's own check for None could not be reached (review of #855, finding 4).

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings November 12, 2026 05:46

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.

Independent review of #1097: on the unit box every rank owns a datum row, so a
build_rotation that evaluates data only on ranks holding datum nodes passed the
test at two, three and four ranks. That mutant hangs on a 1 x 4 box at three
ranks, where one rank owns no wall node (measured in the review). The test now
uses that box; its exact energy is 4/100.

The Open MPI oversubscribe variable on the three-rank CI line is restored with
a comment: it does nothing under MPICH and lets a two-slot Open MPI host start
three ranks.

Underworld development team with AI support from Claude Code
One conflict, in scripts/test.sh: #1092 rewrote the parallel pass to add an
np 3 pass. That pass is opt-in (--full-parallel) and CI runs
'test.sh --p 2' without it, so the dedicated np 3 line for
test_1084_rotated_datum_collectives is kept, placed before #1092's block,
which is taken unchanged.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

NOT READY at 09e3682: the code is correct and every claim H6 makes held when measured, but the new build_rotation test does not guard half of the fix. One small test change is needed (merge condition 1).

PR #1097 review (supersedes #855), independent pass by H1

  • Branch: bugfix/rotated-datum-collectives-855, head 09e3682. Base: development f8c6014.
  • Builds: own worktree wt-1097 at 09e3682 (BUILD EXIT 0, build-1097.log), and base wt-devf8c at f8c6014.
  • Tests ran from git archive copies (br/, base/) with PYTHONDONTWRITEBYTECODE=1 and -p no:cacheprovider. Parallel runs used --with-mpi under mpi_supervisor.py --silence 600.
  • Every run was pinned to 4 cores (taskset -c 88-91).
  • Mutants come from a pytest plugin (plug/mut1097.py, env MUT1097). It recompiles one function from its source with one textual substitution, and asserts that the substitution matched exactly once. No worktree was edited.
  • All logs are in this directory.

Findings

Medium: the new build_rotation test does not catch the outer-gate half of the fix

The fix has two parts:

  • (a) _datum_batches schedules by registered boundary, not by local rows.
  • (b) The evaluation block's gate changed from if datum_nodes: (local) to if datum_specs is not None: (registration).

Mutant M4 reverts (b) only. It survives the whole of test_1084 at np 2, 3 and 4: 4 passed on every rank (mut-M4_gate_local-np{2,3,4}.log).

Why it survives: on the test's 1×1 box with cellSize 1/16, every rank owns at least one Top or Bottom datum row at np 2–4. So no rank is ever empty in build_rotation, and the gate is never exercised. The schedule unit test does build an empty rank, but it calls _datum_batches directly and never reaches the gate.

M4 is a real hang. In probe_owner.py top at np 3, ranks 0 and 2 own no datum rows. M4 makes rank 1 wait in get_max_radius(), supervisor exit 124 (po-M4-top-np3.log).

The fix is cheap and measured:

  • Change the test's box to maxCoords=(1.0, 4.0), cellSize=1/12, with the energy target 0.04 (my copy is br/tests/parallel/test_9999_review_tallbox.py).
  • It passes on the branch at np 1, 2, 3 and 4 (tall-br-np*.log).
  • At np 3 it leaves a rank with no datum rows (rank 2; at np 4, ranks 0 and 3; po-br-both-np{3,4}.log).
  • Under M4 it hangs at np 3, exit 124 (tall-M4-np3.log).
  • Energy matches 0.04 to 2e-12–3e-13 at np 1–4.
  • CI's dedicated np 3 run in scripts/test.sh already covers it. The comment there ("a process owning no prescribed-wall groups") would then be true of the build_rotation test as well as of the schedule test.

Check (1): collectives on every rank, including ranks with no datum rows and no fault rows. PASS (measured)

probe_owner.py solves a 1×4 box with FE wall data. It records each rank's owned datum rows and every _eval_datum call.

case ranks with no datum rows schedules identical energy
both (FE Top + FE Bottom), np 2 none yes exact, 3e-12
both, np 3 rank 2 yes exact, 2e-12
both, np 4 ranks 0, 3 yes exact, 3e-13
top (FE Top only), np 3 ranks 0, 2 yes 0.0389089
top, np 4 ranks 0, 2, 3 yes 0.0389089
mixed (FE Top, constant Bottom, zero-datum Left), np 2–4 np 3: rank 2; np 4: ranks 0, 3 yes 0.0389118
  • The 2.7% energy shortfall in the top and mixed cases is not from this PR. Base and branch give the same value in serial, 0.038908860217 (po-base-top-np1.log, po-br-top-np1.log). It comes from my probe's corner conditions: essential Bottom against essential walls, and a datum at partially constrained corners.
  • On base the same probes hang: top at np 3 and 4, and both at np 3 and 4, all exit 124 with ranks in get_max_radius() (po-base-*.log).
  • Fault rows: probe_sheet.py is test_1092's fault-reaction case with the sheet datum as an FE MeshVariable (so evaluation is collective), at np 2 and 3. The fault lands on one rank and the others have no fault rows. Every rank makes exactly one evaluation call and the solve completes.
    • The fault rank's batch includes the 11 fault rows: 1073 points at np 3, against 1062 under M3.
    • Traction error is 4.3e-4 against a limit of 9.6e-4, and max|u_n − W| is 8e-17 (ps-br-fe-np{2,3}.log). The constant-datum runs match.
  • [read] The other collectives in build_rotation are unchanged by this PR and depend only on registration state: _boundary_velocity_nodes, _fault_pair_nodes, _collective_raise, snes.setUp, Q.assemble and the transpose. _datum_batches skips a boundary only when datum_specs.get(name) is None, which is the same on every rank.

Check (2): the new build_rotation test fails on development and passes on the branch. CONFIRMED, with one addition

np 1 np 2 np 3 np 4
base f8c6014 (-k build_rotation, _datum_batches import removed) pass pass hang, exit 124, rank 0 in get_max_radius() fail: one rank's schedule is ['{DatumRotBottom}'] only
branch 09e3682 (whole file, 4 tests) 4 passed 4 passed ×2 4 passed ×3 4 passed ×4
  • New: at np 4, development does not hang. The rank counts happen to pair up, and the test catches it through the gathered schedule assertion (t1084-base-np4.log). That is good evidence for the gather-before-assert design.
  • At np 2, development passes. CI's np 2 batch alone would not catch this regression, so the dedicated np 3 line in scripts/test.sh is load-bearing and must stay.

Check (3): the SHEET_TANGENCY one-liner (aa02d36). CONFIRMED

test_1092 test_fault_reaction_is_the_membrane_resultant result
branch 09e3682 pass, 16.6 s
base f8c6014 pass, 17.0 s
branch + M3 (row tagged with sheet_dspec again) fail: max error 0.047358 against 0.00096
  • This reproduces H6's 0.0474 exactly.
  • In parallel, M3 at np 3 (ps-M3-fe-np3.log) drops the 11 fault rows from the sheet batch. The fault nodes then stand still: max|u_n − W| = 0.100, the whole amplitude. The defect is silent, and the test is what catches it.
  • [read] test_1092 is tier_b, so CI's -m "not tier_c" runs it.

Check (4): the removed None guard (09e3682). SAFE [read]

  • _datum_batches has two callers: build_rotation (inside if datum_specs is not None:) and test_1084 (which passes a dict).
  • datum_specs reaches build_rotation from getattr(solver, "_rotated_freeslip_datum", None) in solve_rotated_freeslip. The SNES base __init__ sets that attribute to {}, and ThinSheet only adds or pops keys.
  • test_1085 and test_1086 call build_rotation without datum_specs, so it is None and the block is skipped.
  • No caller can pass None to the helper. An empty dict, the common case, yields nothing.

Check (5): neighbouring rotated free-slip tests, branch against base. NO DIFFERENCE (measured)

  • Serial, 10 files, xdist -n 4: test_1018 (two files), 1066, 1085, 1131, 0846 fault contact, 1077 thin-sheet faults, 1092 without Maxwell, 1141 and 0062. Branch 95 passed; base 95 passed.
  • Parallel, 8 files: test_1064, 1066 datum, 1068, 1086, 1088, 1131, 1140 and 1142.
    • At np 2, branch and base both give 44 passed, 2 skipped on each rank.
    • At np 4, branch and base both give 43 passed, 3 skipped on each rank.
    • The skips are the same on both sides: missing accuracy anchors for this host's gmsh mesh, and test_1140 not measured at np 4.
  • Not run: test_1092 Maxwell (32 min in H6's log), anything above np 4, and the full suite.

Check (6): mutants of the main fix

mutant what it does test_1084 at np 3
M1 local-only schedule skip batches with no local rows (pre-fix behaviour) caught: the schedule test fails on every rank (both parameters), then build_rotation hangs (exit 124)
M2 rank order odd ranks evaluate in reverse order caught: the schedule test and build_rotation's gathered schedule fail
M4 local gate if datum_nodes: instead of if datum_specs is not None: survives at np 2, 3 and 4; see the Medium finding
M6 first boundary only stop after the first datum boundary caught: the schedule test and build_rotation fail
M7 tag by expression node_dspec.setdefault(q, dspec) caught: build_rotation fails on the energy comparison
M3 sheet datum revert aa02d36 caught by test_1092 (check 3)

Low: scripts/test.sh np 3 line on Open MPI hosts [read]

  • gthyagi's OMPI_MCA_rmaps_base_oversubscribe=1 was removed as unused under MPICH. That is correct for CI: Linux pixi gives MPICH, so oversubscribing a 2-core runner is fine.
  • On an osx-arm64 dev machine with Open MPI and fewer than 3 slots, --p 2 would now fail that line with "not enough slots". This is unlikely on current Macs and does not block merging.

Low: one evaluation per boundary instead of per expression [read]

  • Development batched by id(dspec). This branch evaluates once per registered datum boundary, so the same field on two walls, or a boundary registered twice, is evaluated twice.
  • It is correct and the same on every rank; it is a small cost only.

Verified as stated [read plus measured]

Merge conditions

  1. Make the build_rotation test leave a rank with no datum rows, so that it catches M4. A 1×4 box with cellSize 1/12 and energy target 0.04 is measured to pass at np 1–4 and to hang under M4 at np 3. If the PR body or test docstring says what the test covers, it should say this too.
  2. Keep the dedicated np 3 line in scripts/test.sh. Development passes this test at np 2, so np 2 alone does not guard the regression.

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

PR #1097 re-check at 009e96e (test change only)

READY at 009e96e.

009e96e changes only tests and scripts/test.sh; the library is unchanged from 09e3682. So I ran 009e96e's tests (from git archive) on the 09e3682 build.

  • test_1084, on the 1 × 4 box, cellSize 1/12, energy 0.04: 4 passed on every rank at np 1, 2, 3 and 4 (rc-t1084-np{1..4}.log).
  • M4 (the outer gate reverted to if datum_nodes:) at np 3: the test now hangs. The supervisor reports "stuck, not slow" and exits 124 (rc-M4-np3.log). The gate is guarded.
  • scripts/test.sh: the dedicated np 3 line is kept, and OMPI_MCA_rmaps_base_oversubscribe=1 is restored on it with a comment. That answers the earlier low finding.

Both merge conditions from the first pass are met.

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 99daafb into development Nov 12, 2026
18 of 20 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.

4 participants