Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link

Summary

This partially reverts PR #1188 to fix convergence issues in OrdinaryDiffEq.jl split ODE methods. Instead of returning the SplitFunction unchanged, we now copy the cache when remaking to ensure proper initialization.

Background

PR #1188 changed promote_f to simply return the SplitFunction unchanged to avoid replacing LazyBufferCache. However, this caused convergence test failures in OrdinaryDiffEq.jl because uninitialized cache memory contains random values that accumulate into the solution.

Solution

This PR modifies promote_f to:

  • Return the original function if there's no cache (no change needed)
  • If there is a cache, remake the function with a copy of the cache
  • This ensures the cache is properly initialized while preserving LazyBufferCache

Why copy instead of zero?

  • The original PR do not replace LazyBufferCache when promoting f #1188 avoided zero(u0) because it replaced LazyBufferCache with a concrete array
  • Using copy on the cache preserves the cache type (including LazyBufferCache)
  • copy for PreallocationTools caches creates a new cache with copied/initialized buffers
  • This gives us clean initial state without changing the cache structure

Test Results

Tested locally with the convergence test that was failing:

Errors: [0.064, 0.031, 0.016, 0.008]
Convergence rates: [1.030, 1.015, 1.007]
Test passed: Convergence rates are correct!

Impact

This fixes the convergence test failures in OrdinaryDiffEq.jl (AlgConvergence_III and others) while preserving the intent of PR #1188 to not unnecessarily replace LazyBufferCache with concrete arrays.

🤖 Generated with Claude Code

…ote_f

This partially reverts PR SciML#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 SciML#1188 to not replace LazyBufferCache unnecessarily.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@ChrisRackauckas ChrisRackauckas merged commit 6ae6ec4 into SciML:master Sep 2, 2025
36 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants