Skip to content

An uncached rotated solve measures its first residual without the gauge (#884) - #1262

Merged
lmoresi merged 3 commits into
developmentfrom
bugfix/rotated-gauge-before-first-residual-884
Nov 20, 2026
Merged

lmoresi merged 3 commits into
developmentfrom
bugfix/rotated-gauge-before-first-residual-884

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member

An uncached rotated free-slip solve now measures its first residual without the rigid-rotation gauge, as a cached re-solve does, so both stop against the same reference.

What changes

On development.

  • The rotated loop measures every residual with the rotation-gauge modes projected out: the solve cannot reduce that component.
  • On an uncached solve the modes are collected only after the first assembly. Iteration 0's residual, r0, the reference, the line search's starting norm and a warm start's rest-state residual therefore kept the component.
  • Every later residual, and a cached re-solve's first one, left it out, so a first solve and its re-solve stopped against different references.

Now.

  • Once the modes are collected at iteration 0, its residual is projected the same way. r0, the reference and the residual history are taken from the projected norm, before the line search starts from it.
  • An uncached warm start re-measures its rest-state residual in the same quotient space. That costs one residual evaluation, only on an uncached solve that has gauge modes.

Measured. Annulus, cell size 0.2, free slip on both walls, body force (-y, x) (a rigid rotation), tolerance 1e-6; serial, macOS (12-core Apple M4).

solve development: rnorm0 = ref this branch
first (uncached) 0.12131 0.070250
re-solve (cached) 0.070250 0.070250

Each takes one increment on both branches. Development's two solves end at 1.08501485567e-9 and 1.08501485575e-9; this branch ends at 1.08501485388e-9 in both. The answers agree to round-off.

Tolerances and coordinate matches

None added. The tests compare the uncached and cached references to 1e-12 relative, two numbers that should be equal and that differed by a factor of 1.7.

Tests

tests/test_0884_rotated_gauge_before_first_residual.py, level 2, tier B:

  • First solve and cached re-solve: equal r0 and reference, and r0 = 0.0703 to 1e-3.
  • Uncached warm start (a fresh solver started from a field) against the same warm start on a cached solver: equal rest-state residual and reference.

Both fail on development: 0.1213 against 0.0703, run with development's rotated_bc.py built in.

Serial runs: the rotated slice (test_0022, 0846, 0884, 1018, 1058, 1061, 1066, 1092, 1113, 1131, 1136, 1142, 1143, 1158, 1159): 172 passed, 1 skipped (an x86-only case).

Not run: any parallel case. The projection uses Vec.dot, which is collective, on modes every rank holds, inside a branch every rank takes (ctx is None and iters == 0).

Review

Adversarial review, below.

Issue state

#884: fixed by this branch (label fixed-in-PR).

Underworld development team with AI support from Claude Code

…ge (#884)

The rigid-rotation modes are collected after the first assembly on an
uncached solve, so iteration 0's residual, r0, the reference and a warm
start's rest-state residual kept the component the solve cannot reduce,
while every later residual and a cached re-solve left it out. A first
solve and its re-solve stopped against different references (annulus,
body force (-y, x): r0 0.1213 uncached, 0.0703 cached).

Once the modes exist at iteration 0, its residual is projected the same
way, r0 and the reference are re-measured from it before the line search
starts from it, and an uncached warm start re-measures its rest-state
residual in the same quotient space.

test_0884: a first solve and its cached re-solve share r0 and reference
(0.0703), and an uncached warm start shares its rest-state residual and
reference with a cached one. Both fail on development.

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings November 20, 2026 05:47

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

Copy link
Copy Markdown
Member Author

Adversarial review, round 1 (head f759dfb)

  • Rank asymmetry. The new block runs when ctx is None (no cached workspace, the same on every rank) and iters == 0 and rot_modes is non-empty. The modes come from the global null space, so every rank holds the same list. Vec.dot and Vec.norm are collective and every rank calls them. On an uncached warm start the re-measured rest-state residual calls snes.computeFunction on every rank.
  • Ordering. The iteration-0 convergence test runs before the assembly that builds the modes, so it still sees the unprojected norm. On a cold start it cannot pass (rnorm = r0). An uncached warm start that is already converged in the quotient but not outside it takes one increment it did not need; that was true on development too. The line search, the continuation switch and every later test use the projected values.
  • The right-hand side. bhat is copied from the projected residual. The KSP carries the same modes as its transpose null space and removes them from the right-hand side itself, so the increment is unchanged up to round-off. The final residuals agree with development's to 1.8e-18.
  • The direct-LU path collects no rotation modes (they are built under not use_lu), before or after this change. It is untouched.
  • Tests that cannot fail. Both fail on development, with its rotated_bc.py built in (0.1213 against 0.0703).
  • CI reach. test_0884 is in scripts/test.sh's test_08*py batch.

No findings.

Issue state:

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Second-desk review by H7 (a Claude review session running parallel probes on a 96-thread Linux workstation: Intel Xeon Gold 6240R, AVX-512, MPICH). The base is development e7e02b9, the merge base of the rotated batch (#1260, #1261, #1262, #1265, #1263). #1261, #1262, #1265 and #1263 change only rotated_bc.py, so each was measured by placing the branch's file, or a clean three-way merge of the files, in a build of e7e02b9. #1260 was built from its own branch. Parallel runs were under the MPI supervisor, at most 4 ranks.

Verdict: passes. Merge it after #1261: on its own it raises one iteration count, and #1261 removes the rise.

Measured

Annulus, cell size 0.2, tolerance 1e-6, serial; the setups are #1261's table.

case development #1262 alone #1261 + #1262
rigid rotation alone: rnorm0 = ref, uncached / cached 0.1213 / 0.07026 0.07026 / 0.07026 0.07026 / 0.07026
datum 0.1 + rotation: increments 1 2 1
datum 0.1 alone: increments 2 2 1
answers – within 3.6e-7 of the reference within 3.6e-7

Findings

Attacks that failed

Underworld development team with AI support from Claude Code

Brings in #1261 (the datum lift reference), which this branch follows; the
merge of rotated_bc.py is automatic.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Merged development into this branch (no rebase, so no force-push): 64c2d26, with development at 71843b9, including #1261. The merge of rotated_bc.py was automatic.

Serial runs on the merge (macOS, 12-core Apple M4): the 33 test files that use rotated free slip, with test_0052, at levels 1 and 2: 403 passed, 1 skipped.

Underworld development team with AI support from Claude Code

Brings in #1260 (rotated sub-solve caps); the merge of rotated_bc.py is
automatic.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Merged development, with #1260 at eabceed, into this branch: 96a0f32. The merge of rotated_bc.py was automatic. Serial: the 34 rotated test files with test_0052, levels 1 and 2, 405 passed, 1 skipped.

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi merged commit 7091a93 into development Nov 20, 2026
10 checks passed
lmoresi added a commit that referenced this pull request Nov 20, 2026
…nts-941

Brings in #1260 and #1262; the merge of rotated_bc.py is automatic.

Underworld development team with AI support from Claude Code
lmoresi added a commit that referenced this pull request Nov 20, 2026
Brings in #1260, #1262 and #1265 (the summed normal this branch's corner
datum reads); the merge of rotated_bc.py is automatic.

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.

2 participants