Chips & architecture · Research feature

Triton Programming Model Applied to Custom AI Accelerator MTIA-2i

A study demonstrates Triton's effective use on Meta's MTIA-2i custom AI accelerator, achieving performance comparable to hand-tuned C++ code.

Adapted from research by Haishan Zhu, Domi Yan, Michael Levesque-Dion and colleagues.

arXiv preprint revision · 2026-08-12 · Attribution & reuse
In this article
Editorial illustration of processor die.

Editor’s introduction

The study evaluates Triton, a high-level kernel programming language, on Meta’s MTIA-2i custom AI accelerator. The work introduces a new compiler backend and language extensions tailored to MTIA-2i’s architecture, enabling efficient kernel development. Triton kernels were deployed across 60 model types, covering 50% of layers and 47% of non-GEMM execution time. This shows that a unified programming model can bridge gaps between ML frameworks and custom hardware.

Introduction

Modern ML applications target a growing range of use cases from LLMs to recommendation systems to video processing for self-driving cars. As a result, model diversity is increasing over time, placing a huge demand on the number of operators that must be supported. For example, PyTorch’s core built-in kernel library (ATen) includes almost 200 operators, while the full ATen library includes more than 540 operators.

Meanwhile, the range of available ML accelerators is also growing, including GPUs from established vendors and custom ASICs developed by hyperscalers and numerous AI chip startups. For example, Meta relies on a combination of multiple generations of AMD and NVIDIA GPUs, along with in-house custom ASICs. Custom ASICs have the benefit of being more tailored to particular ML workloads, but they also require developers to adopt new programming models.

The increasing diversity of ML models and hardware types poses a significant challenge for developers. Delivering good performance requires deep knowledge of the low-level details of the underlying hardware (memory management, command scheduling, etc.). As a result, kernels must be hand-optimized for each type of accelerator, and these optimizations don’t translate well across hardware generations. This conflicts with the need to rapidly iterate to explore new models and ways of optimizing them.

One direction that can ease this burden is to use a Domain-Specific Language (DSL) that abstracts away the complexity of supporting many models and different types of hardware. A popular example of this is Triton, which is a specialized language and compiler (integrated with PyTorch) for writing high-performance kernels. Triton is gaining traction in the industry because it hides many low-level hardware details and allows developers to write code that is portable across multiple accelerators. However, Triton was initially designed for, and currently only supports, accelerators with GPU-style programming models (e.g., NVIDIA and AMD), and it has not yet been demonstrated that it can be used with other types of accelerators.

In this paper, we ask the following question: can we support the full range of ML accelerators that are deployed in today’s datacenters without sacrificing developer productivity? To help answer this question, we study whether we can make Triton compatible with MTIA-2i at production scale. MTIA-2i is a second-generation custom ASIC designed at Meta that targets ML inference workloads. We believe MTIA-2i provides a useful data point because it has a hardware programming model that differs significantly from GPUs.

DSLs for GPU Programming

Several DSLs have been proposed to improve developer productivity in developing high-performance kernels for GPUs. Triton is one of the most popular options. It was originally developed to simplify GPU programming by abstracting away low-level hardware details and enabling developers to write efficient kernels using a Python-like syntax. More recently, Triton has become the de facto language for manual fusion and optimization at the kernel level. Notably, FlashAttention-V2 is one of the many examples where complex kernels and libraries were rapidly developed using Triton.

The kernel DSL landscape is advancing quickly. We briefly discuss a few examples beyond Triton: Helion is a higher-level DSL in PyTorch that further reduces manual effort and provides more automatic tuning than Triton. Pallas is an extension to JAX that provides a combination of high-level and low-level programming interfaces. TLX is a set of low-level Triton language extensions that target GPUs. Gluon and CuTeDSL are lower-level DSLs that expose more GPU architecture details in exchange for a higher performance ceiling. Other notable examples include TileLang, CuTile, and NKI.

Programming Models of Custom ML Accelerators

The industry has explored a wide variety of different programming models for ML accelerators. Google’s TPUs present a VLIW model and multiple levels of scratchpad memory backed by HBM. Groq introduces a Tensor Streaming Processor (TSP) architecture that exposes a stream programming abstraction between producer and consumer on-chip engines. SambaNova introduces a Reconfigurable Dataflow Architecture (RDA) that relies on compilers to map dataflow graphs in models onto compute units. Other notable examples of custom accelerator architectures include Amazon Trainium, Microsoft MAIA, Tenstorrent Blackhole, and Cerebras.

Middle-End: Mapping Operations to Architecture

We now map operations represented in ttir onto various hardware engines in PEs. The compiler accounts for details of the operations, device capabilities, and performance of generated code when making these decisions. We focus on memory and compute operations below; other miscellaneous operations (layout transformation, synchronization, etc.) are omitted for brevity.

The main challenge for the Triton compiler in lowering memory accesses is determining whether such operations can be lowered to DMAs or must be implemented as scalar loads and stores issued by the RISC-V cores. DMAs achieve much higher memory bandwidth utilization, but only support “structured” memory accesses (i.e., a multidimensional memory access that can be expressed using a base address, dimension, and strides for each dimension).

