multi_inspiral
: avoid repeated power chi^2 calculations in the critical loop
#5158
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.
In the presence of loud injections (and perhaps glitches) and with large sky grids,
multi_inspiral
spends most of its time doing chi^2 calculations. This reduces that.Standard information about the request
This is an efficiency update.
This change affects PyGRB.
Motivation
This addresses the first thing I described in #5148, namely the fact that some
multi_inspiral
jobs can take many hours just doing repeated power chi^2 calculations in the critical loop over time slides and sky points. As the calculation is a single-detector operation, it does not depend on time slide or sky position, so its result be cached for reuse in the following iterations.Contents
I introduce a cache for the power chi^2 values and DoF. Every time a new chi^2 calculation is required, I check which time samples had their chi^2 calculated before, and I only call the chi^2 code for the new samples.
This change, together with #5157, brings the wall clock time from 35 hours to 8 for the test job I have been profiling in #5148.
@spxiwh noted that the point chi^2 code is not necessarily the most efficient when there are many points to calculate; in fact, coh_PTF_inspiral used to do the old FFT-based calculation. Still, I already know that this PR leads to a huge speedup in the limiting cases, so I propose we postpone further optimizations to later PRs.
Links to any issues or associated PRs
#5148
Testing performed
I noticed that power chi^2 values tend to be non-deterministic even across runs of the same code done a few minutes apart, so checking that the results do not change is a bit challenging, but I am working on this.
I also need to verify that this does not slow the code down in the case of well-behaved noise without loud signals in it.
Additional notes
N/A