一句话:提出面向量子应用的设计契约框架,通过参数区分、前置条件早检查与断言复用,在模拟器上快速测试与调试量子电路。
量子应用开发通常先用少量量子比特验证构造流程,再在真机上运行已验证的流程。但现有验证技术存在需人工介入、验证时间长、描述能力不足等实用问题。本文提出一个面向量子应用的实用设计契约(Design by Contract)框架,用于在模拟器上测试与调试量子应用。它允许对特定过程构造的量子电路的输入与输出态、以及测量结果的后处理撰写断言,并通过在模拟器测试用例中检查这些断言来快速验证量子应用。框架通过参数区分将构造过程与断言分离,引入早期前置条件检查的求值规则,并提供针对量子电路取逆和叠加态量子比特电路的断言复用机制以减少撰写负担。作者通过实验验证了框架,并调研工业界量子计算机研究者以评估其有效性。
Quantum application development typically involves verifying the construction procedures of quantum applications with a few qubits and running them on actual quantum computers based on the verified procedures. However, existing verification techniques face practical issues, such as the need for human intervention, long verification times, and insufficient descriptions. This study introduces a practical Design by Contract framework for quantum applications, designed for testing and debugging quantum applications on simulators. It allows for writing assertions about the input and output states of quantum circuits constructed by certain procedures and the post-processing of measurement results. The quantum application can be verified quickly by checking these assertions in test cases on simulators. Our framework introduces practical mechanisms for quantum application development. It separates the construction procedure of a quantum application and its assertions through parameter distinction, introduces an evaluation rule for early precondition checking, and reduces assertion-writing effort through assertion reuse mechanisms for inverting quantum circuits and using quantum circuits for qubits in a superposition state. We validated our framework through experiments and surveyed industry quantum computer researchers to assess its effectiveness.