The Triton language supports three ways of expressing memory accesses: tensor-of-pointers, pointer-of-tensor, and tensor descriptor. See Listing for examples; note that tensor-of-pointers (Listing (a)) is flexible and can express arbitrary scatter/gather memory accesses. However, it is also the most widely used of the three options, even for “structured” memory accesses.

To reliably map memory accesses to DMAs when possible, we leverage the open-source Triton IR analysis pass from triton-shared. The pass analyzes pointer arithmetic operations in the IR and rewrites them to explicitly encode structured information if possible. Unconverted memory accesses are lowered to scalar loads and stores executed by RISC-V cores.

For compute operations, the compiler must decide whether an operation should be executed on the FFUs (e.g., DMAs, SE, DPE, etc.) or on the RISC-V vector core. FFUs provide best performance and are designed to support the most common operators (e.g. matrix multiplications on the DPE, element-wise and reduction operations on the SE). On the other hand, the RISC-V cores support a wider range of operations and data types but at lower performance. This compilation stage makes mapping decisions based on architecture constraints and the input IR.

Code Generation: Enabling Easy Manual Examination

While LLVM IR lowering has been the standard code generation path, we have seen more uses of the C++ code generation format among MTIA expert kernel developers. In this flow, the compiler generates human-readable C++ code that can be easily mapped back to the original Triton source. We further enable direct modification of the generated C++ code before final compilation and linking. This shortens the compiler and kernel debugging cycle. Overall, we observe comparable performance for almost all kernels between the LLVM IR and C++ codegen formats.

Effective Shape Propagation

A Triton operation operates on on-chip tensors of static shapes called block sizes. When tensor sizes are not multiples of block sizes, kernels calculate the effective shape of the tensor with masks in memory accesses. We can optimize the code by extracting the effective shape and propagating this information to consumers of the tensors.

Listing shows a kernel snippet where boundary and padding information can be propagated. Through IR analysis, we can determine that the tensor x has a static shape of BLOCK_SIZE, but computation is only effective on row_size elements.

Greedy CB Sizing

MTIA architecture is designed to simplify the construction of software pipelining. In particular, RISC-V cores issue commands to FFUs asynchronously and data dependencies are enforced by participating FFUs using CB abstraction. This design allows RISC-V cores to run ahead in its execution, pre-issue as many commands to FFUs as possible, and keep the entire pipeline of memory accesses and on-chip computation occupied.

To take advantage of this design, the compiler analyzes the IR to identify the capacity requirements for all tensors in the kernel, which is made easy given that all tensors in Triton are statically sized. The compiler then greedily chooses the smallest multiplier in allocating capacity for each tensor, so that all allocations still fit in LS. Since kernels often contain an inner loop (e.g., to iterate over tensors), this optimization allows the resulting code to pipeline memory and compute operations across loop iterations.

CB Pointer Management

We developed an algorithm that inserts such pointer adjustments based on how each buffer is used. The algorithm groups operations into static ranges that read from or write to a buffer, and increments pointers at the boundaries between ranges. This approach has proven robust across a wide range of Triton kernels. See Listing for an example.

To enable software pipelining, the compiler allocates CBs whose size is a multiple of the tile size used by the kernel. Since CP issues commands to FFUs asynchronously and data dependencies are directly enforced via the CB abstraction, multiple commands can be in flight at the same time as long as there is enough space in the relevant CBs.

Optimizing Memory and Register Use

To make best use of the hardware, Inductor needs to model MTIA’s memory and register resources. For example, MTIA-2i supports 15 CBs and 384 KB of LS per PE, differing considerably from the register file and local memory available to streaming multiprocessors (SMs) on a GPU. To prevent spilling between various levels of the memory hierarchy, MTIA’s Inductor backend estimates the resource usage of each kernel, tuning fusion decisions and block sizes as needed.

libdevice

Triton libdevice is a mechanism to call library functions defined for a specific backend. Triton-MTIA compiler takes advantage of this API by giving users direct access to the SIMD Engine (SE), along with configurable compiler directives indicating if libdevice calls should lower to FFUs or to RISC-V operations. This strategy enables seamless execution of unmodified GPU Triton kernels on MTIA hardware while automatically applying hardware-specific optimizations, effectively bridging the architectural differences between GPUs and MTIA without sacrificing either portability or performance.

Enabling Explicit Fine-Grained Memory Reuse

By default, Triton does not support accessing sub-tensors; both computation and memory operations in Triton operate on full tensors. For GPU architectures with more elaborate hardware-managed caches, this design is perfectly reasonable since memory regions that are repeatedly accessed will be cached. However, architectures with software-managed scratchpads (e.g., LS on MTIA) require such reuse to be explicitly expressed.

Listing (a) provides a concrete example of repeated data access in a nested loop. Each iteration of the inner loop uses a slice of a large tensor, while each iteration of the outer loop iterate through the entire tensor. While the compiler can analyze the IR to identify reuse opportunities, such optimizations can be unreliable especially as the program becomes complicated. Kernel authors would also lose the flexibility to explicitly reuse data that has been previously loaded to LS already.

