mikekatz04 / LISAanalysistools

Apache License 2.0
21 stars 9 forks source link

snr on GPU #23

Open Hassankh92 opened 2 months ago

Hassankh92 commented 2 months ago

Hi,

just tried using the version from pip, but can not simply get the snr on GPU. If I pass the cp array waveform from the FEW (doing this as it is mentioned for computing the snr on GPU, "pass CuPy arrays rather than NumPy arrays" ), I get cupy error. It is happening somewhere in the DataResidualArray.

mikekatz04 commented 2 months ago

Can you post code and error?

Hassankh92 commented 2 months ago

Hi Mike,

This is what I am using: snr(Kerr_wave_gen_lmax15, dt, psd="CornishLISASens")

Kerr_wave_gen_lmax15 is the time series I am computing in FEW on gpu However, it works when passing the Kerr_wave_gen_lmax15.get(). But it is slow.

The error is pasted down here:


TypeError Traceback (most recent call last) Cell In[9], line 1 ----> 1 snr(Kerr_wave_gen_lmax15, dt, psd="CornishLISASens")

File ~/.conda/envs/dirty_few/lib/python3.10/site-packages/lisatools/diagnostic.py:376, in snr(sig1, data, *args, *kwargs) 352 """Compute the snr between two signals weighted by a psd. 353 354 The signal-to-noise ratio of a signal is :math:\\sqrt{\\langle a|a\\rangle}. (...) 372 373 """ 375 # get optimal SNR --> 376 opt_snr = np.sqrt(inner_product(sig1, sig1, args, **kwargs).real) 377 if data is None: 378 return opt_snr

File ~/.conda/envs/dirty_few/lib/python3.10/site-packages/lisatools/diagnostic.py:76, in inner_product(sig1, sig2, dt, df, f_arr, psd, psd_args, psd_kwargs, normalize, complex) 36 """Compute the inner product between two signals weighted by a psd. 37 38 The inner product between time series :math:a(t) and :math:b(t) is (...) 73 74 """ 75 # initial input checks and setup ... --> 228 self._data_res_arr = np.asarray(list(new_out), dtype=new_out[0].dtype)

File cupy/_core/core.pyx:1475, in cupy._core.core._ndarray_base.array()

TypeError: Implicit conversion to a NumPy array is not allowed. Please use .get() to construct a NumPy array explicitly.--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[9], line 1 ----> 1 snr(Kerr_wave_gen_lmax15, dt, psd="CornishLISASens")

File ~/.conda/envs/dirty_few/lib/python3.10/site-packages/lisatools/diagnostic.py:376, in snr(sig1, data, *args, *kwargs) 352 """Compute the snr between two signals weighted by a psd. 353 354 The signal-to-noise ratio of a signal is :math:\\sqrt{\\langle a|a\\rangle}. (...) 372 373 """ 375 # get optimal SNR --> 376 opt_snr = np.sqrt(inner_product(sig1, sig1, args, **kwargs).real) 377 if data is None: 378 return opt_snr

File ~/.conda/envs/dirty_few/lib/python3.10/site-packages/lisatools/diagnostic.py:76, in inner_product(sig1, sig2, dt, df, f_arr, psd, psd_args, psd_kwargs, normalize, complex) 36 """Compute the inner product between two signals weighted by a psd. 37 38 The inner product between time series :math:a(t) and :math:b(t) is (...) 73 74 """ 75 # initial input checks and setup ... --> 228 self._data_res_arr = np.asarray(list(new_out), dtype=new_out[0].dtype)

File cupy/_core/core.pyx:1475, in cupy._core.core._ndarray_base.array()

TypeError: Implicit conversion to a NumPy array is not allowed. Please use .get() to construct a NumPy array explicitly.