Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CuPy tensor backend #238

Open
lukasheinrich opened this issue Sep 7, 2018 · 10 comments
Open

CuPy tensor backend #238

lukasheinrich opened this issue Sep 7, 2018 · 10 comments
Assignees
Labels
feat/enhancement New feature or request research experimental stuff

Comments

@lukasheinrich
Copy link
Contributor

Description

following the discussion in #231 it should be quite easy to get a CuPy backend into pyhf

https://cupy.chainer.org/

it's advertised as a drop-in replacement for numpy. This will give us GPU acceleration (like TF and PyTorch, but separate from autodifferentiation -- which might be nice to have)

@matthewfeickert has some experience in writing these backends and iirc access to a CUDA enabled machine.

@matthewfeickert
Copy link
Member

Sweet! That looks really cool. I'll poke at their docs over the weekend and then we can see if it is any more work to add in then normal.

@lukasheinrich
Copy link
Contributor Author

i'd be especially interested in whether we can use the normal scipy based optmization with that. or if we also have to code one ourselves

@matthewfeickert
Copy link
Member

This is looking promising, given this section of the docs:

How to write CPU/GPU agnostic code

@lukasheinrich
Copy link
Contributor Author

maybe relevant cupy/cupy#1196

@matthewfeickert matthewfeickert added feat/enhancement New feature or request research experimental stuff labels Sep 7, 2018
@matthewfeickert matthewfeickert self-assigned this Sep 7, 2018
@matthewfeickert
Copy link
Member

Ah, so I'll need to set things up at my cluster to actually do this, as the requirements to even install include CUDA. So this isn't just CUDA enabled, but actually built using CUDA (this actually sounds like a good thing to me).

@matthewfeickert
Copy link
Member

As an update, I'm still working on this, but I'm waiting to hear back on the HPC admins on my cluster. For technical reasons they might make me submit a list of all software that I want and they will setup the testing environment for me. This could be nice, but might result in a few days delay.

@matthewfeickert
Copy link
Member

Something else that I should look into is ClPy: OpenCL backend for CuPy, as we're going to want to be able to have CuPy tests run in CI and Travis doesn't support CUDA infrastructure.

@lukasheinrich
Copy link
Contributor Author

lukasheinrich commented Sep 14, 2018

once we get a installation of CuPy it would be very interesting to get a feel of what the hardware speed up looks like. Even before implementing the backend we could run this notebook

BetterKitchenSink.ipynb.zip

probably only the tb = np lines in cell [2] need to be adapted if I understood the link

https://docs-cupy.chainer.org/en/stable/tutorial/basic.html#how-to-write-cpu-gpu-agnostic-code

correctly. right now we get a factor 400 comparing a naive implementation with the new vectorized one (from #251 )

numpy: 127 µs ± 12.2 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
naive: 56.1 ms ± 4.55 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

@matthewfeickert
Copy link
Member

Additional overview material: Shohei Hido - CuPy: A NumPy-compatible Library for GPU, PyCon 2018

@matthewfeickert
Copy link
Member

More additional material: ContinuumIO's Numba and CuPy tutorial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat/enhancement New feature or request research experimental stuff
Projects
None yet
Development

No branches or pull requests

2 participants