Skip to content

Fix collective evaluation of prescribed rotated wall data - #855

Merged
lmoresi merged 2 commits into
underworldcode:developmentfrom
gthyagi:bugfix/rotated-datum-collectives
Nov 12, 2026
Merged

lmoresi merged 2 commits into
underworldcode:developmentfrom
gthyagi:bugfix/rotated-datum-collectives

Conversation

@gthyagi

@gthyagi gthyagi commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

When an FE field prescribes wall-normal velocity, ranks owning different subsets of the registered walls can call datum evaluation a different number of times or in a different order. FE evaluation updates mesh local vectors collectively, so the rotated solve can hang before its first Stokes iteration.

Evaluate data in registered boundary order on every rank, including empty (0, dim) coordinate batches. Keep boundary attribution and the existing SVD signs for owned datum rows. No discretization, solver-tolerance or native-code changes are involved.

Validation:

  • Two focused tests pass in serial and on each MPI2 rank locally.
  • A fresh Gadi PETSc int32 installation passes both tests on all 16 ranks, including FE evaluation with no local query points.
  • The benchmark annulus component suite passes 161 tests.
  • The annulus case2 h=1/32 reproducer completes on 16 Gadi ranks in 36 seconds with the corrected installation. Two unchanged pre-fix attempts stalled before their first Stokes iteration. Physical inputs and solver tolerance remain fixed. The matched h=1/64 run also completes.

The regression tests exercise differing local boundary groups and empty FE evaluation batches without running a Stokes model.

Review follow-up (29 October 2026)

  • Corrected the datum-node payload comment and made registration order explicit in the regression assertion.
  • Added level/tier markers and an empty-local-group case at two ranks. CI now also runs this focused file with three MPI ranks, including a rank owning neither registered wall.
  • Rebuilt into an isolated native Mac environment: 3 tests pass in serial (5.11 s), and all 3 pass on every rank at MPI2 and MPI3. Shell syntax and test-file coverage checks pass.
  • This PR owns the generic rotated-datum fix. The annulus PR Add opt-in annulus pressure, wall and traction recovery #857 must share this commit history and land after it; the duplicate implementation/test will disappear from Add opt-in annulus pressure, wall and traction recovery #857's development diff once this prerequisite lands. That dependency is now reconciled: Add opt-in annulus pressure, wall and traction recovery #857 shares this exact commit history and both rotated helper/test files, with no separate diff against this prerequisite.
  • No numerical solver configuration changed. The existing boundary capability guide remains accurate.

Underworld development team with AI support from Claude Code

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.
@gthyagi
gthyagi marked this pull request as ready for review October 23, 2026 06:45
@gthyagi
gthyagi requested a review from lmoresi as a code owner October 23, 2026 06:45
@gthyagi
gthyagi marked this pull request as draft October 25, 2026 15:39
@lmoresi

lmoresi commented Oct 28, 2026

Copy link
Copy Markdown
Member

Adversarial review

1. The library change here is byte-identical to #857's. Both carry
src/underworld3/utilities/rotated_bc.py as blob 4fd412a9, so #857 already
contains this fix in full. The only difference is the test: #857's copy of
tests/parallel/test_1084_rotated_datum_collectives.py is this one plus the
level_1 / tier_b markers every test file is required to carry. Whichever
merges second hits an add/add conflict on that file. One of the two PRs should
own the fix — land this one and have #857 drop its copy, or land #857 and close
this.

2. Stale comment on the payload. rotated_bc.py:444 still reads
# (grows[0], q, dspec) for simple nodes, but the change at :417 makes the
third element a boundary name. One line.

3. The order assertion passes by arithmetic coincidence.

assert uw.mpi.comm.allgather(datum) == [2.0+index]*uw.mpi.size

against datum_specs={"Upper": 2.0, "Lower": 3.0}. It reads as a formula over
the batch index but holds only because 3.0 == 2.0 + 1. Compare against the
explicit [2.0, 3.0] so the test states registration order instead of encoding
it in an expression that would survive a reordering.

4. The empty-rank case the fix exists for is only half-covered in CI. CI
runs ./scripts/test.sh --p 2, so if rank > 1: never holds and "a rank with
no local boundary group at all" is unexercised. The empty-batch path is
covered, since rank 1 owns no Upper. The validation in the description is at
16 Gadi ranks; CI is at 2, and np=2 is a special case for this class of bug. A
3-rank case would close the gap.

What we attacked and could not break: the schedule is driven by boundaries,
which is common to all ranks; datum_specs is None yields no batches on every
rank alike; and an empty items reshapes to (0, dim) rather than failing.

Finding 1 is the only one that blocks.

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
@gthyagi

gthyagi commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @lmoresi. Addressed in 1d2297b8:

An isolated native Mac rebuild passes all 3 tests in serial and on every MPI2/MPI3 rank. Shell syntax and test-file coverage checks also pass. GitHub CI has not yet been verified for this update.

@gthyagi
gthyagi marked this pull request as ready for review October 29, 2026 12:47
@lmoresi

lmoresi commented Nov 6, 2026

Copy link
Copy Markdown
Member

Adversarial review of #855

Verdict: ready with listed changes. The fix is correct and removes a hang we reproduced on development. It cannot merge as it stands: a merge with no conflicts silently drops a datum that development added after this branch forked, and the new tests do not exercise the repaired call site.

Reviewed at head 1d2297b8. The base 0dfb734d is 376 commits behind origin/development eddab707, and rotated_bc.py differs from that tip by 1163 lines. CI last ran on 2026-10-29.

