Reach the boundary-snap reduction on every rank, and scan for the shape (#627) - #628
Conversation
`snap_level_boundaries` guarded its inversion-count `allreduce` on `snapped_any.any()`, a mask over this rank's local vertices. A rank whose partition holds no vertex on a registered bounding surface skipped the block and never arrived, leaving its peers in the reduction. Initialise the count before the guard and reach the reduction unconditionally; the cell-orientation loop stays inside it, since that work really is local. Fixes #627. The same shape has now appeared four times, and it is invisible to `uw.mpi.selective_ranks()` — that catches deliberate rank selection, whereas these guards read as ordinary control flow (`module is None`, `undecided.size`, `snapped_any.any()`) and never enter the context manager. So test_0052 asks the question statically instead: of every `comm.<op>` call site, is it reached on all ranks? Predicates the whole communicator agrees on are recognised as such — the communicator geometry, the mesh's rank-invariant description, a function parameter, and a value that has itself been reduced, which is what makes the library's reduce-first-then-branch idiom come out clean. Across 210 call sites that leaves two entries in ACCEPTED, each with the reason it is uniform, and one in IN_FLIGHT for #612, whose fix is already in an open PR. A stale-entry test deletes either as soon as the site stops tripping the scan. The scan finds #612 and #627 unaided. Its controls cover both directions: the classifier on the predicates that actually deadlocked, and the walker on an injected defect together with its fix. Underworld development team with AI support from Claude Code
Adversarial reviewThe fix. Correct and minimal. Weakest part of the scan: name-level matching. It has already bitten us Second weakness: the guard classifier is textual. Third: What we did not do. No runtime check. A timed Controls. Both directions, because a scan that flags a fix as well as a bug
Verified: pre-fix |
The defect
snap_level_boundariesguarded its inversion-countallreduceonsnapped_any.any()— a mask over the calling rank's local vertices. A rankwhose partition holds no vertex on any registered bounding surface skipped the
whole block and never arrived at the reduction, leaving its peers in it. The
fix initialises the count before the guard and reaches the reduction
unconditionally; the cell-orientation loop stays inside it, because that work
really is local. Fixes #627.
Why a scan
This is the fourth instance of one shape: a collective behind a predicate on
rank-local data.
uw.mpi.selective_ranks()cannot see it. That machinerycatches deliberate rank selection, and it works — but these guards read as
ordinary control flow (
module is None,undecided.size,snapped_any.any()), so the author never reaches for the context manager andthe check never fires.
Nor is annotation the answer. Collectivity is transitive, and in a parallel FE
library that closes over a third of the source — 829 of 2523 functions from
the
comm.*primitives outward.Stokes.solveis collective; saying so addsnothing.
What is rare is the conditional collective.
tests/test_0052asks onequestion of every
comm.<op>call site: is it reached on all ranks? Guards thewhole communicator agrees on are recognised rather than reported —
uw.mpi.size > 1, the commonest guard here),self.dim,.degree,.simplex),convention,
the library's own idiom come out clean:
Across 210 call sites that leaves two entries in
ACCEPTED, each carrying thereason it is rank-uniform, and one in
IN_FLIGHTfor #612, whose fix is in anopen PR. A stale-entry test removes either as soon as the site stops tripping
the scan, so neither list can quietly become a blanket exemption.
Evidence
The scan finds #612 and #627 unaided, and nothing else. Controls run both
ways: the classifier is tested on the predicates that actually deadlocked and
on the uniform ones it must not flag, and the walker is tested on an injected
defect together with the fixed form of the same code — the fix must come out
clean or the check is measuring nothing.
It is a name-level scan, not a proof. It cannot see through a helper, and a
predicate it calls rank-local may be uniform for reasons it cannot read; that
is what
ACCEPTEDis for, and an entry there is a claim with a stated reason.Testing
test_0052— 5 passed (level_1, tier_a; already inside thetest_005[1-9]CI batch, noscripts/test.shchange needed)test_0830,test_0835,test_0836— 33 passedtests/parallel/test_0873_adapt_collective_stop_mpi.pyat np=4 — 4 passeddiscretisation_mesh.pyfrom git scans as one finding at line 8388;post-fix, none
Underworld development team with AI support from Claude Code