ttricco / sarracen

A Python library for smoothed particle hydrodynamics (SPH) analysis and visualization.
https://sarracen.readthedocs.io
GNU General Public License v3.0
15 stars 18 forks source link

NumbaDeprecationWarning when using numba 0.57.0 #64

Closed ostueker closed 9 months ago

ostueker commented 1 year ago

Just as an FYI:

While deploying the sarracen==1.2.2 wheel to the Compute Canada Software stack I noticed the following deprecation warning when using it with numba 0.57.0:

/[...]/venv/lib/python3.10/site-packages/sarracen/kernels/cubic_spline.py:15: 
NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit'
decorator. The implicit default value for this argument is currently False, but it will be 
changed to True in Numba 0.59.0. See 
https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-
fall-back-behaviour-when-using-jit for details.
  @jit(fastmath=True)

It appears that some default behaviour will change in an upcoming Numba 0.59.0.

If I understand the message correctly, chaning line 15 of cubic_spline.py to @jit(fastmath=True, nopython=False) should silence the warning and retain consistent behaviour once Numba 0.59.0 is released.

Steps to reproduce:

$ salloc --time=15 --mem=2000M
$ module load python/3.10
$ virtualenv --no-download  $SLURM_TMPDIR/venv && source $SLURM_TMPDIR/venv/bin/activate
(venv) $ pip install --no-index sarracen
[...]
Successfully installed contourpy-1.0.7+computecanada cycler-0.11.0+computecanada 
fonttools-4.42.0+computecanada kiwisolver-1.4.4+computecanada llvmlite-0.40.1+computecanada 
matplotlib-3.7.0+computecanada numba-0.57.0+computecanada numpy-1.24.2+computecanada 
packaging-23.1+computecanada pandas-2.0.0+computecanada pillow-9.5.0+computecanada 
pyparsing-3.0.9+computecanada python-dateutil-2.8.2+computecanada pytz-2023.3+computecanada 
sarracen-1.2.2+computecanada scipy-1.10.1+computecanada seaborn-0.12.2+computecanada 
six-1.16.0+computecanada tzdata-2023.3+computecanada

(venv) $ python -c "import sarracen; print(sarracen.__version__)"
/[...]/venv/lib/python3.10/site-packages/sarracen/kernels/cubic_spline.py:15: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' 
decorator. The implicit default value for this argument is currently False, but it will be 
changed to True in Numba 0.59.0. See 
https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-
fall-back-behaviour-when-using-jit for details.
  @jit(fastmath=True)
/[...]/venv/lib/python3.10/site-packages/sarracen/kernels/quartic_spline.py:15: 
NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' 
decorator. The implicit default value for this argument is currently False, but it will be 
changed to True in Numba 0.59.0. See 
https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-
fall-back-behaviour-when-using-jit for details.
  @jit(fastmath=True)
/[...]/venv/lib/python3.10/site-packages/sarracen/kernels/quintic_spline.py:15: 
NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' 
decorator. The implicit default value for this argument is currently False, but it will be 
changed to True in Numba 0.59.0. See 
https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-
fall-back-behaviour-when-using-jit for details.
  @jit(fastmath=True)
1.2.2
ostueker commented 1 year ago

By the way: Using -ffastmath with Python can have undesired side-effects: https://moyix.blogspot.com/2022/09/someones-been-messing-with-my-subnormals.html

ttricco commented 1 year ago

@ostueker Thanks Oliver for taking a look at this, and for using our issue tracker to post about it.

This is a good reminder for us about Numba, as we should be more explicit about when we need nopython=True. (Also to get rid of those deprecation warnings.)

And actually I wasn't aware of the -ffastmath issue. Something we will need to investigate also. Thanks again.