Repository navigation
Make NonlinearSolution's retcode field type a parameter - #1620
Merged
ChrisRackauckas merged 3 commits intoSep 26, 2026
Merged
ChrisRackauckas merged 3 commits into
ChrisRackauckas merged 3 commits into
Conversation
`NonlinearSolution.retcode` was declared `::ReturnCode.T`, so a return code carried by another scalar type (e.g. a Reactant `TracedEnum` produced inside a compiled solver loop) cannot be stored in it. Mirror the ODESolution change (SciML#1564): the field becomes `retcode::RC` with `RC` a new trailing type parameter, and `solution_new_retcode` gains a `NonlinearSolution` method that preserves the carrier type. A `NonlinearSolution{T,N,uType,R,P,A,O,uType2,S,Tr}` type application now denotes a non-callable UnionAll, so a constructor covering that ten-parameter spelling keeps downstream code that spells out the parameters working, inferring `RC` from the `retcode` argument. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Devin <noreply@cognition.ai> Agent-Harness: Devin CLI 3000.11.3 Agent-Model: swe-2-high Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/SciMLBase.jl/jobs/1619-devin/log.txt on amdci2.julia.csail.mit.edu
The compatibility constructor keeps every existing public spelling and call working. The only observed downstream effect is a concreteness assertion on SCCNonlinearSolve's internal `sols` buffer (a performance property of its own code, not a public-API break), and the identical ODESolution change in SciML#1564 shipped as a minor release. Leave the version untouched per project policy for behavior-preserving changes. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Devin <noreply@cognition.ai> Agent-Harness: Devin CLI 3000.11.3 Agent-Model: swe-2-high Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/SciMLBase.jl/jobs/1619-devin/log.txt on amdci2.julia.csail.mit.edu
State the constructibility invariant without naming an external call site, matching the package comment convention. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Cursor Agent <noreply@cursor.com> Agent-Harness: Cursor Agent CLI 2026.09.26-dd393fe Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/NonlinearSolve.jl/jobs/1332-cursor/log.txt on amdci2.julia.csail.mit.edu
ChrisRackauckas
marked this pull request as ready for review
September 26, 2026 20:59
ChrisRackauckas
referenced
this pull request
Sep 29, 2026
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.
Please ignore this draft until reviewed by @ChrisRackauckas.
What changed and why
NonlinearSolution.retcodewas declared::ReturnCode.T, so a return code carried by another scalar type (e.g. a ReactantTracedEnumproduced inside a compiled solver loop) cannot be stored in it. This mirrors theODESolutionchange from #1564 (released as minor v3.56.0): the field becomesretcode::RCwithRCa new trailing type parameter,solution_new_retcodegains aNonlinearSolutionmethod that preserves the carrier type, andsuccessful_retcode's existing convertible-carrier fallback applies. Positional andbuild_solutionconstructors are unchanged for ordinaryReturnCode.Tvalues, and no version bump is included per project policy.Because appending
RCturns the ten-parameter spellingNonlinearSolution{T,N,uType,R,P,A,O,uType2,S,Tr}into a non-callableUnionAll, a constructor covering that spelling is added; it takesRCfrom theretcodeargument. Unlike #1563 (which failed released NonlinearSolve precompilation), released downstream code that constructs with all parameters spelled out keeps working — verified below.This change is non-breaking for ordinary constructors. SciML/NonlinearSolve.jl#1332 keeps vector-form SCC users' legacy ten-parameter
FunctionWrappercallbacks converting by matching the declaredSubArrayelement type (including when the legacy wrapper is not the first element of a mixedAny[...]container).Merge/release only after SciML/NonlinearSolve.jl#1332 is merged and released. Otherwise NonlinearSolve.jl's SCC CI goes red on the next SciMLBase release.
Test evidence
New testset
NonlinearSolution retcode type parameterintest/solution_interface.jl. Negative control — samesolution_new_retcodecall on unmodifiedorigin/mastersource (src/solutions/nonlinear_solutions.jlchecked out from master, everything else identical):With this branch the same script prints
retcode fieldtype: Base.RefValue{SciMLBase.ReturnCode.T}, and the full new testset passes insideGROUP=Corebelow.Local test runs (Julia 1.12.7,
Pkg.test())Re-run on this head from job scratch (
agent/1619-nonlinear-retcode-param):GROUP=Core:GROUP=QA(JULIA_CONDAPKG_BACKEND=Null JULIA_PYTHONCALL_EXE=/usr/bin/python3):Lint/format on touched files (incl. comment-only follow-up
2fe56b4d): Runic 0, typos 0.Downstream compatibility
isconcretetype(eltype(scc_sol_debug.original))incore_tests__item4.jl(72 pass / 1 fail / 73). Correctu/ Success retcodes; the ten-parameter spelling is a UnionAll, so the buffer/originaleltype is abstract. Same concreteness trade-off as #1564. Fixed by SciML/NonlinearSolve.jl#1332.NonlinearSolutiontypeoriginal(correct results, loses concreteness) until #1332 is released.Any[plain, legacy_FW](14/14 in item8).Why non-breaking
Every public spelling and call path is preserved: the generic constructor,
build_solution,::NonlinearSolutionannotations, and ten-parameter spelled constructor calls (via the compat method). The observable residual is thatNonlinearSolution{10 params}denotes aUnionAllrather than a concrete type — the same accepted trade-off as the trailing-RCchange toODESolutionin #1564 (minor v3.56.0). Companion #1332 restores concrete eltype for the updated SCC signature and preserves legacy wrapper conversion.Not verified
GROUP=Downstream/DownstreamAD/Python; docs build (no docstring changes).Reviewer push-back points
NonlinearSolution{...,RC}(args...)still uses the default inner constructor.Closes #1619
Please ignore this draft until reviewed by @ChrisRackauckas.
Devin CLI 3000.11.3 (original) + Cursor Agent CLI 2026.09.26-dd393fe, model auto (round-2 text/comment + #1332 companion). Transcript: /home/crackauc/sandbox/agent-jobs/NonlinearSolve.jl/jobs/1332-cursor/log.txt on amdci2.julia.csail.mit.edu