Skip to content

custom_mg #1101 guard: reduce any dependent group exactly (no refusal), distributed, recorded - #1111

Merged
lmoresi merged 7 commits into
developmentfrom
perf/custom-mg-dependent-columns-distributed
Nov 13, 2026
Merged

lmoresi merged 7 commits into
developmentfrom
perf/custom-mg-dependent-columns-distributed

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #1104 (#1101), now merged. It started as items M3 and L1 of the review of #1104 by H1 (review and parallel test runs on a 96-thread Linux workstation), and it now also fixes a regression #1104 introduced: the guard refused solves that had converged before it. Development (264400a) is merged in. The review (H1) is in progress.

The regression: no refusal

On a fault cut into an adapt child that moved before the cut, #1104 refused groups of three coarse columns on one fine node's two component rows ("share fewer fine images than there are of them"). The rotated transfer mixes a node's components, which is how such groups arise. Before the guard, the same solve converged in 6 velocity iterations (W1 (the convergence work; serial runs on macOS, 12-core Apple M4), on development e4076e5).

Every group of columns with the same small support (at most 4 fine rows) is now reduced exactly to as many columns as it spans:

  • the columns are ordered largest norm first, with ties to the lowest global column;
  • a pivoted QR keeps the most independent ones, as many as the group's rank (a pivot's residual above 1e-10 of its own norm) and never more than its rows;
  • every other column is dropped and written as their combination;
  • the level below is folded with the same coefficients, so the composite transfer is unchanged, as in the pair case.

What the guard does and does not do: it removes the dependent groups with small support. It does not make the Galerkin operator nonsingular in general. Dependent columns with different or wider supports are not detected and can remain. On W1's fixture, H1 found ±1-proportional pairs with 5 to 54 fine rows (3 to 64 null directions after the merge, 4 to 86 before), and the solve tolerates them as it did before the guard. Those pairs are a follow-up on the split transfer (W1).

Nothing is refused.

Evidence. W1's fixture (test_1176's _split_level_stokes) moves the child by amp sin(pi x) sin(pi y) before add_fault. The new test is tests/parallel/test_1111_custom_mg_cut_of_a_moved_child_parallel.py:

  • every amplitude W1 measured, 0.002 to 0.015 on both axes, solves at np 1, 2 and 3;
  • the 0.002 case across the fault stays at 6 iterations;
  • on development's code, 5 of the 7 are refused.

Velocity iterations, serial:

amp x y (across)
0.002 6
0.005 7 6
0.01 6 7
0.015 7 6

The guard now also finds dependent groups the pair-only check missed, such as two proportional columns on the same two rows. The unmoved child has one, and still solves in 5.

