Generate Numba CUDA bindings from CUDA C++ declarations.
Project description
Numbast
Numbast generates Python bindings for CUDA C++ declarations so they can be used from Python in Numba CUDA kernels. It is intended for CUDA Python projects that need to expose existing C++ device APIs without hand-writing Numba typing, lowering, and shim code for every function or type.
Numbast works with
ast_canopy, which parses CUDA C++
headers with Clang and serializes declaration metadata. The numbast package
consumes those declarations and registers or emits Numba CUDA-compatible
bindings.
What It Can Bind
Numbast supports a focused subset of CUDA C++ declarations:
- Free functions, overload sets, and supported operator overloads.
- Structs and classes, including constructors, public fields, methods, and conversion operators.
- Enums exposed as Python
IntEnumvalues with Numba-compatible typing. - Function templates and class templates where concrete specializations can be materialized for Numba CUDA.
- External C++ type mappings when a signature mentions a type that should map to an already-known Numba type.
See the supported declarations page for the full support matrix and current limitations.
Binding Workflows
Numbast supports two complementary workflows.
Dynamic Binding Generation
Dynamic generation parses headers and registers bindings at runtime. Use it for experimentation, development, and environments where Numbast, ast_canopy, Clang tooling, and the CUDA headers are all available.
from ast_canopy import parse_declarations_from_source
from numba import cuda, types
from numba.core.datamodel.models import PrimitiveModel
from numbast import MemoryShimWriter, bind_cxx_function, bind_cxx_struct
decls = parse_declarations_from_source("demo.cuh", ["demo.cuh"], "sm_80")
shim_writer = MemoryShimWriter('#include "demo.cuh"')
MyType = bind_cxx_struct(shim_writer, decls.structs[0], types.Number, PrimitiveModel)
my_function = bind_cxx_function(shim_writer, decls.functions[0])
@cuda.jit(link=shim_writer.links())
def kernel(out):
value = MyType(1.0)
out[0] = my_function(value)
Static Binding Generation
Static generation writes a standalone Python module that can be packaged with a project. The generated module depends on Numba CUDA, but end users do not need Numbast or Clang tooling at runtime.
python -m numbast --cfg-path config.yml --output-dir ./generated
Installation
pip install numbast
Generating bindings requires a CUDA Toolkit and Clang tooling environment that can parse the target headers. Running generated bindings requires a compatible Numba CUDA runtime environment.
Documentation
- Overview
- Installation
- Quickstart
- Dynamic binding generation
- Static binding generation
- Supported declarations
- API reference
Project Links
- Source: https://github.com/NVIDIA/numbast
- Documentation: https://nvidia.github.io/numbast/latest/
- Issues: https://github.com/NVIDIA/numbast/issues
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file numbast-0.9.0-py3-none-any.whl.
File metadata
- Download URL: numbast-0.9.0-py3-none-any.whl
- Upload date:
- Size: 148.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8768c5d5d1244cd3d3ba15db0cfc10ef18b11880fc9f1851c236bc147d48205
|
|
| MD5 |
ebe8a789ed4cdde8dd00ba9f2c1317d1
|
|
| BLAKE2b-256 |
f5943dcbbd42af3151cb6c52b05183046bdd161047d5ea9ab4cc221ed153854d
|
Provenance
The following attestation bundles were made for numbast-0.9.0-py3-none-any.whl:
Publisher:
publish.yaml on NVIDIA/numbast
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
numbast-0.9.0-py3-none-any.whl -
Subject digest:
d8768c5d5d1244cd3d3ba15db0cfc10ef18b11880fc9f1851c236bc147d48205 - Sigstore transparency entry: 1510033387
- Sigstore integration time:
-
Permalink:
NVIDIA/numbast@f08ff758fbfcded5de487c2494da98b6f8dda1d1 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/NVIDIA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@f08ff758fbfcded5de487c2494da98b6f8dda1d1 -
Trigger Event:
push
-
Statement type: