You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
In a number of places in the implementation of Column methods, we obtain a result by first converting to a SingleColumnFrame, calling some method there (that unpacks the column, calls into libcudf, and then wraps the column back up in a frame), and then unpacking the frame back into a column.
For example, Column.argsort is implemented by calling into Frame._get_sorted_inds:
Some minimal microbenchmarking suggests that this is ~30microseconds faster (around 1% of the runtime for a column with a million random floats on my hardware).
In [32]: x = cudf.core.column.as_column(np.random.uniform(size=1_0))
In [33]: %timeit x.argsort();
145 µs ± 82.1 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
In [34]: %timeit libcudf.sort.order_by([x], [True], "last")
117 µs ± 128 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
In [35]: x = cudf.core.column.as_column(np.random.uniform(size=1_000))
In [36]: %timeit x.argsort();In [32]: x = cudf.core.column.as_column(np.random.uniform(size=1_0))
In [33]: %timeit x.argsort();
145 µs ± 82.1 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
In [34]: %timeit libcudf.sort.order_by([x], [True], "last")
117 µs ± 128 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
In [35]: x = cudf.core.column.as_column(np.random.uniform(size=1_000))
In [36]: %timeit x.argsort();
192 µs ± 682 ns per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
In [37]: %timeit libcudf.sort.order_by([x], [True], "last")
164 µs ± 360 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
In [38]: x = cudf.core.column.as_column(np.random.uniform(size=100_000))
In [39]: %timeit x.argsort();
418 µs ± 260 ns per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
In [40]: %timeit libcudf.sort.order_by([x], [True], "last")
390 µs ± 247 ns per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
In [41]: x = cudf.core.column.as_column(np.random.uniform(size=10_000_000))
In [42]: %timeit x.argsort();
40.3 ms ± 8.01 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [43]: %timeit libcudf.sort.order_by([x], [True], "last")
40.3 ms ± 11.8 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
192 µs ± 682 ns per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
In [37]: %timeit libcudf.sort.order_by([x], [True], "last")
164 µs ± 360 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
In [38]: x = cudf.core.column.as_column(np.random.uniform(size=100_000))
In [39]: %timeit x.argsort();
418 µs ± 260 ns per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
In [40]: %timeit libcudf.sort.order_by([x], [True], "last")
390 µs ± 247 ns per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
In [41]: x = cudf.core.column.as_column(np.random.uniform(size=10_000_000))
In [42]: %timeit x.argsort();
40.3 ms ± 8.01 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [43]: %timeit libcudf.sort.order_by([x], [True], "last")
40.3 ms ± 11.8 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
Describe alternatives you've considered
None
The text was updated successfully, but these errors were encountered:
Completely agree that we want to get rid of this. Removing ColumnBase.as_frame is mentioned somewhere in my refactoring doc but I guess it's one of the few remaining items that hadn't been converted into an issue. Thank you for documenting the perf implications so thoroughly!
Previously a number of algorithms on Columns first converted to a
single column frame and called a frame-based algorithm (which calls
directly into libcudf using the column we first thought of). This is
unnecessary since we already have the column to hand when calling the
same algorithm at the column level. Moreover, in many cases where the
algorithm is a user-facing API, the frame-based approach does more
work (for example conversions and dtype matching).
By removing this round trip we reduce some (unnecessary) overhead, and
also make the memory footprint and behaviour of column-based methods
more transparent.
- Closes#13565
Previously a number of algorithms on Columns first converted to a single column frame and called a frame-based algorithm (which calls directly into libcudf using the column we first thought of). This is unnecessary since we already have the column to hand when calling the same algorithm at the column level. Moreover, in many cases where the algorithm is a user-facing API, the frame-based approach does more work (for example conversions and dtype matching).
By removing this round trip we reduce some (unnecessary) overhead, and also make the memory footprint and behaviour of column-based methods more transparent.
- Closes#13565
Authors:
- Lawrence Mitchell (https://github.com/wence-)
Approvers:
- GALI PREM SAGAR (https://github.com/galipremsagar)
- Bradley Dice (https://github.com/bdice)
URL: #14491
Is your feature request related to a problem? Please describe.
In a number of places in the implementation of
Column
methods, we obtain a result by first converting to aSingleColumnFrame
, calling some method there (that unpacks the column, calls into libcudf, and then wraps the column back up in a frame), and then unpacking the frame back into a column.For example,
Column.argsort
is implemented by calling intoFrame._get_sorted_inds
:cudf/python/cudf/cudf/core/column/column.py
Lines 1096 to 1101 in ceeb392
But that is just a round-about way of calling
libcudf.order_by
:cudf/python/cudf/cudf/core/frame.py
Lines 1565 to 1583 in ceeb392
Describe the solution you'd like
The
Column
API should not talk about frames at all, and call directly into libcudf, since we have all the information to hand.For example,
argsort
could be implemented directly as a call tolibcudf.sort.order_by
.Some minimal microbenchmarking suggests that this is ~30microseconds faster (around 1% of the runtime for a column with a million random floats on my hardware).
Describe alternatives you've considered
None
The text was updated successfully, but these errors were encountered: