Q-PAC: Automated Detection of Quantum Bug-Fix Patterns (2311.17705v1)
Abstract: Context: Bug-fix pattern detection has been investigated in the past in the context of classical software. However, while quantum software is developing rapidly, the literature still lacks automated methods and tools to identify, analyze, and detect bug-fix patterns. To the best of our knowledge, our work previously published in SEKE'23 was the first to leverage classical techniques to detect bug-fix patterns in quantum code. Objective: To extend our previous effort, we present a research agenda (Q-Repair), including a series of testing and debugging methodologies, to improve the quality of quantum software. The ultimate goal is to utilize machine learning techniques to automatically predict fix patterns for existing quantum bugs. Method: As part of the first stage of the agenda, we extend our initial study and propose a more comprehensive automated framework, called Q-PAC, for detecting bug-fix patterns in IBM Qiskit quantum code. In the framework, we develop seven bug-fix pattern detectors using abstract syntax trees, syntactic filters, and semantic checks. Results: To demonstrate our method, we run Q-PAC on a variety of quantum bug-fix patterns using both real-world and handcrafted examples of bugs and fixes. The experimental results show that Q-PAC can effectively identify bug-fix patterns in IBM Qiskit. Conclusion: We hope our initial study on quantum bug-fix detection can bring awareness of quantum software engineering to both researchers and practitioners. Thus, we also publish Q-PAC as an open-source software on GitHub. We would like to encourage other researchers to work on research directions (such as Q-Repair) to improve the quality of the quantum programming.
- Assessing the effectiveness of input and output coverage criteria for testing quantum programs. In 2021 14th IEEE Conference on Software Testing, Verification and Validation (ICST), pages 13–23. IEEE, 2021.
- Using static analysis to find bugs. IEEE Software, 25(5):22–29, 2008.
- A. Barr. Find the Bug: A Book of Incorrect Programs. Addison-Wesley Professional, 2004.
- E. C. Campos and M. de Almeida Maia. Common bug-fix patterns: A large-scale observational study. In 2017 ACM/IEEE International Symposium on Empirical Software Engineering and Measurement (ESEM), pages 404–413. IEEE, 2017.
- Practical quantum advantage in quantum simulation. Nature, 607(7920):667–676, 2022.
- D. Deutsch and R. Jozsa. Rapid solution of problems by quantum computation. Proc. R. Soc. Lond. A, 439:553–558, 1992.
- Property-based testing of quantum programs in q#. In Proc. of the IEEE/ACM 42nd International Conference on Software Engineering Workshops, pages 430–435, 2020.
- Quantum advantage in learning from experiments. Science, 376(6598):1182–1186, 2022.
- Y. Huang and M. Martonosi. Statistical assertions for validating patterns and finding bugs in quantum programs. In Proc. of the 46th International Symposium on Computer Architecture, ISCA’19, page 541–553. Association for Computing Machinery, 2019.
- How bugs are fixed: Exposing bug-fix patterns with edits and nesting levels. In Proc. of the 35th annual ACM symposium on applied computing, pages 1523–1531, 2020.
- J. Jones. Abstract syntax tree implementation idioms. Pattern Languages of Program Design, 2003. Proceedings of the 10th Conference on Pattern Languages of Programs (PLoP2003) http://hillside.net/plop/plop2003/papers.html.
- Automatic diagnosis of quantum software bug-fix motifs. In Proc. of the 35th International Conference on Software Engineering and Knowledge Engineering (SEKE23), 2023.
- Y. Lee and J. Yang. Analysis of bug types of textbook code with open-source software. In H. R. Arabnia, L. Deligiannidis, F. G. Tinetti, and Q.-N. Tran, editors, Advances in Software Engineering, Education, and e-Learning, pages 629–639, Cham, 2021. Springer International Publishing.
- Projection-based runtime assertions for testing and debugging quantum programs. Proc. of the ACM on Programming Languages, 4(OOPSLA):150:1–150:29, 2020.
- Quantum circuits for dynamic runtime assertions in quantum computation. In Proc. of the 25th International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS’20, page 1017–1030. Association for Computing Machinery, 2020.
- C. Lomont. The hidden subgroup problem-review and open problems. arXiv preprint quant-ph/0411037, 2004.
- A comprehensive study of bug fixes in quantum programs. In 2022 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER), pages 1239–1246. IEEE, 2022.
- Towards an automated approach for bug fix pattern detection. In Proc. of the VI Workshop on Software Visualization, Evolution and Maintenance (VEM), 2018.
- Automatically extracting instances of code change patterns with ast analysis. In 2013 IEEE international conference on software maintenance, pages 388–391. IEEE, 2013.
- A. Miranskyy and L. Zhang. On testing quantum programs. In Proc. of the 2019 IEEE/ACM 41st International Conference on Software Engineering: New Ideas and Emerging Results (ICSE-NIER), pages 57–60. IEEE, 2019.
- Is your quantum program bug-free? In Proc. of the ACM/IEEE 42nd International Conference on Software Engineering: New Ideas and Emerging Results, ICSE-NIER ’20, page 29–32. ACM, 2020.
- On testing and debugging quantum software. arXiv preprint arXiv:2103.09172, 2021.
- Quantum Computation and Quantum Information: 10th Anniversary Edition. Cambridge Univ. Press, 2010.
- Toward an understanding of bug fix patterns. Empirical Software Engineering, 14:286–315, 2009.
- M. Piattini et al. The talavera manifesto for quantum software engineering and programming. In Proc. of the 1st International Workshop on the QuANtum SoftWare Engineering & pRogramming, Talavera de la Reina, Spain, 2020, volume 2561 of CEUR Workshop Proceedings, pages 1–5. CEUR-WS.org, 2020.
- Dissection of a bug dataset: Anatomy of 395 patches from defects4j. In SANER 2018, 03 2018.
- A deeper look into bug fixes: patterns, replacements, deletions, and additions. In Proc. of the 13th International Conference on Mining Software Repositories, pages 512–515, 2016.
- Stack Overflow. 2 entangled qubit gives all states with 25 %. https://stackoverflow.com/questions/62661255/2-entangled-qubit-gives-all-states-with-25, 2022.
- Qiskit/qiskit: Qiskit 0.39.5. https://doi.org/10.5281/zenodo.7545230, Jan. 2023.
- Quanfuzz: Fuzz testing of quantum program. arXiv preprint arXiv:1810.10310, 2018.
- Qdiff: Differential testing of quantum software stacks. In 2021 36th IEEE/ACM International Conference on Automated Software Engineering (ASE), pages 692–704, 2021.
- Qucat: A combinatorial testing tool for quantum software. CoRR, abs/2309.00119, 2023.
- R. J. Wieringa and M. Daneva. Six strategies for generalizing software engineering theories. Science of computer programming, 101:136–152, 4 2015.
- Experimentation in Software Engineering. Computer Science. Springer Berlin Heidelberg, 2012.
- R. Yin. Case Study Research: Design and Methods. Applied Social Research Methods. SAGE Publications, 2009.
- M. Young and M. Pezze. Software Testing and Analysis: Process, Principles and Techniques. John Wiley & Sons, Inc., Hoboken, NJ, USA, 2005.
- J. Zhao. Quantum software engineering: Landscapes and horizons. arXiv preprint arXiv:2007.07047, 2020.
- Qchecker: Detecting bugs in quantum programs via static analysis. arXiv preprint arXiv:2304.04387, 2023.
- Identifying bug patterns in quantum programs. In Proc. of the 2021 IEEE/ACM 2nd International Workshop on Quantum Software Engineering (Q-SE), pages 16–21. IEEE, 2021.
- Bugs4q: A benchmark of real bugs for quantum programs. In 2021 36th IEEE/ACM International Conference on Automated Software Engineering (ASE), pages 1373–1376. IEEE, 2021.