Skip to main content

Tile Kernels

TileKernels is a library of dozens of highly optimized kernels implemented in TileLang, a domain-specific language supporting multiple hardware backends. It provides kernels for several common operations in LLM training and inference, including mixture-of-experts routing, Engram, quantization, and manifold hyper-connections. Most kernels achieve performance close to the hardware's compute or memory bandwidth limits. All of these kernels have already been used in our internal training and inference workloads.

TileKernels 是一个包含数十个深度优化算子的高性能算子库,基于支持多种硬件后端的领域专用语言 TileLang 实现。它为大语言模型训练与推理中的几项常见操作提供算子,包括混合专家路由、Engram、量化和流形超连接(mHC)。大多数算子的性能接近硬件的计算吞吐或内存带宽上限。全部算子已用于我们的内部训练与推理任务。

News

  • [2026-09-30] Huawei Ascend support: Added Huawei Ascend support and updated the usage documentation. Following the NVIDIA path, the kernels now ship a second backend that is selected automatically at runtime, so the same Python APIs run on both NVIDIA GPUs and Huawei NPUs.

Features

  • MoE Routing — Top-k expert selection and scoring for Mixture of Experts routing
  • Quantization — Per-token, per-block, and per-channel FP8/FP4 casting and dequantization, with fused SwiGLU+quantization ops
  • Engram — Engram gating kernels with fused RMSNorm, forward/backward passes and weight gradient reduction
  • Manifold HyperConnection — Hyper-connection kernels including Sinkhorn normalization and mix splitting/application
  • Transform — RoPE kernel
  • Rand - Rand kernel
  • Modeling — High-level torch.autograd.Function wrapper for the Engram gate

Requirements

  • Python 3.12 or higher
  • PyTorch 2.13 or higher
  • TileLang 0.1.15 or higher
  • CUDA Backend
    • NVIDIA SM90 or SM100 architecture GPU
    • CUDA Toolkit 13.1 or higher
  • Ascend Backend
    • Ascend 950 NPU
    • CANN 9.2.0 or higher

Installation

Install a local development version

pip install -e ".[dev]"

Install a release version

pip install tile-kernels

Testing

Tests using pytest:

Test single test file

python -m pytest tests/quant/test_per_token_cast.py -n 4 # Correctness only with 4 workers
python -m pytest tests/quant/test_per_token_cast.py --run-benchmark # Correctness + Benchmarking

Test level

TK_TEST_LEVEL=0 python -m pytest -n 4 # Core tests
TK_TEST_LEVEL=2 python -m pytest -n 4 --count 2 # Full tests

Development

Install pre commit hooks.

pre-commit install --install-hooks

Project Structure

tile_kernels/
├── engram/     # Engram gating kernels
├── mhc/        # Manifold HyperConnection kernels
├── modeling/   # High-level autograd modeling layer (engram)
├── moe/        # Mixture of Experts routing kernels
├── quant/      # Quantization kernels
├── rand/       # Random number generator kernel
├── testing/    # Test and benchmark utilities
├── torch/      # PyTorch reference implementations
└── transform/  # Rotary position embedding kernel

Acknowledgement

This project is built on TileLang, and we extend our thanks and respect to its developers. We also gratefully acknowledge Huawei for its technical support and engineering expertise throughout the development of Tile Kernels' Ascend backend.

License

This code repository is released under the MIT License.

Citation

@misc{tilekernels,
      title={TileKernels},
      author={Xiangwen Wang, Chenhao Xu, Huanqi Cao, Luotian Huang, Yuxuan Zhou, Weilin Zhao, Rui Tian, Anyi Xu, Fucong Dai, Kuai Yu, Ruifan Xu, Yi Qian, Shengyuan Jia, Chenggang Zhao, Wei Zhang and Lei Wang},
      year={2026},
      publisher = {GitHub},
      howpublished = {\url{https://github.com/deepseek-ai/TileKernels}},
}

Metadata

Release files for tile-kernels 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tile-kernels 2.0.0
File Size Uploaded
tile_kernels-2.0.0.tar.gz 225.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tile-kernels 2.0.0
File Interpreter ABI Platform
tile_kernels-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 480.2 kB

Release files / tile_kernels-2.0.0.tar.gz

Download URL tile_kernels-2.0.0.tar.gz
Size 225.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c375451057eca4a0a211bed458fc3c16fab9548ada35c6d220cf01f6fd69dafb
BLAKE2b-256 checksum
How to use checksums
b9eae9ff369a74be9f36ed5170b6d6cc5e2d77a2d6afb6d3e0608132c1ce9274
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / tile_kernels-2.0.0-py3-none-any.whl

Download URL tile_kernels-2.0.0-py3-none-any.whl
Size 254.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b4a9206ec07b6881a72fcfe15a4f8bf18240a13b1808fcc24fd1f372498844fe
BLAKE2b-256 checksum
How to use checksums
b9405b5fba3b405ceec46b4f4d21ca8ef24dd5e2cc8f8c49ddad4414992b1f67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

2.1.0

2 release files

This release

2.0.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page