Projection-based runtime assertions for testing and debugging Quantum programs

In this paper, we propose Proq, a runtime assertion scheme for testing and debugging quantum programs on a quantum computer. The predicates in Proq are represented by projections (or equivalently, closed subspaces of the state space), following Birkhoff-von Neumann quantum logic. The satisfaction of a projection by a quantum state can be directly checked upon a small number of projective measurements rather than a large number of repeated executions. On the theory side, we rigorously prove that checking projection-based assertions can help locate bugs or statistically assure that the semantic function of the tested program is close to what we expect, for both exact and approximate quantum programs. On the practice side, we consider hardware constraints and introduce several techniques to transform the assertions, making them directly executable on the measurement-restricted quantum computers. We also propose to achieve simplified assertion implementation using local projection technique with soundness guaranteed. We compare Proq with existing quantum program assertions and demonstrate the effectiveness and efficiency of Proq by its applications to assert two sophisticated quantum algorithms, the Harrow-Hassidim-Lloyd algorithm and Shor’s algorithm.

[1]  Margaret Martonosi,et al.  QDB: From Quantum Algorithms Towards Correct Quantum Programs , 2018, PLATEAU@SPLASH.

[2]  Lov K. Grover A fast quantum mechanical algorithm for database search , 1996, STOC '96.

[3]  Bei Zeng,et al.  Quantum State Tomography via Reduced Density Matrices. , 2016, Physical review letters.

[4]  Nengkun Yu,et al.  Quantum Temporal Logic , 2019, ArXiv.

[5]  Martin Rötteler,et al.  Q#: Enabling Scalable Quantum Computing and Development with a High-level DSL , 2018, RWDSL2018.

[6]  Yaoyun Shi,et al.  Classical Simulation of Intermediate-Size Quantum Circuits , 2018, 1805.01450.

[7]  Frederic T. Chong,et al.  Contract-based verification of a realistic quantum compiler , 2019, ArXiv.

[8]  Jennifer Paykin,et al.  QWIRE: a core language for quantum circuits , 2017, POPL.

[9]  Andreas J. Winter,et al.  Coding theorem and strong converse for quantum channels , 1999, IEEE Trans. Inf. Theory.

[10]  Jennifer Paykin,et al.  QWIRE Practice: Formal Verification of Quantum Circuits in Coq , 2018, QPL.

[11]  Mingsheng Ying,et al.  Foundations of Quantum Programming , 2016 .

[12]  A. Harrow,et al.  Quantum algorithm for linear systems of equations. , 2008, Physical review letters.

[13]  Martin Rötteler,et al.  Q#: Enabling scalable quantum computing and development with a high-level domain-specific language , 2018, ArXiv.

[14]  Shih-Han Hung,et al.  A verified optimizer for Quantum circuits , 2019, Proc. ACM Program. Lang..

[15]  M. Ying,et al.  Semantic Techniques in Quantum Computation: Predicate Transformer Semantics of Quantum Programs , 2009 .

[16]  Bei Zeng,et al.  From Ground States to Local Hamiltonians , 2011, 1110.6583.

[17]  Mingsheng Ying,et al.  Logic for quantum programs , 2016 .

[18]  Mingsheng Ying,et al.  Floyd--hoare logic for quantum programs , 2011, TOPL.

[19]  K. Thorne,et al.  Quantum Nondemolition Measurements , 1980, Science.

[20]  Dominique Unruh,et al.  Quantum relational Hoare logic , 2018, Proc. ACM Program. Lang..

[21]  Huiyang Zhou,et al.  Quantum Circuits for Dynamic Runtime Assertions in Quantum Computation , 2019, IEEE Computer Architecture Letters.

[22]  W. Wootters,et al.  A single quantum cannot be cloned , 1982, Nature.

[23]  Mingsheng Ying,et al.  Debugging Quantum Processes Using Monitoring Measurements , 2014, ArXiv.

[24]  Margaret Martonosi,et al.  ScaffCC: Scalable compilation and analysis of quantum programs , 2015, Parallel Comput..

[25]  S. Lloyd,et al.  Quantum principal component analysis , 2013, Nature Physics.

[26]  Margaret Martonosi,et al.  Statistical Assertions for Validating Patterns and Finding Bugs in Quantum Programs , 2019, 2019 ACM/IEEE 46th Annual International Symposium on Computer Architecture (ISCA).

[27]  Gregory T. Byrd,et al.  Quantum Circuits for Dynamic Runtime Assertions in Quantum Computation , 2020, ASPLOS.

[28]  H. Dishkant,et al.  Logic of Quantum Mechanics , 1976 .

[29]  Alán Aspuru-Guzik,et al.  A variational eigenvalue solver on a photonic quantum processor , 2013, Nature Communications.

[30]  Peter W. Shor,et al.  Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer , 1995, SIAM Rev..

[31]  Anmer Daskin Quantum Principal Component Analysis , 2015 .

[32]  Olivier Brunet,et al.  Dynamic Quantum Logic for Quantum Programs , 2003 .

[33]  Benoît Valiron,et al.  Quipper: a scalable quantum programming language , 2013, PLDI.

[34]  Thierry Paul,et al.  Quantum computation and quantum information , 2007, Mathematical Structures in Computer Science.

[35]  Li Zhou,et al.  An applied quantum Hoare logic , 2019, PLDI.

[36]  I. Chuang,et al.  Experimental realization of Shor's quantum factoring algorithm using nuclear magnetic resonance , 2001, Nature.

[37]  W. Wootters,et al.  Almost every pure state of three qubits is completely determined by its two-particle reduced density matrices. , 2002, Physical review letters.