CDMPP: A Device-Model Agnostic Framework for Latency Prediction of Tensor Programs

Hanpeng Hu, Junwei Su, Juntao Zhao, Yanghua Peng, Yibo Zhu, Haibin Lin, Chuan Wu

TL;DR

CDMPP is a new framework that accurately predicts the execution latency of deep learning operations (tensor programs) across diverse hardware and model architectures. By using a novel "Compact AST" representation and domain-adaptation techniques, it achieves high accuracy (under 15% error) for both unseen models and unseen devices while training an order of magnitude faster than previous state-of-the-art methods.

What Problem Does This Paper Address?

In the world of Deep Learning (DL) compilers, a single mathematical operation (like a convolution) can be implemented in thousands of different ways, known as "tensor programs." To optimize performance, compilers need to know exactly how long each version will take to run on a specific chip.

However, the search space is astronomical. There are countless neural network architectures and a rapidly expanding "zoo" of hardware accelerators (GPUs, TPUs, specialized IoT chips). Directly profiling every combination is impossible. Existing "cost models" usually suffer from three flaws:

  1. Lack of Generalization: They work well for the hardware they were trained on but fail on new chips (cross-device).
  2. Relative vs. Absolute: Many models only predict which program is faster, but they can't provide the absolute time in milliseconds needed for complex system scheduling.
  3. Efficiency: Representing code structure (Abstract Syntax Trees or ASTs) is often computationally expensive, leading to slow training times.

Methods

The authors introduce CDMPP, which stands for a "Device-Model Agnostic" framework. Its architecture relies on three key innovations:

  • Compact ASTs: Standard ASTs are highly irregular, making them hard for neural networks to process efficiently. CDMPP extracts "computation vectors" from the leaf nodes (where the actual math happens) and uses a pre-order traversal to turn the tree into a regular sequence.
  • Positional Encoding for Code: Borrowing a concept from Natural Language Processing, they use a customized positional encoding to tell the model exactly where an operation sits within the loop nesting structure of the program.
  • Domain-Invariant Learning: The authors treat different hardware and models as different "domains." They use Central Moment Discrepancy (CMD)—a statistical regularization term—to force the model to learn features that are consistent across all devices, rather than memorizing the quirks of a specific GPU.
  • KMeans-based Sampling: When moving to a brand-new device, you still need some data. Instead of random profiling, CDMPP clusters tensor programs and profiles only the most representative "center" of each cluster, drastically reducing the time needed to fine-tune for new hardware.

Datasets

The study utilizes and expands upon Tenset, a massive open-source dataset for tensor program performance.

  • Existing Data: 50 million samples from 120 DL models across 2 GPUs and 4 CPUs.
  • New Contributions: The authors added data for high-end NVIDIA GPUs (A100, V100, P100) and the Habana HL-100 inference accelerator.
  • Open Source: The expanded dataset and the CDMPP implementation are available on GitHub.

Key Insights and Ideas

  • Structure over Raw Code: The "aha" moment is that you don't need the full, messy AST. By focusing on the leaf nodes and their positions, you capture the "physics" of the computation (memory access patterns and arithmetic intensity) without the overhead of irregular graph structures.
  • Hardware as a Distribution Shift: By framing the move from a V100 GPU to an EPYC CPU as a "domain shift," the authors could apply mature transfer learning techniques (like CMD) to a systems optimization problem.
  • Training Efficiency: Because Compact ASTs are regular sequences, they can be processed in large batches. This allows CDMPP to train at 14,241 samples/second, compared to just 1,870 samples/second for Tiramisu (a recursive LSTM-based baseline).

Key Results

  • Cross-Model Accuracy: When predicting latency for entirely new neural network architectures, CDMPP achieved a 14.03% Mean Absolute Percentage Error (MAPE).
  • Cross-Device Accuracy: When predicting for a device the model hadn't seen during primary training, the error was only 10.85%.
  • End-to-End Performance: For full DNN models (like ResNet-50), CDMPP predicted total execution time with an average error of 12.4%, significantly outperforming XGBoost (63.8%) and Tiramisu (293.6%).
  • Speed: CDMPP's inference time is roughly 8ms, making it fast enough to be used "on-the-fly" during compiler optimization.

Limitations and Future Work

  • Dataset Skew: The authors noted that their dataset is "long-tailed"—most programs are very fast, while a few are very slow. While they used Box-Cox transformations to handle this, extreme outliers can still challenge the model.
  • Complex Fusions: While the model handles standard operator fusion (like Conv+ReLU), extremely exotic or custom-coded kernels might require more specialized feature extraction.
  • Future Directions: The authors suggest integrating CDMPP more deeply into automated model-parallelism search tools, where the ability to predict latency on heterogeneous clusters (mixes of different GPUs and CPUs) is critical.

Summary updated

BibTeX
@inproceedings{hu2024cdmpp,
  author = {Hanpeng Hu and Junwei Su and Juntao Zhao and Yanghua Peng and Yibo Zhu and Haibin Lin and Chuan Wu},
  title = {{CDMPP: A Device-Model Agnostic Framework for Latency Prediction of Tensor Programs}},
  booktitle = {EuroSys},
  year = {2024},
  doi = {10.1145/3627703.3629572},
}
Figure