Repository navigation
Resize the member caches of a CompositeCache in a DDEIntegrator - #4958
singhharsh1708 wants to merge 4 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 |
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
AI Disclosure: Claude assisted with this change.