arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2606.25244cs.PL
收藏

通过形式理论的视角解读MLIR中的AI模型编译

Reading AI Model Compilation in MLIR Through the Lens of Formal Theories

Qualcomm Technologies International, Ltd.(高通国际有限公司)

Javed Absar

AI总结:

本文通过形式理论(如项重写系统、精化演算、抽象解释)对应MLIR的匹配-重写引擎、阶段降低和范围分析,论证形式概念有助于明确抽象完备性、理想设计及实际权衡。

摘要:

MLIR等编译器基础设施基于一系列设计原则:IR抽象、接口、匹配-重写、流分析、类型转换、阶段降低等。这些概念在实践中已得到验证。优秀的设计通常源于工程知识、直觉和经验。然而,其中许多概念在形式理论中都有对应。MLIR的匹配-重写引擎对应于项重写系统~\cite{baadernipkow1998};阶段降低具有精化演算的结构~\cite{back1998};范围分析基于抽象解释~\cite{cousot1977,cousot1979}。强调这些对应关系是有用的,因为每种理论都提供了足够精确的词汇来讨论结构性问题。此外,随着编码代理降低实现成本,良好的设计和抽象成为主要关注点~\cite{Lattner2026ClaudeCCompiler}。编码代理可以生成pass,但它只能基于表示所暴露的语义进行推理。当基本结构缺失时,限制在于抽象而非实现。自然的下一个问题是如何良好地设计该基础。精心选择的抽象源于经验和直觉,但它们往往反映了形式理论中更精确处理的概念。我们认为,对这些形式概念的理解有助于明确给定抽象的完备性含义、理想设计是什么,以及实际权衡在何处偏离理想设计。

英文摘要:

Compiler infrastructures such as MLIR rest on a set of design principles: IR abstractions, interfaces, match-and-rewrite, flow analysis, type conversion, staged lowering, and so on. These concepts have proven themselves in practice. Good designs typically arrive through engineering knowledge, intuition and experience. Many of them, however, have correspondences in formal theory. MLIR's match-and-rewrite engine has correspondence to a \emph{term-rewriting-system}~\cite{baadernipkow1998}; staged lowering has the structure of \emph{refinement calculus}~\cite{back1998}; and range analysis is grounded in \emph{abstract interpretation}~\cite{cousot1977,cousot1979}. Highlighting these correspondences is useful because each theory supplies vocabulary precise enough to discuss structural questions. Moreover, as coding agents lower the cost of implementation, good design and abstractions become the main concern~\cite{Lattner2026ClaudeCCompiler}. A coding agent can generate a pass, but it can only reason over the semantics the representation exposes. When essential structure is missing, the limitation is one of abstraction, not of implementation. The natural next question is how to design that substrate well. Well-chosen abstractions emerge from experience and intuition, but they often mirror concepts given a more precise treatment in formal theory. We argue that knowledge of these formal concepts clarifies what completeness means for a given abstraction, what the ideal design would be, and where practical trade-offs depart from it.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