Point Source Spectral Fitting with Normalizing Flows Approximation for Response and Background#515
Point Source Spectral Fitting with Normalizing Flows Approximation for Response and Background#515scipascal wants to merge 15 commits intocositools:developfrom
Conversation
Adding my neural network response and psr implementation to cosipy interfaces Merged latest changes from Israels interfaces branch and applied my changes: Response implementation and PSR folding with EventData and PhotonList
…rlap with background development, fixed batchsize and compile mode setter bug.
… used for background.
…zing flows models contain CPU syncs, the cuda streams provide no benefit and will be removed. This commit saves the current state.
…negative and not just infinite
| from importlib.util import find_spec | ||
|
|
||
| if find_spec("torch") is None: | ||
| raise RuntimeError("Install cosipy with [ml] optional package to use this feature.") |
There was a problem hiding this comment.
put the pip command to use explicitly. pip install -e . "[ml]"
|
@israelmcmc I tried the tutorial notebook with the brightest GRB ( GRB_bn090424592 ) using GPU or CPU. Both worked well. |
|
Thanks @scipascal and @GallegoSav. I'll try it out. @GallegoSav for that GRB that lasted 20-30 min in a CPU, so you know how many event you were analyzing? Or in general, I want to get a sense of the cost per event in both GPUs and CPU, maybe @scipascal knows too. |
@israelmcmc The benchmark that I performed in my thesis was 34e4 evaluations per second for the probability density function on four NVIDIA RTX A5000. Lets assume you need 60 evaluations per event for numerical integration. Then you get 5.7e3 events per second. Thats very slow and therefore we need the caching and optimized integration schemes to use it. |
|
Thanks @scipascal. Do you have the same performance numbers of a CPU? |
|
@israelmcmc, for CPU only (see the hardware specifications) I get around 225 events per second compared to the 5.7e3 events per second with 4 GPUs. |
|
Thanks for checking @scipascal! |
Description
This pull request introduces a neural-network-powered response and background approximation to
cosipy, which powers the unbinned Poisson likelihood analysis of continuum point sources. For more information, refer to the tutorial notebookexample_crab_fit_normalizing_flows.ipynbor my thesis, "Development of an Efficient Response Description for the COSI MeV 𝜸-Ray Telescope."Hardware Testing
The implementation has been verified on the following environment:
Important
Multiprocessing or PyTorch may encounter issues on AMD GPUs or M-Processors.
Installation
Running this code requires additional packages. Install them using the
mlextra:pip install -e ".[ml]"(includestorch,sphericart[torch]andnormflows)Additionally, you’ll need two checkpoint files to run
NFResponseandNFBackground, which you can find on Wasabi (thanks @GallegoSav).Closes #389