Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Projection-based runtime assertions for testing and debugging Quantum programs

Published: 13 November 2020 Publication History

Abstract

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.

Supplementary Material

Auxiliary Presentation Video (oopsla20main-p92-p-video.mp4)
This is a presentation video of my talk at OOPSLA 2020 on our paper accepted in the research track. In this paper, we propose Proq, a runtime assertion for testing and debugging quantum programs on a quantum computer. The predicates in Proq are represented by projections and the satisfaction can be checked upon a small number of projective measurements without many repeated executions. In theory, we prove that checking Proq assertions can help locate bugs or statistically assure that the semantics of the tested program is close to what we expect. In practice, we consider hardware constraints and introduce several techniques to transform the assertions and make them directly executable. We also propose local projections to achieve simplified assertion implementations with soundness guaranteed. We compare Proq with existing assertions and demonstrate its effectiveness and efficiency by asserting two sophisticated quantum algorithms, the HHL algorithm and Shor’s algorithm.

References

[1]
Ali Javadi Abhari, Arvin Faruque, Mohammad Javad Dousti, Lukas Svec, Oana Catu, Amlan Chakrabati, Chen-Fu Chiang, Seth Vanderwilt, John Black, Fred Chong, Margaret Martonosi, Martin Suchara, Ken Brown, Massoud Pedram, and Todd Brun. [n.d.]. 2012. Scafold: Quantum Programming Language. Technical Report. Technical Report TR-934-12. Princeton University.
[2]
Garrett Birkhof and John Von Neumann. 1936. The logic of quantum mechanics. Annals of mathematics ( 1936 ), 823ś843.
[3]
Vladimir B Braginsky, Yuri I Vorontsov, and Kip S Thorne. 1980. Quantum nondemolition measurements. Science 209, 4456 ( 1980 ), 547ś557.
[4]
Olivier Brunet and Philippe Jorrand. 2004. Dynamic quantum logic for quantum programs. International Journal of Quantum Information 2, 01 ( 2004 ), 45ś54.
[5]
Jianxin Chen, Zhengfeng Ji, Bei Zeng, and D. L. Zhou. 2012. From ground states to local Hamiltonians. Phys. Rev. A 86 ( Aug 2012 ), 022339. Issue 2. https://doi.org/10.1103/PhysRevA.86.022339
[6]
Jianxin Chen, Fang Zhang, Cupjin Huang, Michael Newman, and Yaoyun Shi. 2018. Classical simulation of intermediate-size quantum circuits. arXiv preprint arXiv: 1805. 01450 ( 2018 ).
[7]
Google. 2018. Announcing Cirq : An Open Source Framework for NISQ Algorithms. https://ai.googleblog.com/ 2018 /07/ announcing-cirq-open-source-framework. html.
[8]
Alexander S Green, Peter LeFanu Lumsdaine, Neil J Ross, Peter Selinger, and Benoît Valiron. 2013. Quipper: a scalable quantum programming language. In ACM SIGPLAN Notices, Vol. 48. ACM, 333ś342.
[9]
Lov K Grover. 1996. A fast quantum mechanical algorithm for database search. In Proceedings of the twenty-eighth annual ACM symposium on Theory of computing. ACM, 212ś219.
[10]
Aram W Harrow, Avinatan Hassidim, and Seth Lloyd. 2009. Quantum algorithm for linear systems of equations. Physical review letters 103, 15 ( 2009 ), 150502.
[11]
Kesha Hietala, Robert Rand, Shih-Han Hung, Xiaodi Wu, and Michael Hicks. 2019. A Verified Optimizer for Quantum Circuits. arXiv preprint arXiv: 1912. 02250 ( 2019 ).
[12]
Yipeng Huang and Margaret Martonosi. 2019a. QDB: From Quantum Algorithms Towards Correct Quantum Programs. In 9th Workshop on Evaluation and Usability of Programming Languages and Tools (PLATEAU 2018 ). Schloss DagstuhlLeibniz-Zentrum fuer Informatik.
[13]
Yipeng Huang and Margaret Martonosi. 2019b. Statistical assertions for validating patterns and finding bugs in quantum programs. In Proceedings of the 46th International Symposium on Computer Architecture. ACM, 541ś553.
[14]
IBM. 2019. Gate and operation specification for quantum circuits. https://github.com/Qiskit/openqasm.
[15]
Ali JavadiAbhari, Shruti Patil, Daniel Kudrow, Jef Heckey, Alexey Lvov, Frederic T Chong, and Margaret Martonosi. 2015. ScafCC: Scalable compilation and analysis of quantum programs. Parallel Comput. 45 ( 2015 ), 2ś17.
[16]
Gudrun Kalmbach. 1983. Orthomodular lattices. Vol. 18. Academic Pr.
[17]
Yangjia Li and Mingsheng Ying. 2014. Debugging quantum processes using monitoring measurements. Phys. Rev. A 89 ( Apr 2014 ), 042338. Issue 4. https://doi.org/10.1103/PhysRevA.89.042338
[18]
Noah Linden, Sandu Popescu, and William Wootters. 2002. Almost Every Pure State of Three Qubits Is Completely Determined by Its Two-Particle Reduced Density Matrices. Phys. Rev. Lett. 89 (Oct 2002 ), 207901. Issue 20. https: //doi.org/10.1103/PhysRevLett.89.207901
[19]
Ji Liu, Gregory T Byrd, and Huiyang Zhou. 2020. Quantum Circuits for Dynamic Runtime Assertions in Quantum Computation. In Proceedings of the Twenty-Fifth International Conference on Architectural Support for Programming Languages and Operating Systems. 1017ś1030.
[20]
Seth Lloyd, Masoud Mohseni, and Patrick Rebentrost. 2014. Quantum principal component analysis. Nature Physics 10, 9 ( 2014 ), 631ś633.
[21]
Michael A Nielsen and Isaac L Chuang. 2010. Quantum Computation and Quantum Information. Quantum Computation and Quantum Information, by Michael A. Nielsen, Isaac L. Chuang, Cambridge, UK: Cambridge University Press, 2010 ( 2010 ).
[22]
Jennifer Paykin, Robert Rand, and Steve Zdancewic. 2017. QWIRE: A Core Language for Quantum Circuits. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (Paris, France) (POPL 2017 ). ACM, New York, NY, USA, 846ś858. https://doi.org/10.1145/3009837.3009894
[23]
Alberto Peruzzo, Jarrod McClean, Peter Shadbolt, Man-Hong Yung, Xiao-Qi Zhou, Peter J Love, Alán Aspuru-Guzik, and Jeremy L O'brien. 2014. A variational eigenvalue solver on a photonic quantum processor. Nature communications 5 ( 2014 ), 4213.
[24]
Robert Rand, Jennifer Paykin, and Steve Zdancewic. 2018. QWIRE practice: Formal verification of quantum circuits in Coq. arXiv preprint arXiv: 1803. 00699 ( 2018 ).
[25]
Rigetti. 2019. A Python library for quantum programming using Quil. https://github.com/rigetti/pyquil.
[26]
Rigetti Forest team. 2019. Forest SDK. https://www.rigetti.com/forest.
[27]
Yunong Shi, Xupeng Li, Runzhou Tao, Ali Javadi-Abhari, Andrew W Cross, Frederic T Chong, and Ronghui Gu. 2019. Contract-based verification of a realistic quantum compiler. arXiv preprint arXiv: 1908. 08963 ( 2019 ).
[28]
Peter W Shor. 1999. Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. SIAM review 41, 2 ( 1999 ), 303ś332.
[29]
Krysta M Svore, Alan Geller, Matthias Troyer, John Azariah, Christopher Granade, Bettina Heim, Vadym Kliuchnikov, Mariia Mykhailova, Andres Paz, and Martin Roetteler. 2018. Q#: Enabling scalable quantum computing and development with a high-level domain-specific language. arXiv preprint arXiv: 1803. 00652 ( 2018 ).
[30]
Dominique Unruh. 2019. Quantum relational hoare logic. Proceedings of the ACM on Programming Languages 3, POPL ( 2019 ), 33.
[31]
Lieven MK Vandersypen, Matthias Stefen, Gregory Breyta, Costantino S Yannoni, Mark H Sherwood, and Isaac L Chuang. 2001. Experimental realization of Shor's quantum factoring algorithm using nuclear magnetic resonance. Nature 414, 6866 ( 2001 ), 883.
[32]
A. Winter. 1999. Coding theorem and strong converse for quantum channels. IEEE Transactions on Information Theory 45, 7 (Nov 1999 ), 2481ś2485. https://doi.org/10.1109/18.796385
[33]
William K Wootters and Wojciech H Zurek. 1982. A single quantum cannot be cloned. Nature 299, 5886 ( 1982 ), 802.
[34]
Tao Xin, Dawei Lu, Joel Klassen, Nengkun Yu, Zhengfeng Ji, Jianxin Chen, Xian Ma, Guilu Long, Bei Zeng, and Raymond Laflamme. 2017. Quantum State Tomography via Reduced Density Matrices. Phys. Rev. Lett. 118 (Jan 2017 ), 020401. Issue 2. https://doi.org/10.1103/PhysRevLett.118.020401
[35]
Mingsheng Ying. 2011. Floydśhoare logic for quantum programs. ACM Transactions on Programming Languages and Systems (TOPLAS) 33, 6 ( 2011 ), 19.
[36]
Mingsheng Ying. 2016. Foundations of Quantum Programming. Morgan Kaufmann.
[37]
Mingsheng Ying, Runyao Duan, Yuan Feng, and Zhengfeng Ji. 2010. Predicate transformer semantics of quantum programs. Semantic Techniques in Quantum Computation 8 ( 2010 ), 311ś360.
[38]
Nengkun Yu. 2019. Quantum Temporal Logic. arXiv: 1908. 00158 [cs.LO]
[39]
Li Zhou, Nengkun Yu, and Mingsheng Ying. 2019. An applied quantum Hoare logic. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation. ACM, 1149ś1162.

Cited By

View all
  • (2025)GeQuPI: Quantum Program Improvement with Multi-Objective Genetic ProgrammingJournal of Systems and Software10.1016/j.jss.2024.112223219(112223)Online publication date: Jan-2025
  • (2024)Statistical Testing of Quantum Programs via Fixed-Point Amplitude AmplificationProceedings of the ACM on Programming Languages10.1145/36897168:OOPSLA2(140-164)Online publication date: 8-Oct-2024
  • (2024)Analyzing Quantum Programs with LintQ: A Static Analysis Framework for QiskitProceedings of the ACM on Software Engineering10.1145/36608021:FSE(2144-2166)Online publication date: 12-Jul-2024
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Proceedings of the ACM on Programming Languages
Proceedings of the ACM on Programming Languages  Volume 4, Issue OOPSLA
November 2020
3108 pages
EISSN:2475-1421
DOI:10.1145/3436718
Issue’s Table of Contents
This work is licensed under a Creative Commons Attribution International 4.0 License.

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 13 November 2020
Published in PACMPL Volume 4, Issue OOPSLA

Permissions

Request permissions for this article.

Check for updates

Badges

Author Tags

  1. assertion
  2. program testing
  3. quantum computing
  4. quantum programming

Qualifiers

  • Research-article

Funding Sources

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)480
  • Downloads (Last 6 weeks)44
Reflects downloads up to 10 Nov 2024

Other Metrics

Citations

Cited By

View all
  • (2025)GeQuPI: Quantum Program Improvement with Multi-Objective Genetic ProgrammingJournal of Systems and Software10.1016/j.jss.2024.112223219(112223)Online publication date: Jan-2025
  • (2024)Statistical Testing of Quantum Programs via Fixed-Point Amplitude AmplificationProceedings of the ACM on Programming Languages10.1145/36897168:OOPSLA2(140-164)Online publication date: 8-Oct-2024
  • (2024)Analyzing Quantum Programs with LintQ: A Static Analysis Framework for QiskitProceedings of the ACM on Software Engineering10.1145/36608021:FSE(2144-2166)Online publication date: 12-Jul-2024
  • (2024)Symbolic Execution for Quantum Error Correction ProgramsProceedings of the ACM on Programming Languages10.1145/36564198:PLDI(1040-1065)Online publication date: 20-Jun-2024
  • (2024)Testing Multi-Subroutine Quantum Programs: From Unit Testing to Integration TestingACM Transactions on Software Engineering and Methodology10.1145/365633933:6(1-61)Online publication date: 27-Jun-2024
  • (2024)Computational Politeness in Natural Language Processing: A SurveyACM Computing Surveys10.1145/365466056:9(1-42)Online publication date: 2-Apr-2024
  • (2024)UPBEAT: Test Input Checks of Q# Quantum LibrariesProceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis10.1145/3650212.3652120(186-198)Online publication date: 11-Sep-2024
  • (2024)Quantum Control Machine: The Limits of Control Flow in Quantum ProgrammingProceedings of the ACM on Programming Languages10.1145/36498118:OOPSLA1(1-28)Online publication date: 29-Apr-2024
  • (2024)Dynamic Transitive Closure-based Static Analysis through the Lens of Quantum SearchACM Transactions on Software Engineering and Methodology10.1145/364438933:5(1-29)Online publication date: 4-Jun-2024
  • (2024)Delta Debugging for Property-Based Regression Testing of Quantum ProgramsProceedings of the 5th ACM/IEEE International Workshop on Quantum Software Engineering10.1145/3643667.3648219(1-8)Online publication date: 16-Apr-2024
  • Show More Cited By

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media