Repository navigation
test: cover multi-objective optimization acceptance cases - #5196
Draft
ChrisRackauckas-Claude wants to merge 6 commits into
Draft
ChrisRackauckas-Claude wants to merge 6 commits into
ChrisRackauckas-Claude wants to merge 6 commits into
Conversation
Exercise multi-objective costs and their Jacobian with array unknowns, compare weighted scalarization to the objective dot product, and solve a textbook two-objective problem on its known Pareto front. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.156.1 Agent-Model: gpt-6-luna Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/ModelingToolkit.jl/jobs/5150-opencode/log-cont1.txt on amdci2.julia.csail.mit.edu
Drop the seed-fragile Pareto front claim, pin NSGA-II via StableRNG on a bounded off-front problem, assert array-unknown Jacobian values, and declare Random/SciMLBase/StableRNGs plus OptimizationEvolutionary ≥ 0.4.13. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Cursor Agent <noreply@cursor.com> Agent-Harness: Cursor Agent CLI 2026.09.18-9a7762b Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/ModelingToolkit.jl/jobs/5150-opencode/log-cont2.txt on amdci2.julia.csail.mit.edu
…problem Array-unknown 1D Poisson least-squares with Tikhonov regularization: the multi-objective costs and Jacobian match analytic values, the weighted objective equals dot(weights, costs), and the LBFGS minimizer of the weighted problem matches the normal-equations solution and is stationary for weights' * J. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude <noreply@anthropic.com> Agent-Harness: Claude Code 2.1.280 Agent-Model: claude-opus-5-5 Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/ModelingToolkit.jl/jobs/5150-opencode/log-cont3.txt on amdci2.julia.csail.mit.edu
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Devin <noreply@cognition.ai> Agent-Harness: Devin CLI 3000.11.3 (conflict resolution), Claude Code 2.1.285 (orchestration) Agent-Model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium Agent-Session: local Claude session 3c311569-dda6-4687-bc9f-65febb212c33 (fleet master); Devin log /Users/chrisrackauckas/sandbox/master/fusion-fixes/SciML_ModelingToolkit.jl-5196/log.txt
Member
Merged the default branch into this PR (clean merge, no conflicts; head 4e98ad5) so CI runs on current master. 🤖 Posted by an AI agent — harness: Devin CLI 3000.11.3 (merge), Claude Code 2.1.285 (posting) · model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium |
`calculate_cost_gradient`, `calculate_cost_hessian` and `calculate_multiobjective_hessian` now differentiate the cost after `expand_dims_reductions` and `Symbolics.scalarize`, the preparation `canonical_constraints` already gives constraint rows. `Symbolics.gradient` and `Symbolics.sparsehessian` throw for unknowns inside a lazy array reduction nested in a scalar expression such as `2 * sum(A * x)`, so `OptimizationProblem(sys, op; grad = true)` failed for such costs (SciML#5199) and the Poisson acceptance test failed with registered Symbolics 7.45.0. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Agent-Harness: Claude Code 2.1.301 Agent-Model: claude-opus-5-5 Agent-Session: local session ID b63bd656-b711-4e26-b5d7-ba573f27b567 (headless claude -p, no URL)
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.
This test-only PR covers the existing multi-objective
OptimizationProblem(sys, op; multiobjective = true)API: individual costs, analytic Jacobians with whole array unknowns, weighted-sum agreement, and a discretized Poisson weighted solve checked against normal equations and the cost-vector Jacobian. A bounded NSGA-II test checks that OptimizationEvolutionary consumes the generated objectives.Depends on JuliaSymbolics/Symbolics.jl#2013, which fixes the hash-order-dependent nested-reduction gradient failure tracked in #5199. The unchanged Poisson test now passes locally on both Julia LTS and 1.11 using that Symbolics checkout. Keep this draft blocked until the Symbolics fix is reviewed, merged, and released, then raise the relevant dependency floor and validate with the released dependency. A cross-repository dependency cannot be expressed as this Git branch's base; the base remains MTK
master.OptimizationEvolutionary/Evolutionary and StableRNGs are MIT-licensed test dependencies. No production source or public API changes in this MTK PR.
Verification
From the MTK repository root, with
TMPDIRset to the job tmp directory,OPENBLAS_NUM_THREADS=4, and a job-local writable depot followed by the shared dependency depot:The scratch environment develops MTK from this branch and Symbolics at
eff957511cd194d5586972ebf377d281a1c59e60; it uses SymbolicUtils 4.47.2. These are tests of the proposed upstream fix, not a claim that registered dependencies already work.Before the Symbolics fix, round-2 review reproduced 94 passes and 1 error twice on Julia 1.10.12:
The upstream PR includes a standalone regression that fails on clean Symbolics master on both versions (6 pass, 1 failure, 6 errors), then passes with the fix (13/13); its full differentiation test file passes 380/380 on each version.
Earlier verification retained from this PR and its round-2 review:
Limits and reviewer notes
GROUP=Optimizationremains unverified: Pyomo/CasADi precompilation raisesLookupError: no codec search functions registeredin the local environment.Part of #5150.
Please ignore this draft until reviewed by @ChrisRackauckas.
Links
Risk assessment
<local>/REVIEW.md.🤖 Updated with Codex CLI 0.157.1 (model: gpt-6-astra); local session, transcript at /log-cont5.txt. Earlier branch commits retain their opencode, Cursor, and Claude Code attribution.
Review findings addressed
calculate_cost_gradient,calculate_cost_hessianandcalculate_multiobjective_hessiannow differentiateSymbolics.scalarize(expand_dims_reductions(obj))(internal helperdifferentiable_costinlib/ModelingToolkitBase/src/systems/codegen.jl). That is the preparationcanonical_constraintsalready gives constraint rows, and the remedy Symbolics' own error message prescribes. The Poisson testset is unchanged: the array cost,grad = trueand the gradient assertion are all retained. A new testset,derivatives of costs with array reductions nested in scalar expressions, uses2 * sum(A * x). It fails deterministically with registered Symbolics, unlike the Poisson case, which depends on hash order (see verification).This supersedes two statements above:
codegen.jl. No public name is added, removed or re-signatured.Symbolics.gradientandSymbolics.sparsehessiancallers.The cost path of #5199 is covered. Constraint Hessians of scalar constraints containing nested lazy reductions are not changed here.
Verification (registered dependencies: Symbolics 7.45.0, SymbolicUtils 4.51.0, OptimizationEvolutionary 0.4.14; Julia 1.10.12)
multiobjective.jlrun alone in an environment with those registered versions. First without thecodegen.jlchange, then with it:In a first environment, which resolved OptimizationEvolutionary 0.4.10 (below this PR's compat floor), the unfixed Poisson testset reproduced the reviewer's error: 3 pass, 1 error. In the second environment, with 0.4.14 and a recompiled cache, the unfixed Poisson testset passed 6/6. That is the hash-order dependence described in issue 5199, and it is why the deterministic testset was added.
Each changed call site fails on its own without the change. With the registered versions, raw
Symbolics.gradient(cost(sys), dvs),Symbolics.sparsehessian(cost(sys), dvs)andSymbolics.sparsehessian(costs(sys)[i], dvs)all throw the error above for that system.calculate_cost_gradient,calculate_cost_hessian(; sparse = true)andcalculate_multiobjective_hessian(; sparse = true)succeed.GROUP=Optimization julia +1.10 --project -e 'using Pkg; Pkg.test()'inlib/ModelingToolkitBase(realtest/optimizationenvironment, Symbolics 7.45.0):dynamic_optimization.jlwas then rerun alone in the same environment with a fresh conda package cache:Julia 1.13.0,
multiobjective.jlalone, with registered Symbolics 7.46.0 (newer than the 7.45.0 used by the review), SymbolicUtils 4.51.0:MultiObjective Optimization | Pass 107 Total 107. Symbolics 7.46.0 still throws for the rawSymbolics.gradientandSymbolics.sparsehessiancalls above, so the latest release also needs this change.Runic (
--check) and typos on both changed files: exit 0.Not verified
Risk assessment (for the commit added in this round)
OptimizationFunction/OptimizationProblem(grad,hess, orsparse = true, which builds the Hessian prototype) and forMultiObjectiveOptimizationFunction(hess,sparse).grad,hess, sparse Hessians) pass unchanged.fb613e7955.🤖 Posted by an AI agent — harness: Claude Code 2.1.301 · model: claude-opus-5-5
Conversation: local session ID b63bd656-b711-4e26-b5d7-ba573f27b567 (headless, no URL)
Risk assessment (independent review, Codex gpt-6.1-sol, head 4f2b48c)
git diff origin/HEAD...HEAD, and the relevant callers and dependency APIs.git diff --check origin/HEAD...HEADpassed; the checkout remains clean. Targeted local results and CI comparisons follow. G1 pass: hand-derived gradient/Hessian formulas, the Poisson normal-equation solution, and independent dimensioned-reduction checks. G2 not applicable: no GPU kernels, AD rules, Reactant tracing, or MPI implementation paths change; symbolic differentiation is not an AD backend rule change. G3 not applicable: no shared-state/cache/threading/default implementation changes.All local Julia runs used Julia 1.10.12, the requested job-local depot followed by
$HOME/.julia, four Julia threads, four BLAS threads, disabled automatic package precompilation, scratch-local TMPDIR, a 3600-second timeout, and one launched Julia process at a time. The commands were:test-head.jlincludes the exact committedmultiobjective.jl: 107 passed, exit 0, 6m55.2s, with registered Symbolics 7.45.0, SymbolicUtils 4.51.0 and OptimizationEvolutionary 0.4.15. The separate dimensioned-reduction probe passed 8/8, exit 0, with those dependencies.For the same committed regression testset extracted to
new-regression.jl, using registered Symbolics 7.45.0 / SymbolicUtils 4.47.2 / Moshi 0.3.9 on both sides:The independent probe uses
sum(abs2, sum(x; dims=1))atx = [1 3; 2 4]. Base evaluates the objective as 58 but generates gradient[20,20,20,20]; head produces the analytic[6,6,14,14]. Integer dimensions 1 and 2, with scalar multipliers 1 and 2, all pass on head. The exploratory older-dependency command exits 1 because four additional tuple-dimscases fail during expression construction: SymbolicUtils 4.47.2 does not accept tuple dimensions. The same constructor errors occur on base; they are not a PR regression. Its relevant head testsets report 10 committed-regression passes plus four integer-dimension passes. The combined base command exits 1 with two assertion failures and eight errors, including those same four unsupported tuple cases. Logs are inscratch/head.log,head-probe.log,head-old-probe.log, andbase.log.The reported CI problems were checked against actual default-branch logs, not accepted from the PR description:
[:linkcheck]termination.BoundsErrors atcomprehensive_indexing.jl:127,164. A separate read-only baseline investigation also confirmed identical older default failures. It could not identify an introducing commit because historical jobs float the downstream checkout, dependency resolution, and Julia version.🤖 Posted by an AI agent — harness: Codex CLI 0.162.1 · model: gpt-6.1-sol
Conversation: local headless review run (no public session URL); transcript kept by the fleet master.
Risk assessment (independent review, Codex CLI 0.164.0 gpt-6.1-sol, slot 1, head 4f2b48c)
Review round 2, written by the reviewer named above (Codex CLI 0.164.0 / gpt-6.1-sol) in a session other than the PR author's, and copied here by the posting agent without change to its findings. The posting agent did not re-run the reviewer's commands.
Summary: Scalarizes nested cost reductions before differentiation and adds multiobjective acceptance tests. The complete changed file passes locally with analytic derivative and independent Poisson references, while the target base errors on the added nested-reduction cases.
Blast radius: calculate_cost_gradient, calculate_cost_hessian, multiobjective Hessians and optimization test integration.
Evidence: Julia 1.13.2: the complete head multiobjective.jl passes 107/107 assertions, including 10 nested-reduction derivative checks, six Poisson checks and 51 seeded NSGA-II consumption assertions. On origin/master the new nested-reduction testset errors twice after the earlier testsets pass. G1 uses exact quadratic gradients/Hessians and a separately solved Poisson normal equation; G2 is exercised locally and in the previously inspected Optimization CI. G3 does not apply to this stateless differentiation change; NSGA-II assertions are not claimed as a Pareto convergence study. The description remains inaccurate about production source scope.
Blocking findings
None.
Non-blocking findings
What I ran
First-round read-only inspection, retained for this unchanged head. Repository commands below ran in the isolated checkout and exited 0; rev-parse HEAD matched the live head metadata. Base is the fetched target-branch tip at review time, while the three-dot diff uses the merge base. Newest non-merge commit trailers, rather than body attribution, supply AUTHOR_GRADE provenance.
Read-only GitHub inspection (PR views exit 0; pr checks exits 1 because failures exist):
CI check rollup at the captured head: {"CANCELLED": 1, "FAILURE": 2, "SKIPPED": 3, "SUCCESS": 105}. Log-retrieval exit codes are retrieval status, not test exit codes: successful retrieved jobs report
tests passed; failed jobs remain failed. Failed-run logs were retrieved with a writable scratch XDG_CACHE_HOME. Unavailable logs are disclosed above. The recent default-branch five-run listing was also read; exact historical comparisons are identified in the evidence paragraph.MTKBase Optimization CI log reports MultiObjective Optimization 107/107 and package tests passed. Exact analytic quadratic derivatives and the independent Poisson normal-equation solution are asserted. Docs and SII failures match historical master 38846662245/38846662285 signatures. The author's Symbolics-development prerequisite narrative is stale relative to the current MTK workaround; no private dependency checkout was used by this reviewer.
Inspected CI URLs: https://github.com/SciML/ModelingToolkit.jl/actions/runs/38913763435, https://github.com/SciML/ModelingToolkit.jl/actions/runs/38913763498, https://github.com/SciML/ModelingToolkit.jl/actions/runs/38913764407/job/117213585102, https://github.com/SciML/ModelingToolkit.jl/actions/runs/38846662245, https://github.com/SciML/ModelingToolkit.jl/actions/runs/38846662285.
Round 2 local execution:
All 20 live PRs were checked OPEN with unchanged reviewed heads before Julia execution. Each run checked out the exact detached SHA shown below. Julia 1.13.2 ran directly inside the inherited resource scope, with one Julia invocation at a time, four Julia threads and one BLAS thread. The isolated environment was created with
Pkg.activate(temp=true)andPkg.develop(path=...)for the checkout and its MTKBase subpackage, then persisted outside the checkout for dependency reuse. No test project or source was edited in the checkout.The driver activates that environment, resolves compatible registered dependencies without updating registries, and includes each selected script in a fresh module. It catches only at the test-file boundary to record every selected result, then exits nonzero if any selected case failed. Assertions and tolerances are unchanged.
--compiled-modules=existingreuses available dependency caches and loads uncached PR source; it does not disable tests.base-master-basecontext-retry: detached550a27cca63cbe6d7b64bcb2920440aaff9eaa55(origin/master), process exit 1, 311.21 s.Resolved versions: SymbolicUtils 4.54.0, Symbolics 7.47.0, SciMLBase 3.58.0, JumpProcesses 10.0.1, NonlinearSolve 4.32.0, ModelingToolkit 11.47.0, ModelingToolkitTearing 1.20.7, ModelingToolkitBase 1.79.0, OptimizationBase 5.10.0.
head-5196: detached4f2b48ce35e6fd93a3e74dc7acc3bd4f34000498(pr/5196), process exit 0, 153.25 s.Resolved versions: SymbolicUtils 4.54.0, Symbolics 7.47.0, SciMLBase 3.58.0, JumpProcesses 9.33.1, NonlinearSolve 4.32.0, ModelingToolkit 11.45.4, ModelingToolkitTearing 1.20.7, ModelingToolkitBase 1.77.4, OptimizationBase 5.10.0.
Exported the full
lib/ModelingToolkitBase/test/optimization/multiobjective.jlfrom the PR and included it unchanged on both refs. Base: earlier 4+5+9+5+8+5 assertions pass, then the added nested-reduction derivative block errors twice and stops the file. Head: testset counts 4+5+9+5+8+5+10+6+51+4 = 107 passes,CASE_PASS 5196, process exit 0. All packages resolve from registered dependencies; no Symbolics development checkout was used.What I did not verify
No whole suite, GPU, Reactant, MPI or exhaustive optimizer/AD-backend matrix was run. The complete changed multiobjective file and its generated derivatives were executed. The seeded stochastic test checks that the optimizer consumes generated objectives; it is not an independent claim of global Pareto convergence. A clean native-precompile cycle was not verified: the initial batch dependency workload errored during NonlinearSolveFirstOrder AD-backend selection. The recorded test commands use existing caches and JIT-load uncached PR source; no assertion was disabled.
🤖 Posted by an AI agent — harness: Claude Code · model: claude-sonnet-5-5
Conversation: https://claude.ai/code/session_01379heiiB35TtywhR7uSU74