Compile UDFs under Numba's numpy error model - #588
Merged
Merged
Conversation
eriknw
marked this pull request as ready for review
August 4, 2026 16:07
eriknw
force-pushed
the
08-numba-numpy-error-model
branch
2 times, most recently
from
August 5, 2026 00:06
2d14098 to
c4adb70
Compare
eriknw
force-pushed
the
08-numba-numpy-error-model
branch
2 times, most recently
from
August 5, 2026 17:44
6908f99 to
b5525f1
Compare
eriknw
force-pushed
the
08-numba-numpy-error-model
branch
from
August 5, 2026 18:03
b5525f1 to
e7721a6
Compare
eriknw
force-pushed
the
08-numba-numpy-error-model
branch
2 times, most recently
from
August 6, 2026 07:59
d9bf85c to
fb5254d
Compare
eriknw
force-pushed
the
08-numba-numpy-error-model
branch
from
August 6, 2026 15:39
fb5254d to
c877578
Compare
eriknw
force-pushed
the
08-numba-numpy-error-model
branch
from
August 6, 2026 15:41
c877578 to
c24208c
Compare
eriknw
force-pushed
the
08-numba-numpy-error-model
branch
2 times, most recently
from
August 6, 2026 20:41
0861b81 to
d895629
Compare
eriknw
force-pushed
the
08-numba-numpy-error-model
branch
from
August 7, 2026 02:48
d895629 to
ae5ca33
Compare
eriknw
force-pushed
the
08-numba-numpy-error-model
branch
from
August 7, 2026 05:09
ae5ca33 to
611eab0
Compare
eriknw
force-pushed
the
08-numba-numpy-error-model
branch
from
August 26, 2026 17:30
611eab0 to
53eb255
Compare
eriknw
force-pushed
the
08-numba-numpy-error-model
branch
from
September 18, 2026 03:09
53eb255 to
35c4009
Compare
eriknw
force-pushed
the
08-numba-numpy-error-model
branch
from
September 18, 2026 03:46
35c4009 to
d8dfc4a
Compare
Base automatically changed from
07-selectop-borrowed-handle-lifetime
to
main
September 18, 2026 17:34
A UDF that divides by zero silently corrupted the result. Numba's default error model raises ZeroDivisionError inside the cfunc, where Numba prints the traceback and returns without writing, so GraphBLAS keeps whatever the output element already held. Measured at 6f1eb02: def _idiv(x, y): return x // y op = BinaryOp.register_anonymous(_idiv, "_probe_idiv") op(Vector.from_coo([0, 1], [10, 20]) & Vector.from_coo([0, 1], [2, 0])).new() -> [5, 5] # numpy gives [5, 0]; the 5 is the previous element The float case is the same shape: `[0.5, 0.5]` where numpy gives `[0.5, inf]`. The only user-visible signal is an "Exception ignored" traceback on stderr. Pass `error_model="numpy"` at every `numba.njit` and `numba.cfunc` site for user-defined ops. Setting it on the cfunc alone is not enough: `_build` calls `.compile(sig)` on the Dispatcher first, a Dispatcher keeps one compilation per signature, and whichever compile happens first fixes the model. Reverting only the Dispatcher argument, leaving it on the cfunc, reproduces `[5, 5]`. This changes what a dividing UDF returns, but the behaviour it replaces is an unwritten element rather than an error, so there is no correct result being taken away.
eriknw
force-pushed
the
08-numba-numpy-error-model
branch
from
September 18, 2026 17:34
d8dfc4a to
7f9f3f3
Compare
Member
Author
|
This was a good catch by my agents! The "numpy" error model is indeed what we want, not the "python" error model that tries and fails to raise an exception. Merging before the latest CI can complete (it was green before, and this let's us review 589 sooner, which fixes the segfault in CI) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A UDF that divides by zero silently corrupted the result. Numba's default
error model raises ZeroDivisionError inside the cfunc, where Numba prints
the traceback and returns without writing, so GraphBLAS keeps whatever the
output element already held. Measured at 6f1eb02:
The float case is the same shape:
[0.5, 0.5]where numpy gives[0.5, inf]. The only user-visible signal is an "Exception ignored"traceback on stderr.
Pass
error_model="numpy"at everynumba.njitandnumba.cfuncsite foruser-defined ops. Setting it on the cfunc alone is not enough:
_buildcalls
.compile(sig)on the Dispatcher first, a Dispatcher keeps onecompilation per signature, and whichever compile happens first fixes the
model. Reverting only the Dispatcher argument, leaving it on the cfunc,
reproduces
[5, 5].This changes what a dividing UDF returns, but the behaviour it replaces is
an unwritten element rather than an error, so there is no correct result
being taken away.
Stack created with GitHub Stacks CLI • Give Feedback 💬