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

Adapt cudf numba config for numba 0.61 removal #17705

Merged
merged 5 commits into from
Jan 15, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions python/cudf/cudf/utils/_numba.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Copyright (c) 2023-2025, NVIDIA CORPORATION.

import contextlib
import glob
import os
import sys
from functools import lru_cache

import numba
from numba import config as numba_config
from packaging import version


# Use an lru_cache with a single value to allow a delayed import of
Expand Down Expand Up @@ -133,18 +135,19 @@ def _setup_numba():
numba_config.CUDA_ENABLE_PYNVJITLINK = True


class _CUDFNumbaConfig:
def __enter__(self):
self.CUDA_LOW_OCCUPANCY_WARNINGS = (
numba_config.CUDA_LOW_OCCUPANCY_WARNINGS
)
numba_config.CUDA_LOW_OCCUPANCY_WARNINGS = 0
@contextlib.contextmanager
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes we choose to manually implement context managers because the overhead of contextlib.contextmanager is pretty high. Is this such a case? The history / blame might tell us.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears this was added in #13337 without comment about performance, but locally I do see that the decorator version is almost 4x slower than the class version so I'll change this back to the class version.

def _CUDFNumbaConfig():
CUDA_LOW_OCCUPANCY_WARNINGS = numba_config.CUDA_LOW_OCCUPANCY_WARNINGS
numba_config.CUDA_LOW_OCCUPANCY_WARNINGS = 0

self.CAPTURED_ERRORS = numba_config.CAPTURED_ERRORS
numba_config.CAPTURED_ERRORS = "new_style"
is_numba_lt_061 = version.parse(numba.__version__) < version.parse("0.61")

def __exit__(self, exc_type, exc_value, traceback):
numba_config.CUDA_LOW_OCCUPANCY_WARNINGS = (
self.CUDA_LOW_OCCUPANCY_WARNINGS
)
numba_config.CAPTURED_ERRORS = self.CAPTURED_ERRORS
if is_numba_lt_061:
CAPTURED_ERRORS = numba_config.CAPTURED_ERRORS
numba_config.CAPTURED_ERRORS = "new_style"
try:
yield
finally:
numba_config.CUDA_LOW_OCCUPANCY_WARNINGS = CUDA_LOW_OCCUPANCY_WARNINGS
if is_numba_lt_061:
numba_config.CAPTURED_ERRORS = CAPTURED_ERRORS
Loading