A Verified Compiler for a Functional Tensor Language

被引:2
作者
Liu, Amanda [1 ]
Bernstein, Gilbert [2 ]
Chlipala, Adam [1 ]
Ragan-Kelley, Jonathan [1 ]
机构
[1] MIT, 77 Massachusetts Ave, Cambridge, MA 02139 USA
[2] Univ Washington, Seattle, WA 98195 USA
来源
PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL | 2024年 / 8卷 / PLDI期
基金
美国国家科学基金会;
关键词
functional programming; array programming; formal verification; type systems; tensors;
D O I
10.1145/3656390
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Producing efficient array code is crucial in high-performance domains like image processing and machine learning. It requires the ability to control factors like compute intensity and locality by reordering computations into different stages and granularities with respect to where they are stored. However, traditional pure, functional tensor languages struggle to do so. In a previous publication, we introduced ATL as a pure, functional tensor language capable of systematically decoupling compute and storage order via a set of high-level combinators known as reshape operators. Reshape operators are a unique functional-programming construct since they manipulate storage location in the generated code by modifying the indices that appear on the left-hand sides of storage expressions. We present a formal correctness proof for an implementation of the compilation algorithm, marking the first verification of a lowering algorithm targeting imperative loop nests from a source functional language that enables separate control of compute and storage ordering. One of the core difficulties of this proof required properly formulating the complex invariants to ensure that these storage-index remappings were well-formed. Notably, this exercise revealed a soundness bug in the original published compilation algorithm regarding the truncation reshape operators. Our fix is a new type system that captures safety conditions that were previously implicit and enables us to prove compiler correctness for well-typed source programs. We evaluate this type system and compiler implementation on a range of common programs and optimizations, including but not limited to those previously studied to demonstrate performance comparable to established compilers like Halide.
引用
收藏
页数:23
相关论文
共 21 条
[1]   Proof-Producing Synthesis of CakeML from Monadic HOL Functions [J].
Abrahamsson, Oskar ;
Ho, Son ;
Kanabar, Hrutvik ;
Kumar, Ramana ;
Myreen, Magnus O. ;
Norrish, Michael ;
Tan, Yong Kiam .
JOURNAL OF AUTOMATED REASONING, 2020, 64 (07) :1287-1306
[2]  
Chen TQ, 2018, PROCEEDINGS OF THE 13TH USENIX SYMPOSIUM ON OPERATING SYSTEMS DESIGN AND IMPLEMENTATION, P579
[3]   End-to-End Translation Validation for the Halide Language [J].
Clement, Basile ;
Cohen, Albert .
PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL, 2022, 6 (OOPSLA)
[4]   Verified Code Generation for the Polyhedral Model [J].
Courant, Nathanael ;
Leroy, Xavier .
PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL, 2021, 5 (POPL)
[5]  
Delaware B, 2015, ACM SIGPLAN NOTICES, V50, P689, DOI [10.1145/2775051.2677006, 10.1145/2676726.2677006]
[6]   Simple High-Level Code For Cryptographic Arithmetic - With Proofs, Without Compromises [J].
Erbsen, Andres ;
Philipoom, Jade ;
Gross, Jason ;
Sloan, Robert ;
Chlipala, Adam .
2019 IEEE SYMPOSIUM ON SECURITY AND PRIVACY (SP 2019), 2019, :1202-1219
[7]   Indexed Streams: A Formal Intermediate Representation for Fused Contraction Programs [J].
Kovach, Scott ;
Kolichala, Praneeth ;
Gu, Tiancheng ;
Kjolstad, Fredrik .
PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL, 2023, 7 (PLDI)
[8]   CakeML: A Verified Implementation of ML [J].
Kumar, Ramana ;
Myreen, Magnus O. ;
Norrish, Michael ;
Owens, Scott .
ACM SIGPLAN NOTICES, 2014, 49 (01) :179-191
[9]   Refinement to Imperative HOL [J].
Lammich, Peter .
JOURNAL OF AUTOMATED REASONING, 2019, 62 (04) :481-503
[10]  
Lammich P, 2013, LECT NOTES COMPUT SC, V7998, P84, DOI 10.1007/978-3-642-39634-2_9