Numerous quantum algorithms require the use of quantum error correction to overcome the intrinsic unreliability of physical qubits. However, error correction imposes a unique performance bottleneck, known as T-complexity, that can make an implementation of an algorithm as a quantum program run more slowly than on idealized hardware. In this work, we identify that programming abstractions for control flow, such as the quantum if-statement, can introduce polynomial increases in the T-complexity of a program. If not mitigated, this slowdown can diminish the computational advantage of a quantum algorithm. To enable reasoning about the costs of control flow, we present a cost model that a developer can use to accurately analyze the T-complexity of a program and pinpoint the sources of slowdown. We also present a set of program-level optimizations, that a developer can use to rewrite a program to reduce its T-complexity, predict the T-complexity of the optimized program using the cost model, and then compile it to an efficient circuit via a straightforward strategy. We implement the program-level optimizations in Spire, an extension of the Tower quantum compiler. Using a set of 11 benchmark programs that use control flow, we show that the cost model is accurate, and that Spire's optimizations recover programs that are asymptotically efficient, meaning their runtime T-complexity under error correction is equal to their time complexity on idealized hardware. Our results show that optimizing a program before it is compiled to a circuit can yield better results than compiling the program to an inefficient circuit and then invoking a quantum circuit optimizer found in prior work. For our benchmarks, only 2 of 8 tested circuit optimizers recover circuits with asymptotically efficient T-complexity. Compared to these 2 optimizers, Spire uses 54x to 2400x less compile time.
翻译:众多量子算法需要借助量子纠错来克服物理量子比特固有的不可靠性。然而,纠错会引入一种独特的性能瓶颈——T复杂度,这使得量子程序实现的算法在运行速度上可能慢于理想硬件。本工作中,我们发现控制流编程抽象(例如量子if语句)会以多项式级增长程序的T复杂度。若不加缓解,这种降速将削弱量子算法的计算优势。为支持对控制流代价的推理,我们提出一种成本模型,开发者可借此精确分析程序的T复杂度并定位降速根源。我们还提出一组程序级优化方法,开发者可用来重写程序以降低其T复杂度,利用成本模型预测优化后程序的T复杂度,再通过直接策略将其编译为高效电路。我们在Tower量子编译器的扩展Spire中实现了这些程序级优化。基于11个使用控制流的基准程序,我们证明该成本模型准确有效,且Spire的优化能够恢复渐近高效的程序——即纠错下的运行时T复杂度与理想硬件的运行时时间复杂度相等。结果表明,在编译为电路前优化程序,比先编译为低效电路再调用前人工作提出的量子电路优化器效果更佳。在我们的基准测试中,8个受测电路优化器仅有2个能恢复具有渐近高效T复杂度的电路。与这两个优化器相比,Spire的编译时间减少了54至2400倍。