Other evidence on this branch:

  • the perturbed test_1152 seeds 0–7 give results identical to custom_mg: merge coarse unknowns sharing one sole fine image when two levels are not nested (#1101) #1104's;
  • test_1101's refusal test is now a test of the exact reduction of three columns on two rows;
  • test_1101: 12 of 12 at np 1, 2 and 3. Added for H1's review: three columns on two rows whose two largest are 1e-9, 1e-8 and 1e-7 apart (one merged, composite exact to 1e-12; 3f3fc9e keeps all three, silently singular), and a pair independent by 1e-6 that must not merge (_DEPENDENT_REL = 1e-2 fails it);
  • the serial custom-MG set and test_1022: 155 passed, 4 skipped.

The wording is in Louis's terms throughout: a level pair that is not nested, with a mesh move only making it more likely.

What and why

M3 and L1

M3, cost. #1104's detection of coarse columns sharing one sole fine image gathered most of the finest transfer's columns (about 89 %) to every rank and grouped them in a Python loop. That took 9 s per level per install at 1M coarse DOFs on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH), at np 1 and np 4 alike. Louis's refinement 4 and 5 runs install after every move.

It is now distributed:

  1. Each entry goes to its column's owner (one alltoall), which finds the columns with at most 4 fine images.
  2. Each such column's support goes to the owner of its first row (a second alltoall), which groups them with np.unique.
  3. Only the decisions are gathered.

At 1M coarse DOFs this takes 1.4 s serially and 0.36 s at np 4. The decisions and the tie-break are the same.

L1, observability. The repair warning prints once per Python session. What each install merged is now kept on the solver and reported in solver.solve_report.config["multigrid_hierarchy"], on the standard and the rotated solve paths. The note carries the merged unknowns by coarse level for the latest install, and the number of installs that merged any.

It is a note of what the hierarchy build did, not a pc_fallbacks record. The merge is an exact change of basis, and the hierarchy requested is the one installed. An earlier commit on this branch recorded it as a fallback, which broke assert not fallbacks in ptest_0865 and would make every split-fault solve look degraded. That record is gone; no test that asserts on fallbacks was changed.

Tests

Checklist

  • Style Charter followed (S2)
  • No drive-by changes (S9)
  • Tests with level_* / tier_* markers (S8)
  • No hedging names or commented-out code (S3, S4)
  • No exception swallows
  • No new data access
  • Parallel: np 1–4 (S11)
  • No dependency changes
  • AI attribution below

Underworld development team with AI support from Claude Code

🤖 Generated with Claude Code

…repair

M3 (H1's review of #1104). The detection gathered about 89 % of the finest
transfer's columns to every rank and grouped them in a Python loop: 9 s
per level at 1M coarse DOFs on hyperion, on every install, and Louis's
refinement 4 and 5 runs install after every move. Each entry now goes to
its column's owner (one alltoall), which finds the small columns; each
small column's support goes to the owner of its first row (a second
alltoall), which groups them with np.unique. Only the decisions are
gathered. At 1M coarse DOFs: 1.4 s serially, 0.36 s at np 4. Same
decisions, same tie-break.

L1. The warning prints once per Python session. Each install that needed
the merge is now also recorded in solver.pc_fallbacks
("custom_mg.dependent_columns", with the levels, the counts and the number
of installs so far), so a run's report shows how often it fired.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 12:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@lmoresi

lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

The serial custom-MG set (the 24 files from #1104 plus test_1022) gives 155 passed and 4 skipped on f99d870.

Underworld development team with AI support from Claude Code

Louis's framing (#1104): the configuration is a coarse level and the level
above it that are not nested (a placed, cut or add-on level over a base it
was not refined from; any pair whose transfer locates one level's nodes in
the other), an ordinary situation; a mesh move under unmoved coarse levels
only makes it more likely. The docstring, the warning (which names the
level and no longer suggests the mesh was moved wrongly), the refusal, the
pc_fallbacks record and the test's docstring say so; the warning test now
also checks for 'not nested'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lmoresi

lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

933d1c9: the docstring, the warning, the refusal, the pc_fallbacks record and the test text now describe #1101 as a level pair that is not nested, following Louis's framing on #1104. A mesh move under unmoved coarse levels is described only as something that makes it more likely. The warning names the level, and the warning test also checks for "not nested". test_1101: 8 of 8 at np 1, 2 and 3.

Underworld development team with AI support from Claude Code

…hing

On a fault cut into an adapt child that moved before the cut, #1104's
guard refused groups of three coarse columns on one fine node's two
component rows (the rotated transfer mixes components): "share fewer fine
images than there are of them". The same solve converged in 6 velocity
iterations before the guard (W1). Every group with the same small support
is now reduced to as many columns as it spans: columns taken largest norm
first (ties to the lowest global column), each one the kept ones span to a
relative residual of 1e-10 dropped and written as their combination, and
the level below folded with the same coefficients, so the composite
transfer is unchanged, as in the pair case. Nothing is refused.

W1's fixture at the amplitudes he measured (0.002 to 0.015, both axes):
every case solves at np 1, 2 and 3, the 0.002 case at 6 iterations;
development's code refuses 5 of the 7. The refusal test becomes a test of
the exact reduction of three columns on two rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lmoresi lmoresi changed the title custom_mg: find the #1101 dependent columns distributed; record each repair custom_mg #1101 guard: reduce any dependent group exactly (no refusal), distributed, recorded Nov 12, 2026
@lmoresi

lmoresi commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

Verdict: NOT READY at 3f3fc9e. Two small merge conditions: M1, a rank cap in the group reduction, with a test; M2, a correction to the "nonsingular" claim. Everything else the hub asked for checks out: the fix of W1's regression, unchanged behaviour where nothing merges, the pair repair, exactness, rank-uniform decisions, cost and the regression runs.

Method

The headline claims: confirmed

W1's fixture (test_1111, amp 0.002–0.015, both axes)

tree np 1 np 2 np 3 np 4
br 7/7 7/7 7/7 7/7
base (cff3b01) 5 refused 6 refused 5 refused —

Velocity iterations, case by case:

case br np1 nodep np1 pre np1 br np2 nodep np2 br np3 nodep np3 br np4 nodep np4
y 0.002 6 6 6 6 6 6 6 6 6
x 0.005 7 7 7 9 10 9 9 9 9
y 0.005 6 6 6 6 6 7 7 6 6
x 0.01 6 6 6 7 7 7 7 7 7
y 0.01 7 7 7 8 8 8 8 8 8
x 0.015 7 7 7 8 8 8 8 8 8
y 0.015 6 6 6 7 7 7 7 10 10
  • Serial iterations match H5's table exactly. The unmoved child (amp 0) gives 5 on br, br-nodep, base and pre.
  • The parallel iterations are mine, not H5's. They are equal to the no-merge run everywhere but one cell, where the merge saves an iteration (x 0.005 at np 2: 9 against 10).
  • pre (dev01b) at np 2–4 cannot serve as the parallel baseline. It fails 5 of 7 with addon_partition: N fine cell(s) have no local parent cell, an unrelated bug fixed between 01b06c9 and cff3b01. So the build-free branch-nodep run is the pre-custom_mg: merge coarse unknowns sharing one sole fine image when two levels are not nested (#1101) #1104 baseline in parallel.

Check 1: a hierarchy the guard leaves alone is unchanged. Confirmed.

  • W1's fixture, serial. The transfer hashes (all three levels) are identical between branch-nodep and pre (dev01b) in all 7 cases, and so are the iterations. The branch's code with detection off is bit-for-bit pre-custom_mg: merge coarse unknowns sharing one sole fine image when two levels are not nested (#1101) #1104.
  • Cases nothing merges (y 0.002 serial) give the same hashes and iterations on br, base, pre and br-nodep.
  • Elsewhere, every test whose decisions are empty on both trees has identical transfer hashes and iterations, br against base:
    • the whole serial set: 490 of 494 tests identical; the 4 others are listed under check 5;
    • test_1139, test_1147, test_1173, test_0078 ×2 (np 2), test_1152 (np 1, 2, 4) and test_1101 (np 1–4).

Check 2: the pair repair on perturbed test_1152 seeds 0–7. Confirmed.

Check 3: exactness of the general reduction

On W1's fixture (probe1111.py, all 7 cases plus the unmoved child, serial):

  • At each install I took rotated_split_transfers with and without the merge, on the same inputs.
  • I then compared the composites. I also used the spectra of each level's Galerkin operator, built from the fine velocity operator in the solve's PCMG.
case merged on level 2 (group shapes: rows × columns kept in the combination) drop reconstruction error composite diff, levels 1 and 0 λmin levels 1 / 0 (merge = no merge)
unmoved 1 (3r1k) 0 0, 0 0.0154 / 0.0615
y 0.005 2 (2r1k, 3r1k) 0 0, 0 0.01542 / 0.06179
x 0.005 5 (1r1k×2, 2r1k×2, 2r2k) 1.3e-16 0, 0 0.01544 / 0.06186
x 0.01 19 1.3e-16 1.1e-16 equal
y 0.01 6 (incl. 2r2k) 2.0e-16 1.1e-16 equal
x 0.015 41 0 1.1e-16 equal
y 0.015 23 (incl. 3r3k ×2: 4 columns on 3 rows) 2.0e-14 1.1e-16 equal
  • PETSc's level operators equal our composite PᵀAP to 2e-16 to 3e-15 relative.
  • Shapes. "2r2k" is W1's shape: 3 columns on 2 rows, one dropped as a combination of the other two.

Constructed cases (exact1111.py; 1-D Laplacian; P0 a random coarsening; np 1–4; groups spread over ranks, with the fine rows on another rank):

case merged composite diff λmin/λmax after (before)
a: 3 on 2 rows, rotated, mixed signs 1 0 8.9e-3 (−4e-18)
b: 4 on 2 2 6e-17 8.4e-3
c: 4 on 3 1 1e-16 7.7e-3
d: proportional on 2 rows 1 0 4.4e-3
g: 3 independent on 3 rows 0 untouched as before
i: equal-norm tie, 3 on 2 1, lowest column kept 0 1.0e-2

Threshold and residual behaviour (case f: two columns on 2 rows, the second off proportional by δ):

  • δ = 1e-13 and 1e-11 are merged silently, as an approximation: the composite changes by 7e-14 and 1e-12.
  • δ = 1e-9 and 1e-6 are kept, which leaves λmin/λmax at 6e-17 and 4e-13, as on base.
  • So a column outside the span is never refused or warned about. Within 1e-10 it is approximated. That is acceptable for a preconditioner, but the docstring should say so.

Near-dependent kept columns (case e) are M1 below.

M1 (MEDIUM, merge condition): a group with more columns than rows can be kept whole, leaving a silently singular operator

  • The cause. The test is ‖B c − w‖ ≤ 1e-10 ‖w‖. When the first two kept columns are nearly parallel, lstsq on that basis has a residual of about eps·cond·‖w‖, which exceeds 1e-10. So the third column is kept too: 3 independent-by-test columns on 2 rows.
  • The sweep (columns (1,1), (1,1+d), (0.5,0.7) on 2 rows):
d 1e-4 1e-5 1e-6 1e-7 3e-8 1e-8 1e-9 1e-10
columns kept (of 3) 2 2 2 3 3 3 3 2
  • At np 1–4 (case e, d = 1e-8): nothing is merged, there is no warning, and λmin/λmax = −2e-17. The operator is exactly singular.
  • This is a regression in safety. custom_mg: merge coarse unknowns sharing one sole fine image when two levels are not nested (#1101) #1104 refused this group; custom_mg #1101 guard: reduce any dependent group exactly (no refusal), distributed, recorded #1111 now passes it through singular, with no record. I have not seen it on a real mesh. W1's groups are well conditioned: the worst reconstruction error is 2e-14.
  • Fix: cap the kept set at nrows. A column met once len(kept) == nrows is in the span by dimension, so drop it with its lstsq coefficients, whatever the residual. A rank-revealing QR/SVD of W, with a threshold relative to the group's largest singular value, would do the same. Add case e as a test (λmin > 0, one merge).
  • Related (d = 1e-5, e2). One column is merged with coefficients of ±2e4. The two kept columns are themselves nearly parallel, so λmin/λmax = 1e-11. The base would be no better here; this is informational.

M2 (MEDIUM, merge condition): "makes the Galerkin operator nonsingular" is false on W1's fixture

  • The claim appears in the warning text and the docstring.
  • The measurement. On every case of W1's fixture, the repaired level 2 is still singular after the merge. Near-zero eigenvalues (|λ| < 1e-10 λmax) equal the rank deficiency of the level-2 composite (dense SVD):
case unmoved y 0.002 y 0.005 x 0.005 x 0.01 y 0.01 x 0.015 y 0.015
null dim, no merge 4 4 15 21 39 70 86 78
null dim, after #1111 3 4 13 16 20 64 45 55

Check 4: determinism and collectives. Confirmed.

  • Where groups are decided [read]: each group is decided on one rank (the owner of its first fine row), from routed data; only the decisions are allgathered.
  • Measured with exact1111.py at np 1, 2, 3 and 4, with columns of one group on up to 4 ranks and their rows on another:
    • the decision arrays are byte-identical on every rank (decision_uniform true in all 14 cases at every np);
    • they are identical across np (the same md5 of all decisions at np 1–4);
    • the warning is on rank 0 only.
  • Where decisions differ. On W1's fixture they differ between np only because the hierarchy itself depends on the partition (level sizes differ).

Check 5: the new effect (proportional multi-row groups). It fires and changes nothing else.

Where transfers changed, br against base (identical outcome in every case):

  • test_1087_fault_split_multigrid (serial), with iterations unchanged (5, 5, 6):
    • test_iterations_fall_with_refinement_and_the_slip_is_unchanged: 3 installs, 1/6/1 merged;
    • test_a_viscous_fault_solves_in_as_few_iterations: 2 installs;
    • test_a_moving_fault_re_splits_the_levels_at_every_position: 3 installs.
  • test_0078_rebuild_memory_parallel (np 2): 7 installs, 1–7 merged each. It passes; it reports no iteration count.
  • test_1111 (the fixture): y 0.002 at np 2–4 gets 1 merge, with iterations 6 = base = nodep. The unmoved child gets 1 merge (3 rows, 1 column kept), iterations 5 = nodep = base = pre, and composite diff 0.
  • Composites. They are exact (≤ 1.1e-16) wherever I measured, which includes the 2r1k and 3r1k groups on the fixture. I did not probe test_1087's composites separately; its level-2 shape (5984 × 4985) is the unmoved fixture's.
  • Unrelated diff: test_1142 [slide3e-05] gave 9 on br and 5 on base. The transfers are identical, and reruns give 9 and 5 on base and 9 and 9 on br. It is pre-existing nondeterminism, not from this PR.

Check 6: cost. Detection is distributed, and the repairs are recorded.

Near-nested synthetic transfer (cost1111.py, #1101's cost_detect transfer plus G duplicated columns):

n_coarse base np1 br np1 br np1, G=1000 base np4 br np4 br np4, G=1000
10k 0.04 s 0.01 s 0.07 s 0.04 s 0.01 s 0.03 s
100k 0.7 s 0.15–0.17 s 0.29–0.37 s 0.72 s 0.04 s 0.06 s
1M 6.5–7.0 s 1.45–1.59 s 2.39–2.83 s 6.40 s 0.44 s 0.55 s
  • H5's 1.4 s / 0.36 s is reproduced.
  • Distributed [read]: two alltoalls (entries to the column owner; small supports to the owner of the first row) plus an allgather of decisions only. Base's time does not fall with np; the branch's does.
  • L1 is in. Each install that merges calls record_repairs. Measured: pc_fallbacks["custom_mg.dependent_columns"] is present after the solve on every merging fixture case, with "coarse level 2: N unknown(s) merged … Needed on 1 install(s)". It is absent where nothing merged.

Check 7: mutants

mutant test_1101 np1 test_1101 np2 test_1111 np1 (its)
negmulti (−c in the multi-row fold) caught (…reduced_exactly) caught passes, its unchanged
magmulti (1.5c) caught caught passes, its unchanged
negone (−ratio, one-row case) caught (composite…unchanged[±0.5]) caught passes (x 0.01: 7 instead of 6)
keepsmall (smallest norm kept) caught (the_smaller_column_is_dropped…) caught passes (x 0.005: 9, x 0.01: 8, x 0.015: 8)
loose (_DEPENDENT_REL = 1e-2) not caught not caught passes, its unchanged
  • negone on perturbed test_1152 seed 1: it still converges (reasons 3/3/3), with slightly different errors. So only test_1101 guards the fold.
  • L2 (LOW): test_1111 is a solve-only test and catches nothing here. Two additions would help:
    • a near-but-not-dependent case in test_1101 (for example δ = 1e-6 must not merge), which would catch "loose";
    • case e for M1.

Check 8: regressions, br against base. No new failures.

LOW

  • L3: record_repairs still says installed="… coarse unknowns that share one sole fine image merged into one". It should describe the general merge.
  • L4: lstsq leaves ~1e-16 coefficients where the true coefficient is 0 (case i: 1.2e-16), and these become fold entries. This is harmless; zeroing coefficients below eps·max|c| would keep the fold minimal.
  • L5: the group loop uses np.flatnonzero(group == g) per group, which is O(G·N). G = 1000 at 1M adds about 1 s serially (table above). Sorting by group once would remove it. It matters only if a real hierarchy has many thousands of groups.
  • Info: the docstring's "Not detected: dependent columns with different or wider supports" is accurate.
    • My constructed case h (with one group at angle 0, so supports {r}, {r+1}, {r, r+1}) stays singular.
    • The rotated transfer at an axis-aligned normal produces exactly that shape. It is a residual risk worth a sentence.

Merge conditions

  1. M1: cap the kept set of a group at its row count (or use a rank-revealing test), and add the near-parallel case (e) to test_1101.
  2. M2: remove "makes the Galerkin operator nonsingular" from the warning, the docstring and the record wording. Note that dependences with support wider than _SMALL_SUPPORT are not examined.

Recommended, not blocking:

  • the δ = 1e-6 no-merge test (L2);
  • L3 and L5;
  • a follow-up issue on the wide-support ±1 column pairs on W1's split level 2 (M2).

Artifacts (runs/2026-11-13-1111/):

  • logs: logs/;
  • plugins: plug/;
  • probes: probe1111.py, nullan.py, exact1111.py, cost1111.py, seed1152.py, unmoved.py;
  • level-2 matrices: npz/;
  • job summaries: lane*-summary.txt.

Underworld development team with AI support from Claude Code

…QR (H1's M1-M3 on #1111)

M1. With the two largest columns of a group nearly parallel (1e-9 to 1e-7),
the greedy residual test kept all three columns on two rows (rounding in
the fit exceeded its tolerance), leaving the operator exactly singular and
silent. A pivoted QR now keeps the most independent columns, as many as the
group's rank and never more than its rows, and writes the others in that
well-conditioned basis (greedy by norm would write them with coefficients
of 1/angle, which then swamp the level below's relative unreached test).
Test: three columns on two rows with the largest two 1e-9, 1e-8, 1e-7
apart; one merged, composite exact to 1e-12. 3f3fc9e fails all three.

M2. The guard removes the dependent groups with small support; it does not
make the Galerkin operator nonsingular in general (H1: on W1's fixture,
+-1-proportional pairs with 5 to 54 fine rows remain, as before the guard).
The docstring and the warning say so.

M3. A 1e-6 near-dependent pair must not merge; _DEPENDENT_REL = 1e-2 fails it.

W1's fixture: the same merges and iterations as 3f3fc9e, 7/7 at np 1-3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fallback

The merge is an exact change of basis and the hierarchy requested is the
one installed, so recording it in pc_fallbacks ("requested ... unavailable")
was wrong, and it broke every check that reads pc_fallbacks as "what I
asked for was not installed" (ptest_0865's assert not fallbacks, in CI).
Each install's merges are now kept on the solver and reported in
solve_report.config["multigrid_hierarchy"] (merged unknowns by coarse level
for the latest install; installs that merged any), on the standard and the
rotated report paths. No test asserting on fallbacks is changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lmoresi

lmoresi commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Verdict: READY at d76a70d. M1, M2 and the recommended δ = 1e-6 test (M3) are met. The repair is now a solve-report note, not a pc_fallbacks entry, and no development test was edited. Everything else is unchanged against 3f3fc9e and development. Three LOW notes follow; none blocks the merge.

Method

  • Who ran it. H1 (review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)). At most 4 cores were in use at any time.
  • Trees. All runs used git archive copies:
  • Environments. I used prebuilt installs of d76a70d and 264400a.
    • The installed fault_mg.py, custom_mg.py and rotated_bc.py are byte-identical to each archive.
    • The installed solver extension has _note_hierarchy_build.
  • Flags. PYTHONDONTWRITEBYTECODE=1, -p no:cacheprovider, --with-mpi. MPI ran under mpi_supervisor.py --silence 600.
  • Instrumentation reused from the previous review, adapted:
    • Hash plugin. It now also logs, per solver:
      • solve_report.config["multigrid_hierarchy"];
      • _mg_merged_coarse_unknowns;
      • whether a report exists;
      • an allgather showing whether the note and the fallbacks are identical on every rank.
    • Mutant plugin. negone was re-targeted to the new one-row line. A new mutant, greedy, exec's 3f3fc9e's _dependent_columns verbatim; that is 3f3fc9e's logic on this code.
    • Constructed cases were extended (below).
    • The seed harness was adapted to development's 6-tuple _moves. Development added told.
  • The PR's own changes since 3f3fc9e (first-parent):
  • The PR's whole test delta over development is test_1101 and test_1111. Nothing else differs.
  • Logs are kept by the reviewer.

1. M1, the pivoted-QR cap: met

Case e (columns (1,1), (1,1+d), (0.5,0.7) on 2 rows; the columns are spread over ranks and the rows are on another rank):

d 1e-10 1e-9 1e-8 3e-8 1e-7 1e-6 1e-5 1e-4
kept (of 3, on 2 rows) 2 2 2 2 2 2 2 2
max |fold coefficient| 1 1 1 1 1 1 1 1
λmin/λmax after 6.9e-3 6.9e-3 6.9e-3 6.9e-3 6.9e-3 6.9e-3 6.9e-3 6.9e-3
composite diff 0 2e-16 2e-16 2e-16 4e-16 4e-16 0 4e-16
3f3fc9e logic: kept / max coefficient / λmin/λmax 2 / 1 / 6.9e-3 3 / – / 1e-17 3 / – / −2e-17 3 / – / 6e-17 3 / – / −4e-17 2 / 2e5 / 1e-13 2 / 2e4 / 1e-11 2 / 2e3 / 1e-9
  • QR keeps the well-separated pair. It drops (1,1) and writes it as about 1.0·(1,1+d) − (d/2)·(0.5,0.7). This also fixes the e2 note from the previous review: coefficients of 2e4 at d = 1e-5 are now 1.

Other shapes (np 1–4; "after" is λmin/λmax after the merge; it is −4e-18 to −4e-17 before the merge in every merged case):

case kept / columns / rows max |c| composite diff λmin/λmax after 3f3fc9e logic
a: 3 on 2, rotated, mixed signs 2/3/2 0.4 0 8.9e-3 the same
b: 4 on 2 2/4/2 0.63 6e-17 8.4e-3 the same
b2: 4 on 2, a near-parallel pair (1e-8) 2/4/2 1 1e-16 1.0e-2 3 kept, −2e-17 (singular)
c: 4 on 3 3/4/3 0.73 4e-16 7.7e-3 the same
c2: 4 on 3, a near-parallel pair (1e-8) 3/4/3 1 0 4.8e-3 4 kept, −1e-20 (singular)
er: case e rotated by 2.3 rad (mixed signs), d = 1e-9, 1e-8, 1e-7 2/3/2 1 ≤ 4e-16 2.2e-3 3 kept (singular)
es: case e reordered, sign-flipped 2/3/2 1 0 6.9e-3 3 kept (singular)
g / g2: full rank (3 on 3, 2 on 2) nothing merged – untouched 7.7e-3 / 8.4e-3 the same
f: 2 on 2, δ = 1e-9 / 1e-6 nothing merged – – as before the same
d: proportional on 2 rows 1/2/2 0.5 0 4.4e-3 the same

Ties (np 1–4):

  • i, three columns of equal norm on 2 rows, one dependent. The lowest two columns (12, 13) are kept. This holds with the columns on two ranks and with all of them on the last rank.
  • k, three identical columns. The lowest is kept and the other two fold into it with coefficient 1.
  • j, four pairwise-independent columns of equal norm on 2 rows. Two are kept, with coefficients ≤ 0.96. The 3f3fc9e logic gives 3.6.

Determinism.

  • All 33 constructed cases have byte-identical decision arrays on every rank (decision_uniform is true at every np).
  • The md5 of each case's decisions is the same at np 1, 2, 3 and 4.
  • The warning is on rank 0 only.

test_1101 passes 12/12 at np 1, 2, 3 and 4.

2. M3 and the M1 tests catch what they should

mutant test_1101 np 1 np 2
loose (_DEPENDENT_REL = 1e-2) caught: test_nearly_but_not_dependent_columns_are_left_alone caught
greedy (3f3fc9e's _dependent_columns) caught: test_no_more_columns_kept_than_rows…[1e-09, 1e-08, 1e-07], all three caught, all three
negmulti / magmulti caught (4 tests each) –
negone caught (composite…unchanged[±0.5]) –
keepsmall caught (the_smaller_column_is_dropped…) –
  • Unmutated, every test passes.
  • "loose" is now caught. The previous review's L2 is closed.

3. The note, not a fallback: met on both report paths, with one gap (L6)

W1's fixture (test_1111), all 7 cases at np 1, 2, 3 and 4:

  • pc_fallbacks is empty, so there is no dependent-columns entry.
  • solve_report.config["multigrid_hierarchy"] = {merged_coarse_unknowns: {2: N}, installs_with_merges: 1}. N equals the number of unknowns the logged decisions merged, in every case. Examples: np 1 gives x 0.005: 5, x 0.01: 19, x 0.015: 41, y 0.015: 23. np 4 gives x 0.01: 15.
  • The note, _mg_merged_coarse_unknowns and pc_fallbacks are identical on every rank (allgathered).
  • These are rotated-path reports.

Standard path (test_1152 [zone], which reports through the SNES path):

  • np 1: {2: 4}, installs_with_merges: 3;
  • np 4: {2: 2}, 1.

The note is absent where nothing merges:

  • test_1152 at np 2 (no merges);
  • test_1111 y 0.002 at np 1;
  • test_1087's last solve (welded tail).

Elsewhere it is present when the reporting solve merged:

  • test_1087 viscous fault: {2: 1, 3: 6};
  • test_1087 moving fault: {2: 4}.

L6 (LOW, follow-up): a fault-contact solve has no SolveReport at all.

  • fault_contact.solve_with_fault, used by FaultNetwork.solve, calls solve_rotated_freeslip directly and never _capture_rotated_report. So solve_report is None. This was already so on development.
  • Example: in ptest_0865 at np 2 (…the_gathered_split), 2 coarse unknowns are merged. On this path the merge now shows only in the once-per-session warning and in solver._mg_merged_coarse_unknowns. At 3f3fc9e it was in pc_fallbacks.
  • Not a merge condition. Development had no record at all, and the merge is exact.
  • Suggested: call _capture_rotated_report(info) in solve_with_fault (which would also give contact solves a report), or say in the docstring that contact solves are not covered.

4. No development test that asserts on fallbacks was edited

  • Test files that differ, 3f3fc9e against d76a70d (9):

    • test_1084_rotated_datum_collectives, test_1152_fac_zone_survives_a_mover_parallel, test_0029, test_0858, test_1028, test_1032, test_1033. These come from development's merge; each is byte-identical to 264400a.
    • test_1101 and test_1111: the PR's own.
  • The PR's whole test delta over development is test_1101 and test_1111 only.

  • test_1101 test_each_install_that_merges_is_on_the_solver_record is the PR's own test. It asserted on the old pc_fallbacks record and now asserts:

    • _mg_merged_coarse_unknowns = {levels {2: 2}, installs_with_merges 3};
    • that an empty install clears levels and keeps the count;
    • pc_fallbacks == {}.

    That is stricter, not weaker.

  • test_1111 adds "custom_mg.dependent_columns" not in s.pc_fallbacks and the note check for amp ≥ 0.005.

  • No assertion about pc_fallbacks in any development test was touched.

  • ptest_0865 (test_the_split_through_the_seam_is_the_gathered_split) at np 2: passes (2 passed). Its two tests are this one and …the_network_split….

    • br, development and the greedy mutant all merge the same 2 unknowns, so the 08f69ad failure came from the record, not from a new merge.
    • Development passes it too.

5. Unchanged where it matters

W1's fixture. It passes 7/7 at np 1, 2, 3 and 4. Against my 3f3fc9e runs, every case at every np has:

  • the same number of merges;
  • bit-identical transfer hashes (all levels);
  • identical velocity iterations.

The decisions differ only by 1–2 extra fold entries per case, with coefficients of 5e-17 to 2e-16 (L4, below). They do not change the transfers.

Perturbed test_1152, seeds 0–7 (serial, eps 1e-13, 3 moves):

Regression runs:

  • test_1101: 12/12 at np 1–4.
  • test_1111: 7/7 at np 1–4.
  • test_1152: passes at np 1, 2 and 4, with merges, transfers and iterations identical to 3f3fc9e.
  • test_0078_rebuild_memory_parallel (np 2): 21 merges, as at 3f3fc9e, and identical transfers.
  • test_0078 rotated_fmg (np 2): passes.

The serial custom-MG set (53 files):

  • br: 488 passed, 7 skipped. Development: 488 passed, 7 skipped.
  • 490 of 494 tests are identical in transfers, iterations and outcome. The 4 others are the same as in the previous review:
    • test_1087 ×3: the new proportional-group merges, with iterations unchanged (5, 5, 6);
    • test_1142 [slide3e-05]: 9 against 5, with identical transfers. This is the pre-existing nondeterminism noted before.

6. Cost: unchanged

Detection time, cost1111.py, n_coarse = 1M:

np 1 np 1, G = 1000 np 4 np 4, G = 1000
br d76a70d 1.35 s 2.32 s 0.40 s 0.53 s
3f3fc9e (previous review) 1.45–1.59 s 2.39–2.83 s 0.44 s 0.55 s
development 264400a 5.96 s – – –

QR runs only on multi-row groups, which are rare, so it adds nothing measurable.

LOW (none blocks the merge)

  • L6: no SolveReport on fault-contact solves, so the note is not shown there (section 3).
  • L7: the rank test is relative to the pivot's own norm, but pivoting is by absolute residual.
    • The mechanism. A truly independent column smaller than about 1e-10 of a near-dependent large pair in its group is merged.
    • Measured on case s: columns (1,1), (1,1+1e-11), (1e-12,−1e-12). QR merges the third column with coefficient −5e-24. The composite changes by 1.5e-12, which is within the documented 1e-10 approximation; the 3f3fc9e logic changes it by the same 1.5e-12.
    • Without the near pair (case s2), the small column is kept.
    • Possible fix: normalise W's columns before the QR and compare R's diagonal with _DEPENDENT_REL directly.
    • This is informational; I see no realistic hierarchy that hits it.
  • L4 (still open): fold coefficients of order 1e-16 where the exact value is 0. There are 1–2 per case on W1's fixture, and the transfers are bit-identical with or without them. Zeroing |c| < eps·max|c| would keep the fold minimal.
  • L5 (still open): the per-group flatnonzero(group == g) loop. The cost table shows it is not a concern at G = 1000.
  • Note semantics (information): installs_with_merges is reported only when the latest install merged. A later install that merges nothing removes the note even if earlier installs merged. That matches the docstring.
  • Closed:
    • L3: the old installed= wording is gone with the fallback record;
    • L2: "loose" is now caught;
    • M2: the docstring and the warning no longer claim the operator becomes nonsingular, and they say that wider dependences can remain.

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi merged commit 01dec8d into development Nov 13, 2026
10 checks passed
lmoresi added a commit that referenced this pull request Nov 13, 2026
… it is refused

The docs and test_1176's docstrings said that transfers rebuilt from the
moved coordinates were refused by the dependent-column check of #1101.
Development now merges the dependent coarse unknowns (#1111), so nothing
is refused. Measured on this branch merged with development 01dec8d,
serial, macOS (12-core Apple M4):

- split-level fixture, transfers rebuilt: 5 velocity iterations at rest
  and 13 after each of three moves, with 62 to 137 coarse unknowns of the
  level under the fault merged; kept: 5, 6, 6, 6, one merged
- host moved before the cut by 0.002, 0.005, 0.01, 0.02: 6, 6, 7, 6
  iterations, with 0, 2, 6, 62 merged on the split level

No assertion changes; test_1176 and test_1152 pass on one rank (31).

Underworld development team with AI support from Claude Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants