Skip to content

Support for cupyx.scipy.linalg#7563

Merged
jsignell merged 12 commits intodask:mainfrom
quasiben:fix/cupy-lstsq
May 3, 2021
Merged

Support for cupyx.scipy.linalg#7563
jsignell merged 12 commits intodask:mainfrom
quasiben:fix/cupy-lstsq

Conversation

@quasiben
Copy link
Member

@quasiben quasiben commented Apr 15, 2021

@github-actions github-actions bot added the array label Apr 15, 2021
@quasiben quasiben changed the title add safe function for cupyx/scipy linalg solve_triangular CuPy support for solve_triangular Apr 15, 2021
@quasiben quasiben requested a review from pentschev April 15, 2021 22:31
@jrbourbeau jrbourbeau mentioned this pull request Apr 20, 2021
3 tasks
Copy link
Member

@jrbourbeau jrbourbeau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to check in here. Is this something we'd like to get into the release tomorrow, or are we okay waiting until the one after that?

@quasiben
Copy link
Member Author

No, this can wait. But thanks for checking in

Comment on lines +587 to +594
if is_cupy_type(a):
import cupyx.scipy.linalg

func = getattr(cupyx.scipy.linalg, func_name)
else:
import scipy.linalg

func = getattr(scipy.linalg, func_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could use Dispatch for this kind of thing

dask/dask/sizeof.py

Lines 17 to 28 in c5633c2

sizeof = Dispatch(name="sizeof")
@sizeof.register(object)
def sizeof_default(o):
return getsizeof(o)
@sizeof.register(bytes)
@sizeof.register(bytearray)
def sizeof_bytes(o):
return len(o)

We could also then do lazy registration with this

dask/dask/sizeof.py

Lines 97 to 106 in c5633c2

@sizeof.register_lazy("numpy")
def register_numpy():
import numpy as np
@sizeof.register(np.ndarray)
def sizeof_numpy_ndarray(x):
if 0 in x.strides:
xs = x[tuple(slice(None) if s != 0 else slice(1) for s in x.strides)]
return xs.nbytes
return int(x.nbytes)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's a good idea if this grows more. As it stands now, this PR only adds solve_triangular. I tried adding in lu but ran into a number of issues to due to lack of int64 support in the cupy implementation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I had some code here that might be relevant ( jakirkham@81adbc8 ). Though feel free to skip it if you would rather

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also thinking about this in the context of dispatch refactoring work going on around Arrays and DataFrames ( #7505 ) ( #7503 )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried adding in lu but ran into a number of issues to due to lack of int64 support in the cupy implementation

Just to clarify is that suppose to be float64? While we may be able to provide int64 arrays, expect these would likely need to be casted to float64 and then the result would also be in float64. Though maybe I'm misunderstanding something here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I think we need int64 support for lu functionality. Or maybe a conversion is what scipy lu does and I'm unaware of it

Copy link
Member

@pentschev pentschev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, thanks @quasiben .

@quasiben quasiben changed the title CuPy support for solve_triangular Support for cupyx.scipy.linalg Apr 29, 2021
@jsignell
Copy link
Member

jsignell commented May 3, 2021

Seems like this is good to merge right @quasiben?

@quasiben
Copy link
Member Author

quasiben commented May 3, 2021

Yeah, this can be merged now

@jsignell jsignell merged commit a81fed4 into dask:main May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants