Domain-specific language designed to streamline the development of high-performance GPU/CPU/Accelerators kernels
7,392
stars
1,937
commits
Python
primary language
Sep 11, 2026
updated
Tile Language (tile-lang) is a concise domain-specific language designed to streamline the development of high-performance GPU/CPU kernels (e.g., GEMM, Dequant GEMM, FlashAttention, LinearAttention). By employing a Pythonic syntax with an underlying compiler infrastructure on top of TVM, tile-lang allows developers to focus on productivity without sacrificing the low-level optimizations necessary for state-of-the-art performance.
T.mma_gemm_blockscaled and a corresponding SM120 example.T.gemm support for Apple M5, while retaining the simdgroup fallback for unsupported shapes and systems.T.gemm path using simdgroup_matrix MMA.T.copy_cluster for TMA multicast and SM-to-SM cluster transfers.tile::gather4 and tile::scatter4 support.T.gemm: added INT4 matrix multiplication to the CUDA GEMM path.T.CUDASourceCodeKernel for embedding custom CUDA source.__freeze__ annotations to preserve selected code during automatic delta debugging.T.tma_copy.T.tma_copy API.T.gemm: added matrix multiplication support for the CPU target.apache-tvm-ffi to reduce host-side overhead.T.gemm_sp for structured-sparse matrix multiplication.T.print and fragment-layout visualization workflows.See all releases for complete changelogs and compatibility notes.
TileLang is evolving into a multi-backend compiler (TileLang-X) built around a modular backend abstraction. See the backend architecture for the design, or ask a coding agent to use the backend integration skill when porting TileLang to a new backend.
The currently supported backends are listed below. Primary identifies TileLang's core backend, while Supported and Experimental backends are implemented in the main repository. Ecosystem adapters live in separate repositories, are not included in TileLang release wheels, and may follow independent compatibility schedules. Prebuilt wheels are available for Linux x86-64/AArch64, Windows x86-64, and macOS arm64.
TileLang uses Target objects to represent compilation targets. The default auto target detects CUDA, HIP, and Metal devices; select an explicit target when compiling for another backend or architecture. See the target guide for target syntax, architecture options, and backend-specific notes, or the corresponding adapter repository for installation and tested-device details.
| Backend | Target | Platforms and hardware | Support level | Notes |
|---|---|---|---|---|
| NVIDIA CUDA | cuda | Linux x86-64/AArch64, Windows x86-64; code paths from SM70 through SM120 | Primary | Release wheels and CI coverage; TMA, WGMMA, and TMEM features require the corresponding GPU architecture. |
| AMD ROCm/HIP | hip | Linux; CDNA and RDNA GPUs, including gfx942/gfx950 paths | Supported | Included in Linux wheels; a ROCm runtime is required. CI runs on a self-hosted gfx942 (MI300X) runner; gfx950 is not yet covered. |
| Apple Metal | metal | macOS on Apple silicon | Supported | Release wheels and CI coverage; Metal 4 cooperative tensors are available on supported M5 systems. |
| LLVM CPU | llvm | Host CPUs | Experimental | Build from source with USE_LLVM=ON; LLVM 15 or newer is required. |
| NVIDIA CuTe DSL | cutedsl | NVIDIA GPUs | Experimental | Requires nvidia-cutlass-dsl. |
| WebGPU | webgpu | WebGPU runtimes | Experimental | Code generation and runtime integration are still evolving. |
| Huawei Ascend | Ascend C / NPU IR | Ascend A2 and A3 | Ecosystem | Developed in tilelang-ascend and the MLIR-based tilelang-mlir-ascend. |
| MetaX MACA | maca | MetaX C500 and C600 | Ecosystem | Developed in tilelang-metax; requires the MACA software stack. |
| Moore Threads MUSA | musa | S5000, S4000, and M1000 | Ecosystem | Developed in tilelang-musa and released independently. |
| HYGON | hcu | Linux; BW1000, BW1100, BW150 and K100_AI | Ecosystem | Developed in tilelang-hygon; requires the DTK software stack. |
| Sunrise-AI TANG | tang | Sunrise S2 and S3 | Ecosystem | Developed in tilelang-sunrise. The TANG software stack is required. |
Install the latest stable release from PyPI:
pip install tilelang
Verify the installation:
python -c "import tilelang; print(tilelang.__version__)"
Nightly wheels provide recent features and fixes before the next stable release:
pip install tilelang --find-links https://tile-ai.github.io/whl/nightly
On AMD GPUs the same Linux wheels work out of the box: install a ROCm build of PyTorch first (e.g. pip install torch --index-url https://download.pytorch.org/whl/rocm7.0), then pip install tilelang. A host ROCm installation is required at runtime; see the ROCm notes in the installation guide.
Nightly builds may be less stable than official releases. For source builds, editable installs, Docker, ROCm setup, pip-provided CUDA toolchains, or a custom TVM checkout, follow the complete installation guide.
The following example defines, compiles, runs, and verifies an FP16 GEMM kernel with FP32 accumulation and a fused ReLU epilogue. It uses PyTorch CUDA tensors; PyTorch uses the same cuda device name on ROCm systems. TileLang selects the target automatically from the current environment.
import torch
import tilelang
import tilelang.language as T
@tilelang.jit
def matmul_relu(A, B, block_M: int = 128, block_N: int = 128, block_K: int = 32):
M, N, K = T.const("M, N, K")
A: T.Tensor((M, K), T.float16)
B: T.Tensor((K, N), T.float16)
C = T.empty((M, N), T.float16)
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), T.float16)
B_shared = T.alloc_shared((block_K, block_N), T.float16)
C_local = T.alloc_fragment((block_M, block_N), T.float32)
T.clear(C_local)
for k in T.Pipelined(T.ceildiv(K, block_K), num_stages=3):
T.copy(A[by * block_M, k * block_K], A_shared)
T.copy(B[k * block_K, bx * block_N], B_shared)
T.gemm(A_shared, B_shared, C_local)
for i, j in T.Parallel(block_M, block_N):
C_local[i, j] = T.max(C_local[i, j], 0)
T.copy(C_local, C[by * block_M, bx * block_N])
return C
M = N = K = 1024
a = torch.randn((M, K), device="cuda", dtype=torch.float16)
b = torch.randn((K, N), device="cuda", dtype=torch.float16)
c = matmul_relu(a, b)
torch.testing.assert_close(c, torch.relu(a @ b), rtol=1e-2, atol=1e-2)
print("GEMM + ReLU passed.")
@tilelang.jit specializes the kernel for the input shape and compile-time arguments on first use. T.Pipelined stages global-to-shared transfers, T.gemm maps the tile operation to the target backend, and T.Parallel expresses the elementwise ReLU epilogue. Continue with the language basics, then explore the GEMM examples for layouts, autotuning, and architecture-specific optimizations.
Browse the complete examples directory for additional operators, tests, and architecture-specific implementations.
TileLang achieves exceptional performance across a variety of computational patterns. Comprehensive benchmark scripts and settings are available at tilelang-benchmark. Below are selected results showcasing its capabilities:
MLA Decoding Performance on H100
Flash Attention Performance on H100
Matmul Performance on GPUs (RTX 4090, A100, H100, MI300X)
Dequantize Matmul Performance on A100
Welcome to join our Discord community for discussions, support, and collaboration!
We would like to express our gratitude to the TVM community for their invaluable contributions. The initial version of this project was mainly developed by LeiWang1999, chengyupku and nox-410 with supervision from Prof. Zhi Yang at Peking University. Part of this work was carried out during an internship at Microsoft Research, where Dr. Lingxiao Ma, Dr. Yuqing Xia, Dr. Jilong Xue, and Dr. Fan Yang offered valuable advice and support. We deeply appreciate their mentorship and contributions.
(top 30 of 205)
Python
55.0%
C++
43.6%
Domain-specific language designed to streamline the development of high-performance GPU/CPU/Accelerators kernels
7,392
stars
1,937
commits
Python
primary language
Sep 11, 2026
updated
Tile Language (tile-lang) is a concise domain-specific language designed to streamline the development of high-performance GPU/CPU kernels (e.g., GEMM, Dequant GEMM, FlashAttention, LinearAttention). By employing a Pythonic syntax with an underlying compiler infrastructure on top of TVM, tile-lang allows developers to focus on productivity without sacrificing the low-level optimizations necessary for state-of-the-art performance.
T.mma_gemm_blockscaled and a corresponding SM120 example.T.gemm support for Apple M5, while retaining the simdgroup fallback for unsupported shapes and systems.T.gemm path using simdgroup_matrix MMA.T.copy_cluster for TMA multicast and SM-to-SM cluster transfers.tile::gather4 and tile::scatter4 support.T.gemm: added INT4 matrix multiplication to the CUDA GEMM path.T.CUDASourceCodeKernel for embedding custom CUDA source.__freeze__ annotations to preserve selected code during automatic delta debugging.T.tma_copy.T.tma_copy API.T.gemm: added matrix multiplication support for the CPU target.apache-tvm-ffi to reduce host-side overhead.T.gemm_sp for structured-sparse matrix multiplication.T.print and fragment-layout visualization workflows.See all releases for complete changelogs and compatibility notes.
TileLang is evolving into a multi-backend compiler (TileLang-X) built around a modular backend abstraction. See the backend architecture for the design, or ask a coding agent to use the backend integration skill when porting TileLang to a new backend.
The currently supported backends are listed below. Primary identifies TileLang's core backend, while Supported and Experimental backends are implemented in the main repository. Ecosystem adapters live in separate repositories, are not included in TileLang release wheels, and may follow independent compatibility schedules. Prebuilt wheels are available for Linux x86-64/AArch64, Windows x86-64, and macOS arm64.
TileLang uses Target objects to represent compilation targets. The default auto target detects CUDA, HIP, and Metal devices; select an explicit target when compiling for another backend or architecture. See the target guide for target syntax, architecture options, and backend-specific notes, or the corresponding adapter repository for installation and tested-device details.
| Backend | Target | Platforms and hardware | Support level | Notes |
|---|---|---|---|---|
| NVIDIA CUDA | cuda | Linux x86-64/AArch64, Windows x86-64; code paths from SM70 through SM120 | Primary | Release wheels and CI coverage; TMA, WGMMA, and TMEM features require the corresponding GPU architecture. |
| AMD ROCm/HIP | hip | Linux; CDNA and RDNA GPUs, including gfx942/gfx950 paths | Supported | Included in Linux wheels; a ROCm runtime is required. CI runs on a self-hosted gfx942 (MI300X) runner; gfx950 is not yet covered. |
| Apple Metal | metal | macOS on Apple silicon | Supported | Release wheels and CI coverage; Metal 4 cooperative tensors are available on supported M5 systems. |
| LLVM CPU | llvm | Host CPUs | Experimental | Build from source with USE_LLVM=ON; LLVM 15 or newer is required. |
| NVIDIA CuTe DSL | cutedsl | NVIDIA GPUs | Experimental | Requires nvidia-cutlass-dsl. |
| WebGPU | webgpu | WebGPU runtimes | Experimental | Code generation and runtime integration are still evolving. |
| Huawei Ascend | Ascend C / NPU IR | Ascend A2 and A3 | Ecosystem | Developed in tilelang-ascend and the MLIR-based tilelang-mlir-ascend. |
| MetaX MACA | maca | MetaX C500 and C600 | Ecosystem | Developed in tilelang-metax; requires the MACA software stack. |
| Moore Threads MUSA | musa | S5000, S4000, and M1000 | Ecosystem | Developed in tilelang-musa and released independently. |
| HYGON | hcu | Linux; BW1000, BW1100, BW150 and K100_AI | Ecosystem | Developed in tilelang-hygon; requires the DTK software stack. |
| Sunrise-AI TANG | tang | Sunrise S2 and S3 | Ecosystem | Developed in tilelang-sunrise. The TANG software stack is required. |
Install the latest stable release from PyPI:
pip install tilelang
Verify the installation:
python -c "import tilelang; print(tilelang.__version__)"
Nightly wheels provide recent features and fixes before the next stable release:
pip install tilelang --find-links https://tile-ai.github.io/whl/nightly
On AMD GPUs the same Linux wheels work out of the box: install a ROCm build of PyTorch first (e.g. pip install torch --index-url https://download.pytorch.org/whl/rocm7.0), then pip install tilelang. A host ROCm installation is required at runtime; see the ROCm notes in the installation guide.
Nightly builds may be less stable than official releases. For source builds, editable installs, Docker, ROCm setup, pip-provided CUDA toolchains, or a custom TVM checkout, follow the complete installation guide.
The following example defines, compiles, runs, and verifies an FP16 GEMM kernel with FP32 accumulation and a fused ReLU epilogue. It uses PyTorch CUDA tensors; PyTorch uses the same cuda device name on ROCm systems. TileLang selects the target automatically from the current environment.
import torch
import tilelang
import tilelang.language as T
@tilelang.jit
def matmul_relu(A, B, block_M: int = 128, block_N: int = 128, block_K: int = 32):
M, N, K = T.const("M, N, K")
A: T.Tensor((M, K), T.float16)
B: T.Tensor((K, N), T.float16)
C = T.empty((M, N), T.float16)
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), T.float16)
B_shared = T.alloc_shared((block_K, block_N), T.float16)
C_local = T.alloc_fragment((block_M, block_N), T.float32)
T.clear(C_local)
for k in T.Pipelined(T.ceildiv(K, block_K), num_stages=3):
T.copy(A[by * block_M, k * block_K], A_shared)
T.copy(B[k * block_K, bx * block_N], B_shared)
T.gemm(A_shared, B_shared, C_local)
for i, j in T.Parallel(block_M, block_N):
C_local[i, j] = T.max(C_local[i, j], 0)
T.copy(C_local, C[by * block_M, bx * block_N])
return C
M = N = K = 1024
a = torch.randn((M, K), device="cuda", dtype=torch.float16)
b = torch.randn((K, N), device="cuda", dtype=torch.float16)
c = matmul_relu(a, b)
torch.testing.assert_close(c, torch.relu(a @ b), rtol=1e-2, atol=1e-2)
print("GEMM + ReLU passed.")
@tilelang.jit specializes the kernel for the input shape and compile-time arguments on first use. T.Pipelined stages global-to-shared transfers, T.gemm maps the tile operation to the target backend, and T.Parallel expresses the elementwise ReLU epilogue. Continue with the language basics, then explore the GEMM examples for layouts, autotuning, and architecture-specific optimizations.
Browse the complete examples directory for additional operators, tests, and architecture-specific implementations.
TileLang achieves exceptional performance across a variety of computational patterns. Comprehensive benchmark scripts and settings are available at tilelang-benchmark. Below are selected results showcasing its capabilities:
MLA Decoding Performance on H100
Flash Attention Performance on H100
Matmul Performance on GPUs (RTX 4090, A100, H100, MI300X)
Dequantize Matmul Performance on A100
Welcome to join our Discord community for discussions, support, and collaboration!
We would like to express our gratitude to the TVM community for their invaluable contributions. The initial version of this project was mainly developed by LeiWang1999, chengyupku and nox-410 with supervision from Prof. Zhi Yang at Peking University. Part of this work was carried out during an internship at Microsoft Research, where Dr. Lingxiao Ma, Dr. Yuqing Xia, Dr. Jilong Xue, and Dr. Fan Yang offered valuable advice and support. We deeply appreciate their mentorship and contributions.
(top 30 of 205)
Python
55.0%
C++
43.6%