You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
solver.gradient() takes the adjoint of an unconverged forward solve and returns a wrong-signed number #804
_adjoint_support documents that an unconverged solve is refused ("a linearisation about a state the solve never reached is not the adjoint of anything"), caught after the fact by _record_solve_outcome. That catch is on the recorded/transcript path. A direct solver.solve() followed by solver.gradient(...) is not refused.
Reproduced on scratch/adjoint-merge (82e697b): softmin viscoplastic box, snes_max_it = 2.
forward reason -5 # DIVERGED_MAX_IT
gradient RETURNED {eta_min: 0.2197} # converged answer: -0.1423 (FD agrees to 4e-8)
Wrong sign, no warning. Script: ~/+Simulations/adjoint_note_checks/unconverged_refusal.py.
UWTN 2026-020 (draft) currently states that "the library refuses to take the adjoint of a solve that did not converge", so either the guard moves into adjoint_solve/gradient (check snes.getConvergedReason() > 0 on the solver that did the solving) or the note's sentence goes. The first seems right: the note's argument — a multiplier is undefined off the constraint manifold — is exactly why this should be an error rather than a number.
Not reproducible on development (7c9cbbfd) — the adjoint API is not there:
uw.adjoint present: False
Stokes adjoint API: []
files with 'adjoint' in the path: 0
Only scattered references remain (one line in petsc_generic_snes_solvers.pyx, five in mcp/__init__.py, eight in transcript_query.py), not the implementation. So this defect lives in unmerged work — feature/discrete-adjoint (#744, currently conflicting and red), feature/adjoint-rotated-bc (#751, based on #744), or scratch/adjoint-merge.
That is why it has sat untouched: there is nothing on the main line to fix. It is notfixed-in-PR — the opposite. It has to be fixed on the branch before that branch lands, or it lands with the defect.
Checked in the untouched-issue triage. Blocked behind #744, which needs its conflicts resolved and a CI re-run (its red check is test_1063_constrained_traction, whose timeout #814 addressed when it merged on 2026-10-06).
It returns a number 35% off, with no warning. adjoint_solve checks only _adjoint_support() and whether a solve has run. It never reads the converged reason. I'll fix this by refusing in adjoint_solve when the last forward solve did not converge (has_solution / snes.getConvergedReason() <= 0, plus the rotated path's own flag), with this probe as the test.
Underworld development team with AI support from Claude Code
Fixed on development by #1038 (merge commit b618b0f); the label was missing, so the issue read as live.
Probe, run during the review of #1144 on a build of developmentbc3d536 with the Jacobian routine of #1156 added (which does not touch the adjoint), one rank, macOS (12-core Apple M4), PETSc 3.25.3: tests/test_0027_adjoint_solve_guards.py, 8 passed, among them test_the_adjoint_of_an_unconverged_solve_is_refused.
Labelled fixed-in-development; it stays open until the release to main.
Underworld development team with AI support from Claude Code
Activity
lmoresi commentedon Oct 7, 2026
Not reproducible on
development(7c9cbbfd) — the adjoint API is not there:Only scattered references remain (one line in
petsc_generic_snes_solvers.pyx, five inmcp/__init__.py, eight intranscript_query.py), not the implementation. So this defect lives in unmerged work —feature/discrete-adjoint(#744, currently conflicting and red),feature/adjoint-rotated-bc(#751, based on #744), orscratch/adjoint-merge.That is why it has sat untouched: there is nothing on the main line to fix. It is not
fixed-in-PR— the opposite. It has to be fixed on the branch before that branch lands, or it lands with the defect.Checked in the untouched-issue triage. Blocked behind #744, which needs its conflicts resolved and a CI re-run (its red check is
test_1063_constrained_traction, whose timeout #814 addressed when it merged on 2026-10-06).lmoresi commentedon Nov 10, 2026
Confirmed live on development
8f0ed0ab(serial). The 2026-10-07 "not on development" comment is out of date: the adjoint landed with #744.Probe
p804.py(in$HYPERION_WORK/runs/2026-11-10-h4/probes): shear-thinning Stokes withsnes_max_it = 1, thensolver.gradient(J = 1/2 ∫|v|^2, parameters=[eta_0]):It returns a number 35% off, with no warning.
adjoint_solvechecks only_adjoint_support()and whether a solve has run. It never reads the converged reason. I'll fix this by refusing inadjoint_solvewhen the last forward solve did not converge (has_solution/snes.getConvergedReason() <= 0, plus the rotated path's own flag), with this probe as the test.Underworld development team with AI support from Claude Code
Merge pull request #1038 from underworldcode/bugfix/adjoint-solve-gua…
adjoint_solve: hold the linear solve to its own tolerance, check the …
lmoresi commentedon Nov 13, 2026
Fixed on
developmentby #1038 (merge commit b618b0f); the label was missing, so the issue read as live.Probe, run during the review of #1144 on a build of
developmentbc3d536 with the Jacobian routine of #1156 added (which does not touch the adjoint), one rank, macOS (12-core Apple M4), PETSc 3.25.3:tests/test_0027_adjoint_solve_guards.py, 8 passed, among themtest_the_adjoint_of_an_unconverged_solve_is_refused.Labelled
fixed-in-development; it stays open until the release tomain.Underworld development team with AI support from Claude Code