Skip to content

Examples: drop the SVD coarse solve from every example and tutorial (#901) - #945

Merged
lmoresi merged 5 commits into
developmentfrom
docs/examples-no-svd-coarse
Nov 8, 2026
Merged

lmoresi merged 5 commits into
developmentfrom
docs/examples-no-svd-coarse

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

What changed. Forty-four files under docs/examples and docs/beginner/tutorials set the multigrid coarse solve to svd, through fieldsplit_velocity_mg_coarse_pc_type or, in two Poisson examples, mg_coarse_pc_type. This PR removes that one line from each. In tutorials 8 and 15 the line sat in a markdown code fence after a sentence recommending the coarse-level SVD; that sentence now states the rule and the empty fence is gone (03d62f0, from the review below). One other notebook loses a trailing comma, so its JSON stays valid. Documentation only; no library code.

Why. Louis ruled on 2026-11-05 that the multigrid coarse solve has one rule on every route: redundant LU with a nonzero factor shift, with the null space fixed on the fine level. The library sets no SVD coarse solve; a user may still set one by hand under the solver's prefix. The library and guide side merged as #947 (eddab70). These examples are what users copy, so they should not teach the SVD.

How it was checked.

Adversarial review (docs/developer/guides/adversarial-review.md):

Issues in this territory.

Journal: the decision entry and the measurement entry of 2026-11-05 on the solvers topic.

Checklist (UW3 Style Charter — docs/developer/UW3_STYLE_CHARTER.md)

  • I have read the Style Charter and followed it over the surrounding code (S2)
  • No drive-by refactors, renames, or "while I was here" cleanups (S9): the broken examples are left as they are and filed as docs/examples: many scripts fail on development (a removed evalf API, array shapes, nine that do not parse), and nothing runs them #944
  • Bug fixes ship the regression test, written first, with level_* and tier_* markers (S8): not a bug fix
  • No hedging names (maybe_ / try_ / do_) and no commented-out code (S3, S4): one commented-out svd line was removed
  • Every exception swallow states its sanctioned failure mode in a comment (S4): no code
  • New data access uses .array / mesh.X.coords — no with ....access(...), no mesh.data (S7): no code
  • Parallel safety considered — np2/np4 checked where swarm/mesh/solver dispatch is touched (S11): no library code; the examples run at np 1
  • No pixi.toml / pixi.lock or other dependency changes riding in an unrelated PR
  • AI-assisted work carries the attribution line below

Underworld development team with AI support from Claude Code


Generated by Claude Code

Louis, 2026-11-05: no SVD path. Sixteen examples and tutorials set
fieldsplit_velocity_mg_coarse_pc_type (or a Poisson mg_coarse_pc_type) to
svd on problems that leave no direction free: Cartesian boxes with
Dirichlet or free-slip walls, no periodicity, and Dirichlet Poisson
solves. Their coarse operators are nonsingular, so the line only made the
bottom solve dense; without it they take the bundle's redundant LU.

Not in this commit: the 28 curved or periodic examples (the annulus and
shell benchmarks and kernels, the cylinder and ellipse models, three
tutorials, the submesh investigations), which need a run once the shared
bundle carries the zero-pivot shift on the standard route; and the
snesfas investigation README, which describes past work.

Underworld development team with AI support from Claude Code
…ples (#901)

Measured on hyperion, np 1, each example with and without its svd line
(underworld3 A-prime with the bundle shift). Every one builds its mesh
without a refinement hierarchy, so the velocity block falls back to GAMG
and the line only replaced GAMG's own coarse solve. Where the solve ran,
removing it changed nothing: the free-slip annulus kernels, the annulus
benchmark of Kramer et al., the free-slip spherical shell, the ellipse
and tutorial 6 give the same velocity and pressure to 1e-9 or better
with the same iteration counts, and no run met a zero pivot. Tutorial 8
does not converge in either arm (its velocity solve hits its 200-iteration
cap with the svd line as well).

Eleven of these examples fail before their solve on development for
reasons unrelated to the coarse solve: a removed evalf API, the
three-index array shapes, pint units, and two files that do not parse.
Their svd line is removed with the rest; it cannot be the cause and is
no longer the rule. The submesh investigation scripts follow once their
run reports.

Underworld development team with AI support from Claude Code
…ripts (#901)

Measured on hyperion, np 1, each script with and without its svd line
(every solve the GAMG fallback, as in the previous commit). Nine give the
same velocity and pressure to 1e-11 or better with the same iteration
counts. test_region_ds_phase3 segfaults in its first solve and
test_bootstrap_viscosity stalls at its 1e-5 viscosity step, both in both
arms, so neither failure comes from the line. No run met a zero pivot.

With this commit no example or tutorial sets an SVD coarse solve; the
advanced multigrid guide's override example is replaced on the A-prime
branch.

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings November 5, 2026 07:55

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 6, 2026

Copy link
Copy Markdown
Member Author

Adversarial review of #945 at development eddab70

Independent pass, from the diff. Scope: 44 files, 49 removed lines, docs only. Verdict: ready with the changes below.

Findings

  1. Medium. Two tutorials now hold an empty code fence. Removing the line leaves a bare fence in the markdown cell after "the null space.": docs/beginner/tutorials/15-Thermal-convection-with-units.ipynb (diff hunk near line 529) and docs/beginner/tutorials/8-Timestepping-coupled.ipynb (near line 484). Delete the fence, or say how to check the null space.
  2. Low. The PR body is stale. It says the guide on development "still shows an svd override example; A-prime replaces it" and that A-prime's PR is not yet open. At eddab70, docs/advanced/multigrid-preconditioning.md:74 and :109 already say mg_coarse_pc_type = "redundant", and the coarse-solve branch merged as #901: the multigrid coarse solve is redundant LU with a zero-pivot shift on every route; no SVD #947.
  3. Low. The body says two edited files did not parse. Three do not, all failing identically at base: docs/examples/convection/advanced/Ex_Convection_Cylinder-FS.py:321, docs/examples/fluid_mechanics/advanced/Ex_NS_Couette_Flow.py:100, docs/examples/fluid_mechanics/advanced/Ex_Stokes_Spherical_Kernels.py:233. Not caused by the PR; docs/examples: many scripts fail on development (a removed evalf API, array shapes, nine that do not parse), and nothing runs them #944 should list all three.
  4. Low. "There is no SVD path" is policy, not enforced: src/underworld3/utilities/multigrid_options.py:318-325 raises only for coarse="svd"; mg_coarse_pc_type=svd can still be set under the block's prefix.
  5. Low. The claim that removing the line changes nothing rests on the author's runs. CI runs no example, and we did not re-run them. Fourteen examples fail in both arms (docs/examples: many scripts fail on development (a removed evalf API, array shapes, nine that do not parse), and nothing runs them #944), so those have no evidence.

Attacks that failed

  • git apply --check is clean on eddab70; MERGEABLE; style gates and shards 1-4 green.
  • Completeness: what remains in examples and tutorials is docs/examples/snesfas_investigation/README.md:34 (historical, acknowledged) and an unrelated comment in Ex_AdvectionDiffusionSwarm_RotationTest.py:45.
  • All edited notebooks parse. The only Python compile failures are finding 3's, unchanged from base.
  • Each removed line is a one-line option setting; none leaves an empty block. No library, test or dependency file is touched.

Merge conditions

Underworld development team with AI support from Claude Code

…D coarse solve

Review of #945, finding 1: removing the svd line left an empty code
fence after a sentence that recommended the coarse-level SVD. The
sentence now gives the rule (a null space is fixed on the fine operator,
not by the coarse solve, so a rigid rotation can still appear and should
be measured) and the empty fence is gone.

Underworld development team with AI support from Claude Code

lmoresi commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

Review of 2026-11-06, finding by finding:

  1. Fixed in 03d62f0. The empty fences in tutorials 8 and 15 are gone, and the sentence before them, which recommended the coarse-level SVD, now gives the rule: a null space is fixed on the fine operator, not by the coarse solve, so a rigid rotation can still appear and should be measured. A search for the spelled-out form finds nothing else in the 44 files.
  2. Done. The body now says #901: the multigrid coarse solve is redundant LU with a zero-pivot shift on every route; no SVD #947 merged (eddab70) and drops the line about the advanced guide.
  3. Done in the body. Ex_NS_Couette_Flow.py was the third file. docs/examples: many scripts fail on development (a removed evalf API, array shapes, nine that do not parse), and nothing runs them #944 already lists all three, among the nine example scripts that do not parse.
  4. Taken. The body now says the library sets no SVD coarse solve and a user may still set one by hand.
  5. Agreed and stated in the body: the fourteen examples that fail in both arms give no evidence either way.

development is merged in (2d4d3d5), and the docs build shows no warnings on the edited files.


Generated by Claude Code

@lmoresi
lmoresi merged commit 24883ca into development Nov 8, 2026
10 checks passed
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.

2 participants