Skip to content

[BUG] test_empty_slice_1d/test_empty_slice_2d fail with NumPy 2.2.1 #108

@leofang

Description

@leofang

Describe the bug
The same tests pass with NumPy 2.0.1 but fail with 2.2.1.

Upon a closer inspection, I noticed that somewhere in this repo NumPy has been pinned to 2.0.2, so all CI runs in this repo could not catch this test error. However, I am unable to locate where the pinning is done. It could be possible that it comes from the RAPIDS CI setup, since lots of CI infra here seem to come from RAPIDS.

Steps/Code to reproduce bug
Update NumPy to 2.2.x and rerun the tests.

Expected behavior
Test pass.

Environment details (please complete the following information):
See below.

Additional context
This is a spin-off of nvbug 5011593. Below is what QA reported:

(numba_py310) C:\tmp\cuda-python-public\cuda_bindings>pip install numpy -U
Requirement already satisfied: numpy in c:\programdata\miniconda3\envs\numba_py310\lib\site-packages (2.0.1)
Collecting numpy
  Using cached numpy-2.2.1-cp310-cp310-win_amd64.whl.metadata (60 kB)
Using cached numpy-2.2.1-cp310-cp310-win_amd64.whl (12.9 MB)
Installing collected packages: numpy
  Attempting uninstall: numpy
    Found existing installation: numpy 2.0.1
    Uninstalling numpy-2.0.1:
      Successfully uninstalled numpy-2.0.1
Successfully installed numpy-2.2.1

(numba_py310) C:\tmp\cuda-python-public\cuda_bindings>set NUMBA_CUDA_USE_NVIDIA_BINDING=1 && python -m numba.runtests numba.cuda.tests
........s.........s........................s.s................................................................................................................................................................................................................................................................................................................................................................................................................ss.s...............................s......EE.....................................................................................................................s..s........................................sssssssssssssssssssss...s.........s..............s....................................................................................................................................C:\ProgramData\miniconda3\envs\numba_py310\lib\site-packages\numba_cuda\numba\cuda\tests\cudapy\test_atomics.py:673: RuntimeWarning: overflow encountered in scalar subtract
  gold[orig[i]] -= 1
................................s....................................................................ss.............................s................x............x..............................x.......x..........................................................s............................................................................sss.ss............................................................C:\ProgramData\miniconda3\envs\numba_py310\lib\site-packages\numba_cuda\numba\cuda\tests\cudapy\test_math.py:620: RuntimeWarning: overflow encountered in cast
  Cref[i] = math.pow(A[i], B[i])
C:\ProgramData\miniconda3\envs\numba_py310\lib\site-packages\numba_cuda\numba\cuda\tests\cudapy\test_math.py:621: RuntimeWarning: overflow encountered in cast
  np.testing.assert_allclose(np.power(A, B).astype(npdtype), C, rtol=1e-6)
.........................ss...C:\ProgramData\miniconda3\envs\numba_py310\lib\site-packages\numba_cuda\numba\cuda\dispatcher.py:597: NumbaPerformanceWarning: Grid size 1 will likely result in GPU under-utilization due to low occupancy.
  warn(NumbaPerformanceWarning(msg))
....................................................................x...xxxxx..................................sx.s......................................................s.................................................................s......................s....ss........
======================================================================
ERROR: test_empty_slice_1d (numba.cuda.tests.cudadrv.test_cuda_array_slicing.CudaArraySlicing)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\ProgramData\miniconda3\envs\numba_py310\lib\site-packages\numba_cuda\numba\cuda\tests\cudadrv\test_cuda_array_slicing.py", line 189, in test_empty_slice_1d
    self.assertFalse(darr[:0][:0].copy_to_host())
  File "C:\ProgramData\miniconda3\envs\numba_py310\lib\unittest\case.py", line 679, in assertFalse
    if expr:
ValueError: The truth value of an empty array is ambiguous. Use `array.size > 0` to check that an array is not empty.

======================================================================
ERROR: test_empty_slice_2d (numba.cuda.tests.cudadrv.test_cuda_array_slicing.CudaArraySlicing)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\ProgramData\miniconda3\envs\numba_py310\lib\site-packages\numba_cuda\numba\cuda\tests\cudadrv\test_cuda_array_slicing.py", line 202, in test_empty_slice_2d
    self.assertFalse(darr[:0][:0].copy_to_host())
  File "C:\ProgramData\miniconda3\envs\numba_py310\lib\unittest\case.py", line 679, in assertFalse
    if expr:
ValueError: The truth value of an empty array is ambiguous. Use `array.size > 0` to check that an array is not empty.

----------------------------------------------------------------------
Ran 1539 tests in 468.728s

FAILED (errors=2, skipped=53, expected failures=11)

(numba_py310) C:\tmp\cuda-python-public\cuda_bindings>pip list
Package          Version                        Editable project location
---------------- ------------------------------ ---------------------------------------
colorama         0.4.6
cuda-python      12.6.2.post1+16.ge09b7fb       c:\tmp\cuda-python-public\cuda_bindings
Cython           3.0.11
exceptiongroup   1.2.2
iniconfig        2.0.0
llvmlite         0.45.0.dev0+0.ge9f12c6.dirty
mkl_fft          1.3.11
mkl_random       1.2.8
mkl-service      2.4.0
numba            0.62.0.dev0+8.g956ea6c69.dirty
numba-cuda       0.3.0
numpy            2.2.1
packaging        24.2
pip              24.2
pluggy           1.5.0
py-cpuinfo       9.0.0
pyclibrary       0.2.2
pyparsing        3.2.1
pytest           8.3.4
pytest-benchmark 5.1.0
pywin32          308
setuptools       75.1.0
tomli            2.2.1
versioneer       0.29
wheel            0.44.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions