MLProf: A Multi-Level Runtime Performance Profiling Framework for MLIR Operations

Yang Liu, Shihao Gao, Hanghang Cao, Hongbin Zhang, Mingjie Xing, Yanjun WuSEKE 2025

Introduction

The MLIR (Multi-Level Intermediate Representation) ecosystem has become a cornerstone for building domain-specific compilers, particularly in the field of deep learning. By employing a hierarchical structure of "dialects"—ranging from high-level graph operations to low-level memory management—MLIR enables sophisticated optimizations. However, traditional profiling tools often lack the necessary "MLIR-awareness" to map performance bottlenecks back to specific operations within these dialects. MLProf addresses this gap by providing an automated, low-overhead profiling framework designed to identify bottlenecks across various levels of abstraction.

The MLProf Framework

MLProf is designed to be a non-invasive tool that integrates seamlessly into existing compiler toolchains. It automates the instrumentation process, which would otherwise be a manual and error-prone task for large-scale models. The framework consists of three core components:

MLProf System Architecture
  1. MLIR-based Instrumenter: This component traverses the IR tree, identifies target operations based on dialect or name, and automatically injects timingStart and timingEnd calls.
  2. Runtime Agent: A C++ backend that manages "TimeEvent" objects. It captures high-resolution timestamps using std::chrono::high_resolution_clock and associates them with specific MLIR operation pointers.
  3. Data Viewer: A visualization suite that converts raw timing data into intuitive reports, such as pie charts and bar graphs, to facilitate performance analysis.

Experimental Evaluation and Key Insights

The framework was evaluated using several representative machine learning workloads, including MobileNet-v3 and the DeepSeek-R1-Distill-Qwen-1.5B model. One of the most significant findings was the identification of non-obvious bottlenecks in modern Large Language Models (LLMs).

Profiling results for DeepSeek-R1-Distill-Qwen-1.5B

In the analysis of the DeepSeek model, MLProf revealed that tosa.transpose operations accounted for a staggering 68.32% of total execution time. While optimization efforts often focus on matrix multiplications (matmul), these results highlight that data movement and reshaping are frequently the primary performance killers in Transformer-based architectures. In contrast, for convolutional networks like MobileNet-v3, the tool confirmed that tosa.conv2d remains the dominant operation, accounting for 60.82% of runtime.

Performance and Scalability

MLProf demonstrates exceptional scalability and efficiency. It successfully handled the automated profiling of the DeepSeek model, which contains over 3,400 individual operation instances. Crucially, the framework introduces less than 5% runtime overhead, making it suitable for use in production-level development environments.

Conclusion and Future Work

MLProf provides a powerful solution for the automated profiling of MLIR operations, offering visibility that was previously difficult to achieve. By pinpointing bottlenecks at various dialect levels, it enables more targeted and effective compiler optimizations. Future developments will focus on integrating hardware-specific counters (e.g., cache misses) and improving the granularity of GPU-side profiling to provide even deeper insights into hardware utilization.

Summary updated

BibTeX
@inproceedings{liu2025mlprof,
  author = {Yang Liu and Shihao Gao and Hanghang Cao and Hongbin Zhang and Mingjie Xing and Yanjun Wu},
  title = {{MLProf: A Multi-Level Runtime Performance Profiling Framework for MLIR Operations}},
  booktitle = {SEKE},
  year = {2025},
  doi = {10.18293/seke2025-070},
}
Figure