Repository navigation
Count each node once in the gradient density metric's ranking (#1132) - #1158
Conversation
metric_density_from_gradient evaluated |grad field| at every local DOF and gathered every rank's values, so a node on a partition seam entered the percentile window and the front-following ranks once per copy, and its copies could differ in the last bit. With ties in |grad field|, one bit decided where a seam copy sat in a tie block, and the density moved by O(1) from launch to launch. The owner's |grad| is now synced to every copy first, only owned DOFs (the field's global section, i.e. the point star forest's ownership) are gathered, and each density write is synced owner to ghost. Serial is unchanged. mesh_metric_mismatch reduces over cells, which are not shared, and needs no change. Test: tests/parallel/test_1132_metric_density_shared_nodes_parallel.py, with a staircase gradient of exact ties. A one-ulp nudge to one rank's seam copies leaves the density bit-identical, and the density matches np=1 bit for bit at np 2 to 5. Underworld development team with AI support from Claude Code
|
Verdict: READY with conditions at 560c65b. The fix is correct and the collectives are safe. The new test fails on development and has power against the two mutants that matter. One condition: the "development" row of the PR body's results table does not match the committed test and should be corrected (finding 2). Suggestion 3 and the follow-up in finding 1 do not block the merge. Review by H1 (review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)). All runs were pinned to 8 cores. Method.
Findings, by severity1. (Medium, follow-up, not this PR) With a real gradient, the metric still depends on the rank count, because the gradient projection differs by about 1e-3 between partitionsI used a smooth front on the PR's test mesh:
So the PR removes the ranking defect completely. With the same tight-tolerance input, development is still wrong by up to 0.72. What remains on the branch at the default tolerance is the projection. I suggest a follow-up issue on the metric's gradient projection tolerance, or on how the front-following ranking treats the flat region (for example, ranking above a noise floor). It does not belong in this PR. Reproduce: run the PR's mesh with the T above, and call 2. (Low, PR body; this is the condition) The "development" row of the results table does not match the committed testThe committed test nudges the rank with the most ghost rows. Development then fails as follows:
3. (Low, suggestion) The test does not pin
|
| np 2 | np 3 | np 4 | np 5 | np 8 | |
|---|---|---|---|---|---|
| branch | 6 pass | 6 pass | 6 pass | 6 pass | 6 pass |
| development | 4 fail | 3 fail | 4 fail | 3 fail | 4 fail |
On development, front-following and percentile fail at every np, in both the nudge and tie tests (front-following nudge at np 8: 78 DOFs, up to 0.356). The exception is np 3 and 5, where the percentile nudge happens to pass.
Partition independence with the staircase gradient. This used the test's own staircase, plus gradient-uniform, arc-length and refinement=1 cases. The branch is bit-identical to np 1 at all 303 nodes, in all 6 cases, at every layout:
- np 2, 3, 4 and 8 with the default partitioner;
- np 4 with horizontal bands;
- np 4 and np 8 with random cell assignment (np 8: owned counts 0, 1, 1, 8, 21, 45, 78, 149, so one rank owns no nodes while holding cells);
- np 3, 4 and 8 with the last rank empty.
On development, front-following differs at 302 of 303 nodes, by up to 1.87 at np 8 with a random partition.
Mutants (the PR's test at np 2 and np 4):
| mutant | result |
|---|---|
| B: ghosts counted again (gather every local DOF, not owned rows only) | caught: both tie tests fail at np 2 and 4 |
E: no pre-ranking sync, and the density write unsynced (sync=False) |
caught: 2 fail at np 2, 3 fail at np 4 (nudge cases; for example raw, 22 DOFs, up to 4.4e-16) |
| A: no owner-to-ghost sync of | grad |
D: no pre-sync, density written with rho0.data[:, 0] = ... |
passes |
A and D behave the same as the branch, not missed defects. Once only owned rows are gathered, a ghost's own |grad| never enters the ranking, and the final write overwrites the ghost with the owner's value (the .data setter syncs too, as D shows). The pre-ranking sync is a second layer of defence. It is cheap and harmless.
Serial regressions. tests/test_0750_meshing_follow_metric.py and tests/test_0765_mmpde_descent_does_not_stall.py: 15 pass on both arms.
CI wiring. No change to scripts/test.sh is needed:
- The file is a
tests/parallel/test_*.pywithmin_size=2, so thePARALLEL_FILES=(tests/parallel/test_*.py)batch picks it up in the--p 2phase that CI runs. scripts/check_test_coverage.pyreports OK (458 files reachable).- Development fails the test at np 2, so CI would have caught the defect.
Not run
- The two-launch mover check at np 4 (another session is doing it).
- 3-D meshes, degree-2 metric fields, and the
smoothing_length/gradient_smoothing_lengthpaths. - Launch-to-launch reproducibility at a fixed rank count with the real gradient.
- Open MPI.
Logs, drivers, partition hooks and saved arrays are kept by the reviewer.
Underworld development team with AI support from Claude Code
The fix covers arc-length (its window comes from the same gathered list), and no case pinned it. Development fails its tie case at np 2, 3 and 4 and its seam nudge at np 4; the branch passes 8 of 8 at np 2 to 5. Underworld development team with AI support from Claude Code
|
Re-check of #1158 at bd74390: READY. From H1 (review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)), following its review at 560c65b. The PR is Python only, so this was run with its files laid over development bc3d536's build.
Underworld development team with AI support from Claude Code |
Fixes #1132.
The defect
metric_density_from_gradientevaluates|grad field|at every local DOF, gathers the values from every rank, and ranks them. The ranking sets the percentile window and, on the front-following path, each node's rank. A node on a partition seam is a local DOF on every rank that holds it, so it entered the gathered list once per copy. Each copy is evaluated separately, so the copies can differ in the last bit. Where|grad field|has ties (a plateau, a uniform region), that one bit decided whether a seam copy sat at the bottom or the top of a tie block, and the density there moved by O(1) from launch to launch and with the rank count.The fix
Following the Charter rule, ownership is taken from topology, never from coordinates:
|grad|is synced to every copy before the ranking.Serial is unchanged. I checked the other builder in
metrics.py:mesh_metric_mismatchreduces over cells, which are not shared, so it does not need this change.Test
tests/parallel/test_1132_metric_density_shared_nodes_parallel.py(min_size 2). The gradient is replaced by a staircase of exact ties, a function of the coordinates alone. That way the test pins the ranking, not the projection solve. It covers four cases: front-following, arc-length, percentile and raw.test_seam_copy_last_bit: one rank's ghost copies (the rank with the most) are nudged by one ulp. The density at every DOF must be unchanged bit for bit, and every copy must equal its owner.test_ties_match_serial: the density at every node must equal the np=1 value bit for bit. The np=1 value comes fromserial_reference, which runs the module at np=1 on the same mesh.The tests match nodes across rank counts by coordinate, and only to line up two partitions. The code never identifies points by coordinate.
Results on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH):
Four metric cases (front-following, arc-length, percentile, raw), two tests each, 8 in all:
metrics.pyOn development the tie test fails in front-following, arc-length and percentile at every rank count above. The seam nudge fails in front-following at np 2, 3 and 4, in percentile at np 2 and 4, and in arc-length at np 4. Raw passes on development: its density is the synced gradient itself.
Also run on this branch:
test_0750_meshing_follow_metric.pyandtest_0765_mmpde_descent_does_not_stall.py, serially: 15 pass.test_1173_addon_record_after_a_move_parallel.pyandtest_0855_mesh_smoothing_parallel.pyat np 2 and 4: 11 pass.scripts/check_test_coverage.py: OK.Underworld development team with AI support from Claude Code