Speed up calculations of dependent parameters by bypassing unit handling #298
henrikjacobsenfys
started this conversation in
Ideas
Replies: 4 comments 16 replies
|
This is a good idea but should be made an issue on the EasyCore board instead. This sounds like a bug and an idea for a bugfix... |
1 reply
|
Question: How many dependent parameters do you have in a typical fit Henrik? We originally only designed dependent parameters to be used for a few parameters . . . |
7 replies
|
Also, my proposed solution to #291 should give some speed-up. |
4 replies
|
Could you please try and profile your fit Henrik? |
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
General
Evaluating dependent parameters is slow. This means that especially computationally heavy things, such as Bayesian analysis on a global fit, can take hours. Initial tests indicate that it can be sped up to take minutes at most.
The primary reason for the slowness (i.e. more than 99% of the calculation time) is that we handle units every time a dependent parameter is called. We create a bunch of parameters, which create a bunch of scipp variables, we then convert the units etc. etc.
This is pointless in a fit: the output unit is the same throughout the fit, and it's a simple factor that can be multiplied in the end.
Idea
Add a
dependency_compiler(name pending review) which, well, compiles the dependency expression and stores the final unit and any conversion factor needed to get the correct result. This is done only once during e.g. a fit. Then evaulate the expression using numpy functions (see #297 ) on the raw values of the parameters.Disclosure:
I prototyped the code already with Claude. We get a speedup of about a factor 1000 for a typical EasyDynamics use case..
Edit: Ran some profiling, and those numbers are far less impressive - about 70% of the calculation time can be saved, so "only" a factor 3 improvement. Will update with more information when I have it.
All reactions