Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: cub::DeviceReduce::Min (Max too?) returns wrong value for inputs with INF #1388

Closed
1 task done
leofang opened this issue Feb 15, 2024 · 4 comments
Closed
1 task done
Labels
bug Something isn't working right.

Comments

@leofang
Copy link
Member

leofang commented Feb 15, 2024

Is this a duplicate?

Type of Bug

Runtime Error

Component

CUB

Describe the bug

INF should be returned but it is not, see cupy/cupy#8180.

It seems to be the same issue as ArgMin/ArgMax (NVIDIA/cub#642).

How to Reproduce

#include <iostream>
#include <cub/cub.cuh>

constexpr int N = 10;
constexpr float INF = std::numeric_limits<float>::infinity();

int main() {
  float* in;
  float* d_in;
  float* out;
  float* d_out;

  in = new float[N];
  out = new float[1];
  std::fill(in, in + N, INF);

  size_t temp_storage_bytes = 1024;
  void* d_temp_storage;
  cudaMalloc((void**)&d_temp_storage, temp_storage_bytes);

  cudaMalloc((void**)&d_in, sizeof(float) * N);
  cudaMalloc((void**)&d_out, sizeof(float) * 1);

  cudaMemcpy(d_in, in, sizeof(float) * N, cudaMemcpyHostToDevice);
  cub::DeviceReduce::Min(d_temp_storage, temp_storage_bytes, d_in, d_out, N);
  cudaMemcpy(out, d_out, sizeof(float), cudaMemcpyDeviceToHost);

  std::cout << *out << std::endl;  // Expected: inf
}

Expected behavior

return inf

Reproduction link

No response

Operating System

No response

nvidia-smi output

No response

NVCC version

No response

@leofang leofang added the bug Something isn't working right. label Feb 15, 2024
@github-project-automation github-project-automation bot moved this to Todo in CCCL Feb 15, 2024
@leofang
Copy link
Member Author

leofang commented Feb 15, 2024

Hmmm I just found someone actually asked the same question. @gevtushenko does your comment back then (NVIDIA/cub#662 (comment)) still hold? If so, we can probably close this issue without any action on the CCCL side.

@leofang
Copy link
Member Author

leofang commented Feb 15, 2024

(Thinking about it a bit more, I am not sure if this is a regression in CUB. Let me do some checks first...)

@leofang
Copy link
Member Author

leofang commented Feb 15, 2024

Checked all the way back to CCCL/CUB v2.0.1, doesn't seem to be a regression on the CUB side, more like an overlook in CuPy's test suite.

@leofang
Copy link
Member Author

leofang commented Feb 19, 2024

Hmmm I just found someone actually asked the same question. @gevtushenko does your comment back then (NVIDIA/cub#662 (comment)) still hold? If so, we can probably close this issue without any action on the CCCL side.

Confirmed with Georgii offline that this still holds, closing.

@leofang leofang closed this as not planned Won't fix, can't repro, duplicate, stale Feb 19, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in CCCL Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working right.
Projects
Archived in project
Development

No branches or pull requests

1 participant