-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from pynapple-org/dev
Dev
- Loading branch information
Showing
35 changed files
with
1,499 additions
and
1,398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Pynapple has been designed as a lightweight package for representing time series and epochs in system neuroscience. | ||
As such, it can function as a foundational element for other analysis packages handling time series data. Here we keep track of external projects that uses pynapple. | ||
|
||
|
||
## NEMOS | ||
|
||
 | ||
|
||
[NeMOs](https://nemos.readthedocs.io/en/stable/) is a statistical modeling framework optimized for systems neuroscience and powered by JAX. It streamlines the process of defining and selecting models, through a collection of easy-to-use methods for feature design. | ||
|
||
The core of nemos includes GPU-accelerated, well-tested implementations of standard statistical models, currently focusing on the Generalized Linear Model (GLM). | ||
|
||
Check out this [page](https://nemos.readthedocs.io/en/stable/generated/neural_modeling/) for many examples of neural modelling using nemos and pynapple. | ||
|
||
!!! note | ||
Nemos is build on top of [jax](https://jax.readthedocs.io/en/latest/index.html), a library for high-performance numerical computing. | ||
To ensure full compatibility with nemos, consider installing [pynajax](https://github.com/pynapple-org/pynajax), a pynapple backend for jax. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
### Motivation | ||
|
||
Multiple python packages exist for high-performance computing. Internally, pynapple makes extensive use of [numba](https://numba.pydata.org/) for accelerating some functions. Numba is a stable package that provide speed gains with minimal installation issues when running on CPUs. | ||
|
||
Another high-performance toolbox for numerical analysis is | ||
[jax](https://jax.readthedocs.io/en/latest/index.html). In addition to accelerating python code on CPUs, GPUs, and TPUs, it provides a special representation of arrays using the [jax Array object](https://jax.readthedocs.io/en/latest/jax-101/01-jax-basics.html). Unfortunately, jax Array is incompatible with Numba. To solve this issue, we developped [pynajax](https://github.com/pynapple-org/pynajax). | ||
|
||
Pynajax is an accelerated backend for pynapple built on top on jax. It offers a fast acceleration for some pynapple functions using CPU or GPU. Here is a minimal example on how to use pynajax: | ||
|
||
``` bash | ||
$ pip install pynajax | ||
``` | ||
|
||
|
||
|
||
``` python | ||
import pynapple as nap | ||
import numpy as np | ||
|
||
# Changed the backend from 'numba' to 'jax' | ||
nap.nap_config.set_backend("jax") | ||
|
||
# This will convert the numpy array to a jax Array. | ||
tsd = nap.Tsd(t=np.arange(100), d=np.random.randn(100)) | ||
|
||
# This will run on GPU or CPU depending on the jax installation | ||
tsd.convolve(np.ones(11)) | ||
``` | ||
|
||
This documentation page keeps tracks of the list of pynapple functions that can be jax-accelerated as well as their performances compared to pure numba. | ||
|
||
### Installation issues | ||
|
||
To get the best of the pynajax backend, jax needs to use the GPU. | ||
|
||
While installing pynajax will install all the dependencies necessary to use jax, it does not guarantee | ||
the use of the GPU. | ||
|
||
To check if jax is using the GPU, you can run the following python commands : | ||
|
||
- no GPU found : | ||
|
||
```python | ||
>>> import jax | ||
>>> print(jax.devices()) | ||
[CpuDevice(id=0)] | ||
``` | ||
|
||
- GPU found : | ||
|
||
```python | ||
>>> import jax | ||
>>> print(jax.devices()) | ||
[cuda(id=0)] | ||
``` | ||
|
||
Support for installing `JAX` for GPU users can be found in the [jax documentation](https://jax.readthedocs.io/en/latest/installation.html) | ||
|
||
|
||
### Typical use-case | ||
|
||
|
||
In addition to providing high performance numerical computing, jax can be used as a the backbone for a large scale machine learning model. Thus, pynajax can offer full compatibility between pynapple's time series representation and computational neuroscience models constructed using jax. | ||
|
||
An example of a python package using both pynapple and jax is [NeMOs](https://nemos.readthedocs.io/en/stable/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
__version__ = "0.6.4" | ||
from .core import IntervalSet, Ts, Tsd, TsdFrame, TsdTensor, TsGroup, TsIndex, config | ||
from .core import ( | ||
IntervalSet, | ||
Ts, | ||
Tsd, | ||
TsdFrame, | ||
TsdTensor, | ||
TsGroup, | ||
TsIndex, | ||
nap_config, | ||
) | ||
from .io import * | ||
from .process import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.