[BUG] A column with one infinity sums to NaN in `raft::stats::sum`

Open
#3,232 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@galleonli is already working on this.

Since Nov 28, 2026.

  • #3233 by @galleonli — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
cpp
Domain
data

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NVIDIA/raft

All issues in NVIDIA/raft

Similar issues

More Data Engineering issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.