Repository navigation
Use @generated perform_step! to eliminate per-step regression - #3643
Conversation
|
making fixes |
|
@ChrisRackauckas Tried the SArray/SVector refactor (with α as NTuple{S, SVector{S, T2}} to preserve the vector-of-vectors structure) but it actually made things worse — both init and per-step regressed compared to the current @generated-only state. Per-step went from 0 → 16 allocs/call for KenCarp4 because SMatrix/NTuple field access through the mutable cache struct didn't constant-fold even with literal indices in the @generated body. Init went from 67 → 111 allocs for KenCarp4 because the inline SArray fields blow up the cache struct size. The current PR state (just @generated perform_step!) is the best we can get without a fundamentally different cache architecture. |
|
What's the timing vs the pre tableau now? |
|
@ChrisRackauckas Fresh apples-to-apples benchmark vs pre-tableau Summary:
|
Fixes @inferred solve failure where Tab couldn't be inferred concretely.
|
@ChrisRackauckas CI failure was an inference regression: |
…3690) The OOP path of `_perform_step` in `generic_imex_perform_step.jl` sets `nlsolver.c = c[1]` before the stage-1 `nlsolve!` (line 1404); the IIP path was missing this assignment. `nlsolver.c` determines `cache.tstep = integrator.t + nlsolver.c * dt` inside the Newton solver, which is the time argument passed to `f` during the implicit solve. Without this assignment, the IIP path's stage-1 implicit solve carried over the stale `c` value left behind by the previous outer step's stage 2 (= `c[2]`). For `SDIRK2` (`c = [1, 0]`), this means stage 1 ran at `t` instead of `t + dt`, and the cancellation in the SDIRK2 stage-2 algebra reduces both stages to the same fixed point `zs[1] == zs[2] == dt*f(t, uprev)`. The embedded error estimate `btilde[1]*zs[1] + btilde[2]*zs[2] = (zs[1] - zs[2])/2` then collapses to 0, letting the PI controller grow `dt` unboundedly. Reproduces as `DimensionMismatch` in `lib/DelayDiffEq/test/interface/multi_algorithm.jl`'s `Constant delays` testset: iip solves of `prob_dde_constant_2delays_ip` produce 11 timesteps while scalar solves produce 36 (and the iip trajectory is visibly wrong — `u` jumps linearly between discontinuity tstops). Regression bisected to PR #3641 (commit 99187d0, 2026-05-17). That commit dropped `nlsolver.c = c[1]` from both IIP and OOP. A follow-up restored it in OOP only; the @generated rewrite in #3643 and the inline in #3676 preserved the asymmetry. After this patch the `Constant delays` testset goes 27/27 green for all nine algorithms (BS3, Tsit5, RK4, Vern6, SDIRK2, TRBDF2, KenCarp4, Rosenbrock23, Rodas4). SDIRK2 sol.errors[:l∞] = 0.0035, well under the 3.8e-1 threshold. No other algorithm's iip-vs-scalar step counts or l∞ errors changed. Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Add any other context about the problem here.