Skip to content

multi_inspiral: avoid repeated power chi^2 calculations in the critical loop #5158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

titodalcanton
Copy link
Contributor

@titodalcanton titodalcanton commented Jul 17, 2025

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

  • The author of this pull request confirms they will adhere to the code of conduct

@titodalcanton titodalcanton added PyGRB PyGRB development v28_release_branch PRs to be cherry-picked into the v2.8 release branch labels Jul 17, 2025
@titodalcanton titodalcanton marked this pull request as draft July 17, 2025 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PyGRB PyGRB development v28_release_branch PRs to be cherry-picked into the v2.8 release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant