High-performance GPU kernels (GEMM + FlashAttention4) written in TIRx
Project description
tirx-kernels
High-performance GPU kernels written in TIRx.
Kernels
| Name | dtype | Arch |
|---|---|---|
fp16_bf16_gemm |
fp16 / bf16 | sm_100a |
fp8_blockwise_gemm |
fp8 (blockwise) | sm_100a |
nvfp4_gemm |
nvfp4 | sm_100a |
flash_attention4 |
bf16 | sm_100a |
Installation
pip install tirx-kernels # from a release
# or, from a checkout:
pip install -e .
External dependencies
These are not on PyPI and must be installed/available separately. They are
imported lazily, so import tirx_kernels and kernel discovery work without
them — they are only needed to actually compile/run a kernel:
| Dependency | Needed by | Notes |
|---|---|---|
tvm.tirx |
all kernels (compile + run) | The TIRx compiler. Put it on PYTHONPATH, e.g. /path/to/tir/python. |
torch |
all kernels | CUDA build matching your GPU. |
deep_gemm |
fp8_blockwise_gemm data/baseline |
Used for fp8 quantization helpers and the reference. |
flashinfer |
nvfp4_gemm data/baseline |
Used for nvfp4 quantization and the baseline. |
Usage
Command line
# List discovered kernels (with their config labels)
python -m tirx_kernels.registry --format json
# Run correctness tests (optionally filter by kernel / config label)
python -m tirx_kernels.test
python -m tirx_kernels.test --kernel fp16_bf16_gemm
python -m tirx_kernels.test --kernel fp16_bf16_gemm --config bf16_1024x1024x1024
# Benchmark
python -m tirx_kernels.bench --kernel nvfp4_gemm
Programmatic API
Every kernel module exposes a small, uniform interface (see
tirx_kernels/_protocol.py):
from tirx_kernels.registry import discover_kernels
kernels = discover_kernels() # {name: module}
mod = kernels["fp16_bf16_gemm"]
mod.run_test(M=1024, N=1024, K=1024) # compile + run + correctness check
mod.run_bench(M=1024, N=1024, K=1024) # profile (needs a GPU)
func = mod.get_kernel(M=1024, N=1024, K=1024) # the TIRx PrimFunc
Each module also provides KERNEL_META (name / category / compute_capability)
and CONFIGS (the test/bench parameter sweeps) that the registry and CLI use.
License
Apache License 2.0. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 tirx_kernels-0.1.1.tar.gz.
File metadata
- Download URL: tirx_kernels-0.1.1.tar.gz
- Upload date:
- Size: 49.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16b4f4d0283a65947f618b7011e693a0539daca139f16d8cdc3c4fbef70af72f
|
|
| MD5 |
7bf99a655834256d323275de4cebb07b
|
|
| BLAKE2b-256 |
2e5c2eef6b23777a01a5a38efe4156dad34e481d1e74bc487957527110ffc158
|
Provenance
The following attestation bundles were made for tirx_kernels-0.1.1.tar.gz:
Publisher:
publish_pypi.yml on mlc-ai/tirx-kernels
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tirx_kernels-0.1.1.tar.gz -
Subject digest:
16b4f4d0283a65947f618b7011e693a0539daca139f16d8cdc3c4fbef70af72f - Sigstore transparency entry: 1863473236
- Sigstore integration time:
-
Permalink:
mlc-ai/tirx-kernels@dd75cfbbc590da5743d9e6eb3929d9d3070440f2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mlc-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@dd75cfbbc590da5743d9e6eb3929d9d3070440f2 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file tirx_kernels-0.1.1-py3-none-any.whl.
File metadata
- Download URL: tirx_kernels-0.1.1-py3-none-any.whl
- Upload date:
- Size: 54.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
322121e91f0e5fc7b9303fda23dc8a5960bed0463f2429164a882a154fdb071f
|
|
| MD5 |
741ae757b3bcbbd53ece64a42785bcf9
|
|
| BLAKE2b-256 |
75173eb10ce41cccbd70be96a12be757ff70a58bcb5656233079698a82e79f7a
|
Provenance
The following attestation bundles were made for tirx_kernels-0.1.1-py3-none-any.whl:
Publisher:
publish_pypi.yml on mlc-ai/tirx-kernels
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tirx_kernels-0.1.1-py3-none-any.whl -
Subject digest:
322121e91f0e5fc7b9303fda23dc8a5960bed0463f2429164a882a154fdb071f - Sigstore transparency entry: 1863473375
- Sigstore integration time:
-
Permalink:
mlc-ai/tirx-kernels@dd75cfbbc590da5743d9e6eb3929d9d3070440f2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mlc-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@dd75cfbbc590da5743d9e6eb3929d9d3070440f2 -
Trigger Event:
workflow_dispatch
-
Statement type: