Repository navigation
Size a multigrid generation by one percentile over the whole mesh (#865) - #1121
Conversation
Mesh.adapt keeps one refinement generation per halving of the cell size as a multigrid level. The size of a generation was the smallest of the ranks' own 5th-percentile cell diameters, which moves with how the cells are dealt out, so the same adapted mesh kept different levels at different rank counts. The size is now the 5th percentile of the cell diameters over every rank's cells together (edge_split.resolved_cell_size). The pooled values are not gathered: edge_split.percentile_over_ranks finds each order statistic by bisecting on a summed count. The edge_split marking pass takes the size of each pass's mesh as it measures it, collectively. Serial hierarchies are unchanged. The per-rank node_budget truncation and repair=True still make the generations themselves depend on the partition. Underworld development team with AI support from Claude Code
Adversarial review record (before the PR opened)Reviewed by a separate agent on the branch before the last commit; the findings below were answered in 8f86f02. Runs are serial, on macOS (12-core Apple M4, serial runs only). Findings, and what was done
Found sound: the percentile as P simulated ranks in lockstep (P = 2, 3, 5, 8; 10976 cases, none differing, the same collective calls on every rank); the handed sizes are keyed on dms that are alive when read; every test file is reachable from Issue verdicts
Underworld development team with AI support from Claude Code |
Review of #1121: the multigrid levels an adapt keeps no longer depend on the rank count (#865)From H3, the second review desk, on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH). Head 8f86f02 against its base, development 8a3b8d6, with a build of each. Runs used up to 8 ranks under the repository's MPI supervisor; the machine's load average was 27–35. Verdict: READY at 8f86f02, on green CI (4 of 6 jobs green, 2 running when checked). The branch keeps the serial levels at every rank count from 1 to 8, and the percentile is exactly numpy's on the pooled values. It changes which levels some hierarchies keep at higher rank counts, so it needs a register row and the maintainer's sign-off. For the maintainer: the levels kept, from coarsest to the child, in cellsBase: a 0.1 simplex box, refined once. The three fixtures of
|
|
Addendum to the review record: the merged head 348d48d (8f86f02 merged with development 01dec8d, which brings in #1111). From the second review desk (session H3), on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH), with a build of 348d48d. Every run went through the repository's MPI supervisor, one mpirun per file. Load average was about 37. The question was whether #1111's repair of dependent coarse columns behaves differently on the extra level this PR now gives np 7 and 8. All pass.
The repair's merges. The
The READY at 8f86f02 holds at 348d48d. Underworld development team with AI support from Claude Code |
One conflict, in the changelog: both entries are kept. Nothing in adapt or _subsample_mg_levels conflicted. Underworld development team with AI support from Claude Code
… level selection Underworld development team with AI support from Claude Code
What this does
Mesh.adaptkeeps one refinement generation as a multigrid level per halving of the cell size the mesh resolves with. That size was the smallest of the ranks' own 5th-percentile cell diameters, so it depended on how the cells were dealt out: on a box of 968 cells it was 0.04858 on one rank, 0.04592 on 5 and 0.04356 on 8. A generation near the threshold was then kept at one rank count and dropped at another, and the hierarchy, and so the iteration count, changed with the number of ranks (#865).The size is now one 5th percentile over every rank's cells together, so it is a property of the mesh.
edge_split.percentile_over_ranks(values, pct)gives the percentile of the values held on all ranks. It finds the two order statistics by bisection on a value, summing each rank's count below it, and then interpolates asnumpy.percentiledoes. Nothing is gathered to one rank. On one rank it equalsnumpy.percentileof the same values.edge_split.resolved_cell_size(dm)is that percentile of the cell diameters, andMesh._subsample_mg_levelsuses it for every generation.edge_splitengine's marking pass has just measured each generation, so the size is taken there, once, and handed to the selection as before.The rule that picks the levels is not changed.
What changes for a user
On one rank, nothing: the levels of 11 hierarchies are the same before and after (below).
On several ranks, an adapted mesh now keeps the levels the serial run keeps, wherever the refinement gives the serial generations. An iteration count recorded in parallel on an adapted mesh can therefore move. On the fixtures measured on
development(in #865 and in the record on #1119):developmenth_near=0.00625, h_far=0.1, width=0.05,max_levels=4h_near=0.0125, h_far=0.05, width=0.08,max_levels=2What this does not fix
node_budgetis applied rank by rank (each rank truncates its own marked cells), so with a budget the generations themselves depend on the partition, and so do the levels. That is a separate cause and is now adapt: node_budget is applied by each rank to its own cells, so the refined mesh depends on the rank count #1122; the first comment of adapt: the intermediate multigrid levels depend on the partition when h_far sits above the base's finest cell #865 is where it was first noted. This branch does not touch it.repair=Truerepairs rank by rank, which its docstring states as the limit of that option: a flip cannot cross a seam. With it the generations depend on the partition too. The docs changed here say so for both.sbrengine,relax=Trueand the cut route have not been measured for the same generations at every rank count.What has not been run
Nothing here has run on more than one rank. The defect cannot be shown on one rank: there the old rule and the new one give the same levels (415 selection calls compared, all identical), and a mutant that restores the old rule passes every serial test. The evidence for rank independence is:
numpy.percentileof the pooled values in every case, with the same number of collective calls on every rank;tests/parallel/test_1177_mg_levels_same_at_any_rank_count_parallel.py, which deals a fixed set of values out over the ranks and asserts the pooled percentile, and asserts the serial levels of three fixtures at whatever rank count it is run on.The test needs to be run at 1 to 8 ranks on
development, where the level fixtures fail, and on this branch. At CI's 2 ranks only theh_far_above_the_basefixture can show the old rule;two_levelsshows it at 7 and 8.The cost in parallel has not been measured. The bisection makes about 111 collective calls per generation. On one rank that is 5.6 ms on 189 000 cells, beside 286 ms for the cell diameters themselves.
Parallel tests whose fixtures get a different hierarchy at 7 and 8 ranks, none run here: the users of
fault_fixtures.adapted_2d(2)(test_1096, test_1089, test_1086, test_0078's parallel companions) get one more add-on level there; test_1097 and test_1134 sit near a threshold. No file undertests/parallelpins a level count by rank count. On #1119 the faulted fixture's welded branch at 7 and 8 ranks is no longer reached once this lands.Measurements
Serial, on macOS (12-core Apple M4, serial runs only).
Level cells of 11 hierarchies, identical before and after this change:
max_levelsThe three 2-D nvb hierarchies with a fault added (
add_fault) are also unchanged.Tests
tests/parallel/test_1177_mg_levels_same_at_any_rank_count_parallel.py(tier B, also in the serial batch): 110 passed on one rank. Mutants, in memory: the lower-side and the upper-side interpolation alone each fail the percentile tests; every hint replaced by 1.0 fails theedge_splitfixture.scripts/check_test_coverage.py: all 446 files reachable. Docs build clean.Issues
fixed-in-PR): the level selection is fixed by this branch, on serial and simulated-rank evidence; the runs at 1 to 8 ranks decide it.node_budget, moved out of adapt: the intermediate multigrid levels depend on the partition when h_far sits above the base's finest cell #865's comments as a cause of its own.Underworld development team with AI support from Claude Code