Rebase: Unified SDIRK tableau structure and generic perform_step!#3030
Rebase: Unified SDIRK tableau structure and generic perform_step!#3030ChrisRackauckas-Claude wants to merge 5 commits intoSciML:masterfrom
Conversation
Rebase and cleanup of PR SciML#2779 onto current master. - Implement SDIRKTableau struct consolidating all Butcher coefficients - Add generic perform_step! reducing duplication across 20+ methods - Migrate ImplicitEuler, SDIRK2, Cash4, all ESDIRK/SFSDIRK methods - Preserve TRBDF2 special handling with unified coefficients - Unify KenCarp/Kvaerno tableaus with additive splitting support - Add Cash4Tableau_unified with proper embedding support - Add verbose parameter to alg_cache for upstream compatibility - Add regression tests for SDIRK methods with explicit first stages Note: Performance regression identified - generic perform_step! uses Vector{typeof(u)} for stage storage and dynamic dispatch which causes significant overhead vs the original flat-field specialized methods. This needs optimization before merging. Co-Authored-By: Krish Gaur <[email protected]> Co-Authored-By: curd <[email protected]> Co-Authored-By: Chris Rackauckas <[email protected]>
…uctors All unified SDIRK tableau constructors now call the original (correct) per-method tableau constructors and extract z-space coefficients from their fields. This fixes pervasive errors in the original refactor: - ESDIRK methods (Kvaerno3/4/5, KenCarp3/4/5/47/58, ESDIRK436L2SA2, ESDIRK437L2SA, ESDIRK547L2SA2, ESDIRK659L2SA, ESDIRK54I8L2SA, CFNLIRK3): A[1,1] was γ instead of 0 for explicit first stage; A matrix rows were incorrect; b was bhat instead of main weights; b_embed was bhat instead of btilde; wrong γ values in several cases - SDIRK2: A[2,1] was 1-γ instead of -1; b was wrong; b_embed missing - SSPSDIRK2: γ was 1-1/√2 instead of correct 1/4 - TRBDF2: b_embed was bhat instead of btilde - Hairer4/42: wrong γ and coefficients - SFSDIRK4-8: completely wrong coefficients and γ values Co-Authored-By: Chris Rackauckas <[email protected]>
Fixed: All unified SDIRK tableau coefficientsThe unified tableau constructors had pervasive errors causing 10x-50,000x performance regressions. All constructors now call the original (correct) per-method tableau constructors from Bugs fixed:ESDIRK methods (Kvaerno3/4/5, KenCarp3/4/5/47/58, ESDIRK436L2SA2, ESDIRK437L2SA, ESDIRK547L2SA2, ESDIRK659L2SA, ESDIRK54I8L2SA, CFNLIRK3):
SDIRK methods:
Test results:
|
…ia 1.10 LTS
The `@inferred init()` tests were failing on Julia 1.10 LTS because the
return type was inferred as Union{..PIController.., ..PIControllerCache..}
instead of a concrete type.
Root cause: Two code paths for creating controllers existed:
1. `default_controller_v7` returning new-style controllers
2. `legacy_default_controller` returning legacy controllers
Julia 1.10's type inference couldn't determine at compile time which
path would be taken, resulting in a Union type.
Changes:
- Always use `default_controller_v7` for the controller default parameter
- Enable `CompositeController` for composite algorithms instead of returning
`nothing` (which triggered the legacy fallback)
- Add `new_controller_from_legacy_params` to create new-style controllers
when legacy parameters are provided, ensuring type stability
- Replace `legacy_default_controller` call with new controller constructors
This fixes the Regression_II (LTS) test failure without breaking backwards
compatibility for users who specify legacy controller parameters.
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Chris Rackauckas <[email protected]>
The original ESDIRK659L2SA btilde values from sdirk_tableaus.jl had sum(btilde) ≈ -1.69, which violates the consistency requirement that sum(bhat - b) = 0 for embedded RK methods. This caused the algorithm to take 9979+ steps and hit MaxIters on simple problems like exponential decay. The fix corrects btilde9 so that sum(btilde) = 0. This makes the algorithm converge correctly (1322 steps, Success, error=1e-15 vs MaxIters, error=0.62). Note: The individual btilde coefficients may still be incorrect (based on how the error estimator behaves), but this fix is a significant improvement. The coefficients should be verified against the original Kennedy-Carpenter paper for optimal efficiency. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 4.5 <[email protected]>
ESDIRK659L2SA FixFixed a critical bug in ESDIRK659L2SA where Before fix (master)
After fix
The fix corrects Note: The individual btilde coefficients may still be suboptimal (1322 steps vs ~10 steps for similar order methods). The coefficients should be verified against the original Kennedy-Carpenter paper for optimal efficiency. All SDIRK tests pass |
Summary
Rebase of #2779 onto current master with fixes:
SDIRKTableaustruct consolidating all Butcher coefficients usingStaticArraysperform_step!replacing 20+ method-specific implementationsCash4Tableau_unifiedwith proper dual-embedding supportverboseparameter compatibility with upstreamalg_cachesignaturesPerformance Regression Warning
Benchmarking revealed significant performance regressions in the generic implementation:
Root causes:
Vector{typeof(u)}for stage storage vs flat struct fieldsmax_iters, suggesting error estimation bugs in the generic code pathThese must be resolved before merging. The original PR #2779 had similar issues.
Test plan
🤖 Generated with Claude Code