Repository navigation
Apply the chain rule to bounded-problem derivative callbacks - #1269
Merged
ChrisRackauckas merged 2 commits intoSep 13, 2026
Merged
ChrisRackauckas merged 2 commits into
ChrisRackauckas merged 2 commits into
Conversation
Evaluate analytic Jacobians and products in physical coordinates and apply the inverse-transform derivative to Jacobian columns and JVP/VJP directions. Preserve sparse storage and provided parameter Jacobians. Handle scalar states through transformation and solution reconstruction. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Codex <[email protected]> Agent-Harness: Codex CLI 0.154.0 Agent-Model: gpt-6-astra Agent-Session: local transcript /home/crackauc/.codex/sessions/2026/09/12/rollout-2026-09-12T04-30-15-01a094bd-179a-7972-97ec-36badb9448cd.jsonl
Use in-place right multiplication by the transform's diagonal derivative so stored zeros remain available to cached sparse symbolic factorizations. Exercise saturated coordinates and subsequent callback reuse. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Codex <[email protected]> Agent-Harness: Codex CLI 0.154.0 Agent-Model: gpt-6-astra Agent-Session: local transcript /home/crackauc/.codex/sessions/2026/09/12/rollout-2026-09-12T04-30-15-01a094bd-179a-7972-97ec-36badb9448cd.jsonl
ChrisRackauckas-Claude
force-pushed
the
fix/bounded-transform-derivatives
branch
from
September 13, 2026 12:20
a6dad2d to
dc007c8
Compare
ChrisRackauckas
marked this pull request as ready for review
September 13, 2026 13:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bounded problems transformed to unbounded coordinates passed the transformed state directly to analytic derivative callbacks and omitted the inverse-transform derivative. For
f(u) = u² - 4,u = 1, and bounds[0, 10], this produced a Jacobian of-4.394449154672439instead of1.7999999999999992.Evaluate
jac,jvp,vjp, andparamjacin physical coordinates and apply the chain rule to state derivatives. Sparse Jacobians retain their stored-zero structure even when transform derivatives vanish, supplied callbacks remain in use, and scalar states now work through transformation and solution reconstruction. The defect is present in the original bounds-transform commit; executing that original transform against current dependencies reproduces the incorrect Jacobian above.Please ignore this PR until reviewed by @ChrisRackauckas.
Verification
The same array-derivative regression tests were run on unmodified master and with the fix using Julia 1.13.0:
The complete focused file also covers scalar derivatives and scalar solution reconstruction:
The array cases cover in-place/out-of-place callbacks, dense/sparse rectangular Jacobians, all four bound configurations, JVP/VJP, parameter Jacobians, and repeated states/parameters.
Core: 523 assertions passed; QA: 20 assertions passed. Both end with
Testing NonlinearSolveBase tests passed. Runic, typos, andgit diff --checkpass.The root Core group passed 1,028 assertions at 59ffc83c4, including 18 supplemental Newton assertions across dense, sparse, Krylov JVP/VJP, and scalar solves:
GROUP=Core julia +1.13.0 --compiled-modules=existing --project=. -e 'using Pkg; Pkg.test(; julia_args=["--compiled-modules=existing"])'Those integration tests are being carried by the dependent bounded-default PR, which raises the Base minimum version; this prerequisite keeps its regression tests inside Base's own suite.
A second regression test exercises derivative underflow at transformed coordinates
[-1000, 0]. Broadcast scaling incorrectly removed stored zeros; publicrmul!(J, Diagonal(scale))preserves the structure required by cached sparse symbolic factorizations:Three 1,024-variable sparse diffusion cases that previously threw
snlu! requires the same sparsity pattern as the analyzed matrixnow return solutions without exceptions. The root case returnsSuccesswith residual3.06e-10; the two active-bound least-squares cases returnMaxIterswith projected gradients3.30e-13and3.94e-13. These latter two remain benchmark failures under the successful-retcode criterion. The final structural-zero change was checked with the complete Base Core/QA groups and those three solver-level reproductions; root Core was not rerun for that follow-up.GPU/downstream jobs and prerelease Julia were not run. Docs were not built because this changes private implementation only. Arbitrary custom operator-valued
jaccallbacks were not validated; the tested operator path uses JVP/VJP callbacks.🤖 Generated with Codex CLI 0.154.0 (model: gpt-6-astra; session: local transcript
/home/crackauc/.codex/sessions/2026/09/12/rollout-2026-09-12T04-30-15-01a094bd-179a-7972-97ec-36badb9448cd.jsonl).