Introduction
The rapid proliferation of domain-specific tensor accelerators (NPUs) has created a significant "software gap." While hardware design has accelerated, developing the compiler backends necessary to translate high-level mathematical operations into machine-specific instructions remains a labor-intensive, multi-month engineering task. This bottleneck often restricts new hardware to a handful of hand-optimized kernels, hindering the hardware-software co-design cycle.
ACT (Accelerator Compiler Toolkit) addresses this by automatically generating sound and complete compiler backends directly from Instruction Set Architecture (ISA) descriptions. By treating the backend generation as a formal search over equivalent tensor computations, ACT enables the generation of high-performance code for novel AI chips in seconds, matching or even outperforming hand-optimized libraries.
System Architecture
ACT bridges the gap between high-level tensor IRs (such as XLA-HLO, Torch.fx, or ONNX) and low-level hardware instructions. The system operates in two primary phases: parameterized instruction selection and constraint-based memory allocation.
The core innovation lies in representing the hardware's ISA using the same high-level operator language as the compiler's intermediate representation (IR). This "ISA as IR" approach allows the compiler to treat hardware instructions as sub-graphs that can be substituted into the computation graph during optimization.
Technical Approach
1. Parameterized Instruction Selection
ACT utilizes equality saturation via e-graphs to explore the space of semantically equivalent computations. Unlike traditional instruction selectors that perform one-to-one mapping, ACT handles the parameterized nature of NPU instructions (e.g., variable-sized matrix multiplications) using "partially instantiated instructions" (pii). These keep parameters like matrix dimensions abstract until the final mapping phase.
2. Constraint-Based Memory Allocation
Tensor accelerators typically feature user-programmable scratchpads rather than hardware-managed caches. ACT formulates the management of these memories as an integer constraint satisfaction problem (CSP). Using the Google OR-Tools CP-SAT solver, ACT determines valid address mappings for multi-dimensional buffers, ensuring no data overlap within the scratchpad.
An inter-phase fallback mechanism ensures completeness: if the memory allocator cannot find a valid mapping for a specific instruction sequence, it prompts the instruction selector to find an alternative tiling or representation. This loop guarantees that ACT will find a solution if one exists, ensuring the compiler is both sound and complete.
Evaluation and Results
ACT was evaluated on three hardware platforms: Intel AMX, the Gemmini systolic array, and a custom Allo-generated design. Testing involved industry-standard oneDNN kernels, large-scale TPUGraphs, and synthetic kernels from NNSmith.
- Performance: ACT-generated backends matched the performance of the hand-optimized oneDNN library on Intel AMX. On Gemmini, ACT outperformed manual libraries by up to 1.77x by discovering fusion opportunities missed by human programmers.
- Efficiency: Compilation is extremely rapid; even for complex graphs with nearly 400 nodes, ACT generates code in approximately 311 milliseconds.
- Data Movement: By effectively utilizing on-chip scratchpads, ACT reduced host-to-accelerator data movement by up to 55.5% for composite kernels.
Conclusion and Future Work
ACT demonstrates that formal methods can automate the creation of high-performance compiler backends for specialized hardware. While currently focused on single-tile execution and dependent on existing middle-end compilers for high-level transformations, future work aims to integrate these layers more tightly and extend support to multi-tile distributed execution.
Summary updated