TileLang DSL
DeepSeek-V4 用于 kernel 开发的 Domain-Specific Language,平衡开发效率与运行时性能。
Motivation
V4 的复杂架构(CSA/HCA/mHC/MoE)会导致数百个细粒度 Torch ATen operators。TileLang 用 fused kernels 替代大部分,同时支持快速原型开发。
Key Features
Host Codegen
- 将 host 端逻辑从 Python 移到生成的主机代码
- CPU 端验证开销:从数十/数百 μs → <1 μs per invocation
- 基于 TVM-FFI 框架的紧凑调用约定 + zero-copy tensor interop
Z3 SMT Solver 集成
- 将 TileLang 整数表达式转为 Z3 的 QF_NIA(无量词非线性整数算术)
- 用于:layout inference、memory hazard detection、bound analysis、vectorization
- 编译开销仅几秒,但显著提升优化性能
数值精度与可重现性
- 默认关闭 fast-math
- 精度相关的近似需显式 opt-in(T.__exp, T.__log 等)
- IEEE-754 语义有专用 intrinsics(T.ieee_fsqrt, T.ieee_fdiv 等)
- Bitwise reproducibility:algebra simplification 与 NVCC 对齐,layout annotation 固定计算顺序
Relations
- Used in: Deepseek V4, Megamoe Kernel
- Related: Dsec Sandbox