Repository navigation
Swarm.migrate offers a point to every nearby domain before giving up (#1093) - #1107
Conversation
…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>
…evaluate-seam-1093
…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>
Review: PR #1107 (fix #1093) at a4b8278NOT 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 Method
Check 1: the fix
On base, the swarm test lost every stray:
Seam sweep. Max |parallel − serial| at interior points. Each entry is max / count > 1e-4 / count of interior points flagged extrapolated.
Check 2: the new migration logic [read, then measured]What "nearby" is. It is not geometric. Round Duplication or loss [read]. 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.
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].
Check 3: behaviour where nothing is stranded
Check 4: costPaid 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:
Check 6: mutants
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
MMPDE frozen metric (cavity annulus,
FindingsHighNone. Medium
Low
Merge conditions
Underworld development team with AI support from Claude Code |
PR #1107 at a4b8278: the parallel regression stages (merge condition 4)I ran these after the review, with the same runners ( The 26 parallel files (swarm, evaluate/global_evaluate, advection, SLCN, checkpoint):
The only base failures are the PR's new 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>
…evaluate-seam-1093
Re-check: PR #1107 (fix #1093) at 35af689NOT 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 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
Check 1 (M1): test_1093 — met
Check 2 (M2): exterior points — partly meta. The rule [read]. Before the loop,
b. Rounds and timing. The table shows median migrate and global_evaluate times in ms, branch against base (and
* np 6 is oversubscribed on 4 CPUs.
Band check (
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:
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.
Results:
d. The allgather on empty ranks.
e. Where exterior particles are parked (
Check 3: the fix still works
Check 4: conservation — 0 violations32 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:
Check 5: bit-identity where nothing is stranded
All 8 pairs are bit-identical:
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
Check 7: regressions
FindingsMedium
Low
Met
Merge condition
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>
Re-check 2: PR #1107 (fix #1093) at 81a9c55NOT 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. 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
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 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):
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): closedThe count sweep (
3. Is the box test conservative? Not for small cells (the key risk)[read] What the locator admits.
Measured with
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
4. The fix still works
5. The tests
Counts are tests (any rank failing).
6. Collectives
7. Bit-identity where nothing is stranded
8. Regressions
FindingsMedium
Low
Met
Merge condition
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>
#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 The small-cell cases that failed at 81a9c55, rerun at np 3:
Particles kept by
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 |
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.migrateoffers 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:
delete_lost_points);global_evaluateread 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. Onlyswarm.pychanges. #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.
Exterior points held, by rank:
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:
Tests
tests/parallel/test_1093_migration_reaches_containing_rank.pyuses a P1 linear field, so every point FE locates reads exactly.global_evaluate: each one exact, none flagged;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.(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,migrateor advection.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, wheremigrate's changed rounds are not entered, so it takes base's path.test_0052passes.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
level_2/tier_bmarkers (S8)Underworld development team with AI support from Claude Code
🤖 Generated with Claude Code