QDiff: Differential Testing of Quantum Software Stacks

QDiff: Differential Testing of Quantum Software Stacks
复制标题

DOI:
10.1109/ase51524.2021.9678792
复制
发表时间:
2021-11
期刊:
2021 36th IEEE/ACM International Conference on Automated Software Engineering (ASE)
影响因子:
--
通讯作者:
Jiyuan Wang;Qian Zhang;G. Xu;Miryung Kim
Jiyuan Wang;Qian Zhang;G. Xu;Miryung Kim
中科院分区:
其他
文献类型:
--
作者:
Jiyuan Wang;Qian Zhang;G. Xu;Miryung Kim

文献摘要

相似文献

在过去的几年里,随着量子计算硬件的快速发展,已经开发了几个量子软件堆栈(QSS)。QSS包括量子编程语言、将用高级语言编写的量子算法翻译成量子门指令的优化编译器、在经典设备上模拟这些指令的量子模拟器、以及向基于量子电路的非常昂贵的量子硬件发送模拟信号的软件控制器。与传统的编译器和体系结构模拟器相比,QSS由于结果的随机性、缺乏明确的硬件规范和量子编程的复杂性而难以测试,该工作设计了一种新的QSS差异测试方法QDiff,主要有三个创新之处:(1)通过保持语义、源到源的转换来生成待测试的输入程序来探索程序变体。(2)通过分析电路深度、双门操作、门错误率和T1弛豫时间等静态特性,过滤掉不值得在量子硬件上执行的量子电路,从而加快了差分测试的速度。(3)通过Kolmogorov-Smirnov检验和交叉熵等分布比较函数设计了一种可扩展的等价性检验机制,并用IBM的Qiskit、Google的Cirq和Rigetti的PYQUIL三种常用的开源QSS对QDiff进行了评估。通过在真实硬件和量子模拟器上运行QDiff,我们发现了几个关键错误,揭示了这些平台中的潜在不稳定性。QDiff的源变换可以有效地产生语义等价但不完全相同的电路(即34%的测试),其过滤机制可以将差异测试的速度提高66%。
Over the past few years, several quantum software stacks (QSS) have been developed in response to rapid hardware advances in quantum computing. A QSS includes a quantum programming language, an optimizing compiler that translates a quantum algorithm written in a high-level language into quantum gate instructions, a quantum simulator that emulates these instructions on a classical device, and a software controller that sends analog signals to a very expensive quantum hardware based on quantum circuits. In comparison to traditional compilers and architecture simulators, QSSes are difficult to tests due to the probabilistic nature of results, the lack of clear hardware specifications, and quantum programming complexity.This work devises a novel differential testing approach for QSSes, named QDiff with three major innovations: (1) We generate input programs to be tested via semantics-preserving, source to source transformation to explore program variants. (2) We speed up differential testing by filtering out quantum circuits that are not worthwhile to execute on quantum hardware by analyzing static characteristics such as a circuit depth, 2-gate operations, gate error rates, and T1 relaxation time. (3) We design an extensible equivalence checking mechanism via distribution comparison functions such as Kolmogorov–Smirnov test and cross entropy.We evaluate QDiff with three widely-used open source QSSes: Qiskit from IBM, Cirq from Google, and Pyquil from Rigetti. By running QDiff on both real hardware and quantum simulators, we found several critical bugs revealing potential instabilities in these platforms. QDiff’s source transformation is effective in producing semantically equivalent yet not-identical circuits (i.e., 34% of trials), and its filtering mechanism can speed up differential testing by 66%.