Skip to content

Wrap OverrideInitData functions in FWW for type erasure#1286

Closed
ChrisRackauckas-Claude wants to merge 1 commit intoSciML:masterfrom
ChrisRackauckas-Claude:autospecialize-initdata
Closed

Wrap OverrideInitData functions in FWW for type erasure#1286
ChrisRackauckas-Claude wants to merge 1 commit intoSciML:masterfrom
ChrisRackauckas-Claude:autospecialize-initdata

Conversation

@ChrisRackauckas-Claude
Copy link
Contributor

Summary

  • Wraps the function-typed fields inside OverrideInitData with FunctionWrappersWrapper during promote_f, erasing per-model RuntimeGeneratedFunction types:
    • NonlinearFunction.f in initializeprob (IIP, concrete arg types)
    • initializeprobmap (OOP, Any-typed args)
    • initializeprobpmap (OOP, Any-typed args)
  • Models with the same state/parameter structure now reuse compiled solver code through initialization, reducing TTFX from ~4s to <1s per additional model

Benchmark (MTK + Rodas5P, 4 models)

Model FullSpecialize AutoSpecialize (before) AutoSpecialize (after)
M1 (LV 2D, 2p) 5.5s 4.7s 4.8s
M2 (Brus 2D, 2p) 4.2s 3.7s 0.8s
M3 (VdP 2D, 1p) 4.0s 3.7s 3.8s
M4 (Rob 3D, 3p) 4.8s 3.7s 3.8s

M2 benefits fully because it shares the same MTKParameters type as M1 (same number of states and params). M3/M4 still recompile because their MTKParameters types differ.

Test plan

  • DiffEqBase core tests pass locally

🤖 Generated with Claude Code

…rasure

Wraps three function-typed fields in OverrideInitData during promote_f:
- NonlinearFunction.f in initializeprob (IIP, concrete arg types)
- initializeprobmap (OOP, Any-typed args)
- initializeprobpmap (OOP, Any-typed args)

This erases the per-model RuntimeGeneratedFunction types so that
models with the same state/parameter structure can reuse compiled
solver code, reducing TTFX from ~4s to <1s per additional model.

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

Closing — the Union{Nothing, OverrideInitData} abstract typing in unwrapped_f (SciMLBase) already handles the type erasure for initialization data. No need to wrap the individual functions inside OverrideInitData.

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