Findings

  1. High. The clean merge drops the sheet datum on fault pairs, with no error. git merge-tree reports no conflict. build_rotation on development still appends (gp[2], q_plus, sheet_dspec, ...), but _datum_batches now filters on boundary == name, so those rows never reach datum_map. test_1092::test_fault_reaction_is_the_membrane_resultant, serial: passes on development; fails on the merged tree with max error 0.04736 against a limit of 0.00096. Replacing sheet_dspec with SHEET_TANGENCY on that line makes it pass. tests/test_109*py is in scripts/test.sh, so CI on a current merge should catch this; the 29 October green does not cover it.
  2. Medium. No test reaches the repaired call site (Charter section 8). Neither test calls build_rotation, and the per-rank wall lists in the first test are hand-written. On the base's rotated_bc.py the file stops at collection with ImportError: _datum_batches, which is not the bug. A mutant restoring if datum_nodes: in build_rotation while keeping the helper passes all 3 tests at np 2 and 3, while a box probe hangs at np 8 (exit 124 at 334 s). A two-wall box through build_rotation does fail on the old logic for the right reason: development hangs at np 3 (exit 124 at 334 s).
  3. Low. A rank-asymmetric schedule fails as a hang, not an assertion. assert len(batches) == 2 runs on the failing rank while its peers wait in allgather: a mutant exits 124 at np 2 and 3 with no assertion message.
  4. Low. Dead lines (Charter section 5). OMPI_MCA_rmaps_base_oversubscribe=1 does nothing under the MPICH 5.0.1 the CI log reports; assert allreduce(1) == size cannot fail; if datum_specs is None in _datum_batches repeats its only caller's guard.
  5. Low. Stale name (Charter section 3). node_dspec now holds a boundary name, and the comment above that loop still says it holds the datum.

Note, not a defect of this PR: at head, a datum-only cold start returns v = 0 with converged reason 2. development gives energy 1.5340159191e-02 on the same annulus probe, so validation run on this base does not carry over to the rebased code.

Attacks that failed

  • Hang reproduced and fixed: development, box with FE data on Top and Bottom, np 3: rank 0 enters F1 then F2, rank 1 F1, rank 2 F2, then silence and exit 124. Head and the merged tree both complete.
  • Empty ranks: box at np 8 has ranks 3, 5 and 6 with no wall nodes; every rank made both evaluations, including (0, dim) batches.
  • Partition dependence, merged tree: box energy 3.1234315280e-03 at np 1, 2, 3, 4, 8; annulus 1.5340159191e-02 at np 1, 3, 8; both match development wherever it completes. At head, with a body force: box 3.1973039477e-03 and annulus 1.54350760e-02 at np 1, 3, 8.
  • Stale values on a second solve: doubling the FE data gives an energy ratio of 4.00000000 at every np on the merged tree.
  • Exact baseline, mixed constant and FE data: energy 1.0000000000e-02 against exact 0.01, datum residual 2.5e-13, at np 1, 3, 8.
  • Mutants the tests catch: boundary order reversed, 2 of 3 fail at np 2 and 3; evaluator skipped on empty coordinates, hangs at np 2.
  • Determinism, by inspection: the schedule comes from the boundaries list, and the id() keying is gone.
  • CI reach: the log for 1d2297b8 shows 3 passed on every rank at np 2 and np 3. Own tests at head: 3 pass at np 1, 2, 3, 4, 8.
  • Neighbouring tests with the one-line fix: test_1066 np 2 and 4, test_1086 np 2, test_1081 np 3, test_1092 breathing sphere np 2.

Issues

We found no open issue naming this hang. From reading the diff, not probed: #883, #939, #941, #348 and #878 still live, untouched here; #935 unchanged, stays fixed-in-development.

Merge conditions

Not tested

The reported 16-rank annulus at h = 1/32 and 1/64, or anything above np 8 (our annulus runs had no empty rank up to np 8); the 3-rank evaluator-skip mutant, unfinished when written; sheet datum on fault pairs in parallel, since that test also fails at np 3 on development; the full suite on the merged tree. The merged and fixed trees ran as overlays on the eddab707 build.

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 6, 2026

Copy link
Copy Markdown
Member

Correction to the record above. Under "Not tested" it says the sheet datum on fault pairs "also fails at np 3 on development". That failure is not a library defect, so it says nothing against this PR.

test_fault_reaction_is_the_membrane_resultant is a serial test, and under mpirun its assert len(sig) > 5 runs on ranks holding no fault nodes. Gathered across ranks on eddab70, the reaction is the same at every rank count: 11 unique nodes, max relative error 0.00901 at np 1, 2, 3, 4 and 8.

The rest of the record stands, including that the merged tree drops this datum serially.

Underworld development team with AI support from Claude Code

lmoresi pushed a commit that referenced this pull request Nov 12, 2026
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
@lmoresi

lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member

@gthyagi, we have taken this branch forward as #1097 so it can land without another round. It keeps your two commits and authorship, merges current development, and adds the corrections from the review above: the fault-pair sheet datum now carries its boundary name (the merge otherwise dropped it and test_1092 failed), a test that drives build_rotation and hangs on development at three ranks, and the small test clean-ups. The details and the verification table are in #1097's description. This PR can close once #1097 merges.

Underworld development team with AI support from Claude Code

lmoresi added a commit that referenced this pull request Nov 12, 2026
…lectives-855

Fix collective evaluation of prescribed rotated wall data (supersedes #855)
@lmoresi
lmoresi merged commit 6b36557 into underworldcode:development Nov 12, 2026
2 checks passed
gthyagi pushed a commit to gthyagi/underworld3 that referenced this pull request Nov 13, 2026
…fore asserting

Review of underworldcode#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
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.

2 participants