Skip to content

Recognize explicit second-order AD inside AutoSparse - #1288

Closed
ChrisRackauckas-Claude wants to merge 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/fix-mirk-sparse-second-order-warning
Closed

Recognize explicit second-order AD inside AutoSparse#1288
ChrisRackauckas-Claude wants to merge 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/fix-mirk-sparse-second-order-warning

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Jul 29, 2026

Copy link
Copy Markdown
Member

Ignore this PR until it has been reviewed by @ChrisRackauckas.

Problem

OptimizationCache warns that second-order AD is missing when an optimizer requires Hessians even if the user explicitly supplied AutoSparse(SecondOrder(...)). The sparse differentiation path already understands and preserves this representation, so the warning is incorrect.

This became visible in the BoundaryValueDiffEqMIRK downgrade lane after OptimizationIpopt 1.3 moved to the shared OptimizationCache.

Change

  • Recognize AutoSparse{<:SecondOrder} as explicit second-order AD.
  • Add a regression test proving the explicit sparse backend is warning-free while AutoSparse(AutoForwardDiff()) still emits missing_second_order_ad.
  • Bump OptimizationBase from 5.2.4 to 5.2.5.

Local verification

  • GROUP=OptimizationBase julia +1.10 --project=. -e 'using Pkg; Pkg.test()'
    • Core | 54 passed / 54 total
    • OptimizationBase tests passed
  • Runic 1.7.0: --check . passed.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>

Copy link
Copy Markdown
Member Author

Investigation scratchpad:

  1. Reproduced the downstream warning on clean BoundaryValueDiffEq master with OptimizationIpopt 1.3.0 / OptimizationBase 5.2.x.
  2. Verified OptimizationIpopt 1.2.2 did not route through the shared cache and the same solve was warning-free.
  3. Confirmed generate_sparse_adtype already treats AutoSparse(SecondOrder(...)) as the explicit sparse second-order representation.
  4. Added the narrow cache predicate and positive/negative warning tests in commit b56c1803.
  5. Ran the official OptimizationBase Core group and Runic locally; both passed.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>

Copy link
Copy Markdown
Member Author

Follow-up commit 8d5d4d15 bumps OptimizationBase 5.2.4 → 5.2.5, matching the repository's per-fix sublibrary release convention. Runic remains clean; the official Core group is being rerun against the final two-commit head.

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Final-head local validation after the OptimizationBase v5.2.5 bump: GROUP=OptimizationBase julia +1.10 --project=. -e 'using Pkg; Pkg.test()' passed (54/54 Core tests; 257.5 s).

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Closing this as a duplicate of the existing draft #1269. The implementation and regression are identical; I missed the older draft while revalidating the current clean-master failure. The fresh local results will be carried onto #1269.

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