dingo-gw / dingo

Dingo: Deep inference for gravitational-wave observations
MIT License
55 stars 18 forks source link

Speed of calibration marginalization #197

Open stephengreen opened 1 year ago

stephengreen commented 1 year ago

I am finding that when calibration marginalization is turned on, it significantly slows down likelihood evaluations. This is expected to some degree, but I would have thought it would be much faster.

For IMRPhenom waveforms (f_min=20.0, f_max=1024.0, delta_f=0.125) and INI settings

request-cpus-importance-sampling = 2
calibration-model = CubicSpline
spline-calibration-envelope-dict = {H1: ../GWTC1_GW150914_H_CalEnv.txt, L1: ../GWTC1_GW150914_L_CalEnv.txt}

then ~ 500 likelihood evaluations takes many minutes.

mpuerrer commented 1 year ago

Could you point me to a directory containing an example which I can try to replicate?

stephengreen commented 1 year ago

I wonder if it's all the repeated calls to get_calibration_factor(), and if this could be better optimized.

stephengreen commented 1 year ago

But I also don't remember it being this slow. Maybe it's the machine I am running on (saraswati).

stephengreen commented 1 year ago

Could you point me to a directory containing an example which I can try to replicate?

On saraswati, /data/sgreen/dingo-experiments/pipe/speed_gnpe/GW150194.ini.

stephengreen commented 1 year ago
Calculating 484 likelihoods.
Done. This took 16264.02 seconds.
nihargupte-ph commented 1 year ago

image

Indeed I think it is repeated calls to get_calibration_factor. This is a function from Bilby to get the calibration curve from the calibration parameters. Maybe there is a way to vectorize this operation given a matrix of the calibration parameters.

stephengreen commented 1 year ago

Even if this takes 40x the waveform generation time, the latter is quite fast for XPHM, and wouldn't explain 400s per likelihood evaluation.

mpuerrer commented 1 year ago

I think it would be worth testing this in isolation: set up a CubicSpline object and repeatedly call get_calibration_factor() for the envelopes used in this run. I can't see anything that would be very slow in https://git.ligo.org/lscsoft/bilby/-/blob/master/bilby/gw/detector/calibration.py#L242.