Avoid wide Enzyme batches for Lagrangian Hessians - #1328
Avoid wide Enzyme batches for Lagrangian Hessians#1328ChrisRackauckas-Claude wants to merge 4 commits into
Conversation
|
Follow-up |
|
CI audit after #1331 merged:
timeout 3600 /usr/bin/time -f "wall=%e maxrss_kb=%M exit=%x" \
~/.juliaup/bin/julia +1.11 --startup-file=no \
--project=lib/OptimizationBase/test/AD \
-e 'using Pkg; Pkg.instantiate(); include("lib/OptimizationBase/test/AD/enzyme_lagrangian_hessian.jl")'
I found no PR-specific failing check. The PR remains draft and still requires review by @ChrisRackauckas. |
1159155 to
91ee292
Compare
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://chatgpt.com/codex/tasks/01a03a17-ad6f-7131-82fc-d0fd57ea6512
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://chatgpt.com/codex/tasks/01a03a17-ad6f-7131-82fc-d0fd57ea6512
91ee292 to
a40fe7d
Compare
|
This is too extreme: it completely removes all batch duplicated. Just like the hessians and such, shouldn't we limit it to like 8? |
Match the objective Hessian batching from SciML#1331 instead of differentiating one seed at a time. Julia 1.12 still falls back to row-wise seeds because BatchDuplicated forward-over-reverse through the Lagrangian yields NaNs there. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Addressed the review comment: Lagrangian Hessians now use the same width-8 Enzyme FoR batching as objective Hessians ( Julia 1.12 still falls back to row-wise Verified: Enzyme Lagrangian Hessian 26/26 on Julia 1.11.9 (width 8) and Julia 1.12.7 (row-wise fallback). |
Use an out-of-place Lagrangian helper and return a dense symmetric matrix from the OOP path. Narrow the row-wise batch fallback to Julia 1.12.x, and expand coverage with nonzero points, σ/μ cases, and OOP sizes that exercise width-8 padding. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Follow-up addressing the sol review:
Enzyme Lagrangian Hessian: 82/82 on Julia 1.11.9 and 1.12.7. |
Ignore this PR until it has been reviewed by @ChrisRackauckas.
What changed
Compute Enzyme-generated Lagrangian Hessians one direction at a time instead of compiling one forward-over-reverse batch whose width equals the optimization dimension. The previous batch has superlinear LLVM/Enzyme compilation growth and prevents the
OptimizationFrameworks/clnlbeam.jmdbenchmark from reaching its solver comparisons.The row-wise sweep zeroes and differentiates a reusable gradient workspace through a Lagrangian closure. The dense entry point copies the computed triangle symmetrically; the packed entry point consumes the same directional results. The regression test checks both representations, including the objective's off-diagonal term, for optimization dimensions through 183 variables.
The final head
91ee2925cfcc01b1389955542ec74e6f1b8f599eis rebased onto current Optimization masterc2d6a1d45d8b6367620de199669fc57d4a838784, after the width-8 batching change and OptimizationBase 5.5.2 release.Failing before / passing after
Original wide-batch failure
I ran the committed regression test against an unfixed checkout and this branch:
Before, the command exhausted the complete one-hour Bash timeout (
exit 124) while compiling the width-183 Enzyme batch. The termination stack was inEnzyme.removeDeadArgs!/ LLVM Attributor, called from the oldlag_h!.On the rebased final head, the same command completes:
Julia 1.12 regression in the first row-wise implementation
The first pushed row-wise implementation (
53ebab8ac4edb990e1f8b50ae5f1c43c4ca52634) failed the same test locally on Julia 1.12.7 withNaNHessian entries atN = 10,20, and60:The exact Julia 1.12 command passes on the rebased final head:
--compiled-modules=noavoids an unrelated RuntimeGeneratedFunctions world-age precompile failure in the isolated Julia 1.12 depot.Benchmark verification
I developed each OptimizationBase checkout into the SciMLBenchmarks
OptimizationFrameworksenvironment and ran:timeout 3600 ~/.juliaup/bin/julia +1.11.9 --startup-file=no \ --project=. benchmark.jl benchmarks/OptimizationFrameworks/clnlbeam.jmdThe unfixed benchmark exhausted the one-hour timeout while starting
run_enzyme_diff(60). With this branch it completed every chunk through size 200 in 11m55.7s and generated bothclnlbeam.mdandclnlbeam_7_1.png.Test verification
Runic,
typos, andgit diff --checkpassed on the final three-file diff.Not verified locally
I did not run every test group in the Optimization monorepo. The changed extension is covered by the complete OptimizationBase AD group and root QA group. This changes no public API or documentation.
🤖 Generated with Claude Code
https://chatgpt.com/codex/tasks/01a03a17-ad6f-7131-82fc-d0fd57ea6512