-
-
Notifications
You must be signed in to change notification settings - Fork 237
refactor: improve precompile-friendliness #4044
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AayushSabharwal
wants to merge
13
commits into
master
Choose a base branch
from
as/precompile
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
Author
|
|
kwargs aren't inferred the same
Now infers `::SymbolicT`
d8e93d4 to
4f78a51
Compare
4f78a51 to
8e2c9e8
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This enables greatly improved precompilation of many common MTK workflows. On 1.11:
Systemconstructor:This is for a particular signature. Different combinations of kwargs and different input types will cause compilation and we can't foreseeably compile every signature. This signature is
System(::Vector{Equation}, ::Num, ::Vector{Num}, ::Vector{Num}; initial_conditions::Dict{SymbolicT, SymbolicT}, guesses::Dict{SymbolicT, SymbolicT}, name::Symbol). With some discussion, we can arrive at a common signature to precompile. It will likely involve unwrapping theNums.complete(sys):This is for a system that does not have callbacks. The callback handling code is pretty big and needs a lot of work to precompile, so it is left for a future PR.
MTKTearing.TearingState(sys)The compilation here is all related to printing the equations to lexicographically sort them. The printing code in SU needs an overhaul to support precompilation (specifically,
src/ordering.jl)mtkcompile(sys):This is the version of
mtkcompilewith ModelingToolkit.jl loaded. The printing fromTearingState(sys)is already compiled here, so that is not part of this timing. The signatures reported by--trace-compilefor this workload areAnd despite significant digging with Cthulhu I haven't been able to find where they are hit.
Script to reproduce these results:
Which should be run as
The
print(Val(..))are to have unique markers in theprecompilestatements inbad.jlso that it is possible to identify which sections of the script triggers the compilations. They typically show up asThis requires JuliaSymbolics/SymbolicUtils.jl#824, JuliaSymbolics/Symbolics.jl#1711 and JuliaComputing/StateSelection.jl#11