MLIRBench - A Benchmark and Dataset for Compiler and Hardware-Aware Reasoning

Pranava Sai Maganti, Meghasyam Peddireddy, Muzakker Hossain, Kaining Gao, Farhan Ahmed, Ali JannesariarXiv 2026 · arXiv

TL;DR

MLIRBench is a new execution-grounded benchmark designed to test whether Large Language Models (LLMs) actually understand the low-level logic of compiler Intermediate Representations (IRs). The study reveals a significant "reasoning gap": while top models like Gemini 3.1 Pro can often correctly guess if two programs are equivalent, they struggle to predict the actual numerical outputs or explain the underlying execution behavior.

What Problem Does This Paper Address?

LLMs have become surprisingly good at writing Python or C++, but do they actually "understand" the code, or are they just very sophisticated pattern matchers? This question is critical when dealing with compiler IRs like MLIR (Multi-Level Intermediate Representation).

Unlike high-level source code, IRs explicitly represent dataflow, tensor shapes, and memory movement. Reasoning about them requires a deep understanding of compiler semantics—for instance, knowing how a small change in an indexing map might completely change a tensor operation's result. Existing benchmarks mostly focus on source-level code generation or compilation success. MLIRBench addresses the lack of a rigorous, execution-validated framework to measure how well LLMs reason about the semantic impact of compiler transformations.

Methods

The authors developed a sophisticated multi-agent pipeline to build and evaluate the benchmark:

  1. Mutation Agent: Starting from a "seed" program, this agent generates variations across five levels of complexity, ranging from simple variable renaming (L1) to structural rewrites (L4) and intentional error-inducing bugs (L5).
  2. Execution Sandbox Agent: This is the source of ground truth. It uses the IREE compiler to verify, compile, and execute both the original and mutated programs on deterministic inputs. It labels pairs as EQUIV (same output), DIVERGE (different output), or ERROR (compilation/runtime failure).
  3. LLM Reasoning Agent: The model being tested receives the two MLIR programs and the inputs but is "blinded" to the execution results. It must predict the output of both programs and determine their relationship.
  4. Judge Agent: A separate LLM (GPT-4o-mini) acts as a judge, scoring the Reasoning Agent not just on the final label, but on the accuracy of its predicted outputs and the quality of its causal explanation.
Figure 1. Overview of MLIRBench. Benchmark construction (upper): PyTorch programs are lowered to torch and linalg seeds. The Mutation Agent transforms a seed 𝐴into 𝐵, guided by dialect-specific structural analysis, and records the mutation metadata. The Execution Sandbox Agent executes 𝐴and 𝐵on fixed inputs to determine the ground-truth label 𝑦. Execution- hidden evaluation (lower): each evaluated model receives only 𝐴, 𝐵, the dialect tag, and input values. The Judge Agent scores the model response using the execution record, mutation metadata, and reference explanation; only execution determines 𝑦. Blue boxes denote LLM calls. The code example shows a row-wise max reduction whose initial value is changed from −∞ (0xFF800000 in MLIR) to 0.0.

Datasets

The benchmark originates from 40 manually curated PyTorch programs covering common patterns like reductions, tensor transforms, and boolean operations. These were lowered into two specific MLIR dialects: torch (closer to the source) and linalg (exposing low-level structured loops).

The final MLIRBench dataset consists of:

  • 1,768 validated program pairs (888 linalg, 880 torch).
  • Execution-derived labels (EQUIV, DIVERGE, ERROR).
  • Detailed metadata, including mutation rules and execution traces.
Figure 2. Dataset construction pipeline. MLIRBench starts from curated PyTorch programs, lowers them into torch and linalg MLIR, applies dialect-specific mutation rules, and validates the resulting program pairs through compilation and execution.

Key Insights and Ideas

  • The "Illusion of Understanding": The most striking finding is the gap between classification and execution reasoning. Models are much better at picking the right label (e.g., "these are equivalent") than they are at actually tracing the values through the IR to predict the final result.
  • Bit-Exactness Matters: The authors enforced strict bit-exact equality for floating-point operations. Because floating-point math isn't associative, even a "safe" algebraic reordering can change the machine result. MLIRBench captures these subtle semantic shifts that human annotators might miss.
  • Dialect Difficulty: Reasoning about the linalg dialect is generally harder than the torch dialect because linalg exposes complex indexing maps and iterator semantics that require more rigorous symbolic reasoning.
  • Supervision Transfer: The authors showed that MLIRBench isn't just for testing; it can be used for training. Fine-tuning a model on MLIRBench data significantly improved its ability to predict whether a compiler optimization (like fusion) would actually provide a performance benefit.

Key Results

The researchers evaluated nine models, including frontier models like Gemini 3.1 Pro and Claude 4.5, alongside open-weight models like Llama 4 and Qwen3.

  • Top Performer: Gemini 3.1 Pro achieved the highest aggregate score (74.18/100) and a "hard-label" accuracy of 92.65%.
  • The Reasoning Gap: While Gemini got the label right ~93% of the time, its result-behavior score (predicting actual outputs) was only 5.04/10. Other models fared even worse, often scoring below 4/10 on execution tracing.
  • Mutation Sensitivity: Most models performed well on L1 (syntactic) changes but struggled significantly with L5 (error-inducing) mutations, except for Gemini, which showed strong compiler-error recognition.
Figure 3. Benchmark performance across nine evaluated models on 888 linalg and 880 torch pairs. Label accuracy includes all attempts; result and explanation scores are normalized by their maxima and averaged over valid responses.

Limitations and Future Work

  • Dialect Coverage: Currently, the benchmark only covers torch and linalg. The authors plan to expand to other critical dialects like affine, gpu, vector, and memref.
  • Program Diversity: The dataset is built from 40 seed programs. While mutations expand this significantly, the underlying algorithmic variety remains somewhat bounded.
  • Fixed Environment: Ground truth is currently tied to the IREE compiler and specific hardware targets. Results might vary slightly across different backends.
  • Future Directions: The authors suggest using the benchmark's failure signals to develop "compiler-aware" LLMs that can better assist in debugging and optimization-benefit prediction.

Summary updated

Abstract

In recent years, large language models (LLMs) have become increasingly popular in software engineering and have performed well on different programming tasks. However, it is still difficult to know whether these models truly understand program behavior or whether they mainly rely on patterns learned from their training data. This distinction is particularly important for intermediate representations (IRs), where operations, dataflow, and execution semantics are explicitly represented. In this paper, we introduce MLIRBench, a benchmark for evaluating how LLMs reason about MLIR programs. MLIRBench uses a multi-agent pipeline to generate program mutations, validate their behavior through execution, and construct reasoning tasks from torch and linalg program pairs. The dataset contains 1,768 validated pairs, including 888 linalg pairs and 880 torch pairs, labeled as EQUIV, DIVERGE, or ERROR. We evaluated nine models, including five open-weight and four proprietary models. Gemini 3.1 Pro achieved the highest hard-label accuracy of 92.65% across all 1,768 pairs, counting unsuccessful predictions as incorrect. Across its 1,768 scored predictions, it achieved an aggregate score of 74.18 and a judge-assigned result-behavior score of 5.04/10. These results show that strong semantic classification does not necessarily imply accurate prediction of detailed execution behavior, highlighting a gap in current LLM reasoning over compiler IRs. By exposing this gap through execution-validated program pairs, MLIRBench provides a reproducible foundation for studying semantic reasoning over compiler IRs and related tasks such as program repair and semantic classification.
BibTeX
@misc{maganti2026mlirbench,
  author = {Pranava Sai Maganti and Meghasyam Peddireddy and Muzakker Hossain and Kaining Gao and Farhan Ahmed and Ali Jannesari},
  title = {{MLIRBench - A Benchmark and Dataset for Compiler and Hardware-Aware Reasoning}},
  year = {2026},
  eprint = {2611.14881},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.14881},
}
Figure