Repository navigation
OptimizationOptimJL: default extended_trace to false - #1406
Draft
ChrisRackauckas-Claude wants to merge 1 commit into
Draft
ChrisRackauckas-Claude wants to merge 1 commit into
ChrisRackauckas-Claude wants to merge 1 commit into
Conversation
Forcing extended_trace=true made Optim allocate per-iteration Dicts with copies of x, g(x), and ~inv(H); nothing in the wrapper reads that metadata. Default false (opt-in via kwargs) cuts BFGS n=100 solve memory ~42 MB → ~0.6 MB. 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-trace/log.txt on amdci2
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
__map_optimizer_argsalways passedextended_trace = trueintoOptim.Options, so every Optim iteration built a metadataDictwith copies ofx,g(x), and (for BFGS) the fulln×n~inv(H)— even though OptimizationOptimJL never reads that trace (callbacks useoptim_statefields). This defaultsextended_tracetofalsewhile still allowing opt-in viasolve(...; extended_trace=true)through the existing kwargs passthrough. The docs already sayextended_trace"Defaults tofalse" (docs/src/optimization_packages/optim.md:45); this change makes the code match the docs.User-visible change: with
store_trace=true, eachsol.original.traceentry's metadata now keeps only"time"by default. In addition to losingx/g(x)/~inv(H), BFGS also loses"Current step size", and NelderMead loses"centroid"and"step_type". Passingextended_trace=truerestores everything. The printedshow_trace=true/verbose=trueoutput changes the same way (e.g. BFGS no longer prints~inv(H)).Performance (BenchmarkTools minima,
JULIA_NUM_THREADS=1 taskset -c 96)Rosenbrock +
AutoForwardDiff, same machine (amdci2).Julia 1.12.4
Julia 1.10.12
Matches auditor A/B (BFGS n=100: 18.26 ms / 42.0 MB → 13.05 ms / 0.61 MB on 1.12).
Regression test
New
@testset "extended_trace defaults to false"inlib/OptimizationOptimJL/test/core_tests.jl:git stashof src): 5 pass / 3 fail (metadata still hasx/g(x)/~inv(H)).Callback parity
Captured
OptimizationState(u,objective,grad, loss) for LBFGS / BFGS / Newton / IPNewton over 10 iters: identical master vs this PR.Test-group tails
OPTIMIZATION_TEST_GROUP=Core(1.12.4):Core | 6977 Pass / 6977 Total; tests passedOPTIMIZATION_TEST_GROUP=Core(1.10.12):Core | 6977 Pass / 6977 Total; tests passedOPTIMIZATION_TEST_GROUP=QA(1.12.4):Quality Assurance | 54 Pass, 1 Broken / 55 Total; tests passed (broken is pre-existing ExplicitImports)typoson touched files: clean (files were Runic-clean on master)Not verified
GROUP=QA/GROUP=All(never run per policy).store_trace=truealone.Reviewer pushback
store_trace=trueimplicitly getting extended metadata (x/g(x)/~inv(H), BFGS"Current step size", NelderMead"centroid"/"step_type") or the matchingshow_trace/verboselines withoutextended_trace=true? Docs already saidextended_tracedefaults tofalse.extended_tracefrommapped_argsentirely (let Optim's default apply) instead of settingfalseexplicitly? Behavior is the same today because kwargs override.Please ignore until reviewed by @ChrisRackauckas.
Risk assessment
Independent review: MERGE (Claude Code, Opus 5.5) — low risk; callback parity holds; memory 42 → 0.6 MB. Pending @ChrisRackauckas.
🤖 Generated with Cursor Agent 2026.10.01-14929f9 (model: unknown (Cursor auto)), transcript /home/crackauc/sandbox/goals/performance/jobs/opt/opt-trace/log.txt on amdci2; orchestrated by Claude Code (claude-opus-5-5[1m]) https://claude.ai/code/session_01LPHREnnonfLg1VcE1EJovv