Repository navigation
Remove Core.Box captures from the unconstrained OptimizationLBFGSB __solve path - #1402
ChrisRackauckas-Claude wants to merge 1 commit into
Conversation
Drop `local x` and give the unconstrained branch its own iter/loss names so closures stop boxing captures and every function evaluation no longer dispatches dynamically. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Cursor Agent <noreply@cursor.com> Agent-Harness: Cursor Agent 2026.10.01-14929f9 Agent-Model: unknown (Cursor auto) Agent-Session: local session, transcript /home/crackauc/sandbox/goals/performance/jobs/opt/opt-lbfgsb/log.txt on amdci2
Independent review (Devin CLI 3000.11.3, model fusion-claude-opus-5-5-high-sidekick-swe-2-medium): MERGE, risk low. Full reviewVERDICT: MERGE PR: #1402 (head c41cafa, 2 files, +15/−6). The PR links no issue and has no parent tracking issue. Blocking findingsNone. Non-blocking findings
What I ranAll runs used
What I did not verify
🤖 Posted by an AI agent — harness: Devin CLI 3000.11.3 (review), Claude Code 2.1.285 (posting) · model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium |
Summary
SciMLBase.__solveforLBFGSBdeclaredlocal xand assignediter_count/_lossin both the constrained and unconstrained branches, so Julia boxed those captures. Every objective evaluation then went throughCore.Box, which showed up as dynamic dispatch (JET: 23 reports in the module) and extra allocations. This dropslocal x(soxis local to each closure) and renames the unconstrained-branchiter_count/_losstoub_iter_count/ub_lossso the dual-branch assignment no longer forces boxing. Behavior is unchanged: u, objective, iteration/feval/geval counts, and callback sequences are bit-identical before vs after on Rosenbrock n=2/10/100 (Julia 1.12.4 and 1.10.12).Regression test (fail before / pass after)
Unconstrained
__solvetyped IR must contain zeroCore.BoxSSA values (lib/OptimizationLBFGSB/test/core_tests.jl).Before (src stashed;
nboxes = 2):After (
nboxes = 0):Before / after performance
Same machine (amdci2),
JULIA_NUM_THREADS=1 taskset -c <core>, BenchmarkTools minima, Rosenbrock withAutoForwardDiff.JET reports targeting
OptimizationLBFGSB: 23 → 11 on both 1.12.4 and 1.10.12.Correctness fingerprint (u, objective, iters/fevals/gevals, full callback sequence) is byte-identical before vs after on both Julias for n=2/10/100.
Test-group tails
OPTIMIZATION_TEST_GROUP=CoreviaPkg.testonlib/OptimizationLBFGSB(Julia 1.12.4):OPTIMIZATION_TEST_GROUP=QAon the same sublibrary:Runic
--checkandtyposclean on the two touched files (already Runic-clean on master; only changed lines reformatted as needed).Not verified
cache.f.cons !== nothing) path still reassigns λ/μ/ρ/θ captured by closures; remaining JET reports (11) were not chased.GROUP=QA/GROUP=Allnot run; only OptimizationLBFGSB Core + QA.LBFGSB.lbfgsbin this job (audit already had parity after the same patch).Reviewer pushback
Core.BoxSSA count (SSA shape can change across Julia versions; it held on 1.10 and 1.12 here).Please ignore until reviewed by @ChrisRackauckas.
Risk assessment
Independent review: Claude Code (claude-opus-5-5) MERGE, risk low (confidence high): u/objective/retcode/iteration counts/callback-sequence hash byte-identical to master across unconstrained, bounded, equality and mixed-constraint cases; n=2 275.1 -> 224.0 us (481 -> 206 allocs), n=10 870 -> 718 us, constrained 90.4 -> 75.7 ms; JET 23 -> 11 (unconstrained). Scope note: the boxes are removed on the unconstrained path; the augmented-Lagrangian branch still captures reassigned λ/μ/ρ (21 Core.Box, from 23).
🤖 Generated with Cursor Agent 2026.10.01-14929f9 (model: unknown (Cursor auto)), transcript /home/crackauc/sandbox/goals/performance/jobs/opt/opt-lbfgsb/log.txt on amdci2; orchestrated by Claude Code (claude-opus-5-5[1m]) https://claude.ai/code/session_01LPHREnnonfLg1VcE1EJovv
Made with Cursor
Independent review: Devin Fusion (fusion-claude-opus-5-5-high-sidekick-swe-2-medium) rated it low, verdict MERGE: #1402 (comment)