Skip to content
Preprint

An MLIR-Based Compilation Method for Large Language Models

Jul 2026 · 0 citations · 12 references
Computer Science

TL;DR

An MLIR (Multi-Level Intermediate Representation) based compilation method for large language models, illustrated using two dialects of operators, TopOp and TpuOp, supporting a variety of generative models including the Qwen, Llama, InternVL, and MiniCPM-V series.

Abstract

Large Language Models (LLMs) have become the dominant workload on modern AI accelerators, yet deploying them on specialized hardware still faces two core challenges: how to import a trained model into a compiler-friendly intermediate representation, and how to efficiently schedule the autoregressive inference loop under limited on-chip memory. This paper presents an MLIR (Multi-Level Intermediate Representation) based compilation method for large language models, illustrated using two dialects of operators, TopOp and TpuOp. TopOp serves as a high-level graph dialect that is independent of both the source framework and the target chip, and is responsible for expressing model semantics; TpuOp serves as the target hardware dialect, carrying chip-related decisions such as quantization, layer groups, and memory layout. A model is first represented as TopOp, then lowered layer by layer to TpuOp, and finally a deployable binary is generated. In addition, each Transformer layer is split into three stages for static compilation: prefill, prefill_kv (prefill with historical key-value cache), and decode, so as to accommodate the different computational characteristics of prompt-parallel processing and per-token generation. The method has been implemented in the TPU-MLIR compiler {https://github.com/sophgo/tpu-mlir} and the LLM-TPU deployment project {https://github.com/sophgo/LLM-TPU}, supporting a variety of generative models including the Qwen, Llama, InternVL, and MiniCPM-V series, as well as multiple quantization and deployment forms such as GPTQ, AWQ, and AutoRound.

View source

Similar papers

Jul 2026

Portable models as a replacement for industrial heuristics in compiler optimizations

The paper investigates the possibility of predicting function-inlining decisions in compact compilers, source-to-source tools, and interpreters where the reuse of GCC or LLVM optimization infrastructure is impractical and proposes a portable inlining-prediction framework that can be emitted as ordinary C code without a...

F. Nikolai, Vinarsky Alexander · 0 citations
#artificial intelligence Preprint Aug 2026

Evaluating Tiny Recursive Models Across Training for Code Generation

This work compares a ~28M-parameter autoregressive Tiny Recursive Model (TRM-AR) on natural-language-to-Python code generation against parameter-matched and depth-matched controls, tracking fit and generation across 40 epochs and three seeds.

Anjani Sirivella, Aanisha Newaz, Glaucia Melo · 0 citations
Jul 2026

BaseRT: Advancing Best-in-Class LLM Inference with Apple M5 Neural Accelerators

These results establish a new performance ceiling for on-device LLM inference and show that the M5's tensor cores are the decisive lever for prompt processing on Apple Silicon.

Fabian Waschkowski, Prabod Rathnayaka, Lukas Wesemann · 1 citation
Jul 2026

FastTPS: An Optimized Method for LLM Token Phase for AI accelerators

This paper presents FastTPS, a high performance and low-precision loss method for accelerating the token-phase in LLM inference on general AI accelerators which includes three key components: AI accelerator-enabled reloading-free KV Cache concatenation which decreases memory access overhead as well as enables full fusi...

Wenzong Yang, Danyang Zhang, Kunteng Cao et al. · 0 citations
Preprint Jul 2026

Benchmarking LLMs on File System Design and Implementation

This study discloses the model efficiency for different tasks, causes of failed fs tasks, and techniques for mitigating LLM failures, and will open source \phi-Bench to facilitate public research on using LLMs for fs development.

Yu Xue, Daixuan Li, Jian Huang · 0 citations

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.