improve compile time of evm.modifier.compose
#12
Merged
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 PR replaces most python for-loops by
jax.lax.scan
loop constructs inevm.modifier.compose
. It automatically transforms an array ofevm.Modifier
(s) into a singleevm.Modifier
of arrays. This rearrangement allows to usejax.lax.scan
over the stacked axis.Currently it is not clear how to do this for every type of
evm.modifier.ModifierBase
(e.g.evm.modifier.where
, ..., and custom modifiers), however most modifiers in a typical analysis will be of typeevm.Modifier
and thus will usejax.lax.scan
.The compile time reduction is roughly a factor of 4-5, without any performance losses:
This benchmark has been performed with 103.000 nuisance parameters, of which:
These number correspond to roughly 10x the amount of modifiers that are used in a typical HEP analysis.