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.3.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, Chaofan Lin, Wei Zhang and Lei Wang},
      year={2026},
      publisher = {GitHub},
      howpublished = {\url{https://github.com/deepseek-ai/TileKernels}},
}

Metadata

Release files for tile-kernels 2.2.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.2.0
File Size Uploaded Provenance Actions
tile_kernels-2.2.0.tar.gz 207.1 kB Without provenance Details for tile_kernels-2.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 478.6 kB

Release files / tile_kernels-2.2.0.tar.gz

Download URL tile_kernels-2.2.0.tar.gz
Size 207.1 kB
Tags Source
SHA-256 checksum
How to use checksums
559248c7925daffc18672cc851085dfac9955154861e860d6297572aa2cccd39
BLAKE2b-256 checksum
How to use checksums
a8e159cc2669ff6f1da052eb22e90666ba6a2a49cab8a3f8a348f53ed5433046
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.2.0-py3-none-any.whl

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

Security for tile-kernels 2.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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