Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

numbacc: a Numba/MLIR backend for SPy

What it is

numba/numbacc is a next-generation AOT compiler project from the Numba team that uses SPy directly as its frontend — not a hypothetical integration, a working one. Its Makefile vendors spylang/spy as a pinned dependency, and nbcc/frontend/frontend.py reads SPy’s own typed AST objects (W_ASTFunc, SPyVM, FQN) straight out of the SPy VM, in-memory — no text serialization or re-parsing involved.

The pipeline

SPy (typed AST) → sealir (RVSDG representation) → egglog-based e-graph optimization → MLIR → LLVM → native code, plus a separate cutile_backend targeting NVIDIA’s real cuda-tile MLIR dialect for GPU.

A few notable pieces:

Not just a backend

numbacc also ships its own SPy-source library, mlir_tensor_lib.spy, defining a TensorType that splices literal MLIR ops (linalg.add, tensor.dim) directly into compiled output, using @blue-phase metaprogramming rather than compiler changes. This is separate from NumSPy’s existing array[DTYPE, NDIM] — a second, MLIR-native array abstraction, not (yet) unified with NumSPy’s.

Separately, examples/e2e/*.spy (loops, @struct classes, if/else) show a genuine general-purpose backend for SPy’s core language — no MLIR-specific syntax, ordinary SPy compiled straight through.

Caveats