Skip to content

[BUG] matrix::select_k outputs 0.0 for negative bfloat16 numbers #2796

@apivovarov

Description

@apivovarov

Describe the bug
When using raft::matrix::select_k with nv_bfloat16 (bfloat16) input values, any negative numbers in the input are incorrectly converted to 0.0 in the output. The corresponding indices are also incorrect, showing all zeros.

Steps/Code to reproduce bug
GTest Code: PR-2795

./build.sh -v tests

./cpp/build/gtests/MATRIX_SELECT_TEST

Running main() from /root/workspace/raft/cpp/build/_deps/gtest-src/googletest/src/gtest_main.cc
[==========] Running 608 tests from 6 test suites.
[----------] Global test environment set-up.
[----------] 1 test from SelectKBF16Negative
[ RUN      ] SelectKBF16Negative.TopK3
Input: -3.5 -1.5 -7.5 0.5 -2.5
Output: 0.5 0.0 0.0

Expected behavior
Negative input values should be correctly reflected in the output, e.g., [0.5, -1.5, -2.5], with the correct corresponding indices.

Environment details (please complete the following information):

  • branch: branch-25.10
  • Docker container: us-docker.pkg.dev/ml-oss-artifacts-published/ml-public-container/ml-build-cuda12.8-cudnn9.8:latest

Additional context
None

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions