-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Migrate stream APIs from rmm::cuda_stream_view to cuda::stream_ref #23929
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0eaaefc
Adapt stream accessors to cuda::stream_ref
bdice 4200789
Use cuda::stream_ref in reader_impl_dict_transcode.cu
bdice 26732d4
Fix remaining cuda::stream_ref build errors
bdice 9eb23ba
Fix copyright and deprecations
bdice e58849b
Avoid deprecated stream view in streaming groupby test
bdice ba5f035
Fix stream synchronization in C++ examples
bdice b429dc7
Ensure a CUDA context is current when resolving pylibcudf streams
bdice 6ed8041
Extract CUDA context initialization into a helper
bdice 18c6174
Use CUDA bindings stream handles in context tests
bdice 760ac4b
Merge context initialization fix into cuda-stream-ref
bdice 0fae2a3
Add CUDA profiler headers to pylibcudf host requirements
bdice ad4dd18
Use CUDA runtime APIs for pylibcudf stream handling
bdice 815439d
Run CUDA initialization subprocess outside the source checkout
bdice File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import subprocess | ||
| import sys | ||
| from concurrent.futures import ThreadPoolExecutor | ||
|
|
||
| import pyarrow as pa | ||
| import pytest | ||
| from cuda.bindings import runtime | ||
|
|
||
| import pylibcudf as plc | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "stream", | ||
| [ | ||
| None, | ||
| runtime.cudaStream_t(runtime.cudaStreamDefault), | ||
| runtime.cudaStream_t(runtime.cudaStreamLegacy), | ||
| runtime.cudaStream_t(runtime.cudaStreamPerThread), | ||
| ], | ||
| ) | ||
| def test_empty_like_on_fresh_thread(stream): | ||
| column = plc.Column.from_arrow(pa.array([1, 2, 3])) | ||
|
|
||
| def empty_like(): | ||
| result = plc.copying.empty_like(column, stream=stream) | ||
| assert result.size() == 0 | ||
| if stream is not None: | ||
| assert plc.utils._get_stream(stream).__cuda_stream__() == ( | ||
| 0, | ||
| int(stream), | ||
| ) | ||
|
|
||
| with ThreadPoolExecutor(max_workers=1) as pool: | ||
| pool.submit(empty_like).result() | ||
|
|
||
|
|
||
| def test_get_stream_preserves_current_device(): | ||
| status, count = runtime.cudaGetDeviceCount() | ||
| assert status == runtime.cudaError_t.cudaSuccess | ||
|
|
||
| def get_stream(device): | ||
| assert runtime.cudaSetDevice(device) == ( | ||
| runtime.cudaError_t.cudaSuccess, | ||
| ) | ||
| status, stream = runtime.cudaStreamCreate() | ||
| assert status == runtime.cudaError_t.cudaSuccess | ||
| try: | ||
| plc.utils._get_stream() | ||
| assert plc.utils._get_stream(stream).__cuda_stream__() == ( | ||
| 0, | ||
| int(stream), | ||
| ) | ||
| assert runtime.cudaGetDevice() == ( | ||
| runtime.cudaError_t.cudaSuccess, | ||
| device, | ||
| ) | ||
| finally: | ||
| assert runtime.cudaStreamDestroy(stream) == ( | ||
| runtime.cudaError_t.cudaSuccess, | ||
| ) | ||
|
|
||
| with ThreadPoolExecutor(max_workers=1) as pool: | ||
| for device in range(count): | ||
| pool.submit(get_stream, device).result() | ||
|
|
||
|
|
||
| def test_get_stream_rejects_integer_handle(): | ||
| with pytest.raises(TypeError): | ||
| plc.utils._get_stream(runtime.cudaStreamDefault) | ||
|
|
||
|
|
||
| def test_empty_like_initializes_cuda(tmp_path): | ||
| subprocess.run( | ||
| [ | ||
| sys.executable, | ||
| "-c", | ||
| """ | ||
| import pylibcudf as plc | ||
|
|
||
| column = plc.Column(plc.DataType(plc.TypeId.INT32), 0, None, None, 0, 0, []) | ||
| assert plc.copying.empty_like(column).size() == 0 | ||
| """, | ||
| ], | ||
| check=True, | ||
| cwd=tmp_path, | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes
_get_streamacceptruntime.cudaStream_tobjects directly, because older versions ofcuda-bindingsthat we support do not have__cuda_stream__support incuda.bindings.runtime.cudaStream_t.Previously we used Cython wrappers around
rmm::cuda_stream_viewwhich has support for__cuda_stream__and can be implicitly converted tocudaStream_t.