Repository navigation
Fix silent lcons/ucons length mismatch and undef constraint buffers - #1403
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
Zero-initialize OOP constraint buffers used for AD Jacobians so undersized cons! writes cannot leak undef memory into solvers, and reject mismatched lcons/ucons lengths with a clear ArgumentError in _check_opt_alg. 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-cons/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
When
cons!writes fewer entries thanlength(ucons), the DifferentiationInterface out-of-place constraint wrappers allocatedVector{T}(undef, num_cons), leaving garbage in unwritten slots that Ipopt/IPNewton can turn into silent Failure/NaN results. Those wrappers now use zero-initialized buffers (dense and sparse paths). Separately, mismatchedlcons/uconslengths were accepted by SciMLBase and then silently broadcast or crashed opaquely in solvers;_check_opt_algnow throws a clearArgumentErrorwhen both are provided with different lengths (both-nothingand existing one-missing checks unchanged).Regression evidence
61 passed, 6 failed—_check_opt_alg missing lcons/ucons4 fail; zero-init buffer test failed withJ[3,:] == [2.0e-323, 6.9e-310]style garbage. Logs:opt-cons/before.txt.67 passed(Testing OptimizationBase tests passed). Logs:opt-cons/after.txt.Test-group tails
OPTIMIZATION_TEST_GROUP=Core/Pkg.test(OptimizationBase):Test Summary: Core | Pass 67 Total 67— tests passedOPTIMIZATION_TEST_GROUP=QAon OptimizationBase:Test Summary: QA | Pass 20 Broken 1 Total 21— tests passedGROUP=QA/Pkg.test(Optimization):Test Summary: QA | Pass 21 Total 21— tests passed--inplace+typoson touched files: cleanWhat was NOT verified
a3_safety.jlafter the fix (unit regressions cover the two root causes).Array{Num}(undef, num_cons)path (different type; not the float-garbage AD path).Reviewer pushback
num_consexceeds whatcons!writes (masks a user bug as constraint value 0), or should we also warn/error on write undercount?OptimizationProblemconstruction in SciMLBase instead of only onsolve/init?Please ignore until reviewed by @ChrisRackauckas.
Risk assessment
Independent review: Claude Code (claude-opus-5-5) MERGE, risk low (confidence medium-high): every valid constraint path (inequality, equality, mixed; MOI-Ipopt, OptimizationIpopt, IPNewton, AugLag, LBFGSB; unconstrained) gives identical results to master; zero-fill has no measurable cost. Deliberate tightening: the lcons/ucons length check now rejects mismatched lengths even when they were previously tolerated (e.g. lcons length 1 with ucons length 2 through MOI-Ipopt, or bounds given without a constraint function); both are malformed inputs and no in-repo usage relies on them.
🤖 Generated with Cursor Agent 2026.10.01-14929f9 (model: unknown (Cursor auto)), transcript /home/crackauc/sandbox/goals/performance/jobs/opt/opt-cons/log.txt on amdci2; orchestrated by Claude Code (claude-opus-5-5[1m]) https://claude.ai/code/session_01LPHREnnonfLg1VcE1EJovv
Made with Cursor