GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Adds IndexBinaryOp and fixes for JIT by jim22k · Pull Request #576 · python-graphblas/python-graphblas

Conversation

@jim22k

@jim22k jim22k commented Jun 8, 2026

Copy link
Copy Markdown
Member

Summary

This commit adds full IndexBinaryOp UDT support and a suite of SuiteSparse JIT reliability fixes.


New Features

IndexBinaryOp on User-Defined Types (UDTs)

  • IndexBinaryOp._compile_udt now works for UDT operands, including UDT theta values. A new _get_udt_wrapper_indexbinary helper in base.py generates the Numba cfunc wrapper for the 4-index + theta signature (x, ix, jx, y, iy, jy, theta → z).
  • _BoundIndexBinaryOp (the result of ibo[dtype](theta)) gained pickling support via __reduce__, proper type markers (_is_udt, commutes_to, etc.), and stores _theta for round-trip serialization.
  • ParameterizedIndexBinaryOp pickle/deserialize now round-trips the is_udt flag.

JIT C Code Generation for UDTs (udt_utils.py — new file, ~979 lines)

  • Generates C struct typedefs from numpy dtypes (record and array UDTs), enabling SuiteSparse to JIT-compile optimized kernels instead of falling back to Numba cfuncs.
  • Handles nested record UDTs, array UDTs, C-reserved name collisions (synthesizes _gbudt_NNN names automatically), and complex-type field restrictions.
  • Provides _compile_codegen — a safe exec-based helper with AST pre-validation and linecache registration for readable tracebacks.

JIT Config Auto-Repair (jit_config.py — new file)

  • fix_jit_config(): replaces conda-build-baked compiler paths with one from $CONDA_PREFIX/bin/ or sysconfig, strips stale -isysroot / -fdebug-prefix-map flags, and optionally probes the result with a trivial JIT compile.
  • _auto_fix_jit_at_import(): called automatically at gb.ss import time to silently repair common mis-configurations without user intervention.
  • jit_compiler_is_usable(): lightweight check (file existence only) for use in warnings.

DataType JIT Introspection

  • New jit_c_name and jit_c_definition properties expose the C type name and struct typedef that SuiteSparse actually registered — stable across Python-side renames.
  • _set_udt_jit_c_definition() sets GxB_JIT_C_NAME + GxB_JIT_C_DEFINITION on the GrB_Type at registration time.

register_new / register_anonymous Ergonomics

  • Both now accept a bare @dataclass class or instance as the sole argument, inferring name from the class name.

Fixes & Improvements

UDT Wrapper Refactor (base.py)

  • _get_udt_wrapper was a large monolithic function; it's been decomposed into _input_operand, _output_handler, and _compose_wrapper_body, handling record UDTs (tuple-unpack returns), array UDTs, and BOOL-as-INT8 coercion correctly in all combinations.
  • _resolve_udt_return_type resolves Numba BaseTuple return types back to the matching record UDT by field arity and type alignment, with actionable UdfParseError messages when the match fails.

Better UDF Error Messages

  • UdfParseError docstring updated to document wrapping of TypingError, LoweringError, UnsupportedError.
  • _compile_udf_for_udt catches the full NumbaError hierarchy and surfaces the actionable diagnostic line (via _summarize_numba_typing_error) rather than a raw Numba traceback.
  • New NoJITWarning warning class emitted once per process when an auto-lifted UDT op falls back to the cfunc path (JIT compiler unusable, jit_c_control off, or UDT not C-representable).

Scalar / UDT Thunk Binding

  • TypedBuiltinIndexBinaryOp.__call__ stores theta_value before wrapping in a Scalar, fixing a round-trip issue for UDT thunks where Scalar.from_value couldn't infer the dtype from a raw numpy array.

Tests & Docs

  • test_indexbinary.py expanded with UDT cases, pickling, and semiring round-trips.
  • test_op.py added ~1,200 lines covering UDT operator compilation, JIT codegen, and error paths.
  • test_ssjit.py expanded with JIT auto-fix, NoJITWarning, and C typedef generation tests.
  • test_dtype.py and test_pickle.py extended for new jit_c_name/jit_c_definition and register_new(dataclass) behaviour.
  • New user guide pages: udt.rst (UDT reference) and updated udf.rst and operators.rst.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jim22k
Adds IndexBinaryOp and fixes for JIT
bf0cbbe
@jim22k
jim22k requested a review from eriknw June 8, 2026 14:48
jim22k and others added 2 commits June 10, 2026 10:42
@jim22k
updates
bcf3a6f
@jim22k
Merge pull request #14 from jim22k/updates
cba9fef
Additional updates
@jim22k
jim22k merged commit 6f1eb02 into python-graphblas:main Jul 23, 2026
8 of 16 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@eriknw eriknw mentioned this pull request Sep 18, 2026
Custom operations over user defined types that creates new instance of userdefined type #564
Closed
eriknw added a commit that referenced this pull request Nov 3, 2026
@eriknw
Give each UDT the C name gbudt_ and its name, which no kernel identif…
93c7f05
…ier collides with

SuiteSparse's JIT puts a UDT's C name in each kernel beside its own
identifiers, and that name was the UDT's Python name. A UDT named like
one of them did not compile: SuiteSparse raised JitError (with no
message) for that op and set jit_c_control to 'load', so the process
compiled no more kernels, although the code comment and udt.rst say such
a UDT falls back to the cfunc. Main did the same. Names that failed, each
in a fresh process: z and x (parameters of our op definitions), A, B, C,
M, p, i, j, k, Ax, Cx, cnz, tid and result (locals of SuiteSparse's
templates; which kernels fail depends on the name), div, abs, exp,
round, free, index and printf (declared by the C headers), and GB_void
and GrB_Info (SuiteSparse's). A list of reserved names cannot cover the
template locals.

Now the C name of a named UDT is gbudt_ and its name (_pick_c_type_name),
so every one of those compiles and computes; a C keyword as a name
(class) now takes the JIT too, where it got a synthetic name. A name
that is not a C identifier, or would make a C name of 128 characters or
more, gets a synthetic _gbudt_NNN name: SuiteSparse refuses such a long
name and keeps the type with an empty one, and its first kernel (A.T.new()
say) raised JitError, on main too for a UDT name of 128 characters or
more. jit_c_name is unreleased (it came with #576, after 2025.2.0), so
changing it breaks no release.

udt.rst's example and the tests that pin C names say gbudt_. The test
of an op whose C name SuiteSparse refuses now uses a 119-character UDT
name: its C name (125 characters) fits, and plus_ and that does not. New
tests: UDTs named z, A, p, i, div and result take the JIT for ewise_mult,
reduce and mxv; UDT names of 121, 122 and 200 characters get C names
that fit, and transpose under the JIT.
@eriknw eriknw mentioned this pull request Nov 3, 2026
Fix UDT, dtype and JIT edge cases found in #591's review #663
Open
@eriknw eriknw mentioned this pull request Nov 12, 2026
Give UDTs C names that no JIT kernel identifier collides with #669
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@eriknw eriknw Awaiting requested review from eriknw

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@jim22k
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.