带断言引导执行与可检查中间表示的意图级量子编程
Intent-Level Quantum Programming with Assertion-Guided Execution and Inspectable Intermediate Representation
浏览论文内容
中文总结 AI 辅助
提出量子领域特定语言(QDSL),通过意图-执行分离、一等IR内省、断言引导模式推断解决量子程序验证与跨后端移植难题,原型在基准电路及故障注入、差分测试中表现良好,IR生成成本低。
中文摘要 AI 辅助
量子程序难以验证:电路通常表示为可命令门序列,可检查性有限;执行模式必须手动选择;输出本质上是概率性的。当程序需要跨具有不同内部约定的后端框架可移植时,这些挑战会加剧。我们提出一种量子领域特定语言(QDSL),通过三种机制解决这些问题:(i)意图-执行分离,其中制备、叠加、纠缠和测量等算法构造表示为可检查对象,仅在执行前中间表示(IR)验证后编译为特定后端电路;(ii)一等IR内省,在执行前向开发者暴露电路宽度、线映射、操作顺序和测量意图;(iii)断言引导模式推断,引擎检查声明的验证属性,自动选择采样、状态向量或双重执行,无需用户干预。结果以结构化形式记录,支持可复现的回归测试。我们在涵盖纠缠、基于预言机、结构化变换和变分示例的基准电路上评估原型。在对贝尔电路和3量子比特GHZ电路的故障注入实验中,总变差距离检测器在所有评估的采样数预算下识别出注入故障(真阳性率为1.0),仅在128采样时观察到假阳性(假阳性率为2.7%-3.8%)。差分测试在字节序规范化后,证明评估构造在PennyLane和Qiskit编译目标上的数值一致性。IR生成成本为亚毫秒级。
英文摘要
Quantum programs are difficult to validate: circuits are typically expressed as imperative gate sequences with limited inspectability, execution modalities must be selected manually, and outputs are inherently probabilistic. These challenges are compounded when programs must be portable across backend frameworks with differing internal conventions. We present a quantum domain-specific language (QDSL) that addresses these problems through three mechanisms: (i) intent-execution separation, where algorithmic constructs such as preparation, superposition, entanglement, and measurement are represented as inspectable objects compiled into backend-specific circuits only after pre-execution Intermediate Representation (IR) validation; (ii) first-class IR introspection, exposing circuit width, wire mapping, operation order, and measurement intent for developer inspection prior to execution; and (iii) assertion-guided modality inference, where the engine examines declared verification properties to automatically select sampling, statevector, or dual execution without user intervention. Results are logged in structured form to support reproducible regression testing. We evaluate our prototype on benchmark circuits spanning entanglement, oracle-based, structured-transform, and variational examples. In fault-injection experiments on Bell and 3-qubit GHZ circuits, a total-variation-distance detector identifies the injected faults across all evaluated shot budgets (True Positive Rate 1.0), with observed false positives (False Positive Rate 2.7-3.8%) only at 128 shots. Differential testing demonstrates numerical agreement across PennyLane and Qiskit compilation targets for the evaluated constructs after endianness canonicalization. IR generation costs are sub-millisecond.