Skip to content

Fix AutoEnzyme Hessian invalidating Hessian-vector products - #1431

Draft
ChrisRackauckas wants to merge 1 commit into
masterfrom
fix/enzyme-oop-hessian-buffer-1427
Draft

ChrisRackauckas wants to merge 1 commit into
masterfrom
fix/enzyme-oop-hessian-buffer-1427

Conversation

@ChrisRackauckas

Copy link
Copy Markdown
Member

🚧 UNREVIEWED — awaiting maintainer review. Filed by an AI agent; no human has reviewed this.
Harness: Codex CLI 0.162.1 · Model: gpt-6.1-sol
Session: 01a14ba9-e60c-7e90-b8e6-bb5d66b41098

Keep the out-of-place AutoEnzyme Hessian matrix local to the hess closure. Assigning it to the enclosing H overwrites the vector captured by hv, so calling hv after hess throws MethodError: no method matching Duplicated(::Vector{Float64}, ::Matrix{Float64}).

The regression interleaves hv, hess, and fgh on the same instantiated function at two points and two directions, checking against the analytic Rosenbrock Hessian and its products. Public signatures and the Hessian values are unchanged. Please ignore this draft until maintainer review.

Fixes #1427

Reproduction and verification

Reproduced on default-branch commit 902ed1f (OptimizationBase 5.10.0) and the latest registered OptimizationBase 5.9.0, in separate local environments. Both used Julia 1.12.7, Enzyme 0.13.216, SciMLBase 3.58.0, and ChainRulesCore 1.26.2. The checkout was installed with Pkg.develop for the default-branch run.

Commands below use PROBE_ENV for the environment containing the checkout, Enzyme, ChainRulesCore, SciMLBase, and SciMLTesting; all runs use JULIA_NUM_THREADS=4, JULIA_NUM_PRECOMPILE_TASKS=4, and --startup-file=no.

Focused regression, before applying the source fix:

julia --startup-file=no --project="$PROBE_ENV" lib/OptimizationBase/test/AD/enzyme_oop_hessian_products.jl
MethodError: no method matching Duplicated(::Vector{Float64}, ::Matrix{Float64})
Test Summary:                                           | Pass  Error  Total   Time
Enzyme out-of-place Hessian and Hessian-vector products |    9     11     20  17.7s

Same regression with the fix:

Test Summary:                                           | Pass  Total   Time
Enzyme out-of-place Hessian and Hessian-vector products |   20     20  15.5s
  • Runic on all three changed Julia files: passed (julia --startup-file=no --project=@runic -m Runic --inplace <changed files>).

  • typos on the complete diff, and git diff --check: passed.

  • Full AD group: GROUP=AD OPTIMIZATION_TEST_GROUP=AD julia --startup-file=no --project="$PROBE_ENV" lib/OptimizationBase/test/runtests.jl:

    Test Summary: | Pass  Total     Time
    AD            | 1155   1155  2m50.8s
    
  • QA: GROUP=QA OPTIMIZATION_TEST_GROUP=QA julia --startup-file=no --project="$PROBE_ENV" -e 'using Pkg; Pkg.test("OptimizationBase")':

    Test Summary: | Pass  Broken  Total   Time
    QA            |   20       1     21  21.9s
         Testing OptimizationBase tests passed
    

    The broken QA check is the existing no_implicit_imports marking; this PR does not change it. Invoking QA directly through test/runtests.jl stopped before running checks because SafeTestsets was unavailable after environment activation; the standard Pkg.test invocation above passes.

Not verified: GPU execution and downstream packages. No docs build was run because no docs, docstrings, or public API change. CI and independent review are pending.

Risk assessment

  • Risk: low (L6: an erroring Hessian-vector product sequence produces the analytic result; no public signature changes, and Hessian results remain equal to the analytic reference).
  • Blast radius: optional AutoEnzyme out-of-place Hessian generation in OptimizationBase; one local variable declaration, no dependencies or API changes. In-place and other AD backends are untouched.
  • Evidence: regression reports 9 passes and 11 errors before the fix, and 20 passes after; both default branch and latest registered release reproduce the error.
  • Independent review: pending (a different harness reviews it).
  • Merge: needs human review — draft, independent review and CI assessment pending.

🤖 Posted by an AI agent — harness: Codex CLI 0.162.1 · model: gpt-6.1-sol
Conversation: Codex exec session 01a14ba9-e60c-7e90-b8e6-bb5d66b41098 (no session URL)

Prevent hess from rebinding the vector captured by hv. Exercise repeated
interleaved Hessian and Hessian-vector products against analytic references.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Codex <noreply@openai.com>
Agent-Harness: Codex CLI 0.162.1
Agent-Model: gpt-6.1-sol
Agent-Session: 01a14ba9-e60c-7e90-b8e6-bb5d66b41098

This branch has not been deployed

No deployments
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.

AutoEnzyme out-of-place hess rebinds the hv buffer, so hv throws after hess

2 participants