Repository navigation
A custom-P hierarchy re-solves after mesh.deform (#1015) - #1018
Conversation
mesh.deform rebuilds the solver's preconditioner from the options database, and on the standard paths two things then went wrong (hyperion, development ba3fc23, np 1 and 2): - _pcmg_still_installed took the rebuilt PC for the live hierarchy because it had the same level count, so the hierarchy was never installed again; - the FAC level's mg_levels_<l>_pc_type composite key, which the standard paths leave in the database, came back as a composite with no member PCs: PETSc error 73. The live check now also requires the PC's finest interpolation to be the Mat the install set (the install mark keeps the Mat, so a rebuilt PC cannot pass by reusing its address), and _configure_pcmg drops the FAC keys of every level that has no patch this time. test_1146, tier B, Poisson and the Stokes velocity block: one install over three solves, a second after the deform, and the re-solve converges; on development it stops with error 73. The custom-MG, adapt, fault and FAC test set (66 files): 587 passed. Not recovered: the FAC patch itself after a deform. The coarse levels given to set_custom_fmg do not move with the fine mesh, so no fine node coincides with its coarse node any more, every row reads as patch, and the cover gate declines it (1286 of 1286 rows, against 117 before). Filed separately. Underworld development team with AI support from Claude Code
…eform-1015 Underworld development team with AI support from Claude Code # Conflicts: # scripts/test.sh
…asured (M1, L1, L2) M1: the drop of a level's FAC configuration deleted any mg_levels_<l>_pc_type on a level without a patch, the user's own included: a user's jacobi on level 1 ran as SOR. It now drops a level's pc_type only when that is "composite" with no member list of its own (a composite the user built names its members in pc_composite_pcs), with that composite's block keys. test_1146: a user's level-1 jacobi survives an install. L1: on development the live check already answered False after mesh.deform, and the re-solve's error 73 was the FAC keys left in the database; the key drop alone fixes #1015 (hyperion's revert of the identity check alone still passed). The identity check is what a PC reset in place needs: pc.reset() keeps the levels and drops the transfers, the level count passed, the hierarchy was not installed again, and the solve stopped with PETSc error 63. test_1146 resets the PC and re-solves; it fails on development. The docstrings say this. L2: the docstring names the one case the check passes wrongly, a PCMG rebuilt by hand from the installed Mats, which the library never builds. Underworld development team with AI support from Claude Code
Review record for #1018On 4ecd396, the head: ready to merge, and every merge condition below is met.
The record for 1aa389b follows. Paths under Adversarial review: bugfix/custom-mg-after-deform-1015Tip reviewed: 1aa389b (built as
Housekeeping:
Instrumentation: the probe wraps
VerdictReady to merge after one small fix (M1). The change does what #1015 needs:
The findings:
We also found two defects near the change that exist on development as well (P1, P2), and one correction to our own earlier record (fac-review P1). FindingsM1 (medium). The key drop deletes a user's level-indexed smoother key
Probe
( Fix, either way:
Add a regression line to test_1146 or test_1021: a user L1 (low). The described mechanism is wrong for the first re-solve, and test_1146 cannot see the identity half removedThe commit message, the
The reinstall then fails with error 73, because the level-2 So the key drop alone fixes #1015. Mutation by in-process monkeypatch (
The identity half is not dead. Probe
No test covers that case. Fix:
L2 (nit). The identity check can be passed by a PCMG rebuilt from the installed MatsProbe
No code in Pre-existing on development, near this change (not merge conditions; candidates for issues)P1.
P2. Deferred destroys grow with every standard-path reinstall at np > 1, and nothing frees them. Probe
Correction to our fac-review P1. That record said Attack 1: reinstall on every solveInstall count (
Attack 2: the deform re-solve (np 1, 2, 4;
|
| path | np | before: levels, its | re-solve, branch: levels, its | fresh solver on the deformed mesh | base re-solve |
|---|---|---|---|---|---|
| poisson | 1, 2, 4 | 3, sor/composite, 3 | converged, 3, sor/sor, 5 | 3, sor/sor, 5 | error 73 (np 1, 2) |
| stokes_plain | 1, 2, 4 | 3, sor/composite, 1/4 | converged, 3, sor/sor, 1/7 | 3, sor/sor, 1/7 | error 73 (np 1, 2) |
| stokes_rotated | 1 | 3, sor/composite, 1/3 | converged, 3, sor/sor, 1/5 | 3, sor/sor, 1/5 | converged, same |
| stokes_rotated | 2, 4 | 3, sor/composite, 1/3 | converged, 3, sor/sor, 1/6 | 3, sor/sor, 1/6 | converged, same (np 2) |
| sheet_rotated | 1, 2, 4 | 3, sor/composite, 2 | converged, 3, sor/sor, 4 | 3, sor/sor, 4 | converged, same |
(its = outer, or outer/velocity.)
- No FAC level after the deform on any path, which is After mesh.deform the FAC patch is declined: the custom-P coarse levels do not move with the fine mesh #1017, as the test docstring says. The code claims nothing else.
- The re-solve equals the fresh solver: same levels, same iterations, v_rms to ≤ 6.7e-16 relative.
- Installs: exactly one more per deform on the standard paths (2 in total; configure +1 on the rotated ones). The two following solves add none.
- Ranks agree: every rank logged the same verdict sequence and counts in every np 2 and np 4 run (
ranks_agree: truein all logs).
Attack 3: key hygiene (keys probe, np 1 and 2, Poisson and Stokes velocity)
We planted stale level-1 FAC keys (composite, lu, nonzero) under the managed prefix, as if an earlier install had had a patch on level 1. An unrelated solver carried its own mg_levels_1_pc_type jacobi, mg_levels_2_pc_type composite and ..._sub_1_sub_pc_type lu.
- Branch. The first install drops the three level-1 keys and keeps level 2's (the level with a patch). The smoothers are sor/composite. After 3 reinstalls, the DB under the managed prefix holds exactly level 2's three keys. After the deform's re-solve it holds none: the patch is declined.
- The unrelated solver's three keys are unchanged on both builds.
- Base fails every solve of this fixture with error 73, because the planted level-1
compositekey is read. That shows the drop is needed for any stale level, not only the deformed one. - Patch on one level, none on another. In this fixture level 2 has the patch and level 1 has none. The configuration was level-1 sor and level-2 composite of SOR plus ASM/LU, at every install. We did not find a fixture with patches on two levels (see "Could not test").
Attack 4: the identity check
- Reuse of the same Mat object. Only by building a PCMG by hand from the installed Mats (L2). PCReset destroys the interpolations, and the check then answers False. A forced rebuild (
is_setup = False) andsnes.setFromOptions()behave correctly on both builds. AftersetFromOptionsthe verdict is True and FAC is still live. Interpolation set by DM coarsening is a new Mat, and the check answers False on it[read]: the deform's rebuilt PC was a 1-levelmghere, not a DM-coarsened one. - Memory. See P2. The mark adds no RSS, and the live finest's refcount is constant over 10 cycles. The mark holds the old Mat only until the next install replaces it.
- Collective consistency. Same verdicts on every rank at np 2 and 4 in every run.
_managed_pcandgetMGInterpolationare local reads of a collectively built PC, and the verdict involves no communication[read].
Attack 5: tests
- test_1146 fails on base: at np 1, poisson fails with PETSc error 73 and the stokes case then segfaults the process; at np 2, MPI_Abort(59). The branch passes 2/2 at np 1 and 2.
- Mutations: see the L1 table. The key drop is caught; the identity half is not.
- CI reach:
batch 4 tests/test_1146*pyinscripts/test.sh, tier_b. Not excluded by-m "not tier_c". - np 2 regression set, both builds (
t1146/files.txt: the 37 test files that referenceset_custom_fmg,_pcmg_still_installedor_custom_mg_live, plus 6 adapt and fault-split ones; run with the branch's test files): no difference between the builds (t1146/cmp.py,t1146/logs/{1015,ba3f}-np2-none-*.log).- 37 files finish with identical per-test outcomes on both builds. All 18
tests/parallelfiles pass on both builds: 77 passed, plus their skips and one xfail. The serial files that fail at np 2 fail identically on both builds: 0020 (1), 0835 (1), 0840 (2), 0843 (1), 1014 (2), 1016_custom_mg_hierarchy (1) and 1134_structure (2). They are serial tests run on two ranks, not regressions. - 6 serial files time out at np 2 (pytest-timeout or the supervisor's 600 s silence): 1017_nested, 1018, 1021, 1087, 1111 and 1131. They stop at the same test with the same pass/fail string on both builds, e.g. 1131
FFFF.F..............FF......FF........on each. - The only textual difference is 2 "Mean of empty slice" warnings in test_0641 on the branch run, from
discretisation_mesh.py:6071, which this diff does not touch. That is rank-interleaved output, not a behaviour change. - We did not re-run the serial files at np 1. The commit message's "66 files: 587 passed" is the author's np 1 figure, and we did not reproduce it.
- 37 files finish with identical per-test outcomes on both builds. All 18
Attacks that failed (numbers)
- No per-solve reinstall. Over 13 paths at np 1 and 2, install and configure counts equal base. One install per 5 warm solves on every standard path, adapt auto-pickup included; zero on the rotated paths.
- Deform re-solve. It converges on 4 paths at np 1, 2 and 4, and matches a fresh solver on levels, iterations and v_rms (≤ 6.7e-16).
- Ranks agree. Verdicts and counts match on every rank, in every np 2 and np 4 run.
- Key hygiene. Stale FAC keys go for levels without a patch, and a patched level keeps its keys. The unrelated solver's keys are untouched. Rotated paths leave no keys.
- No leak from the check. 20 warm solves at np 2: deferred entries constant (6 Poisson, 36 Stokes), RSS flat.
Merge conditions
- M1: drop only the keys FAC wrote (or only
compositelevels), and add one assertion that a user'smg_levels_1_pc_typesurvives an install. - L1: correct the mechanism in the commit message, the
_pcmg_still_installeddocstring and the test_1146 docstring. The first re-solve does reinstall and fails on the key. Then either cover the identity half with a test (in-placereset()of the managed PC, which fails under mutationcheck), or call it defensive. - Optional (L2): one clause in the docstring saying the check proves the same finest Mat, not the same smoother configuration.
- Issues:
- Custom FMG with a FAC patch: re-solve after mesh.deform fails with PETSc error 73 (empty composite); the hierarchy is not re-installed #1015: fixed by this branch, on the evidence above, for the standard and rotated paths.
- After mesh.deform the FAC patch is declined: the custom-P coarse levels do not move with the fine mesh #1017: still live (no FAC level after a deform; documented as such).
- Stokes adjoint_solve drops the custom-FMG velocity hierarchy and its FAC patch: one-level mg, 29 iterations against the forward's 4 #1016: still live (the adjoint leaves a 1-level velocity mg; the next forward reinstalls once).
- File P1 (gamg on a FAC adapt child, error 73) and P2 (standard-path deferred destroys per reinstall), or fold P1 into After mesh.deform the FAC patch is declined: the custom-P coarse levels do not move with the fine mesh #1017's key handling.
Could not test
- A hierarchy with FAC patches on two levels at once. Every fixture we have puts the patch on the finest level only, so "keys for levels with a patch are kept" is shown for one level. The code keeps them per level
[read]. - A PCMG whose interpolation comes from DM coarsening after a deform. Our fixtures' rebuilt PC is a 1-level
mgbefore the install. - The serial test files at np 1 on both builds. We ran the requested np 2 only, where the serial files' failures and time-outs are identical on both builds.
- Kaiju-scale cost (Custom-P V-cycles across a cut level cost more than they save (7x slower than GAMG at 11x fewer iterations) #622's 55 s install). We measured install counts instead, which are what decide that cost.
- The Stokes adjoint's own injection (another branch).
- np 4 for anything but the deform re-solve.
- Wall times are noisy, because they ran beside another review's jobs.
Underworld development team with AI support from Claude Code
…ering Underworld development team with AI support from Claude Code
…stom-mg-1016 Underworld development team with AI support from Claude Code # Conflicts: # scripts/test.sh
A solver with a custom-P hierarchy and a FAC patch re-solves after
mesh.deform(#1015).The bug
mesh.deformrebuilds the solver's preconditioner from the options database, and the next solve installs the hierarchy again. On the standard (non-rotated) paths, the FAC level'smg_levels_<l>_pc_type compositekey stays in the database after a solve. On a level with no patch this time, the rebuilt PC read it back as a composite with no member PCs, and the re-solve stopped:The issue first said the hierarchy was never installed again. Hyperion measured otherwise: the live check already answered False after the deform, and the stale key alone was the bug.
The change
_configure_pcmgremoves a FAC configuration that a previous install left on any level without a patch now. That is the level'spc_typewhen it iscompositewith nopc_composite_pcsof its own, and that composite's block keys. A smoother key the user set stays. An earlier version of this branch dropped any level key and turned a user'sjacobiinto SOR (hyperion's review, M1)._pcmg_still_installednow also requires the PC's finest interpolation to be the Mat the install set, and the install mark keeps that Mat. The level count alone passed a PC reset in place (pc.reset()), which keeps the levels and drops the transfers. The hierarchy was then not installed again, and the solve stopped with PETSc error 63.Evidence
tests/test_1146_custom_mg_after_deform.py, tier B, 4 tests:Reviews
Issues
preconditioner = "gamg"on an adapt child with a FAC level reads the same leftover key, error 73.Underworld development team with AI support from Claude Code