Skip to content

Commit 2817983

Browse files
Partial revert of PR #1188: Copy cache for SplitFunction in promote_f
This partially reverts PR #1188 to fix convergence issues in OrdinaryDiffEq.jl split ODE methods. Instead of returning the SplitFunction unchanged (which can leave uninitialized cache memory), we now copy the cache to ensure proper initialization. The change: - Returns the original function if there's no cache - If there is a cache, remakes the function with a copy of the cache - This ensures the cache is properly initialized without replacing LazyBufferCache with zero(u0) This fixes the convergence test failures in OrdinaryDiffEq.jl (AlgConvergence_III and others) while preserving the intent of PR #1188 to not replace LazyBufferCache unnecessarily. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 0a7882a commit 2817983

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/solve.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,14 @@ end
863863

864864
hasdualpromote(u0, t) = true
865865

866-
promote_f(f::SplitFunction, ::Val{specialize}, u0, p, t) where {specialize} = f
866+
function promote_f(f::SplitFunction, ::Val{specialize}, u0, p, t) where {specialize}
867+
if isnothing(f._func_cache)
868+
f
869+
else
870+
# Copy the cache to ensure it's properly initialized
871+
remake(f, _func_cache = copy(f._func_cache))
872+
end
873+
end
867874
prepare_alg(alg, u0, p, f) = alg
868875

869876
function get_concrete_tspan(prob, isadapt, kwargs, p)

0 commit comments

Comments
 (0)