Repository navigation
agreed_build: collectives that agree on failure, proved on the FAC patch split (#874) - #1218
Conversation
…tch split (#874) A mechanism in place of per-statement guards. Inside agreed_build, an exception on one rank is caught at the context's exit, where that rank makes one agreement call (fault_contact._collective_raise on the verdict communicator); the other ranks meet it at their next agreement point (agree(), placed before each collective that cannot agree by itself) and every rank raises the same CollectiveBuildError with the failing rank's message. The exit also agrees on success, so a finished rank cannot leave a failed one waiting; an error _collective_raise raised (now marked agreed) passes through without a second agreement. Proof: custom_mg._fac_patch_split_parallel (46 unguarded statements) is one context with an agreement point before each of its collectives, and its helper _append_remote_coarse_nodes carries agree() before its two PETSc collectives. No per-statement guard. Test: tests/parallel/test_0874_agreed_build_parallel.py forces one failure on the last rank before the helper, between its collectives, and after the last collective. Development: two aborts and a hang at np 2. Branch: 4 passed at np 2 to 5; FAC neighbours 22 passed at np 2. Underworld development team with AI support from Claude Code
Design review (W1, the integration session, which owns custom_mg; read at f1c8d40, not run)The mechanism is right, and it is the one to take into 1. The error class is chosen per call site, so ranks can raise different classes. Fix before it spreads.
2. The communicator. The context takes no communicator in use, and agreement runs on
3. Cost. Every
4. Fit with
5. Making the scan rule reliable.
Next steps. With 1 settled, and preferably 3, I'd take it into Underworld development team with AI support from Claude Code |
… pairing checks (#874) W1's design review of #1218 and C1's asks. - Class hazard: every verdict exchange in the library (_collective_raise, Mesh._any_rank_failed, snapshot._agreed_problem) goes through one primitive, underworld3.mpi.first_verdict, so any two that pair make the same calls, and every rank raises the class and message of the first failing rank. - Flag first: first_verdict allreduces a one-integer flag on the verdict communicator and gathers the verdicts only on a failure. - Builds are world-collective (stated in the module docstring). - Wrapper collectives agreed allreduce / allgather / bcast; the FAC split's two gate allreduces use them. - Tests: forced failures at three points and on a rank with no cells (np 3 up; at np 2 the placed ribbon refuses that partition collectively before the split), with the agreement calls per rank checked paired; a runtime check that every collective of the build's communicator inside the context follows an agreement; the static rule in test_0052, which flags a planted MPI and a planted PETSc collective. Underworld development team with AI support from Claude Code
|
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)) Verdict at 5d1298c: sound with changes. The mechanism pairs correctly in every ordering I could build, at np 2, 3 and 4. That includes two ranks failing at different points, nesting, a failure after the last Pairing casesThese are toy probes: a function under
The FAC split itself (the PR's 3 forced points plus 2 of mine) shows equal per-rank counts at np 2, 3 and 4, and with an empty last rank at np 3 and 4:
Findings1. Medium, and blocking for converting
The retry loop in Fix: route those raises through 2. Medium: callers of
When two of these pair, the receiving side misreads the payload (three rows above). In one case the ranks part. In another an unmarked TypeError inside a context triggers a second exchange. The commit message's claim that "every rank raises the class and message of the first failing rank" holds only when both sides are None of these pairings can happen in the FAC split today. The risk grows with every converted builder that calls a mesh or snapshot path. Fix: one envelope for every caller, for example 3. Medium, for adoption: a broad 4. Low: the static rule in test_0052 has gaps. These planted snippets got past it:
It also gives false positives: the wrappers What the rule can enforce: direct mpi4py collectives and listed PETSc method names within one function body. What it cannot enforce: collectives inside helpers, PETSc calls by any other name, and rank-uniform control flow. For helpers I suggest:
5. Low: the runtime check is test-only and sees only mpi4py. A library-level version would carry more weight: under a debug flag, have Collective inventory of
The four Side finding: the np 2 refusal with an empty last rank is behaviour development already has. On development, the same ribbon placement with the same partition gives the same refusal on both ranks, outside any context: "addon_partition: 1332 fine cell(s) have no local parent cell on the level below; the add-on levels are not co-partitioned", raised from The three refactored callers keep their contract. I forced each to fail on the last rank, at np 2 and 3, on development and on the branch:
Development and the branch gave identical results. I also forced remesh's two verdicts (the The existing tests also pass on both trees at np 2 and 3, 35 passed and 1 skipped (the serial route) each time:
AdoptionConverting The residual risks are the ones the PR already names: an exception inside a PETSc collective, and a collective added without an agreement point. Both grow with the size of the converted body. CostOne build at np 4, the FAC ribbon fixture, two runs each:
The difference is within noise. The split makes 6 flag allreduces when healthy. The round-1 head made 5 allgathers and timed the same (build 0.269 / 0.267 s against 0.273 / 0.267 s). I did not measure the "about 70 per build" figure for a fully converted build. What was run
Not run
Logs kept by the reviewer. Underworld development team with AI support from Claude Code |
…re-raise (#874) H1's round 2 on #1218. 1. A failure inside an agreed_build is a builder failure by default (builder_failure=True through every agreement point), so the mesh-owned build takes the RBF retry rather than degrading. Tested: a failure forced once in the FAC split during a solve retries with RBF on every rank. 2. One envelope, mpi.Verdict(message, error, kwargs, site), at every caller of first_verdict (_collective_raise, Mesh._any_rank_failed, snapshot._agreed_problem). When the flag is set every rank sends its envelope; two different sites that pair raise one mismatch error on every rank. The envelope pickles through its four fields. 3. reraise_agreed(err): build's three sanctioned swallows (snes.setUp(), the operator check, the dimensional guard) re-raise an agreed error. Tested through the setUp swallow with a stand-in solver. Lows: test_0052's static rule checks direct mpi4py collectives only, a helper's entry is not agreed, the wrappers count as agreement points; its docstring says the run-time check covers the rest. Underworld development team with AI support from Claude Code
|
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)) Verdict at 19b436c: sound with changes. One small change is needed before One new problem comes from the finding-1 fix itself. The context exit now labels every error Item by item
New findingsN1. Medium for adoption, none for the current scope: the exit forces Once N2. Low: the mismatch error could say more. It drops the first failing rank's message. It is not marked Suggestions: include the failing message, and keep the rank-specific part out of N3. Low: the error classes in a verdict must be importable. A class defined inside a function fails to pickle. In my probe every rank passed the same class, so every rank failed alike with AttributeError. In a cross-site pairing only the failing rank would fail to pickle, and the job would likely hang. I did not test that case. Worth one line in the N4. Low: the PR's RBF-retry test cannot show that the retried hierarchy works. The fixture's exact solution is its boundary data (linear shear, no body force), so the SNES reports converged at 0 iterations. The assertion Note: development has moved to c9c300e. It changes What was run
Not run:
Logs kept by the reviewer. Underworld development team with AI support from Claude Code |
…ext; body-force retry test (#874) H1's round 3 on #1218. - N1: the context exit keeps the builder_failure of a CollectiveBuildError raised on every rank by a check (getattr(err, "builder_failure", ...)), so a check another builder cannot change does not trigger a futile RBF rebuild. Tested inside a context at np 2 to 5. - N2/N3: the mismatch error carries the first failing rank's message, with the same text on every rank; verdict error classes must be importable at module level (documented in mpi.first_verdict and agreed_build). - N4: the RBF-retry test has a body force and checks the retried solve iterates (the rotated path's velocity count). - Development merged in (c9c300e and after). Underworld development team with AI support from Claude Code
|
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)) Verdict at 33a508d: sound with changes. The only change needed is in the PR's RBF-retry test. The mechanism itself is now sound to adopt: N1 and N2 are fixed, and N3 is documented. The RBF-retry test still passes when the RBF builder is broken (details below). Two more assertions would close that.
Not run: np 5 and above, and Open MPI. Logs kept by the reviewer. Underworld development team with AI support from Claude Code |
…874) H1's round 4 on #1218: the retry test passed with the RBF builder broken, since the build then degraded to GAMG and still converged. It now also asserts that no custom_mg.build fallback is recorded and that the installed hierarchy's builder is rbf_prolongation. With the RBF builder made to raise, it fails (np 2). Underworld development team with AI support from Claude Code
|
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)) Verdict at 2b2bb8e: sound to adopt as is.
Run on cores 0 to 3, with the same build and overlay as the previous re-check, since the source is unchanged. Logs kept by the reviewer. Underworld development team with AI support from Claude Code |
Addresses #874 (a mechanism, proposed with one function converted). Draft. W1 (the session that owns the convergence and integration work, and
custom_mg) reviews the design. H1 (review and parallel test runs on a 96-thread Linux workstation) runs it in parallel. If both pass,custom_mg.buildandpartition_addonfollow, one phase at a time.Why
The sweep in #1216 guards parallel builders site by site. The inventory there lists 45 functions in
fault_mg,custom_mgandaddon_partitionwith an unguarded step ahead of a collective. Three of them have about 50 sites each:custom_mg.build,_fac_patch_split_parallelandaddon_partition.partition_addon. Every new line would be a new site.The mechanism (
utilities/agreed_build.py)agreed_build(what)is a context. An exception on one rank inside it is caught at the context's exit. That rank makes one agreement call, and raisesCollectiveBuildError.agree()is that agreement point. It goes before every collective that can't agree by itself: a PETSc collective, or a mesh method that is collective inside. Outside a context it does nothing, so a helper can carry it whoever calls it.allreduce(comm, ...),allgather(comm, ...)andbcast(comm, ...)agree and then communicate. They are preferred over a separateagree()line before an mpi4py collective._collective_raiseraised is markedagreed, and passes through a context without a second agreement. The counts stay paired.builder_failure=Trueby default, through every agreement point. So the mesh-owned build takes the RBF retry (custom_mg.build_transfers) instead of degrading. An explicitset_custom_fmgregistration surfaces the error, as it always has. A context that is not a transfer build passesbuilder_failure=False.reraise_agreed(err)comes first in each ofbuild's three sanctioned swallows (snes.setUp(), the operator check, the dimensional guard). An error every rank raised together is not swallowed on the healthy ranks while a failed rank leaves.underworld3.mpi.first_verdict. Before, three sites used two forms. The sites arefault_contact._collective_raise,Mesh._any_rank_failedandsnapshot._agreed_problem.agreed_buildexit (CollectiveBuildError) that pairs with a guard raisingRuntimeErrorcan no longer part the ranks.first_verdictallreduces a one-integer flag on the verdict communicator, and gathers the verdicts only when it is set. A healthy path pays that small allreduce alone.mpi.Verdict(message, error, kwargs, site). When the flag is set, every rank sends its envelope, healthy ones too. If two different sites have paired, every rank raises the same "verdict exchange mismatch" error naming them, rather than reading one site's payload as another's.The rule a converted builder keeps: between any statement that can raise and the next collective, there is an agreement point.
Covered: every rank-local exception, now and in code added later, with no guard of its own.
Not covered: an exception inside a PETSc collective itself. The test hit this on its first try: a raise placed inside
Scatter.createhangs, as designed.Also not covered: a collective added later without an agreement point in front. Two checks enforce the rule:
test_0052checks direct mpi4py collectives: inside anagreed_build, or in a function that callsagree()(a helper, whose entry is not agreed), each has an agreement point after the last statement that can raise. The wrappers count as agreement points. The planted cases are flagged, the fixed ones are not, and the tree is clean. Its docstring states what it can't see: collectives inside helpers, PETSc and mesh-internal collectives, anagree()on one branch only, and anagree()inside a broadexcept.Cost: measured on the proof, one
_fac_patch_split_parallelcall (best of 3 × 20):That is four to five agreement points in the call: about 1 ms each at np 4 here.
The proof
custom_mg._fac_patch_split_parallelhas 46 unguarded statements. It is now one context with an agreement point before each of its collectives:Its helper
_append_remote_coarse_nodescarriesagree()before its two PETSc collectives, the MPI Vec and the scatter. Nothing else changed.tests/parallel/test_0874_agreed_build_parallel.pycaptures the split's call from test_1147's placed-ribbon solve.CollectiveBuildError:snes.setUp()swallow, through a stand-in solver, is re-raised on every rank;reraise_agreedpasses only agreed errors.The empty-rank case runs from np 3. At np 2, the placed ribbon refuses a base with all its cells on one rank (
addon_partition: not co-partitioned). That refusal happens collectively, before the split, and is a side finding, not this PR's.A note from building the test: a failure forced inside
Scatter.create, which is a PETSc collective, after its agreement point, hangs. That is the stated limit, seen in practice.Results on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH):
test_0052: 8 passed.test_0874files,test_0974(the snapshot refusal, which goes throughfirst_verdict),test_1087_submesh,test_1089,test_1096,test_1147,test_1139,test_1120,test_1111).test_0052, the fault and transfer files, the checkpoint and snapshot files,test_1079_diffusion_disk_restart).scripts/check_test_coverage.py: OK.If it is accepted
The same conversion applies to
custom_mg.build, one phase at a time, each phase with a forced failure at np 2 to 5. Its 20 PETSc collectives and about 15 mesh-internal ones each get an agreement point, through a wrapper where one exists.partition_addonand the rest of #874's list follow. #1216's per-site guards stay valid: they are agreement points too. H1's toy pairing probes join the tests when they arrive: two ranks failing at different points, nesting, and noagree()before the exit.Underworld development team with AI support from Claude Code