Add approx_distinct_count - #20735
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. |
…unction (#779) While working on NVIDIA/cudf#20735, we observed that the HLL ref was not copyable. This PR resolves the issue by converting the `register_mask` data member into a member function, which makes the HLL reference implicitly copyable as intended.
|
As discussed, should the class |
@ttnghia There is a design question to clarify. We generally do not expose public device APIs or templated APIs in libcudf. Making the API templated also means we can’t separate declarations and definitions, which effectively forces it into a This PR was primarily motivated by the Velox use case. After checking with the team, cuDF operators are currently integrated into Velox via host-side APIs rather than device APIs. Given that |
|
How about only implement the detailed class approx_distinct_count as a template class, keeping the class declared in the public header intact? We ( |
|
FYI I'm fine with defer further changes to the next PR merging into the next release. Just want to make clear about the direction that we need to move onto. However, if the suggested changes only take a few lines of code then it would be great to have here 😄 |
Sure, that’s what I wanted to propose as well. We’re already following the same pattern for |
| * | ||
| * This range represents a practical engineering compromise from HLL++ and is widely | ||
| * adopted by systems such as Apache Spark. The default of 12 aligns with Spark's | ||
| * configuration and is the largest precision that fits efficiently in GPU shared memory, |
There was a problem hiding this comment.
This isn't fully correct. p=12 results in a 16KB sketch which is just a small fraction of the available shared memory. cuco's implementation uses dynamic shared memory, and can thus go beyond 200KB on B200 for example. p=13 (32KB) safely fits into static shared memory on older architectures that don't have extended dynamic shared memory capacity.
There was a problem hiding this comment.
My guess is that the tests were run on a the lowest-performance card needed by spark or they need to support multi-stream executions on a single card.
| * @param stream CUDA stream used for device memory operations and kernel launches | ||
| */ | ||
| approx_distinct_count(cuda::std::span<cuda::std::byte> sketch_span, | ||
| std::int32_t precision, |
There was a problem hiding this comment.
precision is a parameter specific to the HLL++ implementation. Ideally the interface is agnostic to the algorithm under the hood. We could replace it with some more general concept like standard deviation and then select the corresponding lower bound precision value for the implementation.
bdice
left a comment
There was a problem hiding this comment.
Some small comments, but generally looks good.
|
/merge |
Description
Closes #20774
This PR adds an
approx_distinct_countclass which uses Hyperloglog++ under the hood to provide approximate distinct count estimation.Checklist