Quantum Intermediate Representation (QIR) is a Microsoft-developed, LLVM-based intermediate representation for quantum program compilers. QIR aims to provide a general solution for quantum program compilers independent of front-end languages and back-end hardware, thus avoiding duplicate development of intermediate representations and compilers. Since it is still under development, QIR is described in natural language and lacks a formal definition, leading to ambiguity in its interpretation and a lack of rigor in implementing quantum functions. In this paper, we provide formal definitions for the data types and instruction sets of QIR, aiming to provide correctness and security guarantees for operations and intermediate code conversions in QIR. To validate our design, we show some samples of unsafe QIR code where errors can be detected by our formal approach.
翻译:量子中间表示(QIR)是微软开发的基于LLVM的量子程序编译器的中间表示。 QIR旨在为量子程序编译器提供通用解决方案,独立于前端语言和后端硬件,从而避免重复开发中间表示和编译器。由于它仍在开发中,因此QIR以自然语言描述,并缺乏正式定义,导致在解释中存在歧义并且在实现量子函数时缺乏严谨性。在本文中,我们提供了QIR数据类型和指令集的形式化定义,旨在为QIR中的操作和中间代码转换提供正确性和安全性保证。为了验证我们的设计,我们展示了一些不安全的QIR代码示例,在我们的形式化方法中可以检测到错误。