Repository navigation
Solver DM clones create their coordinate field on every rank - #1271
Conversation
A clone of the mesh DM does not carry the coordinate field (DMClone copies the coordinates, not the DMField over them), so PETSc created it lazily, the first time an assembly needed a cell's geometry. A rank holding no cells did not need it in the residual-only evaluations, so after a solve it had created fewer objects on the mesh's communicator. Each object takes a tag from that communicator, so the ranks' tag counters drifted apart, and the next two-sided exchange on it waited on messages under a tag the other ranks never use: - np 3, one rank empty: after a viscoelastic solve, the next gmsh mesh load hung in its label read (ReadLabelStratumHDF5); - np 2, one rank empty: a semi-Lagrangian history on an add_fault child failed in UW_DMCreateInterpolationWithinPlex's matrix assembly with an MPI error on one rank while the other waited. clone_dm_hierarchy now creates the field on each clone, where every rank clones. The new parallel test compares the communicator's next tag over the ranks after a solve with one rank empty, then loads a gmsh mesh. Underworld development team with AI support from Claude Code
…ank-labels-load # Conflicts: # src/underworld3/discretisation/discretisation_mesh.py
|
Review from the Underworld development team with AI support from Claude Code (H1: review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)) Review of #1271 at c756d45Verdict at c756d45: ready to merge on green from this review. The fix does what it says. After a viscoelastic solve with one rank empty, development's ranks disagree on the next tag on COMM_WORLD by 1, and the next gmsh load hangs in its label read. On the branch the tags agree and the load finishes. Every solver answer we compared is bit-identical to development, a restart round trip gives the same answers, and the cost cannot be seen in a solve. #975 is still live on the branch, as the author says. Three low findings, none blocking. Method
1. The new test
2. Tag probe after one solve of each kind (np 3, gmsh box, cells [680, 678, 0])Each solve is followed by a gmsh load. Spread = the largest minus the smallest next tag over the ranks.
The same probes with every rank holding cells (np 3 and np 2): spread 0 everywhere, on both. On the refined mesh, head uses one more tag than development, on every rank. That is the coarse level's field, now made at clone time. 3. Solver tests and answers, head vs development (check 1)Files chosen from tests/parallel by grep (VE/stress, adv-diff/SLCN/SUPG, Stokes/MG/fault):
Skips are the same on both, and they come from the tests' own rank-count limits. test_0780 passes at np 4 on both. The probe's solution norms, head vs development:
Identical means all 13 printed digits match. 4. Restart round trip (check 2)The model is Stokes driven by a temperature field, plus SLCN advection-diffusion of that field, for 4 steps. It is checkpointed after step 2 with The SLCN history is not in the checkpoint, so a restart cannot match an unbroken run exactly (max difference 2.4e-2 at the points, the same on head and development). The control is therefore an unbroken run that rebuilds its solvers after step 2.
The restart-vs-control gap is the same on both. The native reader gives the same gap as the remap reader, so the gap comes from what the model does not checkpoint, not from the reload. All runs exit 0, and the tags agree at the end of every phase. A swarm was not included. 5. #975 (check 3)The issue's narrowing probe, at np 3 with cells [8, 8, 0]:
So #975 is not fixed, as the author says. The issue's option 1 stands. 6. Cost
The extra 1.3 ms on a 4-level hierarchy is paid once per solver setup. The solve times differ by no more than the run-to-run spread. Reading the diff
Findings
Run and not runRun: the new test at np 3, 4 and 5 (np 5 oversubscribed on 4 cores) on head and development. 17 solver test files at np 2 and 3 on both (test_0780 at np 4). A tag and answer probe for Stokes, VE, SLCN and refined-mesh Stokes at np 2, np 3, and np 3 with an empty rank. The restart round trip above. #975's probe on both. The cost and memory measurements. Not run:
Logs kept by the reviewer. Underworld development team with AI support from Claude Code |
…ield-sites Lazy coordinate fields: an np 2 empty-rank case and the notes from #1271's review
A fix for two empty-rank failures found in the review of #1232. There is no issue; both have the same cause. Review: H1, the session that reviews pull requests and runs the parallel tests on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH).
The cause
Every PETSc object created on a communicator takes a tag from it. PETSc's two-sided exchanges, such as an SF set-up or a matrix stash, take theirs from the same counter, so the counter must advance in step on every rank.
A solver works on clones of the mesh DM (
Mesh.clone_dm_hierarchy).DMClonecopies the coordinates but not the coordinateDMFieldover them, so PETSc creates that field lazily, the first time an assembly needs a cell's geometry. A rank holding no cells does not need it in the residual-only evaluations, so after a solve it has created fewer objects on the mesh's communicator, and its tag counter is behind the others'. The next two-sided exchange on that communicator then pairs messages under different tags.Measured at np 3 with one rank empty, after one viscoelastic solve: the next tag on
COMM_WORLDwas 536863619, 536863619 and 536863621 on the three ranks. A gdb trace of every tag-taking object creation, compared rank by rank, has exactly one difference: twoDMFieldCreatecalls underDMCreateCoordinateField_Plex, fromDMPlexComputeResidualByKeyon three solver clones, made on the ranks with cells and not on the empty rank.The two symptoms
ReadLabelStratumHDF5). Two ranks are in an SF reduce and the empty rank in an SF broadcast, all inPetscCommBuildTwoSided. This is why test_1107's parallel file hangs at np 3 under a test-only shell partition that leaves the last rank empty.add_faultchild, after a solve on the unfaulted parent, fails inUW_DMCreateInterpolationWithinPlexwith an MPI error ("Invalid buffer pointer" inPetscCommBuildTwoSided_Allreduce, underMatAssemblyBegin_Preallocator) on one rank, while the other waits.The change
clone_dm_hierarchycreates the coordinate field on each clone as it makes it, where every rank clones. It uses the existingdm_force_coordinate_field, which the mesh already calls on its own DM, so the field is never created lazily inside an assembly. Merged with #1244: the coarse levels are moved with the finest first, as before.Test
tests/parallel/test_1107_mesh_load_after_a_solve_on_an_empty_rank_parallel.pyruns a viscoelastic Stokes solve on the empty-rank right triangle (empty_rank_fixtures). It skips at np 2, where that fixture leaves no rank empty. It then makes two checks:PetscCommDuplicate);Regression
These runs used a Python overlay, since the change is Python only.
scripts/test.sh: no failure or hang.scripts/check_test_coverage.py: OK.#975 (metricCreateIsotropic on an empty rank)
This is the same mechanism, but this PR does not fix it. With the reproducer on the issue (cells 8 / 8 / 0 at np 3, the indicator not field 0), the next tag after
metricCreateIsotropicis 536870582, 536870582 and 536870583, and the next distribute hangs, on development and on this branch alike. With the indicator as field 0, the tags agree and it completes.The gdb comparison again has exactly one difference: a coordinate
DMFieldcreated byDMCreateCoordinateField_Plexon ranks 0 and 1, and not on the empty rank. That DM is made inside the metric call, out ofclone_dm_hierarchy's reach. So #975's work-around (option 1 on the issue: build the metric on a DM where the indicator is field 0, or with the field forced first) still stands.Underworld development team with AI support from Claude Code