Introduction
Deep learning models are increasingly complex, requiring highly optimized "tensor programs" to run efficiently on diverse hardware. Compilers like TVM and Ansor generate these low-level programs, but the search space for optimization—encompassing loop tiling, vectorization, and thread binding—is astronomical. Traditionally, auto-tuning relies on hardware measurements or simple cost models to navigate this space. However, these methods are either prohibitively slow or fail to capture the intricate dependencies of modern code.
ATFormer addresses these challenges by introducing a Transformer-inspired performance model. By utilizing attention mechanisms to understand code structure and leveraging transfer learning, ATFormer significantly accelerates the auto-tuning process across different hardware devices, outperforming traditional models like XGBoost in both inference speed and tuning efficiency.
System Overview
The integration of ATFormer into the deep learning compiler stack is central to its effectiveness. It serves as the core cost model within the auto-tuning backend, predicting the performance of candidate programs generated from the computation graph.
The Bottleneck of Auto-Tuning
Existing cost models, often based on XGBoost or multi-layer perceptrons (MLPs), suffer from two primary limitations. First, they lack accuracy in capturing long-range dependencies within tensor programs, such as the interaction between a specific memory access pattern and a distant computation loop. Second, they lack transferability; a model trained for one GPU architecture (e.g., NVIDIA Tesla T4) typically cannot be applied to another (e.g., RTX 3090) without starting the training process from scratch. This "domain gap" forces developers to repeat time-consuming tuning for every new piece of hardware.
ATFormer Methodology
ATFormer treats a tensor program as a sequence of hierarchical features, processing them through a lightweight attention-based architecture.
Hierarchical Feature Extraction
The model employs a two-level approach to feature extraction. It combines coarse-grained features, which identify high-level operator types like Conv2D or Matmul, with fine-grained features that capture low-level implementation details. These details include arithmetic intensity, loop unrolling factors, and memory access patterns, providing a comprehensive view of the program's execution profile.
Attention-Inspired Architecture
At its core, ATFormer uses a computation processing layer with self-attention. This allows the model to "attend" to correlations between all innermost non-loop statements, capturing the global structure of the program. Unlike sequential models like LSTMs, the attention mechanism can identify critical dependencies regardless of their distance in the code sequence, much like how modern NLP models process language context.
Rank-Based Learning
Instead of predicting absolute execution time, which can be noisy and hardware-specific, ATFormer uses a RankLoss function. By learning to rank program configurations—determining which is faster rather than by how much—the model becomes more robust and effective for the optimization task. This approach focuses the model on the relative performance differences that matter most during search.
Transfer Learning Across Hardware
One of the most significant contributions of ATFormer is its ability to bridge the domain gap between different hardware platforms through a specialized transfer learning workflow.
As illustrated above, ATFormer is pre-trained on a massive offline dataset (such as TenSet). When deployed on a new hardware platform, it uses these pre-trained parameters as a foundation. This "jumpstart" requires significantly fewer real-world measurements to adapt the model to the new device, drastically reducing tuning time and resource consumption.
Key Results and Performance
The researchers evaluated ATFormer against industry standards like XGBoost and other deep learning baselines (LSTM, TabNet) across benchmarks including ResNet, MobileNet, and components of BERT and GPT-3.
- Optimization Speedup: On an NVIDIA RTX 2080Ti, ATFormer achieved end-to-end model inference speedups of 1.15x to 1.61x compared to the standard XGBoost model.
- Tuning Efficiency: In transfer learning scenarios, ATFormer reached optimal configurations 4.97x to 6.08x faster than traditional learning methods, representing a massive reduction in developer time.
- Consistency: The model demonstrated superior performance across all tested DNN benchmarks, proving its generalizability across different neural network architectures.
Conclusion and Future Directions
ATFormer represents a significant step forward in automated performance modeling for deep learning compilers. By treating code as a structured sequence and leveraging the power of attention and transfer learning, it overcomes the limitations of previous cost models.
Future work will focus on expanding hardware support beyond NVIDIA GPUs to include CPUs and specialized accelerators like TPUs. Additionally, the authors plan to investigate how quantization (e.g., moving to int8) affects performance modeling and to explore explicit modeling for domain-specific hardware features like Tensor Cores.
Summary updated