numbox.core.cache_key
Overview
numba’s on-disk cache, which cache=True enables, stores
each compiled function under a key. The key holds the signature, the target machine with its CPU features, and
hashes of the function’s bytecode and of the values its closure captures. It does not hold the jit options, the
keyword arguments other than cache that you pass to the decorator, such as fastmath, error_model and
boundscheck. Nor does it hold most of the NUMBA_* environment variables that change the code numba emits, such as
NUMBA_BOUNDSCHECK and NUMBA_OPT. This page calls every NUMBA_* environment variable a setting.
If a jit option or a code-changing setting differs between two runs while the function’s source file stays the same, the
second run loads the code that the first run compiled. numba gives no warning. Suppose you set NUMBA_BOUNDSCHECK=1
to find an indexing bug: a function cached in an earlier run still runs without bounds checks, and an index past the end
of an array reads whatever memory follows the array.
Jit options have the same problem when the decorator takes them from outside the function’s file, as in
@njit(cache=True, **OPTIONS) with OPTIONS imported from a configuration module or read from an environment
variable. A change there does not modify the file, so numba loads the code compiled under the old options. A change
to the options written in the decorator line does not have this problem: it changes the file, and numba compiles the
function again.
numbox adds a part of its own to the key for the functions it compiles itself, such as its bindings to C libraries,
and for the functions you decorate with numbox_njit() or
numbox_cfunc() and cache=True. All of these are called keyed functions below, and the
section Which functions are keyed lists them. numbox’s part holds the jit options, the settings that change the
emitted code, and numbox’s version. The version is in the key because numba compiles the numbox code that a function
calls into the function itself, and numba’s key does not cover that code.
A keyed function compiles again when a jit option or a setting in its key changes. Its cache keeps one entry for each
combination it has run under, so a run that returns to an earlier combination loads that combination’s entry. When a
keyed function compiles more often than you expect, explain_cache_key() shows what numbox
added to its key; the section Reading the key shows how to compare two runs.
A function that you decorate with numba.njit(cache=True) is not keyed. numba caches it under its own key, so
it can load code compiled under old jit options or settings. After a numbox upgrade, it can also load code that numba
compiled from an older numbox’s @overload and @intrinsic implementations. Decorate it with numbox_njit
instead, or delete its cache files after such a change, as described in Deleting a function’s cache files. numbox
handles one case itself: it repairs a cached caller of a function decorated with @proxy, numbox’s decorator that
keeps one compiled copy for all callers, after that function changes. The section “After you edit a proxied function” of
the proxy page describes the repair.
Decorating your own functions
Replace numba.njit with numbox_njit, or numba.cfunc with numbox_cfunc, and keep cache=True. Both
take numba’s arguments unchanged, including signatures and options. Without cache=True, they behave exactly as
numba’s decorators. The following example is saved as bounds.py:
import numpy as np
from numba import njit
from numbox.core.cache_key import numbox_njit
@njit(cache=True)
def index_numba(a, i):
return a[i]
@numbox_njit(cache=True)
def index_numbox(a, i):
return a[i]
view = np.arange(10.0)[:3]
print(index_numba(view, 3))
print(index_numbox(view, 3))
view holds the first three elements of a longer array, so the index 3 is past the end of view but inside
memory that numpy allocated. If you run python bounds.py, both functions compile and print 3.0, because numba
compiles without bounds checks by default. Then run NUMBA_BOUNDSCHECK=1 python bounds.py. index_numba loads
the code from the first run and prints 3.0 again. index_numbox misses the cache, because its key holds the
setting. It compiles again with bounds checks, and its call raises IndexError: index is out of bounds.
Both of index_numbox’s entries stay in the cache. To see that, run the script a third time without the setting and
with NUMBA_DEBUG_CACHE=1, which makes numba report its cache use. numba prints a [cache] data loaded from line
for each function and no data saved to line, because each function loads the entry from the first run. Inside a
program, a dispatcher’s stats.cache_hits and stats.cache_misses count the same events.
The key covers an eager compile, for which the decorator is given a signature, as well as a lazy compile at the first call, because numbox attaches its part when numba sets up the function’s cache at decoration.
Under numba’s own key, a numba.cfunc and a numba.njit of the same Python function share their entries if both
are given the signature as a numba Signature object, such as float64(float64) built from numba.float64.
The two entries are not interchangeable. numba compiles a C callback without the wrapper through which a dispatcher
calls compiled code from Python. An njit that loads the callback’s entry therefore calls a wrapper that the entry does
not contain. The process then crashes with a segmentation fault. The njit’s entry holds both wrappers, so a C callback
that loads it works. numbox’s part holds the decorator kind, so numba caches a numbox_cfunc and a numbox_njit of
the same function in separate entries. numba’s own key also differs between the two when the signature is a string, as
in @numbox_cfunc("float64(float64)", cache=True), because numba keys the njit by the string and the C callback by
the parsed signature.
Which functions are keyed
Every function that numbox compiles with caching enabled is keyed, whichever decorator compiles it:
its own functions, among them its bindings, the jitted wrappers of functions in libc, libm and SQLite;
the jitted constructor, accessors and methods of each struct type that
make_structref()generates, a numba structref that jitted code and Python share;the fused kernel that
compile_kernel()compiles from a graph of formulas;the functions that
make_graph()compiles to build a graph of work nodes, among them, for eachDerivednode, the derive function that computes the node’s value from other nodes;the functions you pass to
proxy(), which keeps one compiled copy of a function for all its callers;the functions you pass to
cres(), which compiles a function for one signature and returns it as a first-class function value.
numbox’s own functions take their jit options from the NUMBOX_JIT_OPTIONS environment variable
(numbox.core.configurations), not from the files that define them. A change of that variable makes each of them
compile again; with numba’s key only, they would load the old code.
Of your functions, only the ones that numbox_njit and numbox_cfunc return are keyed. A numba.njit of the
same Python function is cached under numba’s key alone. numbox has no counterpart of @vectorize, @guvectorize or
numba’s CUDA decorators, so the functions they compile are cached under numba’s key as well.
What the key holds
numbox appends its part to numba’s key and changes nothing else in the key. The part holds three items.
The first is numbox’s version. numba compiles numbox’s @overload and @intrinsic code into each function that
calls that code, while numba’s key covers only the caller’s own bytecode. With the version in the key, a keyed caller
compiles again after an upgrade instead of loading the code compiled from an older numbox. The section After you
upgrade numbox says what the version is in a release and in a source checkout.
The second is the jit options. numba parses them into what it calls flags, filling in its defaults, and the key holds
the flags together with the decorator kind, njit or cfunc, and the types given in locals. The key records
the options that numba compiles under, because they can differ from the ones in the decorator. When numba compiles a
function for a caller that it is compiling, the callee takes the caller’s fastmath, error_model, forceinline
and nrt (which enables numba’s runtime for memory management) wherever the callee’s own options leave them unset.
The callee’s key holds the values that the callee used, so numba saves the code from that compile in a separate entry.
The third is the settings that change the emitted code and that numba’s own key leaves out. The key holds each with
its value in numba.config, the module where numba keeps the current value of every setting. numbox reads the
values when numba looks the function up in its cache, and again when numba saves the compiled code.
Which settings the key holds
KEYED_SETTINGS lists the settings in the key, among them NUMBA_BOUNDSCHECK,
NUMBA_OPT and NUMBA_DEBUGINFO. A setting is on that list if numba’s own key leaves it out and changing it
changes the LLVM IR or the machine code that numba emits, even if only speed or debugging information changes. A
survey of numba 0.63 to 0.68, each minor version at its latest patch release, applied that rule to every setting. The
description of KEYED_SETTINGS explains how the survey applied the rule.
UNKEYED_SETTINGS lists the other settings, each with the reason it is left out.
NUMBA_CPU_NAME and NUMBA_CPU_FEATURES are in numba’s own key already, through the target machine.
NUMBA_DISABLE_JIT disables compilation: the decorated functions run as plain Python, so there is nothing to cache.
The list gives NUMBA_USE_LEGACY_TYPE_SYSTEM the same reason, that it produces no binary; only numba 0.63 and 0.64
read it, to choose which scalar types numba defines. NUMBA_CACHE_DIR and NUMBA_CACHE_LOCATOR_CLASSES choose
where numba stores the cache, not what the cache contains. The rest change no emitted code, NUMBA_NUM_THREADS and
NUMBA_THREADING_LAYER among them: a parallel function cached under one thread count loads under another and returns
the same result. Between them, the two lists name every NUMBA_* setting that numba 0.63 to 0.68 reads.
Reading the key
explain_cache_key() returns numbox’s part of a keyed function’s key. Pass it the dispatcher
or the @cfunc of a keyed function, or the object that cres returns. A proxied function’s .as_func works as
well. .as_func is the proxied function as a first-class function value (passing the function as a value). explain_cache_key reports the values that numba.config holds when you call it, which
are the values the next cache lookup in this process uses. The jit options it reports are the ones the function uses
when it is called from Python. A caller in jitted code can pass the function other options, as described in What the
key holds, and those are not shown.
The result is a dict with three entries: "numbox" holds numbox’s version, "flags" holds the jit options as one
string of name=value items, and "settings" maps each setting in the key to its value as text. The following
example is saved as show_key.py:
from numbox.core.cache_key import explain_cache_key, numbox_njit
@numbox_njit(cache=True)
def total(a):
return a.sum()
key = explain_cache_key(total)
print(repr(key["numbox"]))
print([item for item in key["flags"].split(";") if item.startswith(("kind", "error_model", "nrt", "locals"))])
print({name: key["settings"][name] for name in ("NUMBA_BOUNDSCHECK", "NUMBA_OPT")})
In a source checkout, with no NUMBA_* setting in the environment, python show_key.py prints the version, four of
the flags and two of the settings:
''
['kind=njit', "error_model='python'", 'nrt=True', 'locals=[]']
{'NUMBA_BOUNDSCHECK': 'None', 'NUMBA_OPT': '3'}
The version is empty in a source checkout, and a release shows its version number there. An unset setting appears as the
text 'None'. A setting can appear in the flags as well: NUMBA_DEBUGINFO=1 also sets the debuginfo flag.
Two results that differ belong to two different keys, so you can save the result in each run and compare the runs to
find out why a function compiled again. The following example is saved as compare_keys.py:
import json
import pathlib
from numbox.core.cache_key import explain_cache_key, numbox_njit
@numbox_njit(cache=True)
def total(a):
return a.sum()
saved = pathlib.Path("total_key.json")
now = explain_cache_key(total)
if saved.exists():
old = json.loads(saved.read_text())
print("numbox changed:", now["numbox"] != old["numbox"])
print("flags changed:", now["flags"] != old["flags"])
print("settings changed:", sorted(k for k, v in now["settings"].items() if v != old["settings"].get(k)))
saved.write_text(json.dumps(now))
Run python compare_keys.py, then NUMBA_BOUNDSCHECK=1 python compare_keys.py. The second run prints:
numbox changed: False
flags changed: False
settings changed: ['NUMBA_BOUNDSCHECK']
If the two results match but the function compiled again, something that numba checks itself changed: the source file, the argument types, the values the closure captures, the numba or Python version, the CPU, or the cache directory.
explain_cache_key raises a ValueError for a function that is not keyed, such as a numba.njit function or a
numbox_njit function without cache=True. It also raises one for a function that numbox keeps out of the on-disk
cache, with the reason that the UncachedWarning gives, as described in
If numbox warns that a function is not cached.
Deleting a function’s cache files
numba names a function’s cache files after the module, the function, the line of its decorator and the Python version,
such as bounds.index_numbox-12.py312.nbi and bounds.index_numbox-12.py312.1.nbc for index_numbox in
bounds.py under Python 3.12. The .nbi file is the index, and each .nbc file holds the code of one entry.
numba keeps them in the first of these places that it can write to:
under
NUMBA_CACHE_DIR, if that variable is set, in a subdirectory named after the source’s directory: the directory’s base name, an underscore and the SHA-1 hash of its full path;otherwise in the
__pycache__directory beside the source;otherwise in numba’s user cache directory, which the configurations page describes in where numba writes the cache.
Delete the function’s .nbi file and all its .nbc files. numba then compiles the function again and saves new
files.
What the key leaves out
numba’s cache key for a function does not include the code of the functions it calls, and numbox’s part does not either.
numba compiles each callee into the caller and checks a cached caller only against the source file that defines the
caller. An edit to a callee in another file therefore does not invalidate the cached caller, which still runs the
callee’s old code. numba’s documentation names this
limit. The callee may be an @njit function, an @overload or an @intrinsic, in your own code or in a package
that you edit or upgrade.
Delete the caller’s cache files after such an edit, as described in Deleting a function’s cache files. numba then compiles the caller again at its next call.
numbox handles two such cases itself. A keyed caller compiles again after an upgrade of numbox from one release to
another, because the key holds numbox’s version. numbox also repairs a cached caller of a function decorated with its
@proxy after an edit to that function, whether or not the caller is keyed. The section “After you edit a proxied
function” of the proxy page describes the repair. The repair does not cover
a caller that holds the function as a module-level constant.
The key also leaves out the values of the globals that a function reads. numba compiles a global’s value into the
code as a constant, so a cached function still uses the value from the run that compiled it. A global whose value comes
from outside the function’s file, read from an environment variable at import or imported from another module, can
change while the file stays the same. The following example is saved as scaling.py:
import os
from numbox.core.cache_key import numbox_njit
SCALE = float(os.environ.get("SCALE", "2.0"))
@numbox_njit(cache=True)
def scaled_by_global(x):
return x * SCALE
@numbox_njit(cache=True)
def scaled(x, scale):
return x * scale
print(scaled_by_global(1.0), scaled(1.0, SCALE))
Run python scaling.py, then SCALE=3 python scaling.py. The first run prints 2.0 2.0, and the second
prints 2.0 3.0. scaled_by_global loads its cached code, which holds the old value. scaled takes the value
as an argument, so it uses the new value while its code still loads from the cache.
The same applies to a value that your module derives from NUMBA_NUM_THREADS at import. The thread count itself
changes no emitted code, so it is not in the key. numba compiles the derived value into the code as a constant,
though, so a run under another thread count loads code that holds the old value. Pass such a value as an argument, as
scaled does, or delete the function’s cache files after it changes.
If numbox warns that a function is not cached
The key cannot hold every jit option. If a function’s options include one that the key cannot hold, numbox keeps the
function out of the on-disk cache, so numba compiles it again in every process. An
UncachedWarning names the function once per process:
UncachedWarning: numbox: total is compiled without an on-disk cache: the jit flag parallel is a dict, which numba empties as it parses it. numbox's cache key cannot hold it reliably, so the function is not cached.
The warning names the function, here total, and the option that the key cannot hold, here a parallel dict.
Four kinds of option cause it, and each item below says what to pass or do instead.
A
paralleldict, such asparallel={"fusion": False}. numba empties the dict as it reads it, so a later compile given the same dict would use numba’s defaults. Passparallel=True, which the key holds, if numba’s default parallel options suit the function. Otherwise passparallel=ParallelOptions({"fusion": False}), withParallelOptionsimported fromnumba.core.cpu_options; the key holds that as well.A
pipeline_classother than numba’s default. The pipeline is code, and the key does not hold code. If numba’s key is enough for this function, with the limits that the Overview describes, decorate it withnumba.njitinstead.A function passed as the
inlineoption, which numba calls to decide whether to inline each call. Passinline="always"orinline="never"instead, which the key holds.A type in
localswhose name numba builds from an object’s memory address, as it does for a jitclass instance type and any type that contains one. The address differs in every process, so the key cannot hold the name. If you leave that variable out oflocals, numba infers its type.
In a test run, you can turn the warning into an error with pytest’s -W error::numbox.core.cache_key.UncachedWarning.
If you change a setting inside a running process
Set each NUMBA_* variable in the environment before Python starts. A value changed inside a running process,
through os.environ or numba.config, can be saved under a key that does not describe the compiled code. A later
run whose settings match that key then loads the mismatched code.
numba copies every NUMBA_* variable into numba.config when it is imported, and its compiler reads the values
there. It copies the environment again when a compile starts, if a NUMBA_* variable has changed. numbox computes its
part from numba.config twice for each compile: when numba looks the function up before the compile, and when numba
saves the code after it. numba therefore copies a NUMBA_* variable changed through os.environ into
numba.config at the next compile. The saved key then holds the new value. Until that compile, numba.config keeps
the old value, so a lookup can still load the entry for the old value.
The code and the key do not match when numba has already built something from a setting before that refresh: the parsed
jit options of the compile, or the target machine of the process. numba parses the jit options, taking some of their
defaults from the settings, before it copies the environment again. So NUMBA_DEBUGINFO set through os.environ
gives a key with debugging information enabled and code without it. numba builds its target machine once, at the
first jit decoration in the process, from NUMBA_OPT and NUMBA_ENABLE_AVX, and keeps it until the process
exits. Importing a numbox module that defines jitted functions counts as such a decoration.
For example, a program imports a module of jitted functions and then sets os.environ["NUMBA_OPT"] = "0". Its next
compile runs numba’s optimization passes at level 0, while the target machine stays at level 3, the default. numba saves
the entry under a key that holds the value 0 for NUMBA_OPT. That entry’s .nbc file held 25,375 bytes for a
function that loops over an array, on numba 0.68.0; a run started with NUMBA_OPT=0 saves 28,415 bytes for the same
function. A later run started with NUMBA_OPT=0 loads the 25,375-byte entry. The same happens if the program sets the
variable after import numba but before its first decoration, because numba copies the environment again only when a
compile starts.
numba documents its settings as environment variables, not as values to assign in numba.config. numba does build its
target machine from a value assigned to numba.config before the first jit decoration. Such an assignment is too
late, however, for a setting that numba uses only when it is imported, such as NUMBA_DISABLE_INTEL_SVML. A plain
numba.config.OPT = 0 before the first decoration causes that decoration to fail with
AttributeError: 'int' object has no attribute 'is_opt_max'; set NUMBA_OPT in the environment instead.
A running process keeps the compiled code of every function it has compiled until it exits. A setting changed later does not make it compile the function again.
If several processes compile the same function at once
numba’s cache save takes no lock (numba issue 10862). If two
processes save new entries for the same function at the same time, two keys can share one .nbc file. A lookup under
one of the two keys then loads code compiled for the other. Under numbox’s key, processes that run under different
settings or jit options save different entries for one signature. Two such processes can therefore save at the same
time even when the function already has an entry for that signature from another combination.
To prevent it, fill the cache before the processes start. Run the function once for each signature under each combination of settings and jit options that the processes use, one process at a time.
Installing the key
Do not remove numbox’s modules from sys.modules to import them again. After such a fresh import, the functions that
numbox_njit, numbox_cfunc, cres and proxy decorate are cached under numba’s key alone. numbox’s own
functions remain keyed. After importlib.reload of a numbox module, every function remains keyed. The difference
comes from how numbox installs its part: it wraps numba’s cache functions once per process, when numbox.core is
first imported, and those wrappers never see the functions that a freshly imported second copy of the decorators marks.
If numbox cannot wrap numba’s cache functions, it leaves numba unchanged. numbox then warns once, with the error in parentheses:
RuntimeWarning: numbox: could not add its part to numba's cache key (...); what numbox compiles is cached under numba's key alone
The warning means that the installed numba lacks one of the functions that numbox wraps. Install a numba version that
numbox supports, from 0.63.1 up to but not including 0.69. Until then, numba caches every function under its own key,
including the functions that you decorate with numbox_njit and numbox_cfunc.
After you upgrade numbox
numbox’s release builds write the release’s version into numbox.__version__, and numbox’s part of every key holds
it. The first run after an upgrade from one release to another therefore compiles each keyed function again, once for
each signature and each combination of jit options and settings that it runs under. Later runs load the new entries.
The entries that your keyed functions saved under the old version remain on disk. They match a lookup again only if you reinstall that version. To reclaim the space, delete the functions’ cache files, as described in Deleting a function’s cache files. numbox’s own functions have no old entries in their index. An upgrade replaces their source files, so numba starts a new index for them at the first save. If you reinstall the old version, numba compiles them again.
In a source checkout, numbox.__version__ is an empty string, and it stays empty when the checkout changes. An
update of the checkout, or an edit to numbox’s code, does not change the version in the key. A cached function that
calls numbox’s @overload or @intrinsic code in another file then still runs the old code, whether the function
is yours or numbox’s own. Delete its cache files after such a change.
Modules
numbox.core.cache_key
numbox’s part of numba’s on-disk cache key, and the decorators that add it to a function’s key.
numba caches a compiled function under a key that leaves out the jit options and most of the NUMBA_* settings
that change the emitted code. numbox appends a part of its own to that key for each function that it compiles with
caching enabled: numbox’s version, the jit options that numba compiles under, and the settings in
KEYED_SETTINGS. numbox_njit() and numbox_cfunc() add the same part to the functions you decorate,
and explain_cache_key() returns it. numbox installs the part by wrapping numba’s cache functions once per
process, when numbox.core is first imported.
- numbox.core.cache_key.KEYED_SETTINGS = {'NUMBA_BOUNDSCHECK': 'BOUNDSCHECK', 'NUMBA_DEBUG': 'DEBUG', 'NUMBA_DEBUGINFO': 'DEBUGINFO_DEFAULT', 'NUMBA_DEBUG_ARRAY_OPT': 'DEBUG_ARRAY_OPT', 'NUMBA_DEBUG_ARRAY_OPT_RUNTIME': 'DEBUG_ARRAY_OPT_RUNTIME', 'NUMBA_DEBUG_JIT': 'DEBUG_JIT', 'NUMBA_DEBUG_NRT': 'DEBUG_NRT', 'NUMBA_DEBUG_NRT_STACK_LIMIT': 'DEBUG_NRT_STACK_LIMIT', 'NUMBA_DEVELOPER_MODE': 'DEVELOPER_MODE', 'NUMBA_DIFF_IR': 'DIFF_IR', 'NUMBA_DISABLE_INTEL_SVML': 'DISABLE_INTEL_SVML', 'NUMBA_DUMP_ASSEMBLY': 'DUMP_ASSEMBLY', 'NUMBA_ENABLE_AVX': 'ENABLE_AVX', 'NUMBA_ENABLE_PROFILING': 'ENABLE_PROFILING', 'NUMBA_EXTEND_VARIABLE_LIFETIMES': 'EXTEND_VARIABLE_LIFETIMES', 'NUMBA_FULL_TRACEBACKS': 'FULL_TRACEBACKS', 'NUMBA_GDB_BINARY': 'GDB_BINARY', 'NUMBA_LLVM_REFPRUNE_FLAGS': 'LLVM_REFPRUNE_FLAGS', 'NUMBA_LLVM_REFPRUNE_PASS': 'LLVM_REFPRUNE_PASS', 'NUMBA_LOOP_VECTORIZE': 'LOOP_VECTORIZE', 'NUMBA_OPT': 'OPT', 'NUMBA_PARFOR_MAX_TUPLE_SIZE': 'PARFOR_MAX_TUPLE_SIZE', 'NUMBA_SLP_VECTORIZE': 'SLP_VECTORIZE'}
The
NUMBA_*settings that change the code numba emits, each with thenumba.configattribute numba reads it into. A survey of the latest patch release of each minor version of numba from 0.63 to 0.68 classified them. The survey compiled a fixed corpus with each setting changed in turn and compared the emitted LLVM IR and assembly. A setting that numba’s own key leaves out is keyed if and only if changing it changes the code, even if only speed or debugging information changes.NUMBA_DUMP_ASSEMBLY,NUMBA_DEBUGandNUMBA_DIFF_IRchange the code only as a side effect of the dumps they request, and are keyed as well. Three settings change the code only in combination with another setting or flag, so a survey that changes one setting at a time cannot reveal them. numba’s source shows them.NUMBA_DEBUG_NRT_STACK_LIMIT, which numba reads from 0.66 on, changes the code only underNUMBA_DEBUG_NRT.NUMBA_FULL_TRACEBACKSandNUMBA_DEVELOPER_MODE(its default) change it only where bounds checking is enabled.NUMBA_DISABLE_INTEL_SVMLchanges the code only where Intel’s SVML library is installed, which the survey’s machines lacked; numba then calls SVML for vectorized math.
- numbox.core.cache_key.UNKEYED_SETTINGS = {'NUMBA_ALWAYS_WARN_UNINIT_VAR': 'changes no emitted code', 'NUMBA_CACHE_DIR': 'chooses where the cache lives, not what goes in it', 'NUMBA_CACHE_LOCATOR_CLASSES': 'chooses where the cache lives, not what goes in it', 'NUMBA_CAPTURED_ERRORS': 'changes no emitted code', 'NUMBA_CHROME_TRACE': 'changes no emitted code', 'NUMBA_COLOR_SCHEME': 'changes no emitted code', 'NUMBA_CPU_FEATURES': "in numba's own key, through the target machine", 'NUMBA_CPU_NAME': "in numba's own key, through the target machine", 'NUMBA_CUDA_ARRAY_INTERFACE_SYNC': 'changes no emitted code', 'NUMBA_CUDA_DEBUGINFO': 'changes no emitted code', 'NUMBA_CUDA_DEFAULT_PTX_CC': 'changes no emitted code', 'NUMBA_CUDA_DRIVER': 'changes no emitted code', 'NUMBA_CUDA_ENABLE_MINOR_VERSION_COMPATIBILITY': 'changes no emitted code', 'NUMBA_CUDA_INCLUDE_PATH': 'changes no emitted code', 'NUMBA_CUDA_LOG_API_ARGS': 'changes no emitted code', 'NUMBA_CUDA_LOG_LEVEL': 'changes no emitted code', 'NUMBA_CUDA_LOG_SIZE': 'changes no emitted code', 'NUMBA_CUDA_LOW_OCCUPANCY_WARNINGS': 'changes no emitted code', 'NUMBA_CUDA_MAX_PENDING_DEALLOCS_COUNT': 'changes no emitted code', 'NUMBA_CUDA_MAX_PENDING_DEALLOCS_RATIO': 'changes no emitted code', 'NUMBA_CUDA_MEMORY_MANAGER': 'changes no emitted code', 'NUMBA_CUDA_PER_THREAD_DEFAULT_STREAM': 'changes no emitted code', 'NUMBA_CUDA_USE_NVIDIA_BINDING': 'changes no emitted code', 'NUMBA_CUDA_VERBOSE_JIT_LOG': 'changes no emitted code', 'NUMBA_CUDA_WARN_ON_IMPLICIT_COPY': 'changes no emitted code', 'NUMBA_DEBUG_ARRAY_OPT_STATS': 'changes no emitted code', 'NUMBA_DEBUG_CACHE': 'changes no emitted code', 'NUMBA_DEBUG_FRONTEND': 'changes no emitted code', 'NUMBA_DEBUG_INLINE_CLOSURE': 'changes no emitted code', 'NUMBA_DEBUG_PRINT_AFTER': 'changes no emitted code', 'NUMBA_DEBUG_PRINT_BEFORE': 'changes no emitted code', 'NUMBA_DEBUG_PRINT_WRAP': 'changes no emitted code', 'NUMBA_DEBUG_TYPEINFER': 'changes no emitted code', 'NUMBA_DISABLE_CUDA': 'changes no emitted code', 'NUMBA_DISABLE_ERROR_MESSAGE_HIGHLIGHTING': 'changes no emitted code', 'NUMBA_DISABLE_JIT': 'produces no binary', 'NUMBA_DISABLE_PERFORMANCE_WARNINGS': 'changes no emitted code', 'NUMBA_DISABLE_TYPEINFER_FAIL_CACHE': 'changes no emitted code', 'NUMBA_DUMP_ANNOTATION': 'changes no emitted code', 'NUMBA_DUMP_BYTECODE': 'changes no emitted code', 'NUMBA_DUMP_CFG': 'changes no emitted code', 'NUMBA_DUMP_FUNC_OPT': 'changes no emitted code', 'NUMBA_DUMP_HTML': 'changes no emitted code', 'NUMBA_DUMP_IR': 'changes no emitted code', 'NUMBA_DUMP_LLVM': 'changes no emitted code', 'NUMBA_DUMP_OPTIMIZED': 'changes no emitted code', 'NUMBA_DUMP_SSA': 'changes no emitted code', 'NUMBA_DYLD_WORKAROUND': 'changes no emitted code', 'NUMBA_ENABLE_CUDASIM': 'changes no emitted code', 'NUMBA_ENABLE_SYS_MONITORING': 'changes no emitted code', 'NUMBA_FORCE_CUDA_CC': 'changes no emitted code', 'NUMBA_FUNCTION_CACHE_SIZE': 'changes no emitted code', 'NUMBA_HIGHLIGHT_DUMPS': 'changes no emitted code', 'NUMBA_JIT_COVERAGE': 'changes no emitted code', 'NUMBA_LLVM_PASS_TIMINGS': 'changes no emitted code', 'NUMBA_NRT_STATS': 'changes no emitted code', 'NUMBA_NUM_THREADS': 'changes no emitted code', 'NUMBA_PARALLEL_DIAGNOSTICS': 'changes no emitted code', 'NUMBA_SHOW_HELP': 'changes no emitted code', 'NUMBA_THREADING_LAYER': 'changes no emitted code', 'NUMBA_THREADING_LAYER_PRIORITY': 'changes no emitted code', 'NUMBA_TRACE': 'changes no emitted code', 'NUMBA_USE_LEGACY_TYPE_SYSTEM': 'produces no binary', 'NUMBA_USE_LLVMLITE_MEMORY_MANAGER': 'changes no emitted code'}
Every other
NUMBA_*setting that numba 0.63 to 0.68 reads, with the reason it is not keyed.
- exception numbox.core.cache_key.UncachedWarning[source]
Bases:
RuntimeWarningWarning that numbox compiles a function without an on-disk cache, because its key cannot hold a jit option.
One of these options causes it:
A
paralleldict, which numba empties as it parses it.A pipeline class other than numba’s default.
A function given as the
inlineoption, which numba calls as a cost model.A type in
localswhose name numba builds from an object’s address.Any other value that the key has no stable text for.
numba then compiles the function again in every process. numbox warns once per process for each function and option, and the warning names both.
- numbox.core.cache_key.explain_cache_key(func) dict[source]
Return numbox’s part of
func’s cache key, with the values that the next cache lookup in this process uses.funcis a dispatcher or a@cfuncwhose cache numbox keys, the object thatcresreturns, or the.as_funcof a@proxyfunction. numbox keys the functions that it compiles with caching enabled, and the functions decorated withnumbox_njit()ornumbox_cfunc()andcache=True. The result maps"numbox"to numbox’s version,"flags"to the flags as the key holds them, and"settings"to the text of each keyed setting’s value. The flags are those of a call from Python; a jitted caller can compile the function under other options. Two results that differ belong to two different keys.Raises
ValueErrorif numbox does not keyfunc’s cache, or if numbox compilesfuncwithout an on-disk cache.
- numbox.core.cache_key.numbox_cfunc(*args, **kwargs)[source]
Decorate a function as
numba.cfuncdoes, and add numbox’s part to the key under which numba caches it.The decorator takes numba’s arguments unchanged. With
cache=True, numbox’s part also holds the decorator kind, so numba caches the C callback apart from anumbox_njit()of the same function. Under numba’s key alone, an eagernumba.njitgiven the same signature as a numbaSignatureobject shares the callback’s entry. A call to such an njit after it loaded the callback’s entry crashes the process with a segmentation fault. Withoutcache=True, the decorator behaves exactly asnumba.cfunc.
- numbox.core.cache_key.numbox_njit(*args, **kwargs)[source]
Decorate a function as
numba.njitdoes, and add numbox’s part to the key under which numba caches it.The decorator takes numba’s arguments unchanged, including signatures and options. With
cache=True, numba caches the function under its own key with numbox’s part appended: numbox’s version, the jit options and the settings inKEYED_SETTINGS. The part applies to an eager compile, for which the decorator is given a signature, and to a lazy compile at the first call. Withoutcache=True, the decorator behaves exactly asnumba.njit.