-
Notifications
You must be signed in to change notification settings - Fork 915
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
Optimize to_cupy
and values
#11648
Comments
This issue has been labeled |
CC @mroeschke (might be of interest given some of your recent comments about converting to device and all the internal reworkings you're doing with our columns) |
xref #11648 Essentially refactors `Frame._to_array` to short circuit some checks for a `Frame` with 1 column or `ndim == 1` ```python In [1]: import cudf In [2]: s = cudf.Series(range(10000)) In [3]: %timeit s.to_cupy() 252 µs ± 3.47 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) # PR 419 µs ± 2.21 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) # branch 24.06 ``` I needed to add `Frame.ndim` which will raise a `NotImplementedError` (until Frame actually becomes an ABC) Authors: - Matthew Roeschke (https://github.com/mroeschke) Approvers: - Bradley Dice (https://github.com/bdice) - GALI PREM SAGAR (https://github.com/galipremsagar) URL: #15792
Currently
series.values
and especiallyseries.to_cupy()
are substantially slower thancupy.asarray(series)
.There are at least two obvious potential culprits in
Frame._to_array
(the underlying method forto_cupy
):copy=False
.find_common_dtype
, which is slow (and slower forDataFrame
s with many columns):The implementation of
values
drops down toColumnBase.values
and requires some deeper consideration. However, since we use.values
frequently internally (and we occasionally useto_cupy
) we are likely giving up a lot of performance. We should profile these functions to determine the bottlenecks, and if there are valid reasons for them we should establish some policies on how to select the right function to use when performing these conversions to arrays internally. While this exact analogy does not hold forDataFrame
(because that doesn't support the conversion to an array), any optimization that we make forSeries
will likely also help speed upDataFrame
operations.The text was updated successfully, but these errors were encountered: