Repository navigation
Exposes DeviceBatchedTopK::{Min,Max}{Keys,Pairs} for non-deterministic, unordered, and small segments-only - #9331
Conversation
|
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. |
|
/ok to test 5e447db |
5e447db to
84707e0
Compare
|
/ok to test 84707e0 |
This comment has been minimized.
This comment has been minimized.
5244000 to
bf86bed
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds the public ChangesDeviceBatchedTopK Implementation and Coverage
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
cub/cub/device/device_batched_topk.cuh (1)
131-131: 💤 Low valuesuggestion: Missing
conston non-modified variable.Per coding guidelines, all variables that are not modified must use
const.- auto stream = ::cuda::__call_or(::cuda::get_stream, ::cuda::stream_ref{cudaStream_t{}}, env); + const auto stream = ::cuda::__call_or(::cuda::get_stream, ::cuda::stream_ref{cudaStream_t{}}, env);Source: Coding guidelines
cub/test/catch2_test_device_batched_topk_api.cu (1)
181-191: ⚡ Quick winsuggestion: strengthen pair tests to assert top-k/min-k key content per segment (like the keys-only tests) and add explicit bounds checks before indexing
h_keys_in[h_values_out[...]]. Current checks only verify key/value association and can miss ranking regressions.
As per coding guidelines,cub/**/*reviews should focus on algorithm correctness and test coverage.Also applies to: 249-257
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 15d66aaf-5a41-4f97-8f96-2cc85967f600
📒 Files selected for processing (8)
cub/cub/device/device_batched_topk.cuhcub/cub/device/dispatch/kernels/kernel_batched_topk.cuhcub/examples/device/example_device_batched_topk_keys.cucub/examples/device/example_device_batched_topk_pairs.cucub/test/catch2_test_device_batched_topk_api.cucub/test/catch2_test_device_batched_topk_env_api.cucub/test/catch2_test_device_segmented_topk_keys.cucub/test/catch2_test_device_segmented_topk_pairs.cu
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: eeb0ed08-dd40-4e36-a833-46526b2d846f
📒 Files selected for processing (4)
cub/cub/device/device_batched_topk.cuhcub/cub/device/device_topk.cuhdocs/cub/api.rstdocs/cub/api_docs/device_topk_requirements.rst
✅ Files skipped from review due to trivial changes (2)
- docs/cub/api.rst
- cub/cub/device/device_topk.cuh
🚧 Files skipped from review as they are similar to previous changes (1)
- cub/cub/device/device_batched_topk.cuh
This comment has been minimized.
This comment has been minimized.
4685962 to
074f048
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
cub/cub/device/device_batched_topk.cuh (2)
294-298:⚠️ Potential issue | 🟠 Major | ⚡ Quick winimportant: Remove the default
{}environment from these public overloads, or stop documentingenvas optional.
detail::dispatch_batched_topkhard-rejects any environment that does not explicitly requirecuda::execution::determinism::not_guaranteedpluscuda::execution::output_ordering::unsortedat Lines 89-93, so everyEnvT env = {}here is an unusable default. Right now the public signature and docs advertise an optional parameter that immediately fails at compile time on the default call path.Also applies to: 305-315, 358-366, 413-423, 464-472, 538-550, 590-599, 649-661, 701-710
25-35: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winimportant: Add the direct include for
::cuda::std::int64_t.This header forms
default_policy_selector_twith::cuda::std::int64_tat Line 117 but never includes the defining header. That leaves a public header depending on transitive includes and include order. As per coding guidelines, "Files must include all headers related to the symbols that they are using. No transitive header inclusions are allowed."Also applies to: 114-121
Source: Coding guidelines
🧹 Nitpick comments (1)
cub/cub/device/device_batched_topk.cuh (1)
306-315: ⚡ Quick winsuggestion: Mark the device-storage overloads
[[nodiscard]]too.These four public entry points return
cudaError_t, but only the env-managed overloads enforce status checking. That makes it easy to drop launch or temp-storage query failures silently on the new API surface. As per coding guidelines, "Most functions with a non-void return type shall use[[nodiscard]]attribute."Also applies to: 414-423, 539-550, 650-661
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: db52dab9-9922-4749-8a59-2b2958426960
📒 Files selected for processing (1)
cub/cub/device/device_batched_topk.cuh
This comment has been minimized.
This comment has been minimized.
074f048 to
af679b6
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
docs/cub/api_docs/device_topk_requirements.rst (1)
45-69:⚠️ Potential issue | 🟠 Major | ⚡ Quick winimportant: Reword the default contract and the GPU-to-GPU row.
This still describes the deterministic/stable-sorted contract as the current default, which conflicts with the compile-time checks in
cub::DeviceTopK/cub::DeviceBatchedTopKthat only acceptdeterminism::not_guaranteed+output_ordering::unsorted. The “Bit-identical across GPUs” row also still needsoutput_ordering::stable_sortedif equal-key positions must be pinned.Also applies to: 284-285
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 2df71ae6-19f0-4660-9f51-f60bdeb0ba5c
📒 Files selected for processing (10)
cub/cub/device/device_batched_topk.cuhcub/cub/device/device_topk.cuhcub/cub/device/dispatch/kernels/kernel_batched_topk.cuhcub/examples/device/example_device_batched_topk_keys.cucub/examples/device/example_device_batched_topk_pairs.cucub/test/catch2_test_device_batched_topk_api.cucub/test/catch2_test_device_batched_topk_env_api.cucub/test/catch2_test_device_segmented_topk_keys.cucub/test/catch2_test_device_segmented_topk_pairs.cudocs/cub/api_docs/device_topk_requirements.rst
✅ Files skipped from review due to trivial changes (2)
- cub/cub/device/device_topk.cuh
- cub/cub/device/dispatch/kernels/kernel_batched_topk.cuh
🚧 Files skipped from review as they are similar to previous changes (7)
- cub/test/catch2_test_device_batched_topk_env_api.cu
- cub/test/catch2_test_device_segmented_topk_keys.cu
- cub/test/catch2_test_device_batched_topk_api.cu
- cub/test/catch2_test_device_segmented_topk_pairs.cu
- cub/examples/device/example_device_batched_topk_pairs.cu
- cub/examples/device/example_device_batched_topk_keys.cu
- cub/cub/device/device_batched_topk.cuh
This comment has been minimized.
This comment has been minimized.
af679b6 to
a2c19d1
Compare
This comment has been minimized.
This comment has been minimized.
a2c19d1 to
419fde2
Compare
This comment has been minimized.
This comment has been minimized.
acdc270 to
b9ffd43
Compare
…segmented-topk # Conflicts: # cub/test/catch2_test_device_segmented_topk_keys.cu # cub/test/catch2_test_device_segmented_topk_pairs.cu
This comment has been minimized.
This comment has been minimized.
Jacobfaib
left a comment
There was a problem hiding this comment.
LGTM generally speaking
| "cub::DeviceBatchedTopK: num_segments must be a cuda::args annotation or a plain integral value. A " | ||
| "raw pointer or iterator is not accepted."); | ||
|
|
||
| const auto stream = ::cuda::__call_or(::cuda::get_stream, ::cuda::stream_ref{cudaStream_t{}}, env); |
There was a problem hiding this comment.
@pciolkosz IMO we should at least have an internal cuda::__null_stream_ref that does cuda::stream_ref{cudaStream_t{}}. I see this all the time (and use it myself many times as well).
| template <typename KeyInputIteratorItT, | ||
| typename KeyOutputIteratorItT, | ||
| typename SegmentSizeParameterT, | ||
| typename KParameterT, |
There was a problem hiding this comment.
Do you validate anywhere that KParameterT is an expected type? So either a cuda::args or bare value or whatever.
There was a problem hiding this comment.
Yup, detail::dispatch_batched_topk static_asserts that each of SegmentSizeParameterT, KParameterT, and NumSegmentsParameterT is either a cuda::args wrapper or a plain integral. Raw pointers/iterators are rejected. Every public overload funnels through detail::dispatch_batched_topk.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
suggestion: consider adding new header in |
Good catch. Fixed. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🥳 CI Workflow Results🟩 Finished in 3h 06m: Pass: 100%/287 | Total: 3d 02h | Max: 1h 05m | Hits: 100%/200001See results here. |
Description
Rendered docs:
cub:DeviceBatchedTopK — CUDA Core Compute Libraries.pdf
This work depends on the following work that needs to be merged first:
cuda::execution::tie_breakrequirement #9238 (Introduce an option to specify atie_breakingbehavior in the requirements API #9255)cub::DeviceBatchedTopK#9254)Closes #7616