Skip to main content

Generate PyTorch Custom Operators from Numba-CUDA kernels

Project description

Pytorch-Numba Extension JIT

Documentation | PyPi

Writing custom CUDA operators in C and CPP can make certain operations significantly more efficient, but requires setting up a full C++ project and involves a great deal of boilerplate. Writing CUDA kernels using numba-cuda is significantly easier, but incurs overhead on every call, and still requires some boilerplate to integrate with the tracing systems that underlie torch.compile.

However, many of the CUDA kernels that would be used for deep learning are relatively similar (read from a set of input arrays, write to output arrays). As such, most of the boilerplate and binding code for C++ extensions could be generated automatically.

This project aims to do exactly that: pnex.jit takes a Python function in the form of a Numba CUDA kernel, along with some type annotations, and compiles a user-friendly and highly-performant PyTorch C++ extension.

Additionally, if a convenient wrapper for PyTorch Custom Operators is all that is desired, this library also allows skipping the C++ compilation phase and only generating the boilerplate for a Custom Operator definition.

For an example usage of this package, see my other package pytorch-nd-semiconv

This package is listed on PyPi; it can be installed with

pip install pytorch-numba-extension-jit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytorch_numba_extension_jit-0.1.2.tar.gz (58.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytorch_numba_extension_jit-0.1.2-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file pytorch_numba_extension_jit-0.1.2.tar.gz.

File metadata

File hashes

Hashes for pytorch_numba_extension_jit-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b44b0f4655b0c05c32d44dee34c196d59503ceacf42ccf6317b972d15f3b2b63
MD5 2b53395cf989b17d2f6a2562be1ac23b
BLAKE2b-256 1ac4a28863b873b12e0da0dbbe85136644750b7acabd7d731bfabdfe53ae2e3e

See more details on using hashes here.

File details

Details for the file pytorch_numba_extension_jit-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pytorch_numba_extension_jit-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5114c67379d0a785b21e64926c513f5201c5cb30dc1483e531b05df647947b56
MD5 ceb1199ad68d472d10f0bab3c76ac18a
BLAKE2b-256 6dd61d6e093bf54f1401aa3ca7251d608af78122a26b378446ee2b6a26ebc04c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page