lecture-python.myst icon indicating copy to clipboard operation
lecture-python.myst copied to clipboard

MAINT: update @jit(nopython=True) to @jit with numba>=0.59

Open mmcky opened this issue 1 year ago • 10 comments

This PR updates njit to use jit now that numba>=0.59 and nopython=True is now the default behaviour of the jit

This resolves https://github.com/QuantEcon/meta/issues/112 for this lecture series

mmcky avatar May 08 '24 23:05 mmcky

  • [x] checked support files in _static/lecture_specific
  • [x] link checker is false positive

mmcky avatar May 08 '24 23:05 mmcky

🚀 Deployed on https://667b7f4d7bb2ccbc199998b3--nostalgic-wright-5fa355.netlify.app

github-actions[bot] avatar May 09 '24 00:05 github-actions[bot]

There are a few speed regressions when applying these changes (right is this PR, left is current live site)

Screenshot 2024-05-09 at 11 45 20 AM

@kp992 would you have any time to review this and see what might be causing the slowdown in execution speed?

mmcky avatar May 09 '24 01:05 mmcky

Checking this from numba repo: https://github.com/numba/numba/blob/e15cd6870042125ff025e459f5f7558449b22cf8/numba/core/decorators.py#L49 -- Shows that nopython is set by default to True.

And njit is just jit(nopython=True): https://github.com/numba/numba/blob/e15cd6870042125ff025e459f5f7558449b22cf8/numba/core/decorators.py#L250.

kp992 avatar May 09 '24 03:05 kp992

Hmm, I guess there can 2 reasons behind this:

  1. We are using GPU which calls cuda.jit internally in numba and the docs are just talking about CPU options.
  2. Maybe the cache isn't updated and so the execution time has increased?

kp992 avatar May 09 '24 03:05 kp992

@kp992 I don't fully understand your comments.

We are using GPU which calls cuda.jit internally in numba and the docs are just talking about CPU options.

This PR is strictly update the Numba jit so I don't understand why GPU is involved?

Maybe the cache isn't updated and so the execution time has increased?

For any lecture that has had code change then the cache should be invalidated and the lecture is run fresh.

Perhaps we can link up and discuss this?

mmcky avatar Jun 13 '24 00:06 mmcky

Thanks @mmcky, I can try looking into it in more details and discuss on this.

kp992 avatar Jun 16 '24 18:06 kp992

@mmcky Can we re-run and see if the time results still differ? Maybe sometimes we might have hit some outlier?

kp992 avatar Jun 24 '24 17:06 kp992

@kp992 there are still large differences:

Screenshot 2024-06-26 at 2 18 01 PM

mmcky avatar Jun 26 '24 04:06 mmcky

I will try to debug what's creating these differences.

kp992 avatar Jun 27 '24 03:06 kp992

  • [x] recheck results with latest anaconda environments to see if issue persists.

mmcky avatar Nov 18 '24 03:11 mmcky

🚀 Deployed on https://673ad3a1057182c68b3b9dd6--nostalgic-wright-5fa355.netlify.app

github-actions[bot] avatar Nov 18 '24 05:11 github-actions[bot]

@kp992 and @HumphreyYang it looks like many of the large differences have resolved in the latest run and versions of numba.

mmcky avatar Nov 18 '24 05:11 mmcky

Thanks @kp992. This looks great and clean!

kp992 avatar Nov 19 '24 04:11 kp992