UCBerkeleySETI / hyperseti

A SETI / technosignature search code to find intelligent life beyond Earth
https://hyperseti.readthedocs.io
10 stars 4 forks source link

Passing data to hyperseti from GPU buffer #40

Closed wfarah closed 1 year ago

wfarah commented 2 years ago

It would be handy to be able to parse data to hyperseti directly from a GPU buffer.

@luigifcruz is in the process of writing a real-time GPU beamformer library (BLADE), and we were discussing the possibility today of having a direct hook to hyperseti that we can use in the future. If the data shape/bitsize to hyperseti is known a-priori, we can have BLADE structure data on a GPU memory buffer that complies with hyperseti's requirement, and thus be able to ingest data straight from a GPU buffer. What's everyone's take on this?

texadactyl commented 2 years ago

Interesting.

For the time being, could @luigifcruz use the turboseti_stream to turbo_seti? Streaming doesn't just have to be GRC!

wfarah commented 2 years ago

@texadactyl that's a possibility, if data are already on CPU/flash

texadactyl commented 2 years ago

Take the output buffer from GPU and go to it?

telegraphic commented 2 years ago

Would be very cool, but generally you need to buffer up several minute's worth of data to do the doppler search -- I guess this could work if there is sufficient space on the GPU memory?

At the moment I'm focusing on getting hyperseti working and easy to debug, but I'd be interested in pipelining it using bifrost (https://github.com/telegraphic/bifrost) in the future. We (UNM) got a grant for a postdoc to work on bifrost so it should have a good development path.

I would be keen to look into synergies between BLADE and bifrost beamforming. I ported Ewan's beanfarmer code (beamform + detect + average using dp4a instruction) so it could be used in bifrost, which we are using at UTMOST-2D.

telegraphic commented 1 year ago

2023 update: This is straightforward if the data can be accessed from cupy array. Here's an example converting a setigen frame into a DataArray.

import os
import numpy as np
from astropy.coordinates import SkyCoord
import setigen as stg

from hyperseti.dimension_scale import TimeScale, DimensionScale
from hyperseti.data_array import DataArray

def from_setigen(stg_frame):
    """ Create a DataArray from a setigen Frame object 

    Args:
        stg_frame (setigen.Frame): Setigen frame object

    Returns a DataArray object generated from setigen.
    """

    data  = np.expand_dims(stg_frame.data, axis=1)

    attrs = {'name': 'setigen',
            'source': 'setigen data'}

    dims  = ('time', 'beam_id', 'frequency')
    scales = {
        'time':      TimeScale('time', stg_frame.ts[0], stg_frame.dt, 
                               data.shape[0], time_format='unix', time_delta_format='sec'),
        'beam_id':   DimensionScale('beam_id', 0, 0, data.shape[1], units=''),
        'frequency': DimensionScale('frequency', stg_frame.fch1, stg_frame.df, 
                                    data.shape[2], units='Hz')
    }

    d = DataArray(data.astype('float32'), dims, scales, attrs, units='counts')
    return d

I'm going to close issue now, we can reopen if work on this continues.