Repository navigation
Resize the member caches of a CompositeCache in a DDEIntegrator - #4958
singhharsh1708 wants to merge 7 commits into
Conversation
PR: #4958 Reviewed head: d436d9c Risk assessment
Review reportVERDICT: CHANGES Riskmedium (M1: a new specialization of DiffEqBase.resize_non_user_cache! changes dispatch for existing composite DDE integrators). Blocking findings
[P2] Preserve each member's AD backend when resizing its cache — The new loop passes the whole composite integrator to each cache's resize helper. Reading Runnable reproduction in the resolved test environment: using DelayDiffEq, OrdinaryDiffEqRosenbrock
using OrdinaryDiffEqCore: CompositeAlgorithm
using ADTypes: AutoFiniteDiff
f!(du, u, h, p, t) = (du .= -1000 .* (u .- 0.5); nothing)
prob = DDEProblem(f!, [1.0], (p, t) -> [0.5], (0.0, 0.1);
constant_lags = [1.0])
alg = CompositeAlgorithm((Rosenbrock23(autodiff = AutoFiniteDiff()),
Rosenbrock23()), _ -> 1)
integ = init(prob, MethodOfSteps(alg))
step!(integ)
resize!(integ, 1) # MethodError on this headNon-blocking findingsNone established. What I ran
What I did not verify
AUTHOR_GRADE: {"task": "bugfix", "score": 3, "difficulty": 2, "rounds": 1, "author_harness": "unknown", "author_model": "unknown", "note": "The original bug has failing-before/passing-after evidence and the affected group passes. A targeted head/control comparison confirms a newly introduced mixed-AD-backend regression even for same-size resizing."} Head link: d436d9c 🤖 Posted by an AI agent — harness: codex-cli 0.164.0 · model: gpt-6.1-sol |
@singhharsh1708 The PR body has no risk assessment, and the only review on record (2026-11-13) is for an older head. At Please add this block to the PR description, filled in for this change, so a fresh review can rate it: The change resizes the member caches of a 🤖 Posted by an AI agent — harness: Claude Code 2.1.325 · model: claude-sonnet-5-5 |
PR: #4958 Reviewed head: a8fca87 Risk assessment
Review reportVERDICT: CHANGES Riskmedium-low (ML4: raises OrdinaryDiffEqDifferentiation compat lower bounds to 3.13.1 in DelayDiffEq and OrdinaryDiffEqRosenbrock; reaches peripheral composite-integrator resize paths and adds backward-compatible optional alg arguments to public developer resize helpers without changing default ODE or DDE stepping) Blocking findings
[P2] Resize This regresses composite DDE solves that succeeded before this PR:
Runnable reproduction in the using DelayDiffEq, OrdinaryDiffEqTsit5, OrdinaryDiffEqRosenbrock
using LinearSolve: KrylovJL_GMRES
f_nonstiff!(du, u, h, p, t) = (du .= -1.0 .* (u .- 0.5); nothing)
prob = DDEProblem(f_nonstiff!, [1.0], (p, t) -> [0.5], (0.0, 0.5); constant_lags = [1.0])
integ = init(prob, MethodOfSteps(AutoTsit5(Rosenbrock23(linsolve = KrylovJL_GMRES()))))
step!(integ) # active member is Tsit5 (integ.cache.current == 1)
resize!(integ, 2) # throws MethodError: no method matching similar(::JVPCache, ::Int64, ::Int64)Suggested fix (verified at runtime in a scratch harness without modifying the checkout): replace Non-blocking findings
What I ran
What I did not verify
AUTHOR_GRADE: {"task": "bugfix", "score": 3, "difficulty": 2, "rounds": 4, "author_harness": "unknown", "author_model": "unknown", "note": "The delta cleanly resolves the Round 1 mixed-AD-backend bug across OrdinaryDiffEqDifferentiation, OrdinaryDiffEqRosenbrock, and dense DelayDiffEq composite caches, and wires resize_J_W! for matrix-free composite ODE members, but leaves DelayDiffEq's RosenbrockMutableCache resize path calling similar(cache.J, i, i) and similar(cache.W, i, i), causing composite DDE integrators with matrix-free Rosenbrock members to regress with MethodError on resize!."} Head link: a8fca87 🤖 Posted by an AI agent — harness: Antigravity CLI 1.5.10 · model: gemini-4-carbon-high |
|
Fixed in 7c7ea2d: the DDE Rosenbrock resize now goes through resize_J_W!(cache, integrator, i, cache.alg), so matrix-free members resize (single and composite, which threw before); the Krylov composites and the AutoTsit5 reproducer are in resize.jl. |
DelayDiffEq only resized the Jacobian config of a
RosenbrockMutableCacheand fell through to a no-op for anything else, so a Rosenbrock member of aCompositeCachekept its old config. ADDEIntegratormethod forCompositeCachenow forwards to each member, as OrdinaryDiffEqCore does forODEIntegrator.Resizing a composite whose members use different AD backends then threw
Cannot convert ... JacobianPrep, in ODE as well as DDE and already on master:resize_jac_config!,resize_grad_config!andresize_J_W!took the backend fromalg_autodiff(integrator.alg), which for a composite is the last member's. They now take analgargument (defaulting tointegrator.alg) and the Rosenbrock and DDE resize methods pass each member'scache.alg. Fixing it inalg_autodiff(::CompositeAlgorithm)instead would change other consumers such as DAE initialization.The repro in #4952 (
MethodOfSteps(AutoTsit5(Rosenbrock23())), resized while on the stiff member) threw aDimensionMismatchand now returnsSuccessat[0.5, 0.5]. New ODE and DDE testsets cover a FiniteDiff and a ForwardDiffRosenbrock23, dense and withKrylovJL_GMRES, in both orders; they error without the src change and pass with it.Not covered here: growing a composite with SDIRK members fails on master in
resize_nlsolver!, and its Newton path still resizes withintegrator.alg.Fixes #4952
Risk assessment
resize!paths only; the shared helpers gain analgargument whose default keeps every existing caller's behaviour).resize_J_W!,resize_jac_config!andresize_grad_config!take an optionalalgargument that defaults tointegrator.alg, so existing callers are unchanged. OrdinaryDiffEqRosenbrock'sresize_non_user_cache!passescache.alg. In a composite ODE integrator, each Rosenbrock member now rebuilds its J, W and AD configs with its own backend, where before every member usedintegrator.alg. In DelayDiffEq,resize!,addat!anddeleteat!on a DDE integrator with a CompositeCache now resize every member cache. Rosenbrock members resize J and W throughOrdinaryDiffEqCore.resize_J_W!and their AD configs withcache.alg, as the ODE path does. This means matrix-free (Krylov) members work. That case used to throw a MethodError even for a singleMethodOfSteps(Rosenbrock23(linsolve = KrylovJL_GMRES())). Dense Rosenbrock members are resized as before. For non-composite integratorscache.algisintegrator.alg, so behaviour there is unchanged. DelayDiffEq and OrdinaryDiffEqRosenbrock now require OrdinaryDiffEqDifferentiation 3.13.1.Rosenbrock23, dense andKrylovJL_GMRES, both orders) error without the src change and pass with it; DDEresize.jland the ODEresize_tests.jlpass on this head. The red checks ata8fca87f(AD, GPU, Core, ProbNumDiffEq, SciMLSensitivity Core2) also fail on master.AI Disclosure: Claude assisted with this change.