Commit 6f1966d
authored
Use stream in cudf_polars.DataFrame.to_polars (#20323)
This ensures that the device-to-host transfer used in `cudf_polars.DataFrame.to_polars` performed on the stream associated with the dataframe.
As a rough test, I updated our stream generation function to always return a new stream:
```diff
diff --git a/python/cudf_polars/cudf_polars/utils/cuda_stream.py b/python/cudf_polars/cudf_polars/utils/cuda_stream.py
index 4f8d540..a3cf6c9 100644
--- a/python/cudf_polars/cudf_polars/utils/cuda_stream.py
+++ b/python/cudf_polars/cudf_polars/utils/cuda_stream.py
@@ -7,7 +7,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING
-from rmm.pylibrmm.stream import DEFAULT_STREAM
+from rmm.pylibrmm.stream import DEFAULT_STREAM, Stream
if TYPE_CHECKING:
from collections.abc import Iterable
@@ -22,7 +22,7 @@ def get_dask_cuda_stream() -> Stream:
def get_cuda_stream() -> Stream:
"""Get the default CUDA stream for the current thread."""
- return DEFAULT_STREAM
+ return Stream()
def join_cuda_streams(
```
And then ran that under nsys. Here's a screenshot of the device-to-host copy that was previously on the default stream.
<img width="1427" height="257" alt="Screenshot 2025-10-21 at 10 31 22 AM" src="https://github.com/user-attachments/assets/5a210e06-9e00-469c-a9e1-1000989b2bb0" />
It's not visible in the screenshot, but there are other `to_arrow_host` calls that still show up on the default stream. I'm tracking those down still.
Closes #20309
Authors:
- Tom Augspurger (https://github.com/TomAugspurger)
Approvers:
- Matthew Roeschke (https://github.com/mroeschke)
URL: #203231 parent e10364d commit 6f1966d
File tree
9 files changed
+58
-27
lines changed- python
- cudf_polars/cudf_polars/containers
- pylibcudf
- pylibcudf
- libcudf
- tests
9 files changed
+58
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
| 66 | + | |
63 | 67 | | |
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
67 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
68 | 74 | | |
69 | 75 | | |
70 | 76 | | |
| |||
108 | 114 | | |
109 | 115 | | |
110 | 116 | | |
111 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
112 | 120 | | |
113 | 121 | | |
114 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | | - | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
96 | | - | |
| 98 | + | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
352 | | - | |
| 352 | + | |
| 353 | + | |
353 | 354 | | |
354 | 355 | | |
355 | 356 | | |
356 | 357 | | |
357 | 358 | | |
358 | 359 | | |
359 | 360 | | |
| 361 | + | |
| 362 | + | |
360 | 363 | | |
361 | 364 | | |
362 | 365 | | |
| |||
371 | 374 | | |
372 | 375 | | |
373 | 376 | | |
374 | | - | |
| 377 | + | |
375 | 378 | | |
376 | 379 | | |
377 | 380 | | |
| |||
1324 | 1327 | | |
1325 | 1328 | | |
1326 | 1329 | | |
1327 | | - | |
| 1330 | + | |
1328 | 1331 | | |
1329 | 1332 | | |
1330 | | - | |
| 1333 | + | |
1331 | 1334 | | |
1332 | 1335 | | |
1333 | 1336 | | |
| |||
1346 | 1349 | | |
1347 | 1350 | | |
1348 | 1351 | | |
1349 | | - | |
| 1352 | + | |
1350 | 1353 | | |
1351 | 1354 | | |
1352 | 1355 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
| 225 | + | |
225 | 226 | | |
226 | 227 | | |
227 | | - | |
| 228 | + | |
| 229 | + | |
228 | 230 | | |
229 | 231 | | |
230 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| 86 | + | |
| 87 | + | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
| |||
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
99 | | - | |
| 102 | + | |
100 | 103 | | |
101 | 104 | | |
102 | 105 | | |
| |||
320 | 323 | | |
321 | 324 | | |
322 | 325 | | |
323 | | - | |
| 326 | + | |
324 | 327 | | |
| 328 | + | |
325 | 329 | | |
326 | | - | |
| 330 | + | |
327 | 331 | | |
328 | 332 | | |
329 | 333 | | |
| |||
342 | 346 | | |
343 | 347 | | |
344 | 348 | | |
345 | | - | |
| 349 | + | |
346 | 350 | | |
347 | 351 | | |
348 | 352 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
7 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
8 | 12 | | |
9 | 13 | | |
10 | | - | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | | - | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
29 | | - | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
0 commit comments