TL;DR
Writing fast tensor kernels for modern AI accelerators is a bit like choreographing a ballet where every dancer speaks a different language. Teal flips traditional compiler design on its head: instead of starting with generic loops and trying to guess which hardware instructions fit, it starts with the hardware's native instructions and automatically "lifts" them over larger tensors. By treating both the hardware specification and the execution schedule as programmable inputs, Teal lets one shared compiler statically verify memory safety, layouts, and synchronization—and then emit code that rivals or beats hand-tuned vendor libraries across GPUs, CPUs, and spatial accelerators.
What Problem Does This Paper Address?
To squeeze peak performance out of modern hardware, tensor kernels must be tailored to specific architectural quirks: NVIDIA Blackwell's asynchronous tensor cores and phase barriers, AMD MI350X's wave-distributed registers and flight counters, Intel AMX tiles, or Tenstorrent's spatial dataflow cores.
This creates a two-sided headache:
- For kernel authors (and AI coding agents): Low-level languages like CUDA or HIP give you control, but force you to manually juggle brittle pointer arithmetic, swizzled memory layouts, and hardware barriers. High-level compilers hide this, but rely on opaque heuristics that make performance regressions hard to debug.
- For compiler engineers: Supporting a new accelerator usually means writing custom lowering, layout, and synchronization passes from scratch.
As shown above, even a simple $64 \times 64 \times 64$ matrix multiplication looks completely different on AMD vs. NVIDIA hardware. Yet both face the same underlying compilation problems: generating tile loops, computing memory/register offsets, chaining data movement with math, and inserting waits.
Methods
Teal introduces instruction-centric lifting through a two-sided programming model fed into a single, hardware-parametric compiler:
- The Machine Side (Dialects): A hardware developer (or an AI agent reading hardware docs) writes a reusable dialect declaring the target's processor hierarchy, memory spaces (like shared memory or registers), fixed-size native instructions with their physical layouts, and synchronization primitives modeled as symbolic state machines called tokens.
- The Client Side (Schedules): A kernel author writes a compact, target-specific schedule by applying six generic operator families (
Move,Unary,Linear,Reduce,Scan,Contract) to high-level symbolic tensor views. Execution order and buffer reuse are expressed via chains (which fuse compatible outer loops), processor scopes (assigning work to specific warps or cores), and token wires (explicitly declaring data-readiness dependencies). - Verification & Lowering: Before generating a single line of target code, Teal builds a hierarchical execution graph and uses the Z3 SMT solver to statically prove that all tensor accesses stay in bounds, physical layouts match what the instructions expect, buffer reuse won't clobber live data, and token protocols are valid. Once verified, it lowers the schedule through a compact imperative IR (GLIR) to native C++/CUDA/HIP/TT-Metalium code.
Datasets
This is a systems and compilers paper, so no machine learning training datasets are used. Instead, the authors evaluate Teal on a suite of standard and emerging compute- and memory-bound tensor workloads:
- Dense GEMM (bf16 and fp32) across square matrix sizes.
- Fused Residual + RMSNorm (bf16, 8192 rows, hidden dimensions 1024–8192).
- Grouped-Query Attention (GQA) Non-Causal Forward (bf16, batch size 16, 64 query heads, 8 KV heads, head dim 128).
- Ozaki Scheme II fp64 Emulation GEMM (emulating fp64 matrix multiplication using int8 matrix cores).
Key Insights and Ideas
- Flipping the compiler paradigm: Conventional compilers start with loop nests and try to pattern-match hardware instructions. Teal starts with the fixed-size instruction and derives the loops and address math needed to tile it over arbitrary symbolic tensor shapes.
- Verification before benchmarking: Because Teal's schedules are high-level and symbolic, Z3 can catch out-of-bounds accesses, mismatched register layouts, and race conditions at compile time. This is a huge win for automated kernel-synthesis agents, which otherwise waste hours compiling and benchmarking broken low-level code.
- One compiler, wildly different hardware: By abstracting synchronization as token state machines and layouts as symbolic maps, the exact same compiler core handles SIMT GPUs, CPU tile units, and spatial dataflow arrays without target-specific backend rewrites.
Key Results
Teal was evaluated on five distinct architectures: AMD MI350X, NVIDIA B200, Intel Xeon 6, Apple M6, and Tenstorrent Blackhole.
- Dense GEMM: Matches or beats hand-tuned vendor libraries, achieving 0.93–1.00× hipBLASLt on MI350X, 0.93–0.98× cuBLASLt on B200, 0.89–1.36× oneMKL on Xeon 6, and 1.04–1.21× Apple Accelerate on M6.
- Fused Residual + RMSNorm: Chain fusion keeps intermediates in registers, delivering 0.97–1.14× AITER (MI350X), 1.13–1.28× FlashInfer (B200), 1.04–1.29×
torch.compile(Xeon 6), and 1.21–1.32×torch.compile(M6). - GQA Forward (MI350X): Outperforms Triton (1.19–1.24×) and CK-Tile (1.12–1.13×), reaching 0.87–0.88× of AITER's raw assembly kernels.
- Ozaki-II fp64 GEMM (MI350X): Fusing custom modular arithmetic epilogues directly into int8 MFMA accumulations achieves up to 1.94× the throughput of native hipBLAS fp64 GEMM.
- New Hardware Bring-up: Using GPT-6.1 Sol with Codex to write the Tenstorrent Blackhole dialect, Teal reached parity with TT-Metalium's hand-optimized GEMM in HiFi4 mode and 0.74–0.81× in LoFi mode—without modifying Teal's core compiler.
Limitations and Future Work
- Regular, dense domains only: Teal currently excludes unrestricted data-dependent control flow and arbitrary pointer-based accesses. Extending it to predicated/indirect indexing would open the door to Mixture-of-Experts (MoE) routing, sparse linear algebra, and graph workloads.
- SMT solver scalability: Combining integer division/modulo (from tiling) with bitwise XOR (from swizzled memory) can stress Z3. On Tenstorrent Blackhole, aggressive schedules that decoupled A and B NoC transfers hit Z3's per-query timeout. Improving domain-specific symbolic simplification and query framing is a key next step.
- End-to-end functional equivalence: Teal proves that a lowered schedule faithfully executes its lifted instructions, but not yet that those instructions mathematically equal a high-level equation like $C = AB^T$. Exporting Teal's region certificates to interactive theorem provers like Lean is a promising future direction.
Summary updated