Skip to main content

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


Download files

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

Source Distribution

tirx_kernels-0.1.1.tar.gz (49.8 kB view details)

Uploaded Source

Built Distribution

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

tirx_kernels-0.1.1-py3-none-any.whl (54.5 kB view details)

Uploaded Python 3

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

Hashes for tirx_kernels-0.1.1.tar.gz
Algorithm Hash digest
SHA256 16b4f4d0283a65947f618b7011e693a0539daca139f16d8cdc3c4fbef70af72f
MD5 7bf99a655834256d323275de4cebb07b
BLAKE2b-256 2e5c2eef6b23777a01a5a38efe4156dad34e481d1e74bc487957527110ffc158

See more details on using hashes here.

Provenance

The following attestation bundles were made for tirx_kernels-0.1.1.tar.gz:

Publisher: publish_pypi.yml on mlc-ai/tirx-kernels

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for tirx_kernels-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 322121e91f0e5fc7b9303fda23dc8a5960bed0463f2429164a882a154fdb071f
MD5 741ae757b3bcbbd53ece64a42785bcf9
BLAKE2b-256 75173eb10ce41cccbd70be96a12be757ff70a58bcb5656233079698a82e79f7a

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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