Skip to content

Cache Shooting ODE integrators by eltype - #570

Closed
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:agent/fix-shooting-dual-odecache
Closed

ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:agent/fix-shooting-dual-odecache

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Please ignore this draft until reviewed by @ChrisRackauckas.

Fixes BoundaryValueDiffEqShooting multiple-shooting caches when residual AD
changes the state/time element type. The existing cache held Float64 time
storage and attempted to convert ForwardDiff dual times to Float64.

The cache is now keyed by state element type and number of shooting intervals.
For a nonmatching element type it is remade with a matching tspan; result
time containers are derived from the cache rather than the primal span. This
keeps the primal path unchanged and avoids losing AD information.

Clean-main reproduction and validation on Julia 1.10 with the exact all-deps
resolver:

  • unmodified master f41609ed fails Basic Shooting at
    Float64(::ForwardDiff.Dual) (54 pass, 1 error);
  • the fixed source passes the full Shooting Core group: Basic 82/82, NLLS
    56/56, Orbital 40/40; and
  • repository-wide Runic --check . and git diff --check pass.

The regression bisects to fe630c86.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Validation scratchpad: this is intentionally separate from #569. It was tested against clean master f41609e with the exact all-dependency resolver; it eliminates the reproduced ForwardDiff Dual-to-Float64 error across Basic, NLLS, and Orbital Core groups.

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Closing as a duplicate of #541. The source patch is byte-identical; fresh clean-master f41609e validation is recorded on #541.

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Results (Julia v1.11)

Time benchmarks
master fc4d140... master / fc4d140...
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK2() 0.587 ± 0.0051 s 0.591 ± 0.0023 s 0.994 ± 0.0094
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK3() 12.3 ± 0.25 ms 12.2 ± 0.19 ms 1.01 ± 0.026
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK4() 2.71 ± 0.081 ms 2.68 ± 0.074 ms 1.01 ± 0.041
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK5() 3.23 ± 0.092 ms 3.2 ± 0.081 ms 1.01 ± 0.039
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK6() 1.56 ± 0.045 ms 1.56 ± 0.04 ms 1 ± 0.039
Simple Pendulum/IIP/MultipleShooting(10, Tsit5; grid_coarsening = false) 1.52 ± 0.055 ms 1.52 ± 0.089 ms 1 ± 0.069
Simple Pendulum/IIP/MultipleShooting(10, Tsit5; grid_coarsening = true) 3.12 ± 0.1 ms 3.11 ± 0.11 ms 1.01 ± 0.049
Simple Pendulum/IIP/MultipleShooting(100, Tsit5; grid_coarsening = false) 0.0385 ± 0.0025 s 0.0393 ± 0.003 s 0.981 ± 0.099
Simple Pendulum/IIP/MultipleShooting(100, Tsit5; grid_coarsening = true) 0.0599 ± 0.002 s 0.0588 ± 0.0015 s 1.02 ± 0.042
Simple Pendulum/IIP/Shooting(Tsit5()) 0.175 ± 0.073 ms 0.18 ± 0.072 ms 0.976 ± 0.57
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK2() 0.721 ± 0.0034 s 0.727 ± 0.003 s 0.992 ± 0.0062
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK3() 16.1 ± 4.9 ms 16.2 ± 4.1 ms 0.993 ± 0.39
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK4() 3.32 ± 0.22 ms 3.23 ± 0.11 ms 1.03 ± 0.077
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK5() 3.92 ± 0.21 ms 3.9 ± 0.2 ms 1 ± 0.074
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK6() 1.86 ± 0.1 ms 1.88 ± 0.1 ms 0.99 ± 0.077
Simple Pendulum/OOP/MultipleShooting(10, Tsit5; grid_coarsening = false) 3.25 ± 0.7 ms 3.37 ± 1 ms 0.966 ± 0.36
Simple Pendulum/OOP/MultipleShooting(10, Tsit5; grid_coarsening = true) 6.55 ± 5.3 ms 6.37 ± 5.2 ms 1.03 ± 1.2
Simple Pendulum/OOP/MultipleShooting(100, Tsit5; grid_coarsening = false) 0.0836 ± 0.0029 s 0.0851 ± 0.011 s 0.983 ± 0.14
Simple Pendulum/OOP/MultipleShooting(100, Tsit5; grid_coarsening = true) 0.127 ± 0.0035 s 0.125 ± 0.003 s 1.01 ± 0.037
Simple Pendulum/OOP/Shooting(Tsit5()) 0.608 ± 0.053 ms 0.589 ± 0.036 ms 1.03 ± 0.11
time_to_load 7.02 ± 0.068 s 6.9 ± 0.028 s 1.02 ± 0.011
Memory benchmarks
master fc4d140... master / fc4d140...
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK2() 0.389 M allocs: 0.0443 GB 0.389 M allocs: 0.0443 GB 1
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK3() 0.0436 M allocs: 4.88 MB 0.0436 M allocs: 4.88 MB 1
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK4() 15.7 k allocs: 1.65 MB 15.7 k allocs: 1.65 MB 1
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK5() 22.1 k allocs: 2.04 MB 22.1 k allocs: 2.04 MB 1
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK6() 12.8 k allocs: 1.05 MB 12.8 k allocs: 1.05 MB 1
Simple Pendulum/IIP/MultipleShooting(10, Tsit5; grid_coarsening = false) 25.5 k allocs: 1.82 MB 25.5 k allocs: 1.82 MB 1
Simple Pendulum/IIP/MultipleShooting(10, Tsit5; grid_coarsening = true) 0.049 M allocs: 3.39 MB 0.049 M allocs: 3.39 MB 1
Simple Pendulum/IIP/MultipleShooting(100, Tsit5; grid_coarsening = false) 0.553 M allocs: 0.0535 GB 0.553 M allocs: 0.0535 GB 1
Simple Pendulum/IIP/MultipleShooting(100, Tsit5; grid_coarsening = true) 0.833 M allocs: 0.0778 GB 0.833 M allocs: 0.0778 GB 1
Simple Pendulum/IIP/Shooting(Tsit5()) 4.64 k allocs: 0.224 MB 4.64 k allocs: 0.224 MB 1
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK2() 0.89 M allocs: 0.984 GB 0.89 M allocs: 0.984 GB 1
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK3() 0.0932 M allocs: 24.8 MB 0.0932 M allocs: 24.8 MB 1
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK4() 0.0324 M allocs: 3.96 MB 0.0324 M allocs: 3.96 MB 1
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK5() 0.045 M allocs: 4.99 MB 0.045 M allocs: 4.99 MB 1
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK6() 25.3 k allocs: 2.17 MB 25.3 k allocs: 2.17 MB 1
Simple Pendulum/OOP/MultipleShooting(10, Tsit5; grid_coarsening = false) 0.142 M allocs: 10.2 MB 0.142 M allocs: 10.2 MB 1
Simple Pendulum/OOP/MultipleShooting(10, Tsit5; grid_coarsening = true) 0.266 M allocs: 18.7 MB 0.266 M allocs: 18.7 MB 1
Simple Pendulum/OOP/MultipleShooting(100, Tsit5; grid_coarsening = false) 2.52 M allocs: 0.279 GB 2.52 M allocs: 0.279 GB 1
Simple Pendulum/OOP/MultipleShooting(100, Tsit5; grid_coarsening = true) 3.82 M allocs: 0.404 GB 3.82 M allocs: 0.404 GB 1
Simple Pendulum/OOP/Shooting(Tsit5()) 0.0373 M allocs: 1.69 MB 0.0373 M allocs: 1.69 MB 1
time_to_load 0.159 k allocs: 11.2 kB 0.159 k allocs: 11.2 kB 1

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