Registry / ai-ml / tilelang

tilelang

JSON →
library0.1.11pypypiunverified

TileLang (tile-lang) is a concise domain-specific language designed to streamline the development of high-performance GPU/CPU/accelerator kernels, such as GEMM, Dequant GEMM, and FlashAttention. It provides a Pythonic syntax with an underlying compiler infrastructure built on Apache TVM, allowing developers to focus on productivity while achieving state-of-the-art performance. The library is actively developed, with frequent updates and nightly builds, currently at version 0.1.8.

pip install tilelang
INSTALL
IMPORT
SIG · TILELANG
T
tilelang
ai-mlpythonv0.1.11
Install
73.7s avg
Import
7958ms
Disk
5120MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.9 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 83.1s
py 3.11
✕ build_error
✓ 78.33s
py 3.12
✕ build_error
✓ 66.15s
py 3.13
✕ build_error
✓ 67.05s
py 3.9
✕ build_error
✕ timeout
5120MB installed
● package 5120MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tilelang
import tilelang
tilelang.language
import tilelang.language as T
tilelang.jit
@tilelang.jit
from tilelang import jit
The `@tilelang.jit` decorator is typically imported directly from the top-level package or used as `tilelang.jit`.
T.prim_func
@T.prim_func
from tilelang.language import prim_func
Functions like `prim_func` are typically accessed via the `tilelang.language` alias `T`.

This quickstart demonstrates how to define and execute a matrix multiplication (GEMM) kernel using TileLang, integrating with PyTorch for tensor management and validation. It showcases decorators like `@tilelang.jit` and `@T.prim_func`, memory allocation with `T.alloc_shared`, data movement with `T.copy`, matrix multiplication with `T.gemm`, and loop pipelining with `T.Pipelined`.

import tilelang import tilelang.language as T import torch @tilelang.jit def matmul(M, N, K, block_M, block_N, block_K, dtype=T.float16, accum_dtype=T.float32, out_dtype=T.float32): @T.prim_func def main( A: T.Tensor((M, K), dtype), B: T.Tensor((K, N), dtype), C: T.Tensor((M, N), out_dtype), ): with T.Kernel(T.ceildiv(N, block_N), T.ceildiv(M, block_M), threads=128) as (bx, by): A_shared = T.alloc_shared((block_M, block_K), dtype) B_shared = T.alloc_shared((block_K, block_N), dtype) C_local = T.alloc_fragment((block_M, block_N), accum_dtype) T.clear(C_local) for ko in T.Pipelined(T.ceildiv(K, block_K), num_stages=0): T.copy(A[by * block_M, ko * block_K], A_shared) T.copy(B[ko * block_K, bx * block_N], B_shared) T.gemm(A_shared, B_shared, C_local) T.copy(C_local, C[by * block_M, bx * block_N]) return main M = 1024 N = 1024 K = 1024 block_M = 128 block_N = 128 block_K = 64 # 1. Define the kernel (matmul) and compile/lower it into an executable module matmul_kernel = matmul(M, N, K, block_M, block_N, block_K) # 2. Test the kernel in Python with PyTorch data a = torch.randn(M, K, device="cuda", dtype=torch.float16) b = torch.randn(K, N, device="cuda", dtype=torch.float16) c = torch.empty(M, N, device="cuda", dtype=torch.float16) # Run the kernel matmul_kernel(a, b, c) # Reference multiplication using PyTorch ref_c = (a @ b).to(c.dtype) # Validate correctness torch.testing.assert_close(c, ref_c, rtol=1e-2, atol=1e-2) print("Kernel output matches PyTorch reference.") # (Optional) Profile latency with kernel # profiler = matmul_kernel.get_profiler(tensor_supply_type=tilelang.TensorSupplyType.Normal) # latency = profiler.do_bench() # print(f"Latency: {latency} ms")
Debug
Known issues
breakingThe `tilelang.lower` API will be replaced by `tilelang.compile` in version 0.2.0. Existing code using `lower` will break.
fix
Update calls from `tilelang.lower(...)` to `tilelang.compile(...)`.
affects: >=0.2.0
gotchaAuto-tuning can sometimes fail with 'RuntimeError: Auto-tuning failed: No configuration successfully compiled and passed benchmarking/validation.' This indicates that none of the explored configurations could be successfully compiled or validated on the target hardware.
fix
Review the auto-tuning parameters, kernel definition, and target hardware environment. Ensure dependencies like `nvidia-cuda-nvcc` are correctly installed and meet version requirements (e.g., `>=13.0`).
affects: All versions
gotchaInconsistent CUDA kernel generation has been reported, potentially leading to correctness failures in production despite passing tests. This suggests non-deterministic compilation behavior in certain complex scenarios.
fix
Thoroughly validate kernels across various inputs and environments, including production-like setups. Monitor GitHub issues for updates and potential hotfixes related to compiler determinism.
affects: All versions (observed in 0.1.x)
gotchaLayout inference for shared buffers in GEMM operations with different transpose modes can fail.
fix
Carefully review and test kernels that use shared buffers across multiple GEMM operations with varying transpose configurations. Consider explicit layout annotations if automatic inference proves problematic.
affects: All versions (observed in 0.1.x)
deprecatedThe `primitives` folder and its design are being phased out, with functionalities merged into the `tileop` module. Direct imports or usage of `primitives` may become unstable or removed.
fix
Migrate any usage of modules or functions from the `primitives` folder to their equivalents in the `tileop` module. Consult the latest GitHub repository for the correct paths.
affects: >=0.1.8 (gradual removal)
Upgrade
Version history
0.1.11latest on PyPI · released Jun 8, 2026
Audit
Dependencies
apache-tvmrequiredUnderlying compiler infrastructure for code generation.
torch-c-dlpack-extrequiredRequired for PyTorch integration and tensor operations.
nvidia-cuda-nvccoptionalRequired for CUDA backend compilation; version >=13.0 recommended.
Agent activity
42 hits · last 30 days
node
38
Amazon
1
OpenAI (training)
1
Resources
tilelang — pip install tilelang · libregistry