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

Add more backends #9

Open
6 of 8 tasks
dcharbon opened this issue Feb 19, 2019 · 13 comments
Open
6 of 8 tasks

Add more backends #9

dcharbon opened this issue Feb 19, 2019 · 13 comments
Assignees

Comments

@dcharbon
Copy link

dcharbon commented Feb 19, 2019

@hameerabbasi hameerabbasi self-assigned this Feb 19, 2019
@hameerabbasi
Copy link
Collaborator

@MridulS is working on the Dask backend! (Thanks!)

@hameerabbasi
Copy link
Collaborator

I added the CuPy and PyData/Sparse backends!

@MridulS
Copy link
Contributor

MridulS commented May 9, 2019

@hameerabbasi Have you ran any benchmarks for CuPy yet?

@hameerabbasi
Copy link
Collaborator

Time for calculating the exponential of an array of length 10 ** 8:

float64: 119 ms vs 25.1 ms
float32: 54 ms vs 5.76 ms

@hameerabbasi hameerabbasi transferred this issue from Quansight-Labs/uarray Aug 21, 2019
@grlee77
Copy link
Contributor

grlee77 commented Dec 17, 2019

Another potential candidate for inclusion is MXNet which also provides some subset of the NumPy API. I was recently contacted by their team as a potential user, but have not yet tried it out. There is a nice overview given in this post
https://medium.com/apache-mxnet/a-new-numpy-interface-for-apache-mxnet-incubating-dbb4a4096f9f?

Specifically there appears to be CPU and GPU implementations of NumPy functions (in C++/CUDA) here:
https://github.com/apache/incubator-mxnet/tree/master/src/operator/numpy

@dhirschfeld
Copy link

I'd personally prefer depth rather than breadth at this point in development - i.e. implement a small number of backends well rather than trying to implement (and support) every possible framework out there.

@jbogaardt
Copy link

This conceptually seems like an awesome project and I look forward to seeing its development. I'm wondering if I am trying to jump onto it too soon though or I am using it wrong.

Trying to elaborate on your docs with the following example, I cannot get it to work with a cupy backend. Are the backends available in v0.6.0?

import uarray as ua
import unumpy as np
import unumpy.cupy_backend as cupy_backend
import unumpy.numpy_backend as numpy_backend

def main():
    x = np.zeros(5)
    return np.exp(x)

print(ua.__version__)
print(np.__version__)
# works
with ua.set_backend(numpy_backend):
    print(main())
# does not work
with ua.set_backend(cupy_backend):
    print(main())

0.6.0
0.6.0
[1. 1. 1. 1. 1.]

AttributeError Traceback (most recent call last)
in ()
14 print(main())
15 # does not work
---> 16 with ua.set_backend(cupy_backend):
17 print(main())

~\AppData\Local\Continuum\anaconda3\lib\site-packages\uarray_backend.py in set_backend(backend, coerce, only)
270 pass
271
--> 272 ctx = _SetBackendContext(backend, coerce, only)
273 backend.ua_cache["set", coerce, only] = ctx
274 return ctx

AttributeError: module 'unumpy.cupy_backend' has no attribute 'ua_domain'

@hameerabbasi
Copy link
Collaborator

@jbogaardt Unfortunately, I cannot test CuPy on CI, so it tends to lag behind. #34 fixes this. Thanks, @grlee77.

@jbogaardt
Copy link

Excellent. I look forward to the next release.

@jbogaardt
Copy link

follow up question @hameerabbasi , dask and cupy are starting to become interoperable:
https://matthewrocklin.com/blog//work/2019/01/03/dask-array-gpus-first-steps

Do you envision the backend setup ever supporting combo backends like dask + cupy or will dask_backend always be a chunked numpy array?

@hameerabbasi
Copy link
Collaborator

@jbogaardt

Do you envision the backend setup ever supporting combo backends like dask + cupy or will dask_backend always be a chunked numpy array?

This is already possible. You just do the following:

with ua.set_backend(cupy_backend), ua.set_backend(dask_backend):
    ...

The order is reversed from what one would normally expect, but think of it in the following manner: The inner backend gets set last, and then dominates, and then, inside its own code, skips "itself", and dispatches to the next prominent backend. I guess one could provide a utility in uarray to do this. 😄

@jbogaardt
Copy link

That is awesome. This is truly an amazing library you're building. Thank you @hameerabbasi !

@hameerabbasi
Copy link
Collaborator

@jbogaardt unumpy 0.6.1 is up on PyPI and conda-forge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants