Skip to content

Commit 9ab36e7

Browse files
merge/resolve
2 parents 6f8ddb3 + 6c52fc0 commit 9ab36e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+6913
-548
lines changed

ci/test_thirdparty.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ rapids-logger "Show Numba system info"
4141
python -m numba --sysinfo
4242

4343
rapids-logger "Run Scalar UDF tests"
44-
python -m pytest python/cudf/cudf/tests/dataframe/methods/test_apply.py -W ignore::UserWarning -W ignore::DeprecationWarning:numba.cuda.core.config
44+
python -m pytest python/cudf/cudf/tests/dataframe/methods/test_apply.py -W ignore::UserWarning
4545

4646
rapids-logger "Run GroupBy UDF tests"
47-
python -m pytest python/cudf/cudf/tests/groupby/test_apply.py -k test_groupby_apply_jit -W ignore::UserWarning -W ignore::DeprecationWarning:numba.cuda.core.config
47+
python -m pytest python/cudf/cudf/tests/groupby/test_apply.py -k test_groupby_apply_jit -W ignore::UserWarning
4848

4949
rapids-logger "Run NRT Stats Counting tests"
50-
python -m pytest python/cudf/cudf/tests/private_objects/test_nrt_stats.py -W ignore::UserWarning -W ignore::DeprecationWarning:numba.cuda.core.config
50+
python -m pytest python/cudf/cudf/tests/private_objects/test_nrt_stats.py -W ignore::UserWarning
5151

5252

5353
popd

numba_cuda/numba/cuda/_internal/cuda_bf16.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
)
2828
from numba.cuda.core.imputils import Registry as TargetRegistry
2929
from numba.cuda.core.imputils import lower_cast
30-
from numba.core.typing import signature
31-
from numba.core.typing.builtins import (
30+
from numba.cuda.typing import signature
31+
from numba.cuda.typing.builtins import (
3232
BinOp,
3333
BinOpTrueDiv,
3434
UnaryNegate,

numba_cuda/numba/cuda/_internal/cuda_fp16.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
)
3030
from numba.cuda.core.imputils import Registry as TargetRegistry
3131
from numba.cuda.core.imputils import lower_cast
32-
from numba.core.typing import signature
32+
from numba.cuda.typing import signature
3333
from numba.cuda import CUSource, declare_device
3434
from numba.cuda._internal.cuda_bf16 import _type___nv_bfloat16
3535
from numba.cuda.typing.templates import (

numba_cuda/numba/cuda/api.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,8 @@ def open_ipc_array(handle, shape, dtype, strides=None, offset=0):
271271
# compute size
272272
size = np.prod(shape) * dtype.itemsize
273273
# manually recreate the IPC mem handle
274-
if driver.USE_NV_BINDING:
275-
driver_handle = driver.binding.CUipcMemHandle()
276-
driver_handle.reserved = handle
277-
else:
278-
driver_handle = driver.drvapi.cu_ipc_mem_handle()
279-
driver_handle.reserved[:] = handle
274+
driver_handle = driver.binding.CUipcMemHandle()
275+
driver_handle.reserved = handle
280276
# use *IpcHandle* to open the IPC memory
281277
ipchandle = driver.IpcHandle(None, driver_handle, size, offset=offset)
282278
yield ipchandle.open_array(

numba_cuda/numba/cuda/args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import abc
1010

11-
from numba.core.typing.typeof import typeof, Purpose
11+
from numba.cuda.typing.typeof import typeof, Purpose
1212

1313

1414
class ArgHint(metaclass=abc.ABCMeta):

numba_cuda/numba/cuda/cg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from numba.core import types
55
from numba.cuda.extending import overload, overload_method
6-
from numba.core.typing import signature
6+
from numba.cuda.typing import signature
77
from numba.cuda import nvvmutils
88
from numba.cuda.extending import intrinsic
99
from numba.cuda.types import grid_group, GridGroup as GridGroupClass

numba_cuda/numba/cuda/core/base.py

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
from numba.core import (
1515
types,
1616
datamodel,
17-
config,
1817
)
19-
from numba.cuda import cgutils, debuginfo, utils
18+
from numba.cuda import cgutils, debuginfo, utils, config
2019
from numba.core import errors
2120
from numba.cuda.core import targetconfig, funcdesc, imputils
2221
from numba.core.compiler_lock import global_compiler_lock
@@ -357,6 +356,73 @@ def install_registry(self, registry):
357356
self._insert_cast_defn(loader.new_registrations("casts"))
358357
self._insert_get_constant_defn(loader.new_registrations("constants"))
359358

359+
def install_external_registry(self, registry):
360+
"""
361+
Install only third-party registrations from a shared registry like Numba's builtin_registry.
362+
Exclude Numba's own implementations in this case (i.e., anything from numba.* namespace).
363+
364+
This is useful for selectively installing third-party implementations
365+
present in the shared builtin_registry from Numba without pulling in any CPU-specific
366+
implementations from Numba.
367+
368+
Note: For getattrs/setattrs, we check the TYPE's __module__ (from the signature)
369+
rather than the implementation's __module__, because @lower_getattr/@lower_setattr decorators
370+
always set impl.__module__ = "numba.*" regardless of where they are called from.
371+
"""
372+
373+
def is_external(obj):
374+
"""Check if object is from outside numba.* namespace."""
375+
try:
376+
return not obj.__module__.startswith("numba.")
377+
except AttributeError:
378+
return True
379+
380+
def is_external_type_sig(sig):
381+
"""Check if type in signature is from outside numba.* namespace."""
382+
try:
383+
return sig and is_external(sig[0])
384+
except (AttributeError, IndexError):
385+
return True
386+
387+
try:
388+
loader = self._registries[registry]
389+
except KeyError:
390+
loader = RegistryLoader(registry)
391+
self._registries[registry] = loader
392+
393+
# Filter registrations
394+
funcs = [
395+
(impl, func, sig)
396+
for impl, func, sig in loader.new_registrations("functions")
397+
if is_external(impl)
398+
]
399+
getattrs = [
400+
(impl, attr, sig)
401+
for impl, attr, sig in loader.new_registrations("getattrs")
402+
if is_external_type_sig(sig)
403+
]
404+
setattrs = [
405+
(impl, attr, sig)
406+
for impl, attr, sig in loader.new_registrations("setattrs")
407+
if is_external_type_sig(sig)
408+
]
409+
casts = [
410+
(impl, sig)
411+
for impl, sig in loader.new_registrations("casts")
412+
if is_external(impl)
413+
]
414+
constants = [
415+
(impl, sig)
416+
for impl, sig in loader.new_registrations("constants")
417+
if is_external(impl)
418+
]
419+
420+
self.insert_func_defn(funcs)
421+
self._insert_getattr_defn(getattrs)
422+
self._insert_setattr_defn(setattrs)
423+
self._insert_cast_defn(casts)
424+
self._insert_get_constant_defn(constants)
425+
360426
def insert_func_defn(self, defns):
361427
for impl, func, sig in defns:
362428
self._defns[func].append(impl, sig)
@@ -822,14 +888,15 @@ def _compile_subroutine_no_cache(
822888
Note this context's flags are not inherited.
823889
"""
824890
# Compile
825-
from numba.core import compiler
891+
from numba.cuda import compiler
892+
from numba.cuda.flags import Flags
826893

827894
with global_compiler_lock:
828895
codegen = self.codegen()
829896
library = codegen.create_library(impl.__name__)
830897
if flags is None:
831898
cstk = targetconfig.ConfigStack()
832-
flags = compiler.Flags()
899+
flags = Flags()
833900
if cstk:
834901
tls_flags = cstk.top()
835902
if tls_flags.is_set("nrt") and tls_flags.nrt:

numba_cuda/numba/cuda/core/boxing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77

88
from llvmlite import ir
99

10-
from numba.core import types, cgutils
10+
from numba.core import types
11+
from numba.cuda import cgutils
1112
from numba.cuda.core.pythonapi import box, unbox, reflect, NativeValue
1213
from numba.core.errors import NumbaNotImplementedError, TypingError
13-
from numba.core.typing.typeof import typeof, Purpose
14+
from numba.cuda.typing.typeof import typeof, Purpose
1415

1516
from numba.cuda.cpython import setobj, listobj
1617
from numba.cuda.np import numpy_support

numba_cuda/numba/cuda/core/config.py

Lines changed: 25 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -124,49 +124,6 @@ def _process_opt_level(opt_level):
124124
return _OptLevel(opt_level)
125125

126126

127-
class _EnvVar(object):
128-
"""Descriptor for configuration values that checks numba.config on access."""
129-
130-
def __init__(self, value, name):
131-
self.name = name
132-
if isinstance(value, _EnvVar):
133-
self.value = value.__get__()
134-
else:
135-
self.value = value
136-
self.check_numba_config()
137-
138-
def check_numba_config(self):
139-
"""Check for conflicting value in numba.config and emit deprecation warning."""
140-
try:
141-
from numba import config as numba_config
142-
143-
if hasattr(numba_config, self.name):
144-
config_value = getattr(numba_config, self.name)
145-
if config_value != self.value:
146-
msg = (
147-
f"Configuration value '{self.name}' is explicitly set "
148-
f"to `{config_value}` in numba.config. "
149-
"numba.config is deprecated for numba-cuda "
150-
"and support for configuration values from it "
151-
"will be removed in a future release. "
152-
"Please use numba.cuda.core.config."
153-
)
154-
warnings.warn(msg, category=DeprecationWarning)
155-
self.value = config_value
156-
else:
157-
# Initialize any missing variables in numba.config
158-
setattr(numba_config, self.name, self.value)
159-
except ImportError:
160-
pass
161-
162-
def __get__(self):
163-
self.check_numba_config()
164-
return self.value
165-
166-
def __set__(self, value):
167-
self.value = value
168-
169-
170127
class _EnvReloader(object):
171128
def __init__(self):
172129
self.reset()
@@ -211,18 +168,7 @@ def update(self, force=False):
211168
self.validate()
212169

213170
def validate(self):
214-
current_module = sys.modules[__name__]
215-
try:
216-
CUDA_USE_NVIDIA_BINDING = current_module.CUDA_USE_NVIDIA_BINDING
217-
except AttributeError:
218-
CUDA_USE_NVIDIA_BINDING = 0
219-
220-
try:
221-
CUDA_PER_THREAD_DEFAULT_STREAM = (
222-
current_module.CUDA_PER_THREAD_DEFAULT_STREAM
223-
)
224-
except AttributeError:
225-
CUDA_PER_THREAD_DEFAULT_STREAM = 0
171+
global CUDA_USE_NVIDIA_BINDING
226172

227173
if CUDA_USE_NVIDIA_BINDING: # noqa: F821
228174
try:
@@ -235,7 +181,7 @@ def validate(self):
235181
)
236182
warnings.warn(msg)
237183

238-
current_module.CUDA_USE_NVIDIA_BINDING = 0
184+
CUDA_USE_NVIDIA_BINDING = False
239185

240186
if CUDA_PER_THREAD_DEFAULT_STREAM: # noqa: F821
241187
warnings.warn(
@@ -250,23 +196,18 @@ def process_environ(self, environ):
250196
def _readenv(name, ctor, default):
251197
value = environ.get(name)
252198
if value is None:
253-
result = default() if callable(default) else default
254-
else:
255-
try:
256-
result = ctor(value)
257-
except Exception:
258-
warnings.warn(
259-
f"Environment variable '{name}' is defined but "
260-
f"its associated value '{value}' could not be "
261-
"parsed.\nThe parse failed with exception:\n"
262-
f"{traceback.format_exc()}",
263-
RuntimeWarning,
264-
)
265-
result = default() if callable(default) else default
266-
var_name = name
267-
if name.startswith("NUMBA_"):
268-
var_name = name[6:]
269-
return _EnvVar(result, var_name)
199+
return default() if callable(default) else default
200+
try:
201+
return ctor(value)
202+
except Exception:
203+
warnings.warn(
204+
f"Environment variable '{name}' is defined but "
205+
f"its associated value '{value}' could not be "
206+
"parsed.\nThe parse failed with exception:\n"
207+
f"{traceback.format_exc()}",
208+
RuntimeWarning,
209+
)
210+
return default
270211

271212
def optional_str(x):
272213
return str(x) if x is not None else None
@@ -348,12 +289,6 @@ def optional_str(x):
348289
# Enable NRT statistics counters
349290
NRT_STATS = _readenv("NUMBA_NRT_STATS", int, 0)
350291

351-
# Enable NRT statistics
352-
CUDA_NRT_STATS = _readenv("NUMBA_CUDA_NRT_STATS", int, 0)
353-
354-
# Enable NRT
355-
CUDA_ENABLE_NRT = _readenv("NUMBA_CUDA_ENABLE_NRT", int, 0)
356-
357292
# How many recently deserialized functions to retain regardless
358293
# of external references
359294
FUNCTION_CACHE_SIZE = _readenv("NUMBA_FUNCTION_CACHE_SIZE", int, 128)
@@ -695,53 +630,26 @@ def which_gdb(path_or_bin):
695630
0,
696631
)
697632

698-
# Inject the configuration values into _descriptors
699-
if not hasattr(self, "_descriptors"):
700-
self._descriptors = {}
701-
633+
# Inject the configuration values into the module globals
702634
for name, value in locals().copy().items():
703635
if name.isupper():
704-
self._descriptors[name] = value
636+
globals()[name] = value
705637

706638

707639
_env_reloader = _EnvReloader()
708640

709641

710-
def __getattr__(name):
711-
"""Module-level __getattr__ provides dynamic behavior for _EnvVar descriptors."""
712-
# Fetch non-descriptor globals directly
713-
if name in globals():
714-
return globals()[name]
715-
716-
if (
717-
hasattr(_env_reloader, "_descriptors")
718-
and name in _env_reloader._descriptors
719-
):
720-
return _env_reloader._descriptors[name].__get__()
721-
722-
raise AttributeError(f"module {__name__} has no attribute {name}")
723-
724-
725-
def __setattr__(name, value):
726-
"""Module-level __setattr__ provides dynamic behavior for _EnvVar descriptors."""
727-
# Update non-descriptor globals
728-
if name in globals():
729-
globals()[name] = value
730-
return
731-
732-
if (
733-
hasattr(_env_reloader, "_descriptors")
734-
and name in _env_reloader._descriptors
735-
):
736-
_env_reloader._descriptors[name].__set__(value)
737-
else:
738-
if not hasattr(_env_reloader, "_descriptors"):
739-
_env_reloader._descriptors = {}
740-
_env_reloader._descriptors[name] = _EnvVar(value, name)
741-
742-
743642
def reload_config():
744643
"""
745644
Reload the configuration from environment variables, if necessary.
746645
"""
747646
_env_reloader.update()
647+
648+
649+
# use numba.core.config if available, otherwise use numba.cuda.core.config
650+
try:
651+
import numba.core.config as _config
652+
653+
sys.modules[__name__] = _config
654+
except ImportError:
655+
pass

0 commit comments

Comments
 (0)