Repository navigation
Fix polyalgorithm init+solve! for Simple*/NoInitCache sub-caches (#1348) - #1349
ChrisRackauckas-Claude wants to merge 9 commits into
Conversation
Read u/resid/trace/retcode from sub-solutions returned by solve!, matching __generated_polysolve, instead of probing NoInitCache fields that deliberately do not exist. Also teach InternalAPI.reinit! to forward onto NoInitCache so retain_best escalation works. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9 Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/ibd/NonlinearSolve.jl/jobs/1348-cursor/log.txt on amdci2.julia.csail.mit.edu
Covers the reported FieldError, reinit!, alias_u0, mixed Simple/Newton ladders, and the all-fail residual selection path. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9 Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/ibd/NonlinearSolve.jl/jobs/1348-cursor/log.txt on amdci2.julia.csail.mit.edu
Do not coerce a NoInit winner's `nothing` trace into a sibling stepping
cache's history. Widen `_traceType` to `Union{Nothing,T}` only when a
NoInit sub-cache is present so stepping-only ladders stay inferred.
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/ibd/NonlinearSolve.jl/jobs/1348-cursor/log.txt on amdci2.julia.csail.mit.edu
Cover an immediate Simple* win and a Simple* win after a stepping failure, plus resid/u consistency on the fallback path. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9 Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/ibd/NonlinearSolve.jl/jobs/1348-cursor/log.txt on amdci2.julia.csail.mit.edu
Round-1 review probe: after a Simple* win, parameter-changing reinit!(...; retain_best=true) must not return the unused stepping cache's stale history. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9 Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/NonlinearSolve.jl/jobs/nsi1348c-cursor/log.txt on amdci2.julia.csail.mit.edu
Runtime iteration over the heterogeneous subcache tuple allocated on
every ordinary solve (352 B / 32 B on Julia 1.12). Build `_traceType`
from `fieldtype` of each subcache in the `@generated` body so successful
IIP solves match master's 0 B again, while preserving winner-trace
semantics and NoInit `Union{Nothing,T}` widening.
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9
Agent-Model: auto
Agent-Session: local chat 80ce7063-2ec0-4b6b-9be9-1c7233e907c0, transcript at /home/crackauc/sandbox/agent-jobs/NonlinearSolve.jl/jobs/nsi1348c-cursor/log-followup2.txt on amdci2.julia.csail.mit.edu
State only the measured master IIP allocation budgets and how they are obtained; leave review history to the PR body. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9 Agent-Model: auto Agent-Session: local chat 80ce7063-2ec0-4b6b-9be9-1c7233e907c0, transcript at /home/crackauc/sandbox/agent-jobs/NonlinearSolve.jl/jobs/nsi1348c-cursor/log-followup3.txt on amdci2.julia.csail.mit.edu
Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> 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_NonlinearSolve.jl-1349/log.txt
Merged the default branch into this PR (clean merge, no conflicts; head 5a5296b) 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 |
Independent review (Codex CLI 0.166.0 / gpt-6.1-sol), session 01a19816-2c24-7e51-a248-42c7efb47514, reviewed head 39f57db
Review written by the reviewer named above 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: Fixes cached polyalgorithm solves containing Simple*/NoInitCache methods by reading the returned solutions and forwarding reinitialization. The regression fails on the unfixed base and passes at head; the sole failing CI assertion also fails on current master. Blast radius: CommonSolve.solve!(::NonlinearSolvePolyAlgorithmCache), fallback selection, trace forwarding, and internal reinitialization of NonlinearSolveNoInitCache. No new dependencies or exported API; solver selection and numerical iteration formulas are unchanged. Evidence: Own Julia 1.13.2 runs: added regression file 42/42 at head, but one control passes followed by missing-fu FieldError on the merge base. Analytic square/cube-root and parameter-changing trace/reuse assertions satisfy G1/G3. CI has 96 successful, one failed and three skipped checks; root Core, PolyAlgorithms, Downstream, AD, CUDA and IntegrationTest pass. The failed SCC assertion matches current master's failure exactly. The independent edge probe passes 51/51 and existing inference checks pass 16/16. Blocking findingsNone. Non-blocking findingsNone. What I ran
What I did not verifyNo full package suite, downstream suite, GPU, MPI, reverse-mode AD, alternate Julia version or alternate platform was run locally. Relevant root CUDA/Adjoint and downstream CI checks pass; no GPU/AD/MPI rule or kernel is added or modified. Initialization-failure customization and arbitrary third-party no-init solvers were inspected but not executed. The base run stops at the first cache failure, so it does not establish a before/after result for each later assertion individually. Author context contained an embedded earlier assessment; the initial risk had already been hashed before opening that context, and the dedicated prior review is deferred until the complete independent review is frozen. 🤖 Posted by an AI agent — harness: Claude Code · model: claude-sonnet-5-5 |
PR: #1349 Reviewed head: 39f57db Risk assessment
Review reportVERDICT: CHANGES Riskmedium (M2: the explicit transformed-bounds fallback changes a returned state from unbounded to physical coordinates, verified against the original residual) Blocking findings
Non-blocking findings
What I ran
What I did not verify
AUTHOR_GRADE: {"task":"bugfix","score":2,"difficulty":3,"rounds":5,"author_harness":"Cursor Agent CLI 2026.10.01-14929f9","author_model":"auto","note":"The added regression discriminates for the basic cached Simple solve. Live probes found a stale-parameter crash, cross-stage alias contamination, and lost fallback results."} Head link: 39f57db 🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol |
Please ignore until reviewed by @ChrisRackauckas.
What changed and why
solve!(init(prob, NonlinearSolvePolyAlgorithm((SimpleNewtonRaphson(), SimpleBroyden()))))threwFieldErrorbecause the generated polyalgorithmsolve!probedget_fu/.trace/.retcodeon each sub-cache, whileNonlinearSolveNoInitCache(used by every Simple* algorithm) deliberately has none of those fields. The fix mirrors the working one-shot__generated_polysolvepath: after eachCommonSolve.solve!(subcache), readu,resid,trace, andretcodefrom the returnedNonlinearSolution. Prototype_fuTypecomes from a stepping sibling when present, otherwise fromevaluate_f(prob, u0). The selected sub-solution's actualtraceis forwarded (includingnothing)._traceTypeis chosen statically in the@generatedbody from each subcache'sfieldtype(widening withNothingonly when a NoInit sibling is present), so heterogeneous tuple iteration does not allocate on ordinary solves.::ReturnCode.Tasserts are kept for Julia 1.10 inference (same intent as #1347).InternalAPI.reinit!forwards ontoNonlinearSolveNoInitCachesoretain_bestescalation can refresh those sub-caches.This PR supersedes #1347's change. Both edit the same generated
solve!retcode read; this PR assertssol.retcode::ReturnCode.Tfrom the sub-solution. Restoringcache.caches[idx].retcodewould report a NoInit cache's initialization status instead of the actual sub-solve outcome.Fail before / pass after
FieldError on master for Simple*
init+solve!; with the fix, issue regressions pass (including winner-trace fidelity and retain_best reinit). Round-2 found a runtime_polyalg_solve_trace_typescan that made ordinary IIP solves allocate (0→352 B / 0→32 B on 1.12); that helper is gone and successful-solve allocations again match master.Verification
Remeasured allocations (
probe.jl, 12 warmed@allocated solve!,reinit!outside)Successful solves (must match master; now do):
OOP successful solves also match master exactly on both versions.
Failure-path deltas vs master (not claimed allocation-neutral):
At intermediate head
db2d1950, successful IIP solves on 1.12 were 352 B / 32 B over master; that regression is fixed here.CI status note
Known master-also sublibrary failures remain (FirstOrder Core/QA, Base QA, SCC Core). Documentation currently passes on this PR (earlier curl-28 linkcheck timeout was transient).
Not verified
GROUP=Core/PolyAlgorithmson this exact commit (issue file + inference + NonlinearSolveBase Core + probe were run).Risk assessment
CommonSolve.solve!(::NonlinearSolvePolyAlgorithmCache)andInternalAPI.reinit!(::NonlinearSolveNoInitCache).Fixes #1348
Please ignore this draft until reviewed by @ChrisRackauckas.
Initial NoInitCache
solve!fix and Simple* regressions: Cursor Agent / auto (job 1348-cursor). Round-1 retain_best regression and round-2 static_traceType/ allocation fix: Cursor Agent CLI 2026.10.01-14929f9 / auto (job nsi1348c-cursor, chat 80ce7063-2ec0-4b6b-9be9-1c7233e907c0). Transcript: /log-followup2.txt. A separate Devin checkout explored an earlier helper variant; the commits on this PR are from Cursor Agent.Risk assessment (independent review, codex-cli gpt-6-astra, reviewed head 39f57db)
JULIA_NUM_THREADS=4 julia +release --project=env1349 run1349.jl: 42/42 assertions passed, including reinit, retain_best, mixed ladders, failure selection, trace identity and warmed allocation budgets. Ranjulia +release --project=env1349 inference1349.jl: solve inference 8/8, solve! inference 8/8. Ranjulia +release --project=envmaster baseline.jlon default-branch dd8a550: issue reproducer throws FieldError for missing NoInitCache.fu. Julia 1.13.2, four threads, local test environments/depot. CI currently 18 pass, 79 pending, 1 skipped, no failing PR jobs.🤖 Posted by an AI agent — harness: codex-cli · model: gpt-6-astra (independent reviewer; appended by Claude Code 2.1.301 · claude-opus-5-5)
Conversation: https://claude.ai/code/session_01VZjwf7Ux9YtTzwHGHMqnsq