Noisy Variational Quantum Algorithm Simulation Via Knowledge Compilation for Repeated Inference: Extended Abstract
Total Page:16
File Type:pdf, Size:1020Kb
Noisy Variational Quantum Algorithm Simulation via Knowledge Compilation for Repeated Inference: Extended Abstract Yipeng Huang Steven Holtzen Todd Millstein Guy Van den Broeck Margaret Martonosi Rutgers University UCLA UCLA UCLA Princeton University [email protected] [email protected] [email protected] [email protected] [email protected] Abstract—We present a quantum circuit simulation toolchain QAOA simulation time vs. qubits (iterations=1) 102 targeted for simulating variational algorithms. We do so by qsim sampling with 1 thread qsim sampling with 16 threads encoding quantum amplitudes and noise probabilities in a 1 10 qtorch sampling with 1 thread probabilistic graphical model, and we use knowledge compi- qtorch sampling with 16 threads lation to compile the circuits to logical equations that support 100 knowledge compilation sampling Time (s) efficient repeated simulation of and sampling from quantum 10 1 circuits for different parameters. Compared to state-of-the-art 10 2 state vector and density matrix quantum circuit simulators, 5 10 15 20 25 30 our simulation approach offers greater performance when Qubits, representing Max-Cut problem vertices sampling from circuits with at least eight to 20 qubits and (a) Versus state vector (qsim) and tensor network (qTorch [3]) for with around 12 operations on each qubit. And versus quantum ideal circuits circuit simulation techniques based on tensor network contrac- tion, our simulation approach offers a 66 times reduction in Noisy QAOA simulation time vs. qubits (iterations=1) sampling cost for simulating ideal shallow quantum circuits density matrix sampling 102 with 32 qubits, making the approach ideal for simulating near- knowledge compilation sampling term variational quantum algorithms. 101 0 Time (s) 10 1. Motivation & Key Insights 10 1 Due to the limitations of existing quantum prototypes, 4 5 6 7 8 9 10 11 12 quantum circuit simulation continues to be a vital tool Qubits, representing Max-Cut problem vertices for validating next generation quantum computers and for (b) Versus density matrix simulation (Cirq) for noisy circuits studying variational quantum algorithms. Existing quantum circuit simulators do not address the common traits of varia- Figure 1: Knowledge compilation sampling performance. tional algorithms, namely: 1) their ability to work with noisy qubits and operations, 2) their repeated execution of the same circuits but with different parameters, and 3) the fact networks encode probabilistic knowledge about the world in that they sample from circuit final wavefunctions to drive a factorized format. The Bayesian networks compile down an optimization routine [2]. Quantum computing research to minimized data structures called arithmetic circuits (ACs) would benefit from a simulator that supports variational that enable repeated inference and sampling queries with algorithms specifically, which would require a simulator that different parameters and new pieces of evidence [1]. These 1) simulates the probabilistic effects of noise, 2) can handle features of the knowledge compilation approach—namely, more qubits, and 3) can reuse computation results between 1) the ability to represent and manipulate probabilistic simulation runs with different parameters. information, 2) the ability to compile probabilistic model The key insight of our paper is that knowledge compila- structural information into minimized formats, 3) the ability tion—–a technique for efficient repeated inference originat- to efficiently sample from the same model but for varying ing in artificial intelligence research—can be generalized to parameters and evidence—match well with the requirements work on complex-valued quantum amplitudes, such that the for variational quantum algorithm simulation. technique serves as the basis for a quantum circuit simula- tion toolchain geared for variational quantum algorithms. 2. Our Knowledge Compilation Approach In knowledge compilation, AI models such as Bayesian This work is funded in part by EPiQC, an NSF Expedition in Computing, We built a knowledge compilation toolchain for quantum under grant 1730082. algorithm simulation that excels at simulating noisy circuits CNF encoding of CNF to AC encoding of Quantum circuit Noisy quantum Bayesian Bayesian arithmetic circuit valid sets of Basis state simulation and circuit (quantum Quantum circuit Complex-valued network to amplitude to Bayesian network (AC) compiler qubit states sampling results kernel of Bayesian conjunctive structure calculation and network network returned to variational normal form wavefunction variational algorithm) compiler (CNF) compiler sampling Parameters for gate amplitudes and noise probabilities algorithm New parameters from variational algorithm iterations Figure 2: Toolchain stages and intermediate representations for quantum algorithm simulation via knowledge compilation. TABLE 1: Program transformations converting a noisy quantum circuit to conjunctive normal form (CNF). Quantum circuit The logical sentences comprising the CNF for a noisy Bell state quantum circuit example Compilation / simplification rules semantics encoded Qubits take on bi- q0m0 = j0i ⊕ q0m0 = j1i q1m0 = j0i ⊕ q1m0 = j1i Combine initial value sentences into binary nary values; supply q0m0 = j0i q1m0 = j0i constraint sentences using logical unit res- initial qubit values q0m1 = j0i ⊕ q0m1 = j1i q1m3 = j0i ⊕ q1m3 = j1i olution. Hadamard gate q0m0 = j0i^ q0m1 = j0i =) + p1 q0m0 = j0i^ q0m1 = j1i =) + p1 Weight variables stand in for parameters for 2 2 q0m0 = j1i^ q0m1 = j0i =) + p1 q0m0 = j1i^ q0m1 = j1i =) − p1 amplitudes or probabilities; compiler stores 2 2 equal-value parameters as a single variable. Phase damping q0m2rv = 0 ⊕ q0m2rv = 1 q0m1 = j1i^ q0m2rv = 0= ) +0:8 The simulator resolves variables with val- noise channel q0m1 = j0i =) q0m2rv = 0 q0m1 = j1i^ q0m2rv = 1= ) −0:6 ues that change for repeated simulations. CNOT gate q0m1 = j0i^q1m0 = j0i =) q1m3 = j0i q0m1 = j1i^q1m0 = j0i =) q1m3 = j1i Deterministic parameters (i.e., 0 or 1) are q0m1 = j0i^q1m0 = j1i =) q1m3 = j1i q0m1 = j1i^q1m0 = j1i =) q1m3 = j0i factored to logic without weight variables. for variational algorithms (Fig. 2). It comprises: prior queries such that subsequent queries update val- 1) A front-end for converting noisy quantum circuits ues only as necessary. The ACs also enable a Markov (specified in Google’s Cirq framework1) to complex- chain Monte Carlo procedure for sampling sets of qubit valued Bayesian networks [4], which we extend to outcomes according to their measurement probability. correctly encode quantum noise mixtures and chan- nels. Compared to conventional quantum circuits where 3. Key Results and Contributions complex-valued quantum amplitudes and real-valued noise probabilities are treated separately, the Bayesian Our key results are that 1) a quantum circuit simulation network encoding unifies quantum states and noise approach based on knowledge compilation of probabilistic events in a single representation. program representations is correct for a benchmark suite 2) A compiler that converts Bayesian networks represent- of quantum algorithms, and 2) such an approach offers ing noisy quantum circuits into conjunctive normal advantages in simulating near-term variational quantum al- gorithms, relative to other simulation approaches based on form (CNF) logic equations. The CNFs encode the 2 quantum circuits’ topological information. The sets of state vectors , density matrices, and tensor networks [3] logic variable assignments that satisfy the CNF corre- (Fig. 1). The advantages are due to the more compact spond to all sets of qubit state assignments that are con- representation, the circuit minimization and memoization sistent with a quantum circuit’s semantics (Tab. 1). The capabilites of our approach, and due to the storage costs structural information can be reused across simulations for conventional simulators based on matrix representations. independently of quantum amplitude and noise proba- The improved simulation performance facilitates studying bility parameters, which vary across simulations. More variational algorithms and validating prototype quantum importantly, CNF logical equation encodings for quan- computer results in the NISQ era of quantum computing. tum circuits permits using logical equation compilers based on SAT solvers to minimize the representation. References 3) A compiler that converts CNFs to ACs. An AC enu- [1] Adnan Darwiche. Modeling and Reasoning with Bayesian Networks. merates and assigns a weight value to each set of Cambridge University Press, New York, NY, USA, 1st edition, 2009. variable assignments that satisfy a logical equation [1]. [2] Edward Farhi, Jeffrey Goldstone, and Sam Gutmann. A Quan- Summing the weights across all qubit state assignments tum Approximate Optimization Algorithm. arXiv e-prints, page results in the output amplitudes that we seek to find in arXiv:1411.4028, Nov 2014. the quantum circuit simulation task. The ACs enable [3] E. Schuyler Fried, Nicolas P. D. Sawaya, Yudong Cao, Ian D. the quantum circuit simulator to find the probability Kivlichan, Jhonathan Romero, Alan´ Aspuru-Guzik, and Itay Hen, ed. qTorch: The quantum tensor contraction handler. PLoS ONE, 13(12), amplitude for an outcome, without incurring the cost 12 2018. of finding the amplitudes of intermediate qubit states. [4] Robert R Tucci. Quantum Bayesian nets. Int. Journal of Modern The ACs further memoize the calculated results from Physics B, 9(03):295–337, 1995. 1. https://github.com/quantumlib/Cirq 2. https://github.com/quantumlib/qsim.