Repository navigation
Conversation
|
Gather (scatter) summary:
|
|
This is probably not going to do much for the listed issue. The issue here is the number of raw thrust and kernel calls stemming from nesting (think thousands of columns underneath the top level table). The fix for that is going to be smarter parallelization of what is currently the recursive cpu-side approach. We have some ideas here. |
| // only a single column, the fork/join overhead should be avoided. | ||
| auto streams = std::vector<rmm::cuda_stream_view>{}; | ||
| if (num_columns > 1) { | ||
| streams = cudf::detail::fork_streams(stream, num_columns); |
There was a problem hiding this comment.
I am curious how this works for per-thread default stream. For spark, we build cuDF with PTDS. Will streams will be have number-of-columns vector of the PTDS stream?
There was a problem hiding this comment.
The stream passed in would be the PTDS stream. Then a stream pool (for that thread) would be created (or reused), the work would be executed across that stream pool, and then the join step would insert events for all the elements of streams to be synchronized with stream before new work on stream (the PTDS stream in Spark's case) would be runnable.
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
@mythrocks Could you pick this up? I just merged some changes that pull it up-to-date with |
I'm on it, mate. Thank you for this change. I'll post here with any findings. |
| // only a single column, the fork/join overhead should be avoided. | ||
| auto streams = std::vector<rmm::cuda_stream_view>{}; | ||
| if (num_columns > 1) { | ||
| streams = cudf::detail::fork_streams(stream, num_columns); |
There was a problem hiding this comment.
this will emit a warning when there are more columns than streams in the pool. We can remove with warning; otherwise it's probably good to limit the number of streams to the pool size.
There was a problem hiding this comment.
Is there a good/recommended number? And is it tuned by hand or automatically computed?
There was a problem hiding this comment.
It's fine to use all streams in the pool, I don't think we need to tune this.
but getting more reuses them in round-robin fashion and we have a warning because maybe it's an unexpected behavior for users.
There was a problem hiding this comment.
I knew we did round-robin, I did not know we issued a warning. I think removing the warning would be appropriate.
|
|
||
| auto it = thrust::make_counting_iterator<size_type>(0); | ||
|
|
||
| std::transform(it, it + num_columns, result.begin(), [&](size_type i) { |
There was a problem hiding this comment.
thrust::tabulate saves a bit of code here
There was a problem hiding this comment.
Doesn't work here, because the lambda passed to thrust::tabulate(thrust::host, ...) gets compiled as __host__ __device__ even when using the host execution policy. The lambda returns std::unique_ptr<column> which involves move-assignment that's not valid in device code.
|
I'll retarget this to 25.06. This will be good to have, but it didn't help NVIDIA/cudf-spark#12195. It simply wasn't the slow path, in this case. :/ |
|
Moved to 25.08. @mythrocks said that he should be able to get this done for the next release. |
|
@mythrocks Any interest in picking this up? Rebenchmarking is probably the first step. |
|
Sorry, I've been sitting on this for a while now, and holding up progress. I'd better relinquish, in case someone else is able to run with it. |
|
Regression: After identified the root cause and fix: The regression is due to a bug in CCCL |
|
/ok to test 5ac0ad0 |
6deb582 to
fb980bf
Compare
fb980bf to
fbc3c20
Compare
fce92f2 to
686a6fd
Compare
|
(Re-kicking the build after update.) |
|
/ok to test 4ead16e |
Fixes stream-ordering bugs identified in NVIDIA#14162 (comment). JSON (`ingest_raw_input`): Added a missing `join_streams` call. Fixed a race condition between the `memcpy_batch_async` and `thrust::scatter` on the user stream and `device_read_async` on the pool streams. CSV (`read_csv`): Reassign the deallocation stream on string columns to the user stream so all output columns are deallocated on the user stream. Authors: - Vukasin Milovanovic (https://github.com/vuule) Approvers: - Muhammad Haseeb (https://github.com/mhaseeb123) - Bradley Dice (https://github.com/bdice) - Yunsong Wang (https://github.com/PointKernel) URL: NVIDIA#21908
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR adds stream-forking heuristics to gather and scatter, routes multi-column work through per-column streams, updates null-mask handling and stream rebinds, and expands gather/scatter tests plus integration coverage. ChangesStream-forking support for gather and scatter
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cpp/include/cudf/detail/gather.cuh (1)
97-99: 💤 Low valueConsider simplifying the
effective_capcalculation.The
std::max(size_type{2}, max_forked_streams / 2)guard evaluates tostd::max(2, 4) = 4whenmax_forked_streams = 8. Sincemax_forked_streams / 2 = 4 >= 2always, thestd::maxis redundant. Consider simplifying tomax_forked_streams / 2or defining a named constant likemin_forked_streams = 4.♻️ Optional simplification
- auto const effective_cap = bytes_per_col >= config.bytes_for_full_streams - ? config.max_forked_streams - : std::max<std::size_t>(1, config.max_forked_streams / 2); + auto const effective_cap = bytes_per_col >= config.bytes_for_full_streams + ? config.max_forked_streams + : std::max<std::size_t>(1, config.max_forked_streams / 2);Or define a constant:
constexpr std::size_t half_cap = config.max_forked_streams / 2; auto const effective_cap = bytes_per_col >= config.bytes_for_full_streams ? config.max_forked_streams : std::max<std::size_t>(1, half_cap);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cpp/include/cudf/detail/gather.cuh` around lines 97 - 99, The ternary computing effective_cap is more complex than needed: replace the else branch std::max<std::size_t>(1, config.max_forked_streams / 2) with a simpler, explicit value—either use config.max_forked_streams / 2 directly or introduce a named constant (e.g., constexpr std::size_t min_forked_streams = 4) and use std::max<std::size_t>(min_forked_streams, config.max_forked_streams / 2); update the expression that assigns effective_cap (which uses bytes_per_col and config.bytes_for_full_streams) accordingly so the logic remains the same but the else branch is simplified and clearer.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@cpp/include/cudf/detail/gather.cuh`:
- Around line 97-99: The ternary computing effective_cap is more complex than
needed: replace the else branch std::max<std::size_t>(1,
config.max_forked_streams / 2) with a simpler, explicit value—either use
config.max_forked_streams / 2 directly or introduce a named constant (e.g.,
constexpr std::size_t min_forked_streams = 4) and use
std::max<std::size_t>(min_forked_streams, config.max_forked_streams / 2); update
the expression that assigns effective_cap (which uses bytes_per_col and
config.bytes_for_full_streams) accordingly so the logic remains the same but the
else branch is simplified and clearer.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 8c93fda4-b504-447b-a192-405dd7e686e0
📒 Files selected for processing (8)
cpp/include/cudf/detail/gather.cuhcpp/include/cudf/detail/scatter.cuhcpp/include/cudf/detail/utilities/stream_pool.hppcpp/tests/copying/gather_str_tests.cppcpp/tests/copying/gather_tests.cppcpp/tests/copying/scatter_tests.cppcpp/tests/streams/copying_test.cppcpp/tests/streams/pool_test.cu
|
This shows speedups for some intermediate data sizes but can cause some regression at large sizes (where a single stream can already saturate memory bandwidth), so we aren't going to push it into 26.06. We need to more carefully evaluate heuristics for when to use a stream pool and what number of streams to use. It will probably vary according to the hardware. Generally this is a worthwhile endeavor because intermediate data sizes are fairly common, especially as we move towards more streaming engines. For example, Velox-cuDF targets a batch size of 100k rows. |
Benchmark Comparison: upstream/main vs PR 14162
Summary
Top ChangesClick to expand
|
Description
This PR uses the stream pool introduced in #13922 to gather/scatter each column in a table on a separate stream.
Related: #13509, which this might resolve (need to verify).
Checklist