pycbc icon indicating copy to clipboard operation
pycbc copied to clipboard

Fix problem on pycbc live due to numpy 2

Open Thomas-JACQUOT opened this issue 1 year ago • 8 comments

This fixes #4912.

I explictly convert the PSD to double precision before the division, as soon numpy 2.x is not doing it automatically anymore.

I also add another check of the XML files to make sure that the PSDs in there are valid.

Thomas-JACQUOT avatar Oct 22 '24 13:10 Thomas-JACQUOT

Let me maybe propose a somewhat more difficult solution: Is there any reason for us to still use float32 precision in filtering/PSD estimation etc. as default? Can we just move all of this to float64? (Perhaps the potential to use GPUs might motivate keeping this)

spxiwh avatar Oct 22 '24 13:10 spxiwh

@spxiwh that is probably a bigger discussion/project…

titodalcanton avatar Oct 22 '24 13:10 titodalcanton

Let me maybe propose a somewhat more difficult solution: Is there any reason for us to still use float32 precision in filtering/PSD estimation etc. as default? Can we just move all of this to float64? (Perhaps the potential to use GPUs might motivate keeping this)

To first order, I would expect that to roughly halve performance. Maybe more, if you move from the matched filtering inputs and outputs fitting in cache to no longer doing so. It's probably harmless to compute the PSD in double precision and then convert it to float (though you'd still have to include the dynamic range factor).

josh-willis avatar Oct 22 '24 13:10 josh-willis

One potential concern if we move everything to double would be memory usage. PyCBC Live already uses quite a bit of RAM, which would presumably double if we did this. Using double just for the PSD would not be a problem of course, but then again, what do we gain?

titodalcanton avatar Oct 22 '24 13:10 titodalcanton

Given that this is currently blocking a new release for PyCBC Live, I would strongly prefer that we use the fastest fix available. We can revisit larger changes like moving everything to float64 on a longer timescale.

maxtrevor avatar Oct 22 '24 14:10 maxtrevor

@maxtrevor this only blocks PyCBC Live releases if you decide to run it under Numpy 2.

titodalcanton avatar Oct 22 '24 15:10 titodalcanton

@maxtrevor this only blocks PyCBC Live releases if you decide to run it under Numpy 2.

Ah right. At this point we have to actively choose not to use numpy 2 when making an environment, so I'd still prefer to get this in but you're right its not necessarily a blocker.

maxtrevor avatar Oct 22 '24 15:10 maxtrevor

@spxiwh The psd calculation itself is actually not problematic. It can be done in either float32 or float64 already just by choice of input (e.g. whatever the precision of the data is). The issue is just that float32 only can have exponents within 10^(+- ~38).

ahnitz avatar Oct 22 '24 17:10 ahnitz