rapidsai / raft

RAFT contains fundamental widely-used algorithms and primitives for machine learning and information retrieval. The algorithms are CUDA-accelerated and form building blocks for more easily writing high performance applications.
https://docs.rapids.ai/api/raft/stable/
Apache License 2.0
680 stars 180 forks source link

[FEA] Consolidate SUM reductions across raft #2366

Open mfoerste4 opened 1 week ago

mfoerste4 commented 1 week ago

Is your feature request related to a problem? Please describe. Brought up by https://github.com/rapidsai/raft/issues/2205 the sum kernel has been adapted to account for underflow issues when adding large amounts of values. However, there are several other locations within the code where summations are done naively like stdev/var, and the more general reduction abstraction.

Describe the solution you'd like I would prefer a more robust implementation (e.g. KahanBabushkaNeumaierSum as in the sum kernel ) to be placed as a special implementation for the add-operator within the general reduction implementation (coalesced/strided). We already have a specialization for add reduction operator in the strided reduction. APIs like sumand stdev should delegate to these abstractions.

Additional context See https://github.com/rapidsai/raft/issues/2205 for the initial bug report.