Skip to content

Recognize explicit second-order AutoSparse AD - #1269

Draft
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:agent/recognize-sparse-second-order
Draft

Recognize explicit second-order AutoSparse AD#1269
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:agent/recognize-sparse-second-order

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Summary

  • recognize AutoSparse AD types that explicitly wrap DifferentiationInterface.SecondOrder
  • retain the missing_second_order_ad warning for implicit first-order AutoSparse inputs
  • add focused regression coverage for both cases

Context

Optimization's exact-Hessian cache warning only recognized a top-level SecondOrder. The documented sparse form is instead AutoSparse(SecondOrder(inner, outer)), so an explicitly configured sparse second-order backend was incorrectly warned as missing second-order AD.

This became visible in BoundaryValueDiffEq after OptimizationIpopt 1.3 switched to the generic OptimizationCache. A separate downstream follow-up supplies an explicit sparse SecondOrder; this PR only fixes OptimizationBase's classification.

Related prior art: #1061 called out this false warning while working around it downstream, and #1240 concerns another second-order warning edge case. I found no open duplicate PR.

Investigation

  1. Reproduced the warning on current master and confirmed the parent of OptimizationIpopt 1.3 remained silent because it did not use the generic cache path.
  2. Verified that AutoSparse(SecondOrder(AutoForwardDiff(), AutoForwardDiff())) solves successfully.
  3. Verified that moving AutoSparse outside the individual SecondOrder backends is the working sparse representation; the alternative top-level construction fails in DifferentiationInterface's pullback path.
  4. Added a positive no-warning assertion for explicit sparse second-order AD and a negative assertion that implicit sparse AD still warns.

Local verification

  • OPTIMIZATION_TEST_GROUP=Core: 54 passed
  • OPTIMIZATION_TEST_GROUP=QA: 16 passed, 1 pre-existing broken assertion; package test passed
  • Runic check on all changed Julia files: passed
  • Stacked BoundaryValueDiffEq integration reproduction: 4/4 assertions passed across bounded and unbounded MIRK/Ipopt problems (no warning and successful return code for each)

Please ignore this draft until it has been reviewed by @ChrisRackauckas.

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Fresh downstream verification on 2026-07-20:

  • Clean SciML/BoundaryValueDiffEq.jl@5e9eb4eff5e493c5ae56d5f4fc2027b446c55610 on Julia 1.12.6, with BoundaryValueDiffEqMIRK 1.17.2, OptimizationIpopt 1.3.0, OptimizationBase 5.2.1, and SciMLBase 3.36.0, reproduces both MIRK failures independently. BVP with inequality constraints and StandardBVProblem optimize path without user lcons/ucons each report 1 passed / 1 failed: Ipopt reaches Optimal Solution Found, and the only failed assertion is @test_nowarn capturing missing_second_order_ad.
  • The same clean BoundaryValueDiffEq commit pinned to OptimizationIpopt 1.2.3 passes both focused testsets (4/4 assertions), confirming the release boundary at be6fbd279 / Use the default OptimizationCache in OptimizationIpopt #1257, where Ipopt moved to the generic OptimizationCache.
  • A stacked local candidate using this PR commit (dc1da441a) plus the BoundaryValueDiffEq companion change that supplies AutoSparse(SecondOrder(...)) passes both focused testsets (4/4 assertions) with OptimizationIpopt 1.3.0; no warning is emitted.

This confirms that #1269 is the OptimizationBase half of the fix. BoundaryValueDiffEq still needs the companion explicit-second-order change; #1269 alone correctly continues warning for its current first-order AutoSparse(AutoForwardDiff()) input.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@ChrisRackauckas-Claude
ChrisRackauckas-Claude force-pushed the agent/recognize-sparse-second-order branch from dc1da44 to ec83d4e Compare July 29, 2026 01:51
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Rebased onto current clean upstream/master (4d25faca8); new head ec83d4e9e. Before the lease-protected push I audited the remote branch: it contained only the original ChrisRackauckas-Claude commit and no intervening contributor work. The rebased tree is byte-for-byte identical to the freshly validated tree. Current local verification: OptimizationBase Core 54/54, Runic clean, and the combined BoundaryValueDiffEqMIRK integration removes the false warnings. Versioning remains intentionally untouched here because #1287 is coordinating the sequential OptimizationBase 5.2.3 release.

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