Closed peterstangl closed 6 years ago
This is related to issue #42, but it is a somewhat different problem.
I'm not sure how the bug that a wc_function is assumed to return vanishing Wilson coefficients for vanishing arguments is exactly related to this.
Hm, this is a bit surprising to me since even when using wc=True
, the Wilson coefficients should still have value 0, so no running should be performed. It could be that it is just the part of the SMEFT running that determines the SM parameters that slows it down.
How to tried snakeviz to check which function calls (in wilson) take most of the time?
The Wilson coefficients have value 0. However, if wc=True
, the wc_obj
that is subsequently used to calculate observable predictions is defined by
https://github.com/flav-io/flavio/blob/0208eb093b785b400ee1d54d21a1a7a6d4067a9c/flavio/statistics/fits.py#L328-L329
while for wc=False
it is given by
https://github.com/flav-io/flavio/blob/0208eb093b785b400ee1d54d21a1a7a6d4067a9c/flavio/statistics/fits.py#L330-L331
The former is a flavio.physics.eft.WilsonCoefficients
instance with initial values containing eft
, basis
, and scale
set according to the definition of the FastFit
instance. It contains all Wilson coefficients included in the fit with their values set to 0.
The latter is also a flavio.physics.eft.WilsonCoefficients
instance but with no initial values set:
https://github.com/flav-io/flavio/blob/0208eb093b785b400ee1d54d21a1a7a6d4067a9c/flavio/physics/eft.py#L215
Those two different instances of flavio.physics.eft.WilsonCoefficients
behave differently when their method get_wc
is called (the same applies to their get_wcxf
method introduced in https://github.com/DavidMStraub/flavio-dev/commit/7cbccba543a187cc008501e58d25f448aa258bbf). In particular, for the _wc_sm
-instance, self.wc
is None
, such that no running is performed, while for the get_wc_obj(x)
-instance, self.wc
is not None
and running is performed even though all Wilson coefficients have value 0:
https://github.com/flav-io/flavio/blob/0208eb093b785b400ee1d54d21a1a7a6d4067a9c/flavio/physics/eft.py#L206-L208
OK you are right! Prior to v0.28 (before wilson), zero WCs were not run so this made no difference. So this should actually be implemented in wilson. But in addition it certainly makes sense to fix this in flavio as well by using wc=False
.
The bug should be solved in PR #47.
In addition, it might be useful to change https://github.com/flav-io/flavio/blob/0208eb093b785b400ee1d54d21a1a7a6d4067a9c/flavio/physics/eft.py#L206 into
if not self.wc or not any(self.wc.values.values()):
However, due to the changes introduced in https://github.com/DavidMStraub/flavio-dev/commit/7cbccba543a187cc008501e58d25f448aa258bbf, it might be more reasonable to apply this modification only after the new get_wcxf
method has been added in the flavio master branch.
Oh right, it's time to cherry-pick that commit.
Thinking twice about it, I added your suggested change without cherry-pciking the other one.
Closed by #47.
After defining a
FastFit
instancefit
with SMEFT WCs, callingis considerably faster than the parallelized version
This seems to be due to the fact that the single thread version calls
self.get_predictions_array
with argumentspar=False, nuisance=True, wc=False
, https://github.com/flav-io/flavio/blob/9a6b071d9f88362dffdbdfd5faec9873da9ef118/flavio/statistics/fits.py#L539 while the multi thread version callsself.get_predictions_array
without arguments, thus using the default valuespar=True, nuisance=True, wc=True
, https://github.com/flav-io/flavio/blob/9a6b071d9f88362dffdbdfd5faec9873da9ef118/flavio/statistics/fits.py#L544 https://github.com/flav-io/flavio/blob/9a6b071d9f88362dffdbdfd5faec9873da9ef118/flavio/statistics/fits.py#L319 where the crucial argument iswc=True
. Due to this argument, running in SMEFT is performed for each calculation of observable predictions, which can increase the calculation time by several orders of magnitude.