To address this gap, we introduce tl.extract_slice, which allows users to explicitly express fine-grained memory reuse patterns. Semantically, it returns a copy of the slice of the data defined by user-specified offsets and shape parameters; the compiler can only return a view (and avoid the extra copy) after verifying that such a rewrite is safe. See Listing (b) for an example.

On top of the additional expressiveness, we introduce further optimizations that attempt to hide the latency of fully loading the tensor by breaking it up and sinking it into the innermost loop body. We skip details for brevity.

Custom Types and Integration In a C++-Based Software Stack

To close this gap, we augment Triton language with the ability to define custom types using ctypes.Structure. This allows users to access fields of the custom structures, passing them by reference, even creating nested custom types. We further define utility functions to work on common custom types and data structures, in order to present a familiar programming interface to expert MTIA kernel authors. Listing shows a brief example of how this feature can be used.

Model Coverage and Performance

Fusion plays a major role in achieving the performance improvements. Analyzing the compilation result, the average fusion depth for Inductor-generated kernels is 3.9 operators. Notably, we observe data movement and type conversion operators are fused with element-wise ops, with the deepest fusion being 12 operators. Even when fusion depth is shallow, shape-specialized kernels from Inductor can often reach performance comparable to general manual kernels at runtime.

Porting Triton Kernels from GPUs to MTIA

Portability of Triton kernels between GPUs and MTIA was one of the main motivations for faithfully supporting the baseline Triton language. In a recent effort to enable production models on MTIA, we ported a suite of 16 Triton kernels from GPUs to MTIA. These kernels range widely in complexity, from tensor layout transformation to variants of fused attention.

Among the 16 kernels, 11 kernels are directly portable and provided good enough performance to unblock the use cases. A notable observation in this exercise was the reliance on Triton’s undefined behavior on GPUs. In particular, tl.load with non-block pointers takes an optional mask parameter, which is often used to filter out out-of-bounds memory accesses. Users can provide an additional optional other parameter, which is used to initialize the masked-out elements in the resulting tensor. Without specifying these other values, these masked-out elements were initialized to zeroes on certain GPU backends, while we left them uninitialized on MTIA. This was the root cause for a variety of unexpected numeric errors. This same issue also led to out-of-bounds memory accesses, as indices were loaded from memory with uninitialized masked-out values. We fixed these kernels and verified the fixes were portable to GPUs.

As expected, we found that portability was one of the most significant benefits to using Triton on MTIA-2i accelerators. Using Triton made it possible to quickly support existing kernel libraries, which significantly accelerated our ability to support new models. Educating users to avoid using undefined behavior and using an MTIA-friendly coding style (e.g., to make sure the compiler can lower to DMAs when possible) also goes a long way in improving kernel portability across architectures.

Alternative DSLs

Triton was not the only DSL we explored for MTIA architecture. In an earlier attempt, we developed a custom low-level DSL codenamed KNYFE which predates Triton. KNYFE exposes MTIA’s architectural details (e.g., CB, DMA, on-chip memory) directly to kernel authors, and enables performance that matches that of expert-tuned C++ kernels for GEMM and long-tail kernels. However, we found that the barrier to entry posed by the language’s unfamiliar syntax was too high for all but the most experienced experts. This factor, combined with the need for portability and a higher level of abstraction, led us to abandon KNYFE in favor of Triton.

As the industry continues to drive the performance of ML models and kernels, recent DSL efforts have started to incorporate more architectural details into the language to regain some lost performance. Specifically, there are two approaches: (1) introducing architecture-tailored DSLs, and (2) extending Triton or other languages with optional access to lower levels of abstraction. Our Triton-MTIA extensions use the same strategy as TLX, but tailor the exposed operations and controls to the MTIA architecture. This composable approach preserves baseline Triton for general and portable kernels while allowing developers to selectively use MTIA-specific extensions in performance-critical code.

We also created a separate low-level DSL that directly exposes MTIA architectural features. Rather than maintaining an independent backend, this DSL reuses the same compiler infrastructure, including a subset of the dialects and passes developed for Triton-MTIA. More broadly, we are evolving the boundaries and interfaces between these dialects and passes so that future DSLs can reuse the appropriate compiler layers. This design should make it easier to support new programming models at different abstraction levels without duplicating the compiler stack.

Conclusion

The proliferation of specialized accelerator architectures, such as MTIA-2i, has transformed the landscape of large-scale machine learning deployments. While these custom accelerators offer important gains in performance and reductions in cost, they also introduce new programmability challenges, especially as operators adopt a heterogeneous mix of in-house and vendor-provided hardware. Our work demonstrates that, despite the diversity of programming models across accelerators, it is possible to bridge the gap between ML frameworks, kernels, and custom hardware by leveraging a flexible DSL like Triton. We hope our experience is useful for other accelerator efforts, and that it helps to build a stronger community around standardized DSLs to lower the barrier to adoption of new accelerators.