MLIRBench - A Benchmark and Dataset for Compiler and Hardware-Aware Reasoning
Organizations: Iowa State University, Ames, Iowa, USA
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.
Figures & tables
torch or linalg seed. The Mutation Agent uses dialect-specific structural analysis, mutation-rule selection, LLM candidate generation, and validation to transform seed into program and produce a mutation record. The Execution Sandbox Agent executes and with IREE on fixed inputs and assigns the ground-truth label as Equiv, Diverge, or Error. The lower band evaluates models without execution access. The LLM Reasoning Agent receives , , the dialect tag, and input values, predicts the program outputs and label, and returns a structured response. The Judge Agent evaluates the response using the execution record, mutation metadata, and reference explanation, producing scores for label accuracy, result behavior, and explanation quality.| Quantity | Count |
| Source PyTorch programs | 40 |
| Total MLIR program pairs | 1,768 |
| linalg program pairs | 888 |
| torch program pairs | 880 |
| linalg mutation rules | 24 |
| torch mutation rules | 22 |
| Quantity | Value |
| linalg program pairs | 888 |
| torch program pairs | 880 |
| Total program pairs | 1,768 |
| Models evaluated | 9 |
| Structured reasoning records | 15,912 |
| Quantity | Value |
|---|---|
| Structured reasoning records | 15,912 |
| Mean aggregate score | 57.21 |
| Mean hard-label accuracy | 74.59% |
| Mean result-behavior accuracy | 3.63 / 10 |
| Mean explanation-quality score | 2.43 / 4 |
| Model | L1 | L2 | L3 | L4 | L5 |
|---|---|---|---|---|---|
| Gemini 3.1 Pro | 68.16 | 68.58 | 72.82 | 67.57 | 94.94 |
| Claude Sonnet 4.5 | 63.82 | 60.72 | 65.38 | 65.13 | 59.11 |
| GPT-OSS 120B | 60.90 | 61.08 | 65.02 | 62.47 | 52.59 |
| Kimi K2.6 | 57.48 | 56.52 | 63.62 | 62.11 | 51.67 |
| Claude Haiku 4.5 | 59.14 | 56.70 | 56.29 | 60.54 | 53.57 |
| GLM 5.1 | 59.34 | 58.40 | 61.50 | 61.69 | 32.78 |
| Category | Included |
|---|---|
| Programs | Original and mutated MLIR pairs |
| Dialects | torch , linalg |
| Annotations | Mutation level and metadata |
| Execution Data | Compile, runtime, and labels |
| Performance Data | Latency and percentile statistics |
| Model Outputs | Predictions and explanations |
| Dialect | Level | Total | Diverge | Equiv. | ExpInv |
| Linalg | L1 | 185 | 17 (9%) | 168 (91%) | 0 |
| Linalg | L2 | 147 | 76 (52%) | 71 (48%) | 0 |
| Linalg | L3 | 184 | 41 (22%) | 143 (78%) | 0 |
| Linalg | L4 | 184 | 32 (17%) | 152 (83%) | 0 |
| Linalg | L5 | 185 | 0 (0%) | 7 (4%) | 178 |
| Torch | T1 | 200 | 3 (2%) | 197 (98%) | 0 |
Appendix figures & tables21 assets
Supplementary material from the paper’s appendix.
Appendix
| Seed | Category | Programs |
|---|---|---|
| Seed 1 | Reduction operations | 10 |
| Seed 2 | Small tensor operations | 10 |
| Seed 3 | Boolean reasoning operations | 10 |
| Seed 4 | Aggregation operations | 10 |
| Total | – | 40 |
| Level | Description |
|---|---|
| L1 | Syntax-preserving edits such as SSA renaming and formatting changes |
| L2 | Parameter or attribute edits such as constants, dimensions, and dtypes |
| L3 | Operator substitutions between related operations |
| L4 | Structural edits affecting dataflow, shape behavior, or computation structure |
| L5 | Failure-inducing edits that violate compiler or runtime constraints |
| Dialect | Number of rules |
|---|---|
| linalg | 24 |
| torch | 22 |
| Total | 46 |
| Field group | Stored fields |
|---|---|
| Identity | Program ID, seed, dialect, level, requirement ID |
| Programs | Original MLIR and mutated MLIR |
| Validation | Status, attempts, errors, failure category |
| Requirement | Description and mutation constraints |
| Provenance | Pipeline metadata and validation history |
| Status | Count | % |
|---|---|---|
| success | 1,402 | 79.3 |
| expected_invalid | 338 | 19.1 |
| runtime_error | 25 | 1.4 |
| compile_error | 3 | 0.2 |
| Total | 1,768 | 100 |
| Dialect | Number of pairs | Total records |
|---|---|---|
| linalg | 888 | 7,992 |
| torch | 880 | 7,920 |
| Total | 1,768 | 15,912 |
| Artifact | Visible to Reasoning Agent | Used for Evaluation |
|---|---|---|
| Program MLIR source | Yes | Yes |
| Program MLIR source | Yes | Yes |
| Dialect tag | Yes | Yes |
| Concrete input values | Yes, when available | Yes |
| Executed output of Program | No | Yes |
| Executed output of Program | No | Yes |
| Field | Type | Description |
|---|---|---|
| predicted_output_A | string/object | Predicted output or symbolic behavior for Program |
| predicted_output_B | string/object | Predicted output or symbolic behavior for Program |
| label | enum | One of Equiv , Diverge , or Error |
| confidence | float | Self-reported confidence in |
| key_differences | list | Program-level semantic differences identified by the model |
| witness | string/object/null | Optional input or condition supporting divergence |
| Status | Meaning |
|---|---|
| SUCCESS | Valid JSON satisfying the required schema |
| PARSE_ERROR | No recoverable JSON object was found |
| SCHEMA_ERROR | JSON parsed, but required fields were missing or malformed |
| API_ERROR | Provider request failed |
| MODEL_FAILURE | Model returned an explicit error payload |
| Model | Provider/family | Open/closed | Role in comparison |
|---|---|---|---|
| Qwen3-Next-80B-A3B-Instruct | Alibaba | Open | Code-oriented open baseline |
| Llama-4-Maverick | Meta | Open | General-purpose open baseline |
| GLM-5.1 | Zhipu AI | Open | Non-U.S. open model family |
| Kimi-K2.6 | Moonshot AI | Open | Long-context open model family |
| gpt-oss-120b | OpenAI OSS | Open | Large open-weight baseline |
| GPT-4.1-Mini | OpenAI | Closed | Cost-efficient proprietary baseline |
| Field group | Stored fields |
|---|---|
| Pair metadata | pair_id , program_id , mutation_id , dialect, mutation kind |
| Model metadata | model key, model identifier, model name, provider, model family |
| Prediction | predicted label, confidence, predicted outputs for Program and Program |
| Explanation | key differences, witness, natural-language explanation |
| Execution-hidden inputs | deterministic input values supplied to the prompt when available |
| Reliability metadata | status code, retry count, latency, raw-response head when parsing fails |
| Input group | Contents |
|---|---|
| Program pair | Original MLIR and mutated MLIR |
| Dialect context | torch or linalg guidance |
| Mutation metadata | Mutation ID, level, rule description, and constraints |
| Execution record | Statuses, inputs, outputs, diagnostics, and divergence flag |
| Model prediction | Predicted label, outputs, confidence, and explanation |
| Setting | Value |
|---|---|
| Invocation unit | One prediction for one program pair |
| Default judge model | gpt-5.4-mini |
| Temperature | Not explicitly set |
| Response format | JSON object |
| Label space | Equiv , Diverge , Error |
| Returned fields | Scores, evidence, reasoning, verdict |
| Block | Examples | Purpose |
|---|---|---|
| Program pair | Program , Program | Source-level audit |
| Dialect knowledge | Torch/Linalg guidance | Dialect-aware reasoning |
| Mutation metadata | Level, rule, constraints | Scoring emphasis |
| Execution truth | Statuses, outputs, diagnostics | Ground truth |
| Prediction | Label, outputs, explanation | Object being scored |
| Score | Interpretation |
|---|---|
| 4 | Correct, causal, evidence-specific, and dialect-aware |
| 3 | Mostly correct but missing one important detail |
| 2 | Partially relevant but weak on causality or evidence |
| 1 | Minimal relevant content with major omissions or errors |
| 0 | Empty, generic, fabricated, or contradicted by evidence |
| Profile | Typical mutations | Emphasis | |
|---|---|---|---|
| Low | 1 | SSA renaming, formatting | Exact values |
| Default | 2 | General edits | Balanced scoring |
| Medium | 3 | Parameters, dtypes, operators | Mixed structure/value |
| High | 4 | Shapes, ranks, indexing maps | Structure-sensitive reasoning |
| Error | – | Invalid MLIR or failed execution | Failure recognition |
| Field group | Stored fields |
|---|---|
| Identity | Evaluated model, pair ID, program ID, mutation ID, dialect |
| Labels | Ground-truth label, predicted label, label match |
| Subscores | Hard-label accuracy, result accuracy, explanation rating |
| Weighted scores | Weighted label, weighted result behavior, weighted explanation |
| Aggregate | Total score, categorical verdict |
| Evidence | Semantic audit, correct claims, incorrect claims, unverifiable claims |
| Candidate model | Original | R1 | R2 | R3 | Alt. | No ref. | Fixed |
|---|---|---|---|---|---|---|---|
| Gemini 3.1 Pro Preview | 62.51 | 61.77 | 62.14 | 61.89 | 67.55 | 62.67 | 61.75 |
| GPT-OSS 120B | 53.15 | 54.30 | 52.70 | 53.50 | 60.31 | 54.09 | 52.71 |
| Claude Sonnet 4.5 | 52.51 | 52.88 | 52.57 | 51.59 | 58.55 | 53.03 | 51.45 |
| GLM 5.1 | 50.53 | 49.77 | 50.74 | 49.59 | 55.87 | 50.16 | 49.07 |
| Kimi K2.6 | 49.20 | 49.34 | 49.09 | 48.93 | 56.02 | 48.78 | 46.94 |
| Claude Haiku 4.5 | 46.98 | 47.80 | 47.27 | 47.09 | 53.45 | 47.70 | 45.91 |
| Setting | Task 1 | Task 2 |
|---|---|---|
| Base model | Qwen2.5-Coder-14B | Qwen2.5-Coder-14B |
| LoRA rank | 16 | 64 |
| LoRA alpha | 32 | 128 |
| LoRA dropout | 0.0 | 0.0 |
| LoRA targets | q/v projections | attention + MLP projections |
| Learning rate |