Quantum Pattern Detection: Accurate State- and Circuit-based Analyses
Julian Shen, Joshua Ammermann, Christoph König, Ina Schaefer
TL;DR
The paper tackles the challenge of making quantum software more understandable and maintainable by automatically detecting eight practical quantum computing patterns in source code. It introduces a framework that combines state-based (dynamic) and circuit-based (static) analyses, supported by a benchmarking dataset of 20 quantum algorithms, and demonstrates superior detection accuracy compared to prior work. Key findings show state-based detectors achieve perfect precision/recall/F1 for some patterns, while circuit-based detectors offer scalable performance, with the overall system outperforming Pérez-Castillo et al.’s approach in both coverage (eight vs five patterns) and accuracy. The work lays groundwork for using patterns as high-level building blocks in quantum software, and points to future expansion to more patterns and automatic identification of code passages that lack pattern coverage.
Abstract
Quantum computers have the potential to solve certain problems faster than classical computers by exploiting quantum mechanical effects such as superposition. However, building high-quality quantum software is challenging due to the fundamental differences between quantum and traditional programming and the lack of abstraction mechanisms. To mitigate this challenge, researchers have introduced quantum patterns to capture common high-level design solutions to recurring problems in quantum software engineering. In order to utilize patterns as an abstraction level for implementation, a mapping between the theoretical patterns and the source code is required, which has only been addressed to a limited extent. To close this gap, we propose a framework for the automatic detection of quantum patterns using state- and circuit-based code analysis. Furthermore, we contribute a dataset for benchmarking quantum pattern detection approaches. In an empirical evaluation, we show that our framework is able to detect quantum patterns very accurately and that it outperforms existing quantum pattern detection approaches in terms of detection accuracy.
