Skip to content

Swarm.migrate offers a point to every nearby domain before giving up (#1093) - #1107

Merged
lmoresi merged 8 commits into
developmentfrom
bugfix/global-evaluate-seam-1093
Nov 13, 2026
Merged

lmoresi merged 8 commits into
developmentfrom
bugfix/global-evaluate-seam-1093

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Fixes #1093. The review by H1 (review and parallel test runs on a 96-thread Linux workstation) round 1 (M1, M2, L4) is answered below; the re-check is in progress.

What and why

Swarm.migrate offers each unplaced point to its nearest domain (by domain centroid), then to the next nearest, and so on. It also stopped as soon as a round claimed nothing.

Take a point inside the mesh near a partition seam, where its own rank's centroid is nearest but its cell is on the next rank. In the first round it is offered to its own rank and claims nothing. When that is true of every unplaced point, the loop stopped there, and the point stayed on a rank that does not contain it. Two things followed:

  • a swarm lost it (delete_lost_points);
  • global_evaluate read it from the out-of-domain fallback.

On the cavity annulus of #1086 at np 2, one interior point read 5.761 where serial reads 5.058. The MMPDE mover's default frozen metric drifted 7e-3 from serial through it.

The "no progress" exit is removed, together with two dead assignments. The round cap, min(max_its, size), stays. The fallback is untouched. Only swarm.py changes. #859 is separate: applied to development, the repro is unchanged.

Exterior points: a per-point bound

With the "no progress" exit gone, a migrate whose unclaimed points are outside the mesh ran every round (min(10, size)), where base ran 1. It also parked those points on the farthest domain, a rank with no cells included.

Each unclaimed point is now offered only to the ranks whose domain box contains it, nearest centroid first. The boxes are the vertex bounds, padded by the larger of two amounts: four times the locator's face tolerance of the largest cell radius, and an absolute floor of 1e-4. The floor covers the locator's absolute face slab (about 1e-5 outside a wall, from its 1e-3 control-point offset). Without it, on cells finer than about 7.5e-4, a migrate that deletes lost points deleted a point that some rank claims (review M3). Once a point's list is exhausted, it stays where it is.

Where exterior points end up: on the last rank, in centroid order, whose box holds them, or, in no box, on the nearest domain. Always a rank with cells near the point; that is where global_evaluate's fallback reads them.

Measured migrate cost: 1e6 points, 1 % of them exterior. The box case puts them just outside a wall (0.0005 to 0.01 beyond it, a cell being 0.02). The annulus case puts half in the hole and half just outside the outer wall. Each entry is rounds (ms, min of 5). The workstation (a 96-thread Linux workstation, single system image; Intel Xeon Gold 6240R, AVX-512; MPICH) was under a load average of 27 from other work, so the round counts are the reliable column.

case np base (development) first bound (35af689) this branch
box, natural partition 4 1 (1084) 4 (1654) 2 (1207)
box, natural partition 6 1 (933) 6 (1966) 2 (864)
annulus, natural partition 4 1 (965) 4 (1758) 2 (1238)
annulus, cells scattered over 3 ranks, the 4th empty 4 1 (2388) 4 (5297) 3 (4809)
box, cells scattered over 3 ranks, the 4th empty 4 1 (2670) 4 (6496) 3 (5211)

Exterior points held, by rank:

case base (development) first bound (35af689) this branch cells
box, natural, np 4 0, 0, 5096, 4904 6585, 3415, 0, 0 0, 0, 5093, 4907 1417, 1480, 1432, 1495
annulus, 4th rank empty 126988, 6972, 123540, 0 0, 0, 0, 257500 128959, 5612, 122929, 0 2086, 2047, 2135, 0
box, 4th rank empty 83733, 173767, 0, 0 0, 0, 0, 257500 82877, 172322, 2301, 0 1938, 1897, 1989, 0

On a natural partition the cost is one extra round, for the points within a wall's padding, which lie in two boxes. On the scattered layouts every box spans the whole domain, so the boxes cannot narrow the list, and the cost is one round per rank with cells. That is the worst case for this bound, and it is still bounded. My earlier "within noise of base" held only for points beyond the padding and is withdrawn.

Notes:

  • A periodic mesh: a rank's vertex box would miss its wrapped cells. Untestable today.
  • Interior point order: with exterior points present, the local order of interior particles can change; the sets are identical.

Tests

tests/parallel/test_1093_migration_reaches_containing_rank.py uses a P1 linear field, so every point FE locates reads exactly.

  • The global_evaluate returns a partition-dependent wrong value for interior points stranded at a seam (best-claim picks nearest centroid, not containing cell) #1093 point, asked by the last rank on the platform's own partition.
  • Strays are interior points a rank holds but does not contain, and whose nearest domain centroid is its own. The annulus is cut into vertical slabs at off-centre cuts (a shell partition), so strays exist on any platform. Two checks:
    • through global_evaluate: each one exact, none flagged;
    • as a swarm: none lost.
  • Points outside the mesh, just beyond the outer wall and in the hole, on the slab partition and on one whose last rank has no cells. Each must end on a rank with cells whose box holds it (or on its nearest domain), none on the empty rank, in at most two rounds on the slabs. Base fails the placement test; the first bound (35af689) fails both.
  • A fine mesh (a 1e-3 box at cellSize 6e-5), with points up to 3e-5 outside its walls and delete_lost_points=True: every point some rank's locator claims is kept. Without the pad's floor, 226 of 227 survive at np 2.
  • Points in a third-nearest domain or further (H1's M1). The cells are dealt to the ranks at random (a seeded shell partition). Such points are asked many at once, as a swarm, and one alone. They need three ranks.
np 2 np 3 np 4 np 5
this branch 6 passed (3 need np ≥ 3) 9 passed 9 passed 9 passed
development 3 failed 4 failed 5 failed 5 failed
a 2-round cap 2 failed 3 failed 3 failed
an exit after 2 idle rounds 2 failed 3 failed 3 failed

(H1's review found the exit-after-2-idle-rounds mutant caught at np 4 and 5, not at np 3, on the current head.)

On development at np 3, 129 strays read from the fallback (error 0.086), and a swarm loses all 143.

Regressions: every serial and parallel test file that uses swarms, global_evaluate, migrate or advection.

  • Serially (105 files), all pass except two:
    • test_0052's collective-guard scan, which flagged a cached allgather. It is fixed, and now passes.
    • test_1061 (level_3, tier_c, not gated). It runs serially, where migrate's changed rounds are not entered, so it takes base's path.
  • At np 2 (23 files): 88 passed, 14 skipped.
  • test_0052 passes.

Not fixed here (H1's L4)

#1093 is partly fixed by this PR: the seam residual below remains on record there.

With #1086 and this PR, the seam step is gone. The MMPDE mover with its default frozen metric is still 1.5e-5 off serial at np 2 and 1.3e-6 at np 3, against a rounding control of 6e-10. It is deterministic. H1 traces it to an evaluate error near vertices, of about 5e-6, that predates this PR and also appears in serially. It is being filed separately.

Checklist

  • Style Charter followed (S2)
  • No drive-by changes (S9)
  • Regression test written first, with level_2 / tier_b markers (S8)
  • No hedging names or commented-out code (S3, S4)
  • No exception swallows
  • No new data access
  • Parallel: np 2–5 (S11)
  • No dependency changes
  • AI attribution below

Underworld development team with AI support from Claude Code

🤖 Generated with Claude Code

…1093)

Swarm.migrate offers each point it has not placed to its nearest domain
(by domain centroid), then the next nearest, and stopped as soon as a
round claimed nothing anywhere. A point inside the mesh near a partition
seam, held by a rank whose centroid is nearest but whose cells do not
contain it, is offered in the first round to its own rank: nothing is
claimed, and when that held for every unplaced point (a few stray query
points) the loop stopped there. The point stayed on a rank that does not
contain it. A swarm lost it (delete_lost_points); global_evaluate, which
moves its query points with a swarm, read it from the out-of-domain
fallback: 5.761 where serial reads 5.058 on #1086's cavity annulus, and
the MMPDE mover's default frozen metric drifted 7e-3 from serial at np 2.

The exit is removed; the round cap (min(max_its, size)) still bounds the
cost for points outside every domain. Measured at np 4, no added time.
The fallback itself is unchanged.

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

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.

…rm's

The stray tests asserted, as a precondition, that the partition left some
interior points a rank holds but does not contain whose nearest domain
centroid is its own. Whether a partitioner does is platform-dependent
(test_0858 failed its precondition on macOS). The stray tests now cut the
annulus into vertical slabs with off-centre cuts (a shell partition), where
each centroid midpoint misses its cut, so strays exist on any platform. On
development they fail at np 2-5 (np 3: 129 points read from the fallback,
error 0.086; a swarm loses all 143); with the fix they pass. The #1093
point is still asked on the platform's own partition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lmoresi

lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

Review: PR #1107 (fix #1093) at a4b8278

NOT READY at a4b8278. The fix is correct and removes the #1093 strays on every mesh and rank count tested. Two things block it: the regression test misses half the fix (two plausible partial reverts pass it), and an exterior-point cost and behaviour change that the PR does not disclose (and whose cost line is not reproduced). Both are small to address.

Reviewer: H1 worker. Base: development at 01b06c9 (wt-dev01b). Branch: wt-1107 at a4b8278. Both builds as provided; the installed swarm.py is byte-identical to each worktree. Everything below is measured unless marked [read].

Method

  • Tests come from git archive copies (br/ and base/), run with PYTHONDONTWRITEBYTECODE=1, -p no:cacheprovider and --with-mpi. MPI ran under scripts/mpi_supervisor.py --silence 600. Runners: run_t.sh, run_p.sh, regress.sh. At most 6 cores at once.
  • probe.py has four modes:
    • seam evaluates a linear P1 field (2x + 3y) through global_evaluate at:

      • midpoints and fractions of every partition-seam edge;
      • the same points offset ±1e-12 to ±1e-3 normal to the seam;
      • vertices shared by 2 ranks and by 3 or more ranks;
      • every mesh vertex, 6000 random interior points, and 400 exterior points.

      Every rank asks every point. Then two adversarial sets: each rank asks only points it holds but does not contain ("strays", split by whether the nearest domain centroid is its own), and 24 single-point calls in which one rank asks one stray and every other rank asks nothing. serial_ref.py evaluates the same points serially for comparison. Meshes: annulus (the MMPDE redistribution depends on the partition: seam vertices see only their own rank's edges (step cap) and facets (slip corners) #1086 geometry, cellSize 0.25, refinement 1), a simplex box (1/16) and a quad box (16×16).

    • count checks conservation and single ownership through Swarm.migrate. Particles carry ids, and a ground truth for "inside" is taken from every rank's points_in_domain. Five scenarios:

      • populate, then jitter by 0.2 cells;
      • populate, then jitter by 2 cells;
      • random global points plus exterior points on every rank (migrate=False);
      • the same with rank 0 holding nothing;
      • seam and vertex points asked by a fixed rank.

      Each runs with delete_lost_points False and True. Layouts: natural, all cells on rank 0 (np 3), and rank 1 with no cells (np 3 and 4).

    • advect runs 5 RK2 advection steps (rigid rotation on the annulus; a cellular flow and a uniform outflow on the box, with clip on and off). After each step it hashes per-rank local order and the id-sorted positions and ownership. It also hashes global_evaluate of a P2 field at 3100 points, and does a swarm write_timestep/read_timestep round trip.

    • time runs repeated timings (first rep dropped, medians). Rounds are counted by wrapping uw.utilities.gather_data: migrate calls it 2 + 2×rounds times.

  • Mutants are injected by mut/sitecustomize.py (an import hook that patches underworld3/swarm.py source at import, with UW_MUTANT). No worktree was edited, and every mutant log shows the injection line.
  • Frozen MMPDE uses H1's MMPDE redistribution depends on the partition: seam vertices see only their own rank's edges (step cap) and facets (slip corners) #1086 probe (p86.py annulus --metric frozen) on the wt-1086 build (c3e5260, which carries the MMPDE redistribution depends on the partition: seam vertices see only their own rank's edges (step cap) and facets (slip corners) #1086 seam fix that development lacks). Swarm.migrate offers a point to every nearby domain before giving up (#1093) #1107 is applied to it with mutant fix, which removes the no-progress exit. Comparison is with cmp86.py against the MMPDE redistribution depends on the partition: seam vertices see only their own rank's edges (step cap) and facets (slip corners) #1086 review's serial reference. A fresh serial run reproduces that reference bit for bit.

Check 1: the fix

np 2 np 3 np 4 np 5
test_1093, base 3 failed 2 failed 2 failed not run
test_1093, branch 3 passed 3 passed 3 passed not run (the seam probe covers np 5)

On base, the swarm test lost every stray: assert 0 == 143 at np 3, 1 == 0/212 == 0 style failures elsewhere.

ge_point2.py (H5's repro, copied):

np 1 np 2 np 3 np 4
base — 5.76069 5.05828 5.05828
branch 5.05828 5.05828 5.05828 5.05828

Seam sweep. Max |parallel − serial| at interior points. Each entry is max / count > 1e-4 / count of interior points flagged extrapolated.

mesh, np strays (own centroid nearest), base same, branch single-point calls, base same, branch
annulus 2 7.8e-2 / 243 / 252 0 / 0 / 0 7.6e-2 / 22 / 23 0
annulus 3 8.0e-2 / 188 / 190 0 6.2e-2 / 21 / 21 0
annulus 4 9.7e-2 / 445 / 463 0 7.1e-2 / 23 / 24 0
annulus 5 1.1e-1 / 661 / 690 0 8.0e-2 / 22 / 23 0
box 2–5 4.2e-2 to 5.1e-2, 210–952 points ≤ 4.2e-6, 0 / 0 3.5e-2 to 4.1e-2 0
quad 2–5 4.5e-2 to 4.6e-2, 268–911 points ≤ 3.0e-6, 0 / 0 3.1e-2 to 4.0e-2 ≤ 2.0e-6
  • When every rank asks every point (seam on/off, vertices shared by 2 or by 3+ ranks, all vertices, random interior, exterior), base and branch are bit-identical, values and flags, on all 12 mesh/np combinations. Base does not fail there, because other points in the same call keep the round loop making progress. The defect needs a call in which every unplaced point is self-offered.
  • The residual ≤ 6e-6 is a pre-existing serial-versus-parallel difference at points within about 1e-6 of a vertex or seam. It is identical on base, and serial evaluate shows it too: P1-linear errors of 2.4e-6 at such points in serial. It is not this PR's (finding L3).

Check 2: the new migration logic [read, then measured]

What "nearby" is. It is not geometric. Round it sends each unclaimed point to the rank of its (it+1)-th nearest domain centroid, a mean of the cell centroids per rank. The loop now runs until nothing is unclaimed, or for min(max_its=10, size) rounds. So "every nearby domain" means every domain at np ≤ 10, and the 10 nearest centroids above that. Empty ranks have a 1e30 sentinel centroid, so they come last in every point's order, but at np ≤ 10 they are still offered (see M2).

Duplication or loss [read]. dm.migrate(remove_sent_points=True) moves; it never copies. Only the holding rank tests a point, and a claimed point is never re-sent: its rank field is never rewritten, because only not_my_points are re-ranked. So no point can be held twice, and loss is only delete_lost_points on unclaimed points. The PR does not touch either path.

Measured conservation. 5 scenarios × 2 delete modes on annulus and box, at np 2, 3, 4 and 5, plus the rank0 (np 3) and skip1 (np 3 and 4) layouts, on base and branch. That is 140 scenario runs.

  • 0 violations.
  • With delete_lost_points=False the global count is conserved, and with True it equals the interior count.
  • Every id is held once.
  • No interior particle was held by a rank whose domain does not contain it. No interior particle was lost.
  • Seam points claimed by 2+ ranks' points_in_domain (722 at annulus np 2) are still held once.
  • No hang with an empty rank, ranks with no particles, or ranks with no cells and no neighbours.

The probe's own scenarios happen not to strand on base, for the reason in Check 1. The test and the stray probe show the base loss.

Collectives [read, then measured].

  • uw.mpi.size > 1 is global.
  • The round cap min(max_its, size) is identical on every rank, given the same max_its; no caller passes it.
  • The only exits use global_unclaimed_points, which is reduced.
  • dm.migrate and points_in_domain (which reaches get_max_radius first) run unconditionally every round. The kd-tree query, guarded by not_my_points.shape[0] > 0, is local.
  • The removed exit was also on reduced values, so lockstep is unchanged.
  • Measured: no hangs in any run above, including all cells on rank 0 at np 3, a cell-less rank 1 at np 3 and 4, and rank 0 with no particles.

Check 3: behaviour where nothing is stranded

  • Calls in which every point is claimed (the early return), or claimed by some round: the code path is identical. Measured bit-identical:
    • advection (annulus rotation and box cellular flow, np 2 and 4, 5 steps): positions, ownership, per-rank local order, and the variable values at every step;
    • global_evaluate (P2 field, 3100 points);
    • checkpoint reload (count, coordinates, values, per-rank counts);
    • box uniform outflow with clip on and off, np 2 and 4. return_coords_to_bounds keeps every particle, so nothing goes exterior.
  • Calls in which the only unclaimed points are exterior. These are where the PR changes behaviour. Base stopped after the first idle round. The branch runs every remaining round, to min(10, size). The differences:
    1. Where exterior particles are parked (delete_lost_points=False). On the branch, every exterior particle ends on the rank of its min(10, size)-th nearest centroid: the farthest domain at np ≤ 10. When a rank is empty, that is the empty rank: skip1 np 4 parked all 6791 on rank 1 (cells [588, 0, 584, 588]), and rank0 np 3 parked them on rank 2 (cells [1760, 0, 0]). Base parked at the stop round, often the 3rd-nearest, or left them on rank 0. This contradicts the stated intent in _get_domain_centroids ("starved ranks correctly receive no particles"), though base also did it in some layouts (skip1 np 3). The branch's parking is deterministic per point, whereas base's depended on the global progress of the other points. That is arguably better for read_timestep, which relies on "end up somewhere deterministic" (swarm.py:2598) [read].
    2. Per-rank local order of interior particles can change: all cells on rank 0, np 3, jitter scenarios, both delete modes. Each rank holds the same set, in a different order, because the extra rounds send the exterior points away from the populated rank. On natural partitions (annulus np 4 and 5, box np 4 and 5) the interior order and sets were identical. Anything summed over particles in local order could change at rounding level there.
    3. global_evaluate results do not change. The best-claim block allgathers the stranded set, so where a point is parked does not matter. Exterior values and flags are bit-identical in every seam run.

Check 4: cost

Paid only when, after some round, every remaining unclaimed point is unclaimable: exterior, or stranded beyond the cap. Measured on the box mesh (cs 1/32), medians of 6 or 4 reps, base → branch:

case np 2, 1e5 np 2, 1e6 np 4, 1e5 np 4, 1e6 np 6, 1e5
settled swarm, nothing to move (early return) 68 → 67 ms 662 → 685 18 → 18 171 → 173 9 → 9
jittered swarm (rounds equal) 97 → 97 981 → 981 35 → 36 326 → 318 18 → 24 (4 → 7 rounds; jitter pushes some out of the box)
settled swarm + 20 exterior per rank 81 → 93 (1 → 2 rounds) 817 → 993 23 → 33 (1 → 4) 205 → 306 (×1.49) 12 → 23 (1 → 6, ×1.88)
global_evaluate, 20 exterior points per rank only 16 → 17 15 → 18 18 → 20 17 → 19 19 → 26
global_evaluate, local interior + 20 exterior 211 → 218 1947 → 2178 70 → 82 520 → 621 43 → 58
global_evaluate, 1e5/1e6 random points ± exterior equal within noise (rounds equal)
  • An earlier np 4 run showed br ×1.5 with equal round counts. Three interleaved repeats gave equal times, so it was machine-load noise (load average about 8–9 from other sessions).

  • Per extra round:

    • 1 dm.migrate, collective with point-to-point exchange of the unclaimed points only;
    • 1 points_in_domain (one Allreduce in get_max_radius);
    • 2 gather_data(bcast=True), each 5 barriers + gather + Gatherv + bcast;
    • 2 uw.mpi.barrier.

    That is about 20 collectives a round, plus full-swarm local work: _coordinate_row_keys and np.isin against the claimed keys, over every local particle. That full-swarm work is why the 1e6 case pays about 100 ms a round at np 4.

  • Extra rounds per call are min(10, size) minus the rounds base would have run, so up to 9 at np ≥ 10. Measured: base ran 1 round in the exterior-only cases, and the branch ran 2, 4 or 6 at np 2, 4 or 6.

  • Who pays:

    • global_evaluate with any exterior query point: semi-Lagrangian departure points near boundaries, sampling grids, the mover's frozen metric;
    • advection steps in which particles leave the domain;
    • read_timestep with exterior saved points;
    • a clip_to_mesh=False swarm that holds exterior particles. That one pays the full cap on every migrate, for as long as they are held.
  • In the advection probe, annulus np 4 ran one extra round per step (gather_data 18 against 16), in identical time within noise.

  • The PR body's cost line (55 ms against 60 ms, at np 4 with 20 outside points per rank) is not reproduced. On exterior-only calls I measure +2 ms (18 → 20 ms) at np 4 and +7 ms at np 6, and for migrate +10 to +100 ms depending on swarm size.

Check 6: mutants

mutant test_1093 np 2 / 3 / 4 stray probe (np 3–5, three meshes)
noprog: restore the no-progress exit (= base) caught / caught / caught caught (base numbers)
first: offer only to the nearest domain every round caught / caught / caught —
once: a single round caught / caught / caught —
cap2: at most 2 rounds survives / survives / survives caught: box np 3–5 3.5e-2 to 3.8e-2 (95/22/122 strays), quad 4.2e-2 to 4.4e-2; annulus survives
noprog2: exit after 2 consecutive idle rounds survives / survives / survives caught only by single-point calls: box 1.6e-2 to 3.5e-2, quad 1.7e-2 to 3.1e-2; annulus survives

On natural np 6 partitions, the containing domain is the nearest centroid for 29014/30000 annulus points; for the rest it is the 2nd nearest. Box: [27109, 2460, 133, 298] at nearest, 2nd, 3rd, 4th. Quad: [27950, 1796, 135, 119]. So about 1.4% of box points need a 3rd- or 4th-nearest offer, and the PR's test never reaches the 3rd round. Its slab partition makes every stray's containing domain the 2nd nearest.

Check 7: regressions

  • Serial, 62 files (swarm, evaluate/global_evaluate, advection, SLCN/ddt, checkpoint): branch 500 passed, 2 skipped; base 500 passed, 2 skipped (39 min each). In serial the round loop is never entered (uw.mpi.size > 1), so the serial path is code-identical [read].
  • Parallel np 2 and 4 (26 parallel files) and the serial files under np 2 and 4: not completed. The run was stopped at hand-back, after 16 s of the np 2 stage. This needs running before merge (merge condition 4). The bit-identity probes in Check 3, the 140-run conservation sweep and test_1093 at np 2–4 cover the migration paths directly, but they do not replace the suite.

MMPDE frozen metric (cavity annulus, metric_eval="frozen", #1086 build c3e5260). Max |x_np − x_serial| after the run, then per outer iteration:

final per-iteration trace
np 2, #1086 only 6.95e-3 (as in the #1086 review)
np 3, #1086 only 9.62e-3 0, 8e-13, 4e-12, 9.2e-4 (iteration 4), 1.9e-3, 2.0e-2, …
np 2, #1086 + #1107 1.48e-5 0, 7.9e-13, 3.8e-12, 2.2e-11, 1.1e-10, 1.4e-9, 4.8e-9, 1.1e-8, 4.9e-8, 1.5e-7, 1.2e-6, 1.1e-6, 4.0e-6, 5.3e-6, 1.5e-5
np 3, #1086 + #1107 1.35e-6 identical to np 2 through iteration 8, then 1.8e-8, 4.4e-8, 2.9e-7, …, 1.3e-6
serial control: metric amplitude × (1 + 5e-14) 6.1e-10 0, 1.3e-12, 6.0e-12, 1.3e-11, …, saturating at about 1e-9

Findings

High

None.

Medium

  • M1. The test misses half the fix.
    • Mutants cap2 (at most 2 rounds) and noprog2 (exit after 2 idle rounds) pass test_1093 at np 2, 3 and 4. Both are real defects:
      • the stray probe on natural box/quad partitions at np 3–5 gives errors of 1.5e-2 to 4.4e-2 under them;
      • on box np 6, 1.4% of points need the 3rd- or 4th-nearest domain.
    • The slab partition only ever needs the 2nd round.
    • Condition: add a case whose containing domain is the 3rd-or-later nearest centroid, for example a shell partition at np ≥ 3 whose cut puts strays three centroids away. Also add a single-point-call case, which is what catches noprog2.
  • M2. Exterior points now always run the full min(10, size) rounds, and the PR does not say so.
    • Cost: +10 ms (1e5 points) to +100–180 ms (1e6 points) per migrate when the only unclaimed points are exterior, at np 2–6 (×1.2 to ×1.9). Up to 9 extra rounds at np ≥ 10, each about 20 collectives plus full-swarm key and isin work.
    • It hits global_evaluate with exterior query points (semi-Lagrangian departure points, the frozen metric), advection with exits, read_timestep, and every migrate of a clip_to_mesh=False swarm holding exterior particles.
    • Behaviour: exterior particles are now parked on the farthest domain, which is the empty rank when there is one, and per-rank local order can change.
    • The PR's "55 ms against 60 ms" is not reproduced.
    • Condition: state the cost and parking change in the PR body, or bound it. Two ways to bound it: stop offering a point once it has been offered to every domain whose bounding box (inflated by the max cell radius) contains it, or treat points no domain's bounding box contains as exterior from round 0. Either keeps the global_evaluate returns a partition-dependent wrong value for interior points stranded at a seam (best-claim picks nearest centroid, not containing cell) #1093 fix and restores one round for far-exterior points.

Low

  • L1. Empty ranks receive exterior particles at np ≤ 10. Measured: all 6791 on the cell-less rank at np 4 skip1. This contradicts the _get_domain_centroids comment. It is pre-existing in some layouts but now systematic. Fix with the bounding-box rule above, or by skipping sentinel centroids.
  • L2. The cap at np > 10 (acknowledged in the PR) is real in principle: the containing domain reaches the 4th-nearest centroid at np 6. Not measurable here at 6 cores.
  • L3 (pre-existing, not this PR). Near-vertex evaluate drift. evaluate and global_evaluate return values off by up to about 5e-6 from the exact P1-linear value for points within about 1e-6 of a vertex or seam. It happens in serial too, and the parallel and serial values differ there. A likely contributor to the frozen-metric residual. Worth its own issue.
  • L4. Frozen MMPDE still is not rank-independent after this PR. 1.5e-5 at np 2 and 1.3e-6 at np 3, against a 6e-10 rounding control. There is no seam step any more, but the PR body's framing ("drifted 7e-3 … through it") should not be read as "now matches serial". It needs follow-up before claiming rank-independent MMPDE.

Merge conditions

  1. Extend test_1093 to catch cap2 and noprog2 (M1). Re-run the mutants.
  2. Disclose or bound the exterior-point rounds (M2, L1). Correct the cost line in the PR body.
  3. Note in the PR (or global_evaluate returns a partition-dependent wrong value for interior points stranded at a seam (best-claim picks nearest centroid, not containing cell) #1093) that frozen MMPDE retains a 1e-5-class np-dependence (L4).
  4. Run the parallel swarm/evaluate/advection/SLCN/checkpoint files at np 2 and 4, base against branch (regress.sh, stages 2–6). Not completed in this review.

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

PR #1107 at a4b8278: the parallel regression stages (merge condition 4)

I ran these after the review, with the same runners (regress2.sh, which is stages 2–6 of regress.sh), on base 01b06c9 and branch a4b8278.

The 26 parallel files (swarm, evaluate/global_evaluate, advection, SLCN, checkpoint):

np 2 np 4
branch 98 passed, 8 skipped, on every rank 105 passed, 1 skipped, on every rank
base 3 failed, 95 passed, 8 skipped 2 failed, 103 passed, 1 skipped

The only base failures are the PR's new test_1093_migration_reaches_containing_rank.py (all three tests at np 2; two at np 4), as expected. No regressions.

The 62 serial files launched under mpirun as one batch: this run is not informative. Both builds abort at the same point after the same tests (np 2: 32 passed then 3 F, exit 142; np 4: 64 passed then 2 F, exit 63). That makes it a pre-existing failure of running the serial set as one batch under MPI, not this PR. The serial files themselves were compared in serial in the review: 500 passed and 2 skipped on both builds.

Underworld development team with AI support from Claude Code

 review)

M2. With the "no progress" exit gone, a migrate whose only unclaimed points
are outside the mesh ran every round (min(10, size)) and left them on the
farthest domain: up to 2.7x base's time at 1e6 points. A point outside
every rank's domain box (vertex bounds inflated by the largest cell radius,
Mesh._get_domain_boxes, cached per mesh version) can be claimed by no rank:
it goes to its nearest domain in the first round, where base always left
it, and is not offered again; the loop ends when no point that might still
be inside some domain is unclaimed. Measured at 1e5 and 1e6 points with 1%
and 10% exterior, np 2-6: within noise of base, and exterior points on the
same ranks as base.

M1. Two-round partial reverts passed test_1093 (a stray's domain is its
second-nearest). The cells are now also dealt to the ranks at random (a
seeded shell partition), where a point's domain is often the third-nearest
or further; such points are asked many at once, as a swarm, and one alone.
A 2-round cap and an exit after 2 idle rounds both fail them at np 3-5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test_0052's scan flagged the version-cached allgather in _get_domain_boxes
(a collective under a guard). The boxes are one small allgather; they are
now computed once per migrate, unconditionally, and passed to the
rank-local exterior test. Measured cost unchanged (1e6 points, 10% exterior:
984 ms at np 4, 664 ms at np 6).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lmoresi

lmoresi commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Re-check: PR #1107 (fix #1093) at 35af689

NOT READY at 35af689. M1 is met, L4 is in the PR body, the cost line is corrected, and the fix, conservation, bit-identity and regressions all hold. M2 is only partly met. Exterior points farther than one cell from the wall now take one round, as on base. But exterior points within one cell of the wall, or in the annulus hole, still drive every migrate to the full min(10, size) rounds and are still parked on the farthest domain, an empty rank included. That case is the common one: advection exits, semi-Lagrangian departure points, the MMPDE target annulus. There, the branch runs exactly as a4b8278 did. The PR's timing table and its sentence "exterior points land on the same ranks as base" cover only points beyond that band.

Reviewer: H1 (review and parallel test runs on a 96-thread Linux workstation: Intel Xeon Gold 6240R, AVX-512; MPICH). Base: development 264400a. Everything is measured unless marked [read].

Method, and one deviation

  • The branch build. The reviewer's branch build was still at a4b8278, so the branch here is the development 264400a build plus the PR's two changed source files from 35af689 (swarm.py, discretisation/discretisation_mesh.py), as a package overlay placed first on PYTHONPATH.
    • 264400a..35af689 changes only those two files plus the test.
    • The overlay matches H5's own 35af689 install file for file. The only differences are the compiled .so files (build paths) and _uwid.py.
    • Base and branch therefore share one compiled build and differ only in those two Python files.
  • Tests run from git archive copies (br/ = 35af689, base/ = 264400a, with the branch's test_1093 copied into base/). Flags: PYTHONDONTWRITEBYTECODE=1, -p no:cacheprovider, --with-mpi. MPI runs go through scripts/mpi_supervisor.py --silence 600.
  • Cores. Every run is pinned with taskset -c 44-47, so this re-check never used more than 4 cores. The np 5 runs, and the np 6 timings, are therefore oversubscribed on 4 CPUs. The np 6 times are indicative only; the round counts are exact.
  • Probes and mutants are those of the first review, adapted:
    • Round counting. The loop no longer calls gather_data, so rounds are now counted as points_in_domain calls inside Swarm.migrate, minus one per migrate. This works the same on both builds.
    • New boxcheck mode tests the exterior rule (Check 2c).
    • Count mode now also splits parked exterior points into far (outside every inflated box) and near.
    • New far.py times exterior points in distance bands from the wall.
    • Mutants. noprog and noprog2 were adapted to the new exit, which is now a reduced seeking count; they reconstruct base's no-progress test from reduced unclaimed and claimed counts. cap2, first and once apply unchanged. New mutant nobox (seeking = not_my_points) reverts 806877f and so reproduces a4b8278's exterior handling. Every mutant log shows the injection line.

Check 1 (M1): test_1093 — met

np 2 np 3 np 4 np 5
branch 3 passed, 3 skipped 6 passed 6 passed 6 passed
base 3 failed 4 failed 5 failed 5 failed
cap2 — 2 failed 3 failed 3 failed
noprog2 — 2 failed 3 failed 3 failed
noprog — 4 failed 5 failed 5 failed
first — 4 failed 5 failed 5 failed
once — 4 failed 5 failed 5 failed
nobox (a4b8278 exterior rule) — 6 passed 6 passed 6 passed

cap2 and noprog2 fail the three new third-nearest tests: many at once, as a swarm, and the single point. This matches H5's figures. nobox passing is expected, because the test has no exterior points.

Check 2 (M2): exterior points — partly met

a. The rule [read]. Before the loop, Mesh._get_domain_boxes() allgathers each rank's local vertex bounding box, padded by get_max_radius(). After each round, unclaimed points outside every box are dropped from seeking. The loop exits when the reduced seeking count is 0.

  • A point outside every box takes round 0 (to its nearest centroid) and stops there.
  • A point inside some box but outside the mesh keeps seeking to the cap, min(10, size).
  • A single such point anywhere keeps every rank in the loop to the cap. The exit is global.

b. Rounds and timing. The table shows median migrate and global_evaluate times in ms, branch against base (and nobox = a4b8278), with round counts in brackets. The box mesh has cs 1/32. The swarm is settled, with 20 exterior points per rank uniform in [-0.3, 1.3]² outside the box. Medians are over 2 interleaved runs × 5 reps.

case base branch a4b8278 (nobox)
migrate, settled + 20 ext/rank, 1e5, np 2 85 [1] 108 [2] 96 [2]
same, 1e5, np 4 29 [1] 45 [4] 41 [4]
same, 1e5, np 6* 35 [1] 56 [6] 69 [6]
same, 1e6, np 2 852 [1] 1024 [2] 1029 [2]
same, 1e6, np 4 210 [1] 309 [4] 460 [4]
same, 1e6, np 6* 197 [1] 342 [6] 374 [6]
global_evaluate, 20 exterior/rank only, np 2 / 4 / 6* 17–22 / 20–21 / 60–64 [1] 19–21 / 26–28 / 68–75 [2 / 4 / 6] same rounds as branch
global_evaluate, local interior + 20 ext, 1e6, np 4 537 [1] 626 [4] 942 [4]

* np 6 is oversubscribed on 4 CPUs.

  • The branch still runs the full cap, as a4b8278 did, because some of the 20 exterior points per rank lie inside the union of padded boxes. That is 1–3 of 40 at np 2, 2–5 of 80 at np 4, and 5–7 of 120 at np 6. About 6 % of this exterior distribution lies within one pad (0.024) of the wall.
  • Times are noisy under machine load. The settled early-return path runs identical code on both builds yet varied by up to ±30 %. The round counts are exact.

Band check (far.py; box cs 1/32, pad 0.0238; settled 1e5 swarm plus 20 exterior points per rank in a band of x; medians of 5):

exterior band base np 2 / np 4 branch np 2 / np 4
x in 1.05–1.5 (beyond the pad; H5's benchmark) 86 ms [1] / 36 ms [1] 86 ms [1] / 25 ms [1]
x in 1.001–1.012 (within half a pad) 87 [1] / 42 [1] 101 [2] / 37 [4]
x in 1.001–1.020 85 [1] / 41 [1] 100 [2] / 36 [4]
global_evaluate, the same exterior points alone, within the pad 18 [1] / 34 [1] 22 [2] / 23 [4]

So H5's "within noise of base" holds for exterior points beyond one cell radius of every rank's box, and I reproduce it. Within a cell of the wall, the rounds are unchanged from a4b8278. A swarm advected out through a wall, or a semi-Lagrangian departure point just outside it, sits in exactly that band.

Annulus (cs 0.0625; half of the exterior points are in the hole, which lies inside the boxes): settled + 20 exterior per rank:

base branch nobox
1e5, np 2 / 4 / 6* 102 [1] / 27 [1] / 26 [1] 116 [2] / 40 [4] / 62 [6] 117 [2] / 35 [4] / 59 [6]
1e6, np 2 / 4 / 6* 991 [1] / 358 [1] / 196 [1] 1110 [2] / 523 [4] / 366 [6] 1096 [2] / 319 [4] / 352 [6]

The branch equals a4b8278 here. The PR body names the annulus hole as a capped case, but not the within-a-cell-of-the-wall case.

c. Is the box test conservative? Yes, in every case tested. boxcheck gathers points that some rank's points_in_domain claims and tests them with the PR's own _outside_every_domain(mesh._get_domain_boxes(), ·). The candidates are:

  • every cell's corners pulled inward by 1e-12 to 1e-3;
  • edge midpoints 1e-10 inside;
  • cell centroids;
  • 4001-point lines at ±1e-12, 1e-7 and 1e-9 either side of every rank's unpadded box faces;
  • on the annulus, circles at R_O(1 ± 1e-9), R_O(1 − 1e-4), R_I(1 ± 1e-9) and R_I(1 + 1e-4).

Results:

  • 0 claimed points classed exterior in all 18 runs:
    • annulus at np 2, 3, 4 and 5;
    • box and quad at np 2, 3 and 4;
    • annulus and box with a deformed mesh (mesh.deform, which moves the walls too) at np 2 and 3;
    • annulus skip1 np 4, annulus rank0 np 3, box skip1 np 4.
  • Claimed points lie at most 2.2e-9 outside the unpadded vertex boxes. That is the points_in_domain tolerance at the walls, against a pad of 0.05–0.10.
  • The PR's boxes equal an independent replica, and are identical on every rank.
  • [read] Every claim is validated by cell location (strict_validation=True), and a cell's straight-sided hull lies within its rank's vertex box. So conservativeness rests on the pad covering only the locator tolerance. It covers it by about 7 orders of magnitude.
  • Caveat [read]: a periodic mesh holds localized cell coordinates, which getCoordinatesLocal() does not include. SegmentedSphericalSurface2D, the one default periodic constructor, fails in petsc_dm_set_periodicity (PETSc error 75) on both builds, so this case cannot be exercised today. If periodic meshes return, the box should come from the cell coordinates.

d. The allgather on empty ranks.

  • [read] _get_domain_boxes() is called inside if uw.mpi.size > 1, after the early return. That return is gated on a reduced count, so every rank reaches the call or none does. get_max_radius inside it is called unconditionally.
  • An empty rank contributes an inf box and is excluded.
  • Measured: no hang with two cell-less ranks (rank0 np 3), a cell-less rank 1 (skip1 np 3 and np 4), or ranks holding no particles (global_random_rank0_empty). Boxes were [inf, inf] for those ranks.
  • test_0052 (the collective-guard scan) passes on both builds.

e. Where exterior particles are parked (delete_lost_points=False; count sweep, both builds):

  • Far exterior (outside every box) is parked on its nearest centroid (k = 0) in every run.
  • Near exterior (inside a box: the hole, or within a cell of the wall) is parked on the farthest centroid (k = size − 1), as on a4b8278.
  • Empty ranks still receive exterior particles (L1 not resolved):
layout scenario branch parked per rank base nobox
annulus skip1 np 4 (rank 1 cell-less) jitter_large [790, 4583, 570, 848] [3463, 0, 0, 3328] [0, 6791, 0, 0]
annulus rank0 np 3 (ranks 1–2 cell-less) jitter_large [1981, 0, 4774] [6755, 0, 0] [0, 0, 6755]
box skip1 np 4 jitter_large [270, 518, 117, 281] [590, 0, 0, 596] [0, 1186, 0, 0]
box rank0 np 3 jitter_large [714, 0, 484] [1198, 0, 0] [0, 0, 1198]
  • The PR's "in every case the exterior points land on the same ranks as base" is therefore true only of points beyond the pad. Base parked at whatever round it stopped in (k = 1–2, or k = 0 when it ran one round). The branch splits the exterior points between nearest and farthest.
  • Interior particle sets per rank are identical to base in all 320 scenario runs. The per-rank local order of interior particles differs from base in every scenario that has exterior particles, because those particles leave by a different route.

Check 3: the fix still works

  • Stray sweep (probe.py seam then serial_ref.py; annulus, box and quad at np 2–5; 12 runs): 0 points above 1e-4.
    • The residual max |parallel − serial| at interior points is ≤ 6.2e-6. That is the pre-existing near-vertex L3.
    • 0 flag mismatches.
    • Strays whose own centroid is nearest: 202–984 per run, error 0 to 4.2e-6. Single-point calls: 0 to 2e-6.
  • ge_point2.py: branch 5.05828 at np 1, 2, 3 and 4. Base at np 2: 5.76069.

Check 4: conservation — 0 violations

32 count runs (annulus and box; np 2, 3, 4 and 5; rank0 np 3; skip1 np 3 and np 4; branch and base), each 5 scenarios × 2 delete modes, give 320 scenario runs and 0 violations. In all of them:

  • no duplicates;
  • no interior particle lost;
  • no interior particle held by a non-containing rank;
  • with delete_lost_points=False the count is conserved, and with True it equals the interior count.

Check 5: bit-identity where nothing is stranded

probe.py advect, branch against base at np 2 and 4:

  • the cases: annulus rotation, box cellular flow, and box uniform outflow with clip on and off;
  • what was compared: 5 RK2 steps, then global_evaluate of P2 at 3100 points, then a swarm checkpoint round trip.

All 8 pairs are bit-identical:

  • id-sorted positions and owners at every step;
  • per-rank local-order hashes;
  • the global_evaluate values and flags;
  • the checkpoint (count, coordinates, values, per-rank counts).

Rounds per step are equal, except annulus np 4, which runs 6 against 5. That is the near-exterior effect, with no change in the results.

Check 6: the text

  • L4 is in the PR body, under "Not fixed here (H1's L4)": 1.5e-5 at np 2 and 1.3e-6 at np 3, deterministic, to be filed separately.
  • The cost line "55 against 60 ms" is withdrawn. A timing table replaces it. The table is right for its benchmark (exterior at x 1.05–1.5, beyond the pad), but it is presented as the general cost.
  • The body says "Points inside some box but outside the mesh (a concave boundary, an annulus hole) still take the capped rounds". It does not say that exterior points within a cell of a straight wall are such points. It also does not say that one such point makes every rank run the cap, or that these points are parked on the farthest domain, empty ranks included.

Check 7: regressions

np 2 np 4
26 parallel files, branch 98 passed, 11 skipped, on every rank 108 passed, 1 skipped, on every rank
26 parallel files, base 3 failed, 95 passed, 11 skipped 5 failed, 103 passed, 1 skipped
  • The base failures are all test_1093.
  • test_0052 (serial): branch 5 passed; base 5 passed.
  • The serial-under-mpirun stages were skipped as instructed.

Findings

Medium

  • M2′. The exterior bound misses near-wall exterior points, which are the common case.
    • Measured:
      • one exterior point within one get_max_radius() of any rank's vertex box keeps every rank looping to min(10, size) rounds. That is 2, 4 or 6 rounds at np 2, 4 or 6, against base's 1, and identical to a4b8278.
      • At 1e6 points that costs +100 to +150 ms per migrate (×1.5–1.7 at np 4–6).
      • Those points are parked on the farthest domain, including cell-less ranks (4583 of 6791 on the empty rank, annulus skip1 np 4).
    • Advection exits, semi-Lagrangian departure points and the annulus hole all produce such points.
    • Condition, preferred: make the bound per point. Offer each unclaimed point only to ranks whose inflated box contains it, in centroid order, and stop offering it once that list is exhausted. Exit when no point has a candidate left.
    • Minimum, if the hub accepts disclosure: say in the PR body that exterior points within a cell of a wall, or in a concave hole, still take min(10, size) rounds for the whole call and are parked on the farthest domain, empty ranks included. Also say that the timing table and the "same ranks as base" sentence apply only to exterior points beyond that band.

Low

  • L1 (open, narrowed). Empty ranks receive near-exterior particles. They no longer receive far ones.
  • L5 [read]. The box uses getCoordinatesLocal(), so a periodic (cell-coordinate) mesh would get a box missing its wrapped cells. The case is untestable today, because the one default periodic constructor fails in PETSc. Worth a comment in _get_domain_boxes.
  • L6. The per-rank local order of interior particles differs from base whenever exterior particles are present. Sets and values are identical. Order-dependent sums over particles could change at rounding level.

Met

  • M1 (Check 1), L4 and the cost-line withdrawal (Check 6).
  • The fix (Check 3), conservation (Check 4), bit-identity (Check 5) and regressions (Check 7).
  • Box conservativeness and the allgather on empty ranks (Check 2c and 2d).

Merge condition

  1. Per-point box bound (preferred), or the disclosure above (M2′).

Scripts, probes and logs are kept by the reviewer and can be posted on request.

Underworld development team with AI support from Claude Code

…lds it (#1093 review)

M2'. The exterior bound of 806877f tested "outside every box" globally:
a point just outside a wall or in a hole sits inside some padded box, so
every rank still ran min(10, size) rounds and the point was parked on the
farthest domain, a rank with no cells included. Each unclaimed point now
has its own list: the ranks whose box contains it, nearest centroid first
(_candidate_ranks), offered in turn; it stays where it is when the list is
exhausted. A point in no box goes to its nearest domain once, as on base.
A rank with no cells has an empty box and no finite centroid, so it is
never sent a point. The pad shrinks from a cell radius to four times the
locator's face tolerance of it (a point in a domain is in the rank's
unpadded vertex box; the pad covers the locator's tolerance outside).

Measured (1e6 points, 1% exterior near a wall or in a hole): 2 rounds on
natural partitions at np 4 and 6 (base 1, the earlier bound 4 and 6), 3 on
layouts scattered over 3 ranks with a 4th empty; exterior points held on
ranks with cells only.

Tests: exterior points (beyond the outer wall, in the hole) on the slab
partition and with the last rank empty: none lost, each on a rank whose box
holds it or its nearest domain, none on the empty rank, at most 2 rounds on
the slabs. 806877f fails both; development fails the placement one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lmoresi

lmoresi commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Re-check 2: PR #1107 (fix #1093) at 81a9c55

NOT READY at 81a9c55. One small change is needed: the box pad needs an absolute floor. M2′ is closed: exterior points near a wall now take 1 round on the box, and the annulus hole takes 2. L1 is closed: no exterior particle lands on a rank with no cells. The fix, conservation, collectives and regressions all hold.

The smaller pad breaks the invariant this re-check was asked to verify. points_in_domain claims points up to about 1e-5 model units outside a wall, and up to 3e-5 at corners. That is an absolute slab, not a fraction of the cell. The pad is 0.04 cell radii. Below a largest cell radius of about 7.5e-4 model units, some claimed points lie outside every padded box. On a mesh with cells 6e-5 across, the branch then deletes 83 of 2342 such particles that base keeps. An absolute floor on the pad (+1e-4) removes every case and changes nothing else measured.

Reviewer: H1 (review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)). Base: development 264400a. Everything is measured unless marked [read]. Logs are kept by the reviewer.

Method

  • The builds:
  • Tests run from git archive copies, with PYTHONDONTWRITEBYTECODE=1, -p no:cacheprovider and --with-mpi. Every MPI run goes through mpi_supervisor.py --silence 600.
  • Cores: every run was pinned to the same 4 CPUs, so np 5, 6, 8 and 12 are oversubscribed. Their round counts are exact; their times are indicative only. The machine's load was about 35 throughout.
  • Rounds are counted as points_in_domain calls inside Swarm.migrate, minus one per migrate, the same way on every build.
  • How the previous re-check's tools were adapted:
    • boxcheck:
      • The pass criterion is now: the rank that claims a point must appear in that point's _candidate_ranks list. The list is computed with the PR's own boxes and centroids, and the check is also made within the round cap.
      • The candidate points now include points outside the walls, which the previous re-check never tested (its farthest was 1e-9 outside). They are corners pushed outward along centroid→vertex, edge points pushed outward along the edge normal, and lines and circles beyond the walls.
      • The offsets are 1e-9 to 3e-5 absolute, and 0.25, 0.5, 0.9 and 1.1 × pad.
      • --scale scales the mesh from 1e-4 to 1e6.
    • count:
      • The far/near split uses the PR's boxes.
      • New placement detail: for each parked exterior particle, whether it sits in its holder's box (and its position in the candidate list), or in no box on its nearest domain. The detail also counts particles on cell-less ranks.
    • New strand mode: exterior points that some rank claims are handed to a rank that does not claim them, then migrated with delete_lost_points=True. The count of particles kept is compared across builds.
    • far.py:
      • The bands are now fixed: x in 1.05–1.5, 1.001–1.012 and 1.001–1.020, plus the uniform exterior case from the previous re-check.
      • An annulus variant was added: outer far, outer near (+0.001 to +0.02), hole, and mixed (the previous re-check's annulus case).
      • The swarm size is a parameter (1e5 or 1e6), and the output is JSON.
    • New rounds_hi.py: round counts at np 4, 8 and 12, on the annulus and a 3-D spherical shell.
    • Mutants:
      • first, once, cap2, noprog and noprog2 were re-targeted at 81a9c55's loop. The no-progress exit is reconstructed from reduced unclaimed and claimed counts.
      • New nolist reproduces 35af689's rule on 81a9c55: k-th nearest centroid over all ranks while the point is in some box.
      • New mesh-module mutants: pad1 (35af689's pad of one cell radius) and padabs (81a9c55's pad + 1e-4).
      • Every mutant log shows its injection line.

1. M2′: closed

[read] The rule. Each unclaimed point gets a list: the ranks whose padded box contains it, nearest centroid first. A point in no box gets only its nearest centroid. Round it sends the point to entry it. The loop exits when no point has an entry left, or at min(10, size).

Rounds and migrate time (median ms, 2 interleaved runs × 5 reps, settled swarm + 20 exterior points per rank; rounds in brackets; np 6 is oversubscribed):

case base 35af689 81a9c55
box cs 1/32, x 1.001–1.012, 1e5, np 2 / 4 / 6 83 [1] / 26 [1] / 57 [1] 99 [2] / 39 [4] / 75 [6] 82 [1] / 26 [1] / 31 [1]
same, 1e6, np 2 / 4 / 6 ~830 [1] / 380 [1] / 194 [1] ~990 [2] / 431 [4] / 332 [6] ~900 [1] / 286 [1] / 198 [1]
box, x 1.001–1.020, 1e6, np 4 / 6 363 [1] / 194 [1] 440 [4] / 339 [6] 290 [1] / 208 [1]
box, uniform exterior (the previous re-check's case), 1e6, np 4 / 6 299 [1] / 189 [1] 441 [4] / 336 [6] 288 [1] / 204 [1]
box, x 1.05–1.5 (far), 1e6, np 4 372 [1] 306 [1] 299 [1]
annulus cs 0.0625, hole, 1e5, np 2 / 4 / 6 116 [1] / 28 [1] / 36 [1] 110 [2] / 39 [4] / 67 [6] 114 [2] / 33 [2] / 45 [2]
annulus, hole, 1e6, np 2 / 4 / 6 987 [1] / 232 [1] / 204 [1] 1120 [2] / 344 [4] / 369 [6] 1158 [2] / 290 [2] / 255 [2]
annulus, outer near (+0.001 to +0.02), 1e6, np 4 / 6 233 [1] / 207 [1] 345 [4] / 369 [6] 233 [1] / 239 [1]
annulus, mixed (the previous re-check's case), 1e6, np 4 / 6 233 [1] / 210 [1] 334 [4] / 384 [6] 315 [2] / 240 [2]
global_evaluate of the 20 exterior points per rank alone 1 round min(10, size) 1 (walls), 2 (hole)
  • Near a wall, the branch now runs as base: 1 round. The pad, 0.04 cell radii (0.00095 at cs 1/32), is smaller than the band's 0.001 offset. These points are in no box and go to their nearest domain once.
  • In the annulus hole, the branch takes 2 rounds. That costs +25 to +60 ms per migrate at 1e6 points, against +110 to +165 ms on 35af689.
  • With 35af689's one-cell pad (pad1), near-wall points would take 2 rounds. So the smaller pad is what brings them to 1.
  • Higher np and 3-D (rounds_hi.py; round counts only):
base 35af689 81a9c55
annulus hole, np 4 / 8 / 12 1 / 1 / 1 4 / 8 / 10 2 / 2 / 2
annulus outer near, np 4 / 8 / 12 1 / 1 / 1 4 / 8 / 10 1 / 1 / 2
spherical shell (3-D) hole, np 4 / 8 / 12 1 / 1 / 1–2 4 / 8 / 10 4 / 5 / 4
shell outer near, np 4 / 8 / 12 1 / 1 / 1 4 / 8 / 10 3 / 3 / 3

In 3-D, the hole of a shell lies inside 4–5 ranks' boxes, so the rounds are 3–5 rather than 2. That is bounded by the overlap of the boxes, not by the cap, and is well below 35af689's. The PR body's "one or two" rounds applies to 2-D.

2. Placement (L1): closed

The count sweep (jitter_large and the other scenarios, delete_lost_points=False) gives these exterior particle counts per rank:

layout base 35af689 81a9c55
annulus skip1 np 4 (rank 1 has no cells) [3463, 0, 0, 3328] [790, 4583, 570, 848] [1981, 0, 2722, 2088]
annulus rank0 np 3 (ranks 1–2 have no cells) [6755, 0, 0] [1981, 0, 4774] [6755, 0, 0]
box skip1 np 4 [590, 0, 0, 596] [270, 518, 117, 281] [495, 0, 204, 487]
box rank0 np 3 [1198, 0, 0] [714, 0, 484] [1198, 0, 0]
  • Exterior particles on cell-less ranks, summed over all 10 scenarios per layout: 0 in every 81a9c55 run. 35af689 put 5495–5650 there. Base put 150 there in rank0 np 3, all from global_random_rank0_empty: base parks wherever its no-progress exit stops.

  • Where exactly they go. Over the 15 count runs, every parked exterior particle is in one of two places:

    • In its holder's padded box, in which case the holder is the last entry of the particle's candidate list. Those lists have 1–3 entries.
    • In no box, on its nearest domain.

    No other placement occurred.

    • In the annulus runs, about 60 % of parked exterior particles are in a box and 40 % in none.
    • In the box runs, about 98 % are in no box (box np 4: 1174 in no box, 27 in a box).
  • The new test test_exterior_points_never_reach_a_rank_with_no_cells encodes this.

3. Is the box test conservative? Not for small cells (the key risk)

[read] What the locator admits.

  • _test_if_points_in_cells_internal places its face control points at ±1e-3 along the normal, an absolute offset in model units. With tol = _EVAL_FACE_TOL = 1e-2, the in-cell test admits points up to 1e-2 × 1e-3 = 1e-5 model units outside a face, at any mesh size.
  • At a cell corner the two face slabs meet beyond the vertex, which extends the reach further.
  • _get_domain_boxes's docstring says the pad, 4 × _EVAL_FACE_TOL × the largest cell radius, "covers a point just outside the mesh that the locator still gives a cell". That holds only while 0.04 × the largest cell radius exceeds this absolute slab.

Measured with boxcheck (np 3 unless stated). In the table, "excess" is the largest distance by which a claimed point lies outside its claimer's unpadded box, and "not offered" counts points whose claiming rank is not in their candidate list.

mesh largest cell radius pad max excess claimed points not offered in no box
box, annulus, quad at scale 1 (np 2–5); deformed box and annulus (np 2, 3); annulus skip1 np 4 and rank0 np 3; box skip1 np 4 0.05–0.10 0.002–0.004 1.2e-5 230k–570k per run 0 0
box ×0.1 4.9e-3 2.0e-4 1.7e-5 287k 0 0
box ×0.01 5.0e-4 2.0e-5 2.25e-5 309k 10 52
annulus ×0.01 9.6e-4 3.8e-5 2.0e-5 491k 0 0
quad ×0.01 6.3e-4 2.5e-5 1.0e-5 277k 0 0
box ×1e-3 4.9e-5 2.0e-6 2.4e-5 335k 7656 54763
annulus ×1e-3 9.2e-5 3.7e-6 2.0e-5 569k 901 2688
quad ×1e-3 6.3e-5 2.5e-6 1.0e-5 311k 19582 50056
box ×1e4, ×1e6; annulus and quad ×1e6 ≥ 488 ≥ 19.5 ≤ 3e-5 0 0
35af689 (pad = 1 cell), box ×0.01 and ×1e-3 5e-4 / 4.9e-5 2.4e-5 0 0
padabs (pad + 1e-4), box ×0.01 and ×1e-3 0 0
  • The claim excess is absolute: about 1.2e-5 outside a straight wall and up to 3e-5 near corners, from scale 1e-3 to 1e6. The pad scales with the cell size. So the box test fails once the largest cell radius falls below about 7.5e-4 model units, roughly 1000 cells across a unit domain.
    • Base and 35af689 do not have this problem: base has no boxes, and 35af689 uses a full cell radius.
  • Interior points are not affected, so global_evaluate returns a partition-dependent wrong value for interior points stranded at a seam (best-claim picks nearest centroid, not containing cell) #1093's fix holds. A point inside a cell is inside that cell's vertex hull, and so inside its owner's unpadded box. The owner is therefore always in the point's list.
    • At scale 1e-4 the 1e-5 slab is wider than a cell, so some ranks also claim interior points of a neighbour's cell. Those ranks are not offered the points, but the true owner is.
  • What a wrongly classed point costs (strand mode). Claimed exterior points were handed to a non-claiming rank and migrated with delete_lost_points=True; the table gives the particles kept.
mesh base 35af689 81a9c55 pad1 / padabs
box ×1, ×0.1, ×0.01 1758 / 1763 / 1769 same same same (×0.01)
box ×1e-3 (cells 6e-5) 2342 of 2372 2342 2259 (83 lost) 2342 / 2342
quad ×1e-3 1361 of 1361 — 1316 (45 lost) —
annulus ×1e-3 5908 of 5908 — 5905 (3 lost) —

These are particles within about 3e-5 of the wall, outside it, that some rank's locator accepts. Base delivers them to that rank. The branch leaves them on the wrong rank, where they are deleted. With clip_to_mesh=True, the default, that deletion happens on every migrate.

  • With evaluate uses the cell that contains a point before any face tolerance (#1115) #1117 (two-pass locator, a8e3a2f) plus this PR: the claimed sets, excesses and "not offered" counts are identical to the branch's at scales 1 and 1e-3. That covers annulus, box, quad and the deformed box. evaluate uses the cell that contains a point before any face tolerance (#1115) #1117 changes only which cell a point gets, not which points a rank claims, so the tolerance and the pad agree or disagree exactly as without it.
  • [read] Does a point that "stays when its list is exhausted" ever strand an interior point?
    • Only if its owner is not in its list, which the argument above rules out, or sits past entry 10. That can happen only at np > 10 when more than 10 boxes hold a point. Base's cap had the same limit with a worse ordering, so this is not a regression.
    • The conservation and stray sweeps (sections 4 and 5) found no stranded interior point.
  • Condition (M3):
    • Give the pad an absolute floor that covers the locator's slab, for example pad = 4 * _EVAL_FACE_TOL * get_max_radius() + 10 * _EVAL_FACE_TOL * 1e-3. That is +1e-4, and it would be better tied to the control-point offset constant.
    • Correct the docstring's statement of what the pad covers.
    • Measured with padabs (+1e-4):
      • "not offered" is 0 at scales 0.01 and 1e-3;
      • strand keeps what base keeps;
      • test_1093 gives 8/8 at np 3 and 4.
    • At cs 1/32, +1e-4 widens the pad from 0.00095 to 0.00105. That puts only exterior points within 0.00105 of a wall in a box, so the near-wall rounds stay at 1–2.

4. The fix still works

  • Stray sweep (probe.py seam then the serial reference; annulus, box and quad at np 2–5; 12 runs): 0 points above 1e-4.
    • The largest interior |parallel − serial| is ≤ 6.2e-6, the pre-existing near-vertex L3.
    • 0 flag mismatches.
  • ge_point2: 5.05828 at np 1, 2, 3 and 4 on the branch. Base at np 2 gives 5.76069.
  • Conservation:
    • 15 branch count runs: annulus and box at np 2–5, rank0 np 3, skip1 np 3 and skip1 np 4.
    • 12 runs for base and 35af689 together: rank0 np 3, skip1 np 4 and np 4, each on annulus and box.
    • Each run covers 5 scenarios × 2 delete modes, so 270 scenario runs gave 0 violations.
    • In every one:
      • there are no duplicates;
      • no interior particle is lost;
      • no interior particle is held by a non-containing rank;
      • with delete_lost_points=False the count is conserved, and with True it equals the interior count.
  • The round counts for interior jitter in the count sweep are 2–3 at np 2–4 and 3–4 at np 5. On 35af689 they were 3–4 at np 4.

5. The tests

test_1093 (8 tests) np 2 np 3 np 4 np 5
branch 5 passed, 3 skipped 8 passed 8 passed 8 passed
#1117 + #1107 overlay 5 passed, 3 skipped 8 passed 8 passed —
base 5 failed 6 failed 7 failed 7 failed
35af689 2 failed 2 failed 2 failed 1 failed
nolist (35af689's rule on 81a9c55) 2 failed 2 failed 2 failed 1 failed
cap2 — 2 failed 3 failed 3 failed
first — 4 failed 5 failed 5 failed
once — 4 failed 5 failed 5 failed
noprog — 2 failed 1 failed 1 failed
noprog2 — 8 passed 1 failed 1 failed
pad1 / padabs — 8 passed 8 passed —

Counts are tests (any rank failing).

  • The two new tests fail under 35af689 and nolist, and under base, at every np:
    • test_exterior_points_stay_near_where_they_could_be;
    • test_exterior_points_never_reach_a_rank_with_no_cells.
    • On base, part of the failure is an AttributeError, because base has no _get_domain_boxes. On some ranks it is the "none lost" assertion.
    • On 35af689 the failures are behavioural: the rounds exceed 2, and particles are placed on the cell-less rank.
  • The old mutants are still caught, with one weakening (L7). noprog2 is no longer caught at np 3. It is caught at np 4 and 5, by test_a_single_point_in_a_third_nearest_domain only. Previously it was caught at np 3–5 by three tests. The shorter per-point lists make two idle rounds rarer.
  • test_0511 (evaluate uses the cell that contains a point before any face tolerance (#1115) #1117's new test) passes on the overlay: 8 passed.
  • The new tests do not exercise small cells, so they cannot catch M3. pad1 and padabs both pass.

6. Collectives

  • [read] _get_domain_boxes() (one allgather, plus the get_max_radius allreduce) and _get_domain_centroids() (gather_data with bcast) are both called after the early return. That return is gated on a reduced count, so every rank reaches them or none does.
    • _candidate_ranks is rank-local and needs no communication.
    • The loop's exit is an allreduce reached by every rank on every round.
    • A cell-less rank contributes an inf box (never inside) and a 1e30 centroid, which is never nearest.
    • The docstring calls it "no finite centroid". The sentinel is finite, but the effect is the same.
  • Measured: no hang or supervisor kill in any run. That includes the cell-less layouts (rank0 np 3, skip1 np 3 and 4, the last_empty test fixture at np 2–5), ranks holding no particles, and np 8 and 12. test_0052 passes on the branch and on base.

7. Bit-identity where nothing is stranded

probe.py advect, branch against base at np 2 and 4: annulus rotation, box cellular flow, and box uniform outflow with clip on and off (8 pairs).

  • In all 8 pairs the id-sorted positions, owners and values at every step are bit-identical, and so are the global_evaluate values and flags.
  • The per-rank local order differs in 4 pairs: annulus np 2 and 4, and uniform outflow np 4 with clip on and off. This is L6 from the previous re-check. Some steps there have exterior RK midpoints, which leave by a different route.
  • Checkpoint: 6 of 8 pairs are identical. In the 2 uniform-outflow np 4 pairs, one particle's value differs.
    • Two particles share the coordinate (0.2289, 0.999) after clipping, and hold different values (0.9673 and 0.9536). Their step-5 state is identical on both builds.
    • After read_timestep, both particles carry the same value: 0.9673 on the branch and 0.9536 on base.
    • So the swarm reader resolves duplicate coordinates by local order. That ambiguity is pre-existing; the PR only changes the order it sees. It is worth its own issue, and is not a merge blocker.

8. Regressions

np 2 np 4
26 parallel files, branch 100 passed, 11 skipped, on every rank 110 passed, 1 skipped, on every rank
26 parallel files, base (with the branch's test_1093) 5 failed, 95 passed, 11 skipped 7 failed, 103 passed, 1 skipped
  • The base failures are all in test_1093.
  • test_0052 (serial) passes on both: 5 passed each.

Findings

Medium

  • M3. The 0.04-cell pad does not cover the locator's tolerance on small cells.
    • The in-cell test admits points about 1e-5 model units outside a face, up to 3e-5 at corners, whatever the mesh size.
    • Once the largest cell radius falls below about 7.5e-4 model units, points that some rank claims fall outside every padded box. Measured: 10 points at cells 5e-4 across, and thousands at 5e-5.
    • Particles there that base delivers are then deleted: 83 of 2342 on the box and 45 of 1361 on the quad, with cells about 6e-5 across.
    • Interior points, and so global_evaluate returns a partition-dependent wrong value for interior points stranded at a seam (best-claim picks nearest centroid, not containing cell) #1093's fix, are unaffected.
    • The docstring's justification of the pad is incorrect.
    • Condition: add an absolute floor tied to the control-point offset, for example + 10 × _EVAL_FACE_TOL × 1e-3 (= 1e-4), and correct the docstring. That floor (padabs) was measured: 0 claimed points not offered, strand losses equal to base, test_1093 8/8.

Low

  • L7. test_1093 no longer catches noprog2 (the no-progress exit after two idle rounds) at np 3. It is caught at np 4 and 5 by one test.
  • L8. In 3-D (spherical shell), hole points take 3–5 rounds and near-wall points 3, against base's 1. This is bounded by box overlap, not the cap, and far below 35af689's 4–10. The PR body's "one or two" applies to 2-D only.
  • L6 (open, as before). The per-rank local order differs from base when exterior particles take part. One visible effect: read_timestep resolves two particles with identical coordinates differently. The ambiguity is pre-existing; it needs its own issue.
  • Docstring nit: a cell-less rank's centroid is a finite 1e30 sentinel, not "no finite centroid". The behaviour is right.

Met

  • M2′ closed: near-wall points take 1 round, the hole 2, in 2-D.
  • L1 closed: 0 exterior particles on cell-less ranks.
  • The fix: 0 strays, ge_point2 = 5.05828, 0 conservation violations.
  • The tests: the new tests fail under 35af689 and base.
  • Collectives, bit-identity of results, and regressions all hold.

Merge condition

  1. M3: an absolute floor on the domain-box pad covering the locator's face slab, and a corrected docstring.

Underworld development team with AI support from Claude Code

… M3)

The pad (4 face tolerances of the largest cell radius) did not cover the
locator's face slab, which has an absolute part from its 1e-3 control-point
offset (about 1e-5 outside a wall, 3e-5 at a corner). On cells finer than
about 7.5e-4 a point some rank claims fell outside every box, and a migrate
that deletes lost points deleted it where base keeps it. The pad is now at
least 10 face tolerances of that offset (1e-4).

Test: a 1e-3 box at cellSize 6e-5, points up to 3e-5 outside its walls,
delete_lost_points=True: every point some rank's locator claims is kept.
Fails without the floor at np 2 and 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lmoresi

lmoresi commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

#1107 at c61f890: M3 re-check (the absolute pad floor)

READY at c61f890. Checked by H1 (review and parallel test runs on a 96-thread Linux workstation: Intel Xeon Gold 6240R, AVX-512; MPICH), on a build of c61f890.

The change. One commit on 81a9c55. The pad is now max(4·_EVAL_FACE_TOL·r_max, 10·_EVAL_FACE_TOL·1e-3), so its floor is 1e-4. The docstring now explains both the relative and the absolute parts of the locator's slab. The new test_1093 case covers a 1e-3 box at cell size 6e-5.

The small-cell cases that failed at 81a9c55, rerun at np 3:

mesh, scale claimed points claimed but not offered to the claimer claimed and outside every box
box ×0.01 309,412 0 (was 10) 0 (was 52)
box ×1e-3 334,596 0 (was 7,656) 0 (was 54,763)
quad ×0.01 277,327 0 0
quad ×1e-3 310,523 0 (was 19,582) 0 (was 50,056)
annulus ×0.01 490,953 0 0
annulus ×1e-3 569,261 0 (was 901) 0 (was 2,688)

Particles kept by migrate(delete_lost_points=True), for claimed exterior slab points handed to a rank that does not claim them, at np 3:

mesh ×1e-3 development c61f890 81a9c55
box 2342 of 2372 2342 2259
quad 1361 of 1361 1361 1316
annulus 5908 of 5908 5908 5905

These now equal development everywhere, in 2 rounds.

test_1093: 6 passed, 3 skipped at np 2; 9 passed at np 3 and np 4.

The low notes from the previous re-check stand as written in the PR body: noprog2's coverage at np 3, the 3-D hole rounds, and the order of interior particles.

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi merged commit a729719 into development Nov 13, 2026
10 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