[BUG] A column with one infinity sums to NaN in `raft::stats::sum`
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start in the raft::stats::sum implementation, which is identified by the reproducer’s raft/stats/sum.cuh include. Trace how partial sums and compensation are combined, then run the provided 32-float reproducer for positive infinity, negative infinity, and both signs. Done means single-sign infinity returns that infinity while mixed signs still return NaN; pull request #3233 is already open.
Written by the indexing model from the issue text.
Description
Describe the bug
Put one positive infinity in a column of 32 floats and fill the rest with ones. raft::stats::sum returns NaN. The same thing happens with a single negative infinity and with doubles.
Steps to reproduce
#include <raft/stats/sum.cuh>
#include <rmm/device_uvector.hpp>
#include <array>
#include <cstdio>
#include <limits>
int main()
{
raft::resources handle;
auto stream = raft::resource::get_cuda_stream(handle);
std::array<float, 32> host;
host.fill(1.0f);
host[0] = std::numeric_limits<float>::infinity();
rmm::device_uvector<float> x(host.size(), stream), y(1, stream);
raft::update_device(x.data(), host.data(), host.size(), stream);
raft::stats::sum(handle,
raft::make_device_matrix_view<const float, int, raft::row_major>(x.data(), 32, 1),
raft::make_device_vector_view(y.data(), 1));
float result;
raft::update_host(&result, y.data(), 1, stream);
raft::resource::sync_stream(handle);
std::printf("%g\n", double(result));
}
Expected behavior
The example should print inf. Changing the first entry to negative infinity should give -inf. A column that contains both signs of infinity should still give NaN.
Environment
RAFT main at b74966f, CUDA 12.9.1, GeForce GTX 1660 SUPER, driver 580.159.03. The example was compiled against the source headers with nvcc in the nvidia/cuda:12.9.1-devel-ubuntu24.04 image on Vast.ai.
Additional context
The running sum reaches infinity, then the compensation step subtracts infinity from itself and gets NaN. Adding that correction back changes the result. A local patch keeps the ordinary partial sum when it is already nonfinite. The same example prints inf with that patch.
- Dominant language
- Cuda
- Stars
- 1.1k
- Forks
- 260
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 21
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NVIDIA/raft
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
[BUG] Half-precision gemm fails with CUBLAS_STATUS_NOT_SUPPORTED when A or B is not 16-byte alignedOpenbug
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
[FEA] Return centers generated by raft::random::make_blobsPossibly taken @NIne-WIngEd claimed this 36 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 53/100
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 58/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
emeryberger/CSrankings#15742 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Unstructured-IO/unstructured#4876 ·
Maintainers usually reply within 6 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
fairagro/m4.2_sql_to_arc#388 ·
Maintainers usually reply within 1 day
-
Add: FAP TV Gay FeedOpencheck:failed feeds:add
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
iptv-org/database#40182 · 1 comment ·
Maintainers usually reply within 1 day