Open mpuerrer opened 3 years ago
Great, thanks Michael! This all makes sense. Regarding the separation between training and inference stage: Is there an elegant way to provide 2 separate interfaces for these? The training pipeline will have many dependencies which are not required for inference. I always find it annoying that I have to install a whole bunch of LIGO modules when actually all I need is a single function. So for users only interested in downloading pretrained models and doing inference on real or simulated data it would be nice to have a simplified interface. That would make the tool more accessible.
We could put the import
statements under if
statements, depending on whether the command line is invoked in inference or training mode.
This is a good point, Max. What I put above is purely from the perspective of a user of the code and does not described how it should be implemented and which objects need to be shared between training and inference. So, the next, harder step will be to add additional technical details about what the code does at a medium level and then using this information come up with classes and how they interact with each other, and then we can look at separating dependencies as Stephen suggests. I'll have to do a lot more code reading :-)
We ultimately want to make it pip installable, right? And in that case it would be nice to have an option that only installs the 'enduser' requirements, rather than the full pipeline with all external dependencies. I am not sure if that is possible though (if statements won't be sufficient for this). I mean something like the following:
pip install dingo-full pip install dingo-inference
Anyway, I agree that this is a rather technical issue that, but I wanted to put it out there so we are aware.
Yes, this is a good point. We may also not want to provide the entire code initially and just release the inference part. If we split into two packages then dingo-full is a superset of dingo-inference and they will have shared code.
Since duplicate code is in general a bad idea, perhaps this could be solved by having three packages:
I suppose that could work, aside from the Detector objects, which are needed at inference, and depend on Bilby / LAL.
Currently I see that Detector
is imported from pycbc. pycbc probably gets this from lalsuite. It makes sense to reuse it, at least for the more complicated detector geometries, but if deemed necessary we can probably decouple it and have our standalone detector package.
There will also be other dependencies that will appear for the inference code when we integrate it more tightly into the LSC infrastructure. E.g. we will want to run on incoming data, or use datafind, or run on frame files, and will want to reuse libraries such as gwpy and interface with other tools such as pesummary. Also we need to deal with queuing systems, e.g. condor and slurm. This additional layer could happen in a dingo-pipe
package similar to bilby-pipe.
Thinking about use cases, we also may want to enable the code to be adapted more broadly to problems in astronomy. For example, to study 2-D telescope images and study lensing (just to pick something). If some of the operations (e.g., building the flow, GNPE iterations, noise vs signal models) could be sufficiently abstracted such that they could be collected into a core/
part of the code, then we may want to consider this. This would only make sense if the astronomy use cases are more specific than what is covered by codes such as Jakob's NPE package, and at the same time more general than what we do for gravitational waves.
We also want to find a way to allow for changes to the data representation / network architecture beyond simple changes to values of hyperparameters, in a way that allows for backward compatibility with previously-trained models. As we developed the previous version of the code, we frequently made such changes when we thought they would improve performance (e.g., adding the initial linear layers of the embedding network). However, this would frequently break old trained models. (There's no way the models I trained in the reduced-basis representation for the August paper would still work.) Maybe the solution is to just add a new class every time we design a new architecture, but if that's the case then we should find a nice way to do this.
DINGO use cases
Let's assemble all of the planned use cases of the dingo code below., separated into training and inference. This should be useful input for designing the classes and their interaction.
The current sketch is quite high level and more details are needed for this to properly describe what the code should do.
Train NDE
Read parameters - from some agreed upon configuration file
build waveform data set: (5 million waveform samples from intrinsic prior)
add noise realizations and extrinsic parameters to waveform (now using stationary Gaussian noise; support real noise in future)
train network given hyperparameters
save network and parameters (metadata, e.g. how the PSD was determined)
Perform inference with NDE on single GW event
Extensions
Support non-uniform frequency grids
Add flexibility about which parameters to sample in
Support prior specifications similar to bilby?
output additional quantities
Support subdomains in parameter space
Marginalization over detector calibration
(a) Could compute logL for each sample and then run the reweighting code (make sure that you have enough samples in the tail) (b) Put realizations of det cal uncertainty into waveform data set and rebuild network
Non-Gaussian noise
Extending to arbitrary noise is straightforward since no Gaussianity assumptions are made
SEOBNRv4PHM
Flexibility to support ground based detectors and LISA
Flexibility to change the flows
Have sane default parameters
Look into PSD reweighting
Improve load balancing between GPU and CPU
Support multiple GPUs
In the future will maybe want to make use of multiple GPUs