Addressing Temporal Variations in Qubit Quality Metrics for Parameterized Quantum Circuits
AAddressing Temporal Variations in Qubit Quality Metrics forParameterized Quantum Circuits
Mahabubul Alam, Abdullah Ash-Saki, Swaroop Ghosh
Department of Electrical EngineeringPennsylvania State University, University Park, [email protected], [email protected], [email protected]
Abstract —The public access to noisy intermediate-scale quantum(
NISQ ) computers facilitated by
IBM , Rigetti , D − W ave , etc.,has propelled the development of quantum applications that may offerquantum supremacy in the future large-scale quantum computers.Parameterized quantum circuits (
P QC ) have emerged as a major driverfor the development of quantum routines that potentially improve thecircuit’s resilience to the noise.
P QC ’s have been applied in bothgenerative (e.g. generative adversarial network) and discriminative (e.g.quantum classifier) tasks in the field of quantum machine learning.
P QC ’s have been also considered to realize high fidelity quantum gateswith the available imperfect native gates of a target quantum hardware.Parameters of a
P QC are determined through an iterative training pro-cess for a target noisy quantum hardware.
However, temporal variationsin qubit quality metrics affect the performance of a
P QC . Therefore, thecircuit that is trained without considering temporal variations exhibits poorfidelity over time.
In this paper, we present training methodologies for
P QC in a completely classical environment that can improve the fidelityof the trained
P QC on a target
NISQ hardware by as much as 42.51%.
I. I
NTRODUCTION
Quantum computing has observed a shift from being a purelyacademic exploration to a realistic industrial technology in recentyears. However, the qubits have small coherence time (i.e., thequantum states are short-lived), the gate operations are imperfect,and the overall computation is extremely error-prone. Moreover, thenear-term quantum devices offer a limited number of qubits withoutthe costly feature of error correction. Due to these limitations, it isimpossible to implement and test the target quantum algorithms (e.g.shor’s factorization, grover’s search, etc.) which have made quantumcomputing so attractive on a useful scale on these noisy intermediate-scale quantum (
NISQ ) hardware. In recent years, quantum routineshave been developed which are inherently resilient to errors usingvariational/parameterized quantum circuits (
P QC ) [1]–[3].
P QC iscomposed of a set of parameterized single and controlled singlequbit gates. The parameters are iteratively optimized by a classicaloptimizer to attain a desired input-output relationship.
For example,RZ( θ ) gate available in Rigetti 8Q-Agave hardware can be used toperform an arbitrary amount of rotation of a target qubit along Z-axis. By employing variational hybrid quantum/classical algorithms, P QC ’s have been applied to accomplish both the generative anddiscriminative tasks in the field of quantum machine learning [4]–[9].For example, Romero et al. proposed a generative variational circuitthat consists of two parts: a quantum circuit employed to encode aclassical random variable into a quantum state, and a
P QC whoseparameters are optimized to mimic a target probability distribution[9]. Schuld et al. [6] proposed a low-depth variational quantumalgorithm for supervised learning where the input classical featurevectors are encoded into the amplitudes of a quantum system, and aquantum circuit of parameterized single and two-qubit gates togetherwith a single-qubit measurement is used to classify the inputs. In [10],
P QC ’s are used to develop arbitrary high-fidelity quantum gates withthe imperfect native gates of a target hardware.
Motivation:
The trained
P QC is supposed to be noise resilientas the training is generally performed with the noisy hardware inthe loop approach to address the impact of noise as shown inFigure 5(a) [11]–[13]. However, the quantum computers operateunder extremely controlled environment (i.e. operating temperatureis in millikelvin range [14]) and the qubit performance metrics that define the qubit quality (e.g. T1 relaxation time, T2 dephasing time,single-qubit gate error, multi-qubit gate error, readout error, etc.)experience significant fluctuations over time. Generally, the quantumcomputers (e.g., IBMQX4 and IBMQX2 from IBM) are periodicallycalibrated through randomized benchmarking [15] and the updatedqubit quality metrics are reported for the users to validate theirquantum experiments on any target hardware. The variations in theperformance metrics of the qubits in IBMQX4 quantum computer isshown in Figure 2. The data has been collected over a 43 days period.
The significant variations in the qubit quality metrics indicate thatvariational circuits that are trained at any particular time using thehardware in the loop training methodology may not show the desiredbehavior all the time.
The temporal variability at the output of a quantum circuit isexpected for any arbitrary quantum circuit. As a motivational ex-ample, we have executed the workload shown in Figure 1(b) on5-qubit IBMQX4 quantum computer (the coupling graph of thedevice is shown in Figure 1(a)) on 5 different occasions. The qubitsare prepared in the basis state | (cid:105) . Ideally, at the end of theexecution period, the qubits will be in another basis state | (cid:105) . Aprojective measurement on the target hardware is expected to generatea measurement of ’10’ most of the time. However, due to temporalvariations of the qubit quality metrics, we have received significantlydifferent outcomes at different points of time as shown in Figure1(c). The y-axis shows the fidelity of the measurements (which isthe % of the correct output for 1024 samples at a time). For circuitssuch as circuit-centric binary quantum classifiers based on P QC (discussed in Section II), the final outcome is decided after analyzingthe measurement distributions in a classical computer which can becompletely wrong due to the temporal variations of the qubit qualitymetrics. Moreover, quantum computers are expected to operate ina client-server mode (for reliable hardware operation, the quantumcomputer is kept in extremely controlled environment). Training ofan arbitrary
P QC of a client with the target server hardware inthe loop approach becomes impractical as the training requires aconsiderable amount of time and the access to any target hardwarethrough the client-server mode goes through a long wait queue. Thisis true for IBM and Rigetti that provide free access to their quantumcomputers through a cloud service accessible through qiskit and QCS,respectively.
Hence, fully classical training of
P QC to address thevariations in qubit quality metrics of a target hardware can be achallenging task. (b) Random Workload Q A Q B X HH HH X (a) Coupling Graph ofIBM Q 5 Tenerife(IBMQX4) A Q B The qubits (1 and 0) are prepared in the basis state
Terminal state of the qubits (after executing the workload) should be another basis state (c) Fidelity of the measuredoutput at different point of time
Single-qubit Parameterized Gates (
𝑼𝑼𝑼𝑼 , 𝑼𝑼𝑼𝑼 , 𝑼𝑼𝟏𝟏 )are supported for all the qubits.2-Qubit CNOTgates allowed between: 1
0, 2
0, 2
1, 3
2, 4
2, 3 target) Fig. 1. (a) Coupling graph of IBMQX4 (Tenerife) hardware from IBM; (b)Random quantum workload; (c) outcome at different points in time.
Contributions:
In this paper, we, (a) present a framework forsimulating any given quantum workload for any target
NISQ hard- a r X i v : . [ c s . ET ] M a r a) (b) (c) (d) Fig. 2. Temporal variations in qubit performance metrics for IBMQX4 (a) T1 relaxation; (b) T2 dephasing; (c) single qubit gate error; (d) two-qubit gateerror. ware; (b) demonstrate training methodologies of
P QC and addresstheir respective pros and cons; (c) present a fully classical heuristictraining methodology for
P QC to address the temporal variations inqubit quality metrics; (d) used
P QC based circuit-centric quantumclassifiers to demonstrate our solutions and verified their effectivenesson real quantum hardware from IBM.The paper is organized as follows: the design methodologies of
P QC based circuit-centric binary quantum classifier are presentedin Section II. The training methodologies and their pros/cons areis discussed in Section III. The framework for modeling circuitbehavior on a generic
NISQ hardware is discussed in Section IV.We demonstrate the proposed training methodology for
P QC on twobinary quantum classifiers in Section V. We conclude in Section VI.II. B
INARY Q UANTUM C LASSIFIERS
A. Quantum Computing Preliminaries1) Qubit and State Vector:
Qubit is the building block of quantumcomputers. Besides storing classical bits 0 and 1, a qubit can be in asuperposition of both 0 and 1 simultaneously. Qubit state is expressedwith a ket ( | . (cid:105) ) notation which is represented by a column matrixknown as state vector . A single qubit state | ψ (cid:105) is described as | ψ (cid:105) = a | (cid:105) + b | (cid:105) . Here, | (cid:105) and | (cid:105) are known as computational basis statesrepresented by [1 0] T and [0 1] T respectively (T stands for matrixtranspose), and a and b are complex numbers s.t. | a | + | b | = 1 .
2) Density Matrix:
An alternate approach of representing qubitstate is the density matrix ( ρ ) formalism which is expressed as ρ = (cid:80) i p i | ψ (cid:105) (cid:104) ψ | where p i is the probability of pure state and | ψ (cid:105) isthe density matrix. This representation is beneficial since qubit statesmay end up in a mixed state due to noise that can be expressed nicelyusing density matrix.
3) Quantum Gates:
Quantum gates are the operations that mod-ulate the state of qubits and thus perform computations. Mathemat-ically, quantum gates are represented by n × n unitary matrices(n = number of qubits). Quantum gates can work on a single qubit(e.g., Pauli-X ( σ x ) gate) or on multiple qubits (e.g., 2-qubit CNOTgate). When multiple gates work on different qubits, the overallunitary matrix can be calculated using tensor product ( ⊗ ). Forexample, in Fig. 4(a) two U3 (native gate of IBMQX4) gates areworking on qubit-1 and 0. Therefore, the overall gate matrix will be U = U ⊗ U . The gate matrices of the quantum gates used in thiswork are shown in Figure 3.
4) Expectation Value:
Expectation value is the average of theeigenvalues, weighted by the probabilities that the state is measured tobe in the corresponding eigenstate. In quantum computers, measure-ment of a qubit is performed in the so-called Z-basis or computationalbasis | (cid:105) and | (cid:105) . These are the eigenvectors (eigenstates) of Pauli-Z( σ z ) operator with eigenvalues +1 and -1 respectively. For quantumcomputing, (a) a positive expectation value means that the measure-ments will yield more | (cid:105) than | (cid:105) , if a qubit prepared in identical 𝑈3 𝜃, 𝜙, 𝜆 = 𝑒 − 𝑖 𝜙+𝜆 cos( 𝜃
2) −𝑒 − 𝑖 𝜙−𝜆 sin( 𝜃 𝑖 𝜙−𝜆2 sin(𝜃 ) 𝑒 𝑖 𝜙+𝜆2 cos(𝜃 ) 𝑃𝑎𝑢𝑙𝑖 − 𝑋 =
Fig. 3. Gate matrices of the quantum gates used in this article. setup is measured many times. The measurements will always yield | (cid:105) if the expectation value is exactly +1, (b) a negative expectationvalue means that the measurement outcomes will have more | (cid:105) sthan | (cid:105) s. If the expectation value is exactly -1, the measurementswill always yield | (cid:105) , and c if the expectation value is 0, it meansthe qubit state is in a perfect superposition of both | (cid:105) and | (cid:105) (e.g., ψ = ( | (cid:105) + | (cid:105) ) / √ ) and large number of measurements will resultin equal probabilities of | (cid:105) and | (cid:105) .For more clarity, suppose the state of a qubit after a quantumcomputation routine is | ψ (cid:105) = 0 . | (cid:105) + 0 . | (cid:105) (note the higheramplitude of | (cid:105) ). The expectation value of Pauli-Z operator in thisstate | ψ (cid:105) is (cid:104) ψ | σ z | ψ (cid:105) = 0.28, a positive expectation value whichvalidates a in the above discussion. Figure 4(a) shows the variations inthe expectation value of a target qubit with respect to a gate parameter( θ ). B. Classifier Basics
Binary classification is the task of classifying any input data intoone of two possible groups. In supervised machine learning, thisclassification problem is solved by training a mathematical model( f ( x, θ ) ) with a properly labeled input data-set { ( x , y ), ( x , y ), ...., ( x M , y M ) } where x i is the feature vector (can be multi-dimensional)of the i (cid:48) th input data and y i is the associated label. The mathematicalmodel predicts the class of any input data based on its features ( x )and the parameters ( θ ) of the model. The parameters ( θ ) are updatediteratively until the model predictions are satisfactory over the inputdata-set.In [6], a binary classification on quantum computers is proposedfor classical data where a P QC serves as the mathematical model.A state-preparation routine is required to encode the classical dataand feed it to the
P QC . The output is captured from a target qubit.During the training phase of the
P QC , the parameters are updatediteratively based on the given input data-set so that the probability ofgetting 1 through a measurement of the target qubit for one class ismaximized (and 0 for the other class).
C. State Preparation
A state preparation circuit (which is applied to the qubits at groundstate) is used to convert any classical input data to a quantum formatso that quantum gates can be applied on the data and/or quantumspeed-up can be exploited. The structure of this circuit depends on thechosen encoding scheme. A multitude of quantum encoding schemeof classical data have been proposed [16]. However, in this paper, wehave utilized the basis encoding for parity classification and amplitudeencoding for iris classification. These schemes are described below.
Basis Encoding:
In this scheme, binary 0 (1) is encoded ascomputational basis state | (cid:105) ( | (cid:105) ). For instance, a classical data x =9 (binary ) can be represented by 4-qubits (say, Q Q Q Q )where Q and Q ( Q and Q ) are prepared in qubit state | (cid:105) ( | (cid:105) ).The effect of the state-preparation routine can be written as - U φ : x ∈ {
0, 1 } n → | ψ x (cid:105) .Here, U φ is the unitary transformation that prepares the desiredquantum state representative of classical data. For IBM quantumcomputers, all qubits start from a | (cid:105) state. Therefore, quantum NOTgate (Pauli-X, σ x ) has to be applied on Q and Q whereas Identity2ates are applied on Q and Q to prepare x = 9 state. Thus, forthis case U φ = σ x ⊗ I ⊗ I ⊗ σ x . Although, the scheme results in atrivial quantum state-preparation circuit (that only requires NOT andIdentity gates) which is fairly easy to implement on existing quantumhardware, the required number of qubits may grow linearly with thenumber of input features (e.g., two 4-bit classical features will require8 physical qubits). Amplitude Encoding:
In this scheme, normalized input vectors x = ( x , x , ....., x N ) T ∈ R of dimension N = n are associated withthe amplitudes of a n qubit state | ψ x (cid:105) ( U φ : x ∈ R → | ψ x (cid:105) = (cid:80) Ni =1 x i | i (cid:105) ). Example:
The state ( ψ ) of a 2-qubit quantum system, due tosuperposition, is a linear combination of all possible computationalbasis state i.e. ψ can be written as a | (cid:105) + b | (cid:105) + c | (cid:105) + d | (cid:105) such that √ a + b + c + d = 1 . Suppose, we have a classicalinput vector x = { , , , } . After normalizing the input vector, weget x norm = { . , . , . , . } . The amplitude encodingscheme will encode this normalized classical input vector entriesas the amplitude of the computational basis states of the wholequantum system such that state ψ becomes . | (cid:105) +0 . | (cid:105) +0 . | (cid:105) + 0 . | (cid:105) .In this scheme, the number of qubits grows only logarithmicallywith the dimension of the classical input vectors (e.g. for the aboveexample, only log (4) = 2 qubits are required to encode 4 classicalvalues). Furthermore, multiple inputs in superposition state can beprocessed simultaneously leading to potential speed-up in computa-tion. Mathematically, quantum algorithms that are only polynomialin the number n of qubits can perform computations on the n amplitudes leading to a poly-logarithmic processing time. However,the encoding scheme results in a non-trivial state-preparation circuitwhich can be unsuitable for existing resource limited quantumhardware. D. Model Circuit
The model circuit is a parameterized unitary transformation U θ (where θ is a set of trainable variables) that acts as the mathemati-cal model for the classification task. The model circuit transformsencoded state | ψ x (cid:105) to another state, say, ψ (cid:48) ( | ψ (cid:48) (cid:105) = U θ | ψ x (cid:105) ).Generally, the model circuit has a layered architecture. Each layercan have identical or dissimilar constructs. A single layer consists ofa parametric and an entanglement sub-layer as shown in Figure 4(b).The parametric sub-layer consists of the parametric single qubit gates( P G ( θ ) in Figure 4(b)). These parameters ( θ ) are updated duringtraining in an iterative fashion. The entanglement sub-layer consistsof multi-qubit gates ( MQ gates shown in Figure 4(b)) which createa dependency between the target qubit and all other qubits in thecircuit. The state preparation and model circuit is executed, the stateof the target qubit is measured, and these execution and measurementoperations are repeated multiple times. The measured distribution isanalyzed in a classical computer to determine the class of a singleinput during inferencing. E. Design Considerations
The selection of gates for the model circuit depends on the avail-able native gates of the target NISQ hardware. For instance, Rigetti 8-Q Agave quantum hardware only supports parametric single-qubitRZ( θ ) operation with a single rotational parameter ( θ ). IBMQX4 andIBMQX2 supports parametric single-qubit U3( θ , φ , λ ) operation with3 rotational parameters. The entanglement is realized by applyingmulti-qubit unitaries on qubits (multi-qubit gates like CNOT or CZ).IBM quantum computers support two-qubit CNOT gates betweenneighbouring qubits and Rigetti 8-Q Agave supports two-qubit CZgates. Tree-like structures ( T T N ) have been proposed for the entan-glement sub-layer as shown in Figure 4(c) [17].
MERA ’s are similarto
T T N ’s, but make use of additional unitary transformations toeffectively capture a broader range of quantum correlations as shownin Figure 4(c) [18]. A CNOT gate between two neighbouring qubitsin entanglement sub-layer in Rigetti hardware is compiled to 6 unitarytransformations resulting in a manifold increase of the depth of themodel circuit. Moreover, the CNOT’s are allowed in limited directionsin hardware such as, IBMQX4 or IBMQX2 which is known as thecoupling constraint (e.g., the directional coupling graph of IBMQX4,Figure 1(a)). If the model circuit has a CNOT gate that violates thecoupling constraint, a swap insertion procedure is executed during thecompilation process to ensure that a desired CNOT operation takesplace between two target qubits which also increases the depth of thecircuit significantly [19]. Higher-depth circuits are more susceptibleto decoherence induced errors which is the prominent source of errorfor qubits with a short lifetime.
Therefore, the entanglement sub-layerstructure should be chosen based on the available native gates andcoupling graph with a goal to minimize the depth of the circuit.
Quantum Circuit Simulator(ideal) Parameters UpdateExpectation value post-processingEvaluationYESNO
Stop Criterion
Save (b) Classical simulator training approach (Ideal)
Quantum Circuit Simulator(Noisy) Parameters Update
Expectation value post-processingEvaluationYESNO
Stop Criterion
Save (c) Training in a classical environment for target noisy quantum hardware
Single/multi-qubit gate errors, T1/T2 time of target quantum hardware
ParameterizedQuantumCircuit (PQC) ProjectiveMeasurement Parameters UpdateReadout post-processingEvaluationYESNO
Stop Criterion
Save
Quantum Hardware Classical Hardware (a) Quantum hardware in the loop (/hybrid) training approach State Preparation
Fig. 5. Training of variational circuits (
P QC ) in, (a) quantum-classical hybridsetup; (b) fully classical setup considering an ideal target hardware; (c) fullyclassical setup for a target noisy hardware.
III. T
RAINING OF
P QC
Training of a model circuit (
P QC , Figure 4(b)) for binary classi-fication can follow three disparate strategies as described below. MQ PG(Ɵ ) PG(Ɵ )PG(Ɵ )PG(Ɵ ) MQ MQ MQ MQPG(Ɵ )PG(Ɵ )PG(Ɵ )PG(Ɵ ) MQ MQ MQ ParametricSub-layer ParametricSub-layerEntanglementSub-layer Entanglement
Sub-layer
Layer 1 Layer 2 (b) Structure of a multi-layer circuit-centric quantum classifier (4-qubits)
Measurement (c) Generic Structures for the entanglement sub-layers (8-qubits)
Tree Tensor Network (TTN) Multi-scale Entanglement Renormalization Ansatz (MERA)
State Prepar-ation Circuit
Two-qubit Unitaries 𝑄 𝑇 (a) Variations in the expectation value of a target qubit with respect to a gate parameter Additional Unitaries
Fig. 4. (a) Variations in the expectation value of a target qubit in a variational circuit with respect to the tunable parameter; (b) generic structure of amulti-layer
P QC for binary classification task; (b) generic structures for the entanglement sub-layers. . Existing Approaches Two classes of
P QC training proposals exist in the literature:i) Train the
P QC in a hardware-in-the-loop fashion. Hereafter,we term this approach as app . In this approach, the P QC isexecuted on a real quantum computer. For a certain input, the outputis measured and then the measured output is post-processed in aclassical computer. Statistical techniques such as, Kullback-Leibler(KL) divergence method is used to calculate the disparity betweenthe target distribution and the measured distribution (hence the cost)to update the parameters with any classical optimization techniquessuch as stochastic gradient descent or particle swarm optimizationetc. [11]–[13]. Then, the
P QC is executed again with updatedparameters and process iterates until measured output matches targetoutput up to a certain threshold. While it may seem to be an idealapproach, the technique is plagued with certain impediments.
First, qubits quality changes over time (Fig. 2) which means that a trained
P QC on a certain day may not show optimal behavior over timedue to qubit specification drift.
Second, the quantum computersare expected to operate in a client-server fashion. Iterative trainingscheme may get prohibitively lengthy. Moreover, unlike classical bitstates, intermediate quantum-mechanical states cannot be saved in amemory for computation at a later stage since the saved states willbe lost due to decoherence.ii) Simulation based training of the
P QC where a model quantumcomputer is simulated (we name it app ). The simulation results inthe expectation value of the result qubit which is then compared withtarget expectation value to calculate the cost. Now, we can definethe following cost-function to iteratively update the parameters ofthe P QC (Figure 5(b)) to solve the binary classification problem(described for the hybrid approach) [6]: J ( θ ) = 1 m m (cid:88) i =1 ( y i − expectation ( P QC ( x i , θ ) : Q T )) (1)where m is the batch-size, y i is the label of the i (cid:48) th data inthe batch (data are labeled as -1 and +1 for class A and class Brespectively), x i is the i (cid:48) th input, and ’expectation(PQC( x i , θ ): Q T )’is the expectation value of the target qubit ( Q T ) for the i (cid:48) th input andcurrent values of the θ . The target is to minimize the cost. Gradientdescent technique is applied to achieve the optimization goal wherethe partial derivatives of the cost function (Equation 1) with respect tothe circuit parameters are calculated using numerical differentiation[20].In this approach, the client need not wait for the server (quantumhardware) to train and get the parameters of P QC . However, thesimulation models an ideal (i.e., without noise) quantum computerwhereas quantum computers are noisy (and noise behavior showstemporal variation) as pointed out in Section I. Therefore, the pa-rameter optimization without considering noise may not give optimalresult during inferencing phase in the real noisy quantum computer.
B. Proposed Approach: Classical Training with Noise Effects
To deal with the noisy hardware related dependency of the trained
P QC , we propose to update the parameters where the expecta-tion values are calculated with modeled noise behavior of a targethardware with our noisy quantum hardware simulation framework(described in Section IV). The cost function remains same as inEquation 1. To address the stochastic behavior of the noise sourcesas evident from Figure 2, we use the average value of the qubitquality metrics collected over a significant amount of time (43 days)to optimize the
P QC parameters. Before averaging, outliers areremoved from the data-set using an interquartile range rule [21]. Weterm this approach as app . It is expected that circuits optimizedwith app will perform better than circuits optimized with app but executed on a different day and app . In Section V will providesufficient evidence behind this claim, both from simulation and realquantum computer. Kraus Operators 𝐸 = 1 − 𝑝 𝐼𝐸 = 𝑝3 𝜎 𝑦 𝐸 = 𝑝3𝜎 𝑧 𝐸 = 𝑝3𝜎 𝑥 Depolarizing Channel
Amplitude Damping 𝐸 = 1 00 𝑝 𝐸 = 0 1 − 𝑝0 0 Phase Damping 𝐸 = 𝑝𝐼 𝐸 = 1 − 𝑝𝜎 𝑧 I is 2 × 𝜎 𝑥 ,𝜎 𝑦 and 𝜎 𝑧 are Pauli X, Y and Z matrices.The operators are defined such that: p = Error probability (for depolarizing channel) but 1 - p = Damping (error) probability (other) Q Q Q E ,E ,E , and E E = I E = I 𝜌 ↦ ℰ 𝜌= 𝑘=0 𝑗=0 𝑖=0
൫൯ 𝐸 𝑖,𝑄0 ⊗ 𝐸 𝑗,𝑄1 ⊗ 𝐸 𝑘,𝑄2 𝜌 𝐸 𝑖,𝑄0 ⊗ 𝐸 𝑗,𝑄1 ⊗ 𝐸 𝑘,𝑄2 † ℰ Extending Kraus operators for multi-qubit case
Considering a test-case with: (a) three qubits, (b) Q1 is undergoing depolarizing channel (maybe, due to a preceding gate operation on that.), (c) no-operation is done on Q0 and Q2, and (d) ℰ () is the Kraus map that translate 𝜌 without noise to ℰ ( 𝜌 ) with noise. Kraus operators can be extended using tensor operation among single qubit Kraus ops.
Fig. 6. Kraus operators for different noise channels and extending Krausoperators for multi-qubit case.
IV. M
ODELING AND S IMULATION S ETUP
A. Modeling of Noisy Quantum System1) Gate Error:
To simulate 1-qubit and 2-qubit gate errors,depolarizing noise channel is applied. Under depolarizing noise, thequbit retains its state with a probability of (1 − p ) (p = probability oferror) and undergoes X (bit-flip), Z (phase-flip) and Z (bit-phase-flip)errors with a probability of ( p/ each.
2) T1 Relaxation:
T1 relaxation is simulated with amplitudedamping channel. Note that the T1 relaxation affects only thestate | (cid:105) (i.e., | (cid:105) → | (cid:105) ) leaving state | (cid:105) invariant. Reported T1times are converted to probability (of no error) using the formula p = exp ( − t/T where t is the time of operation that dependson the gate-time of a particular quantum computing hardware. Forexample, for IBMQX4 quantum computer 1-qubit U2 gate-time isabout ns [22].
3) T2 Dephasing:
T2 dephasing is simulated with phase dampingchannel. Phase damping is a quantum-mechanical phenomenon andtherefore difficult to comprehend intuitively. Mathematically, the off-diagonal elements of a density matrix (representing the qubit state)decay to 0 due to T2 dephasing or phase damping. For example, Bellstate ( ( | (cid:105) + | (cid:105) ) / √ ) is an example of entangled state. If the qubitsin Bell state undergo dephasing then eventually the off-diagonal termsin the density matrix become zero and entangled qubits end up in amixed state. Entanglement is believed to be one of the key propertiesthat fuel quantum computers’ computing ability and dephasing isdetrimental to that. Reported T2 times are converted to probability(of no error) using the formula p = exp ( − t/T where t is the timeof operation.
4) Operator-sum Representation:
To simulate the effect of noiseon the quantum computation, we adopt the operator-sum representa-tion using the appropriate Kraus operators [23]. In this representation,a quantum operation E () , that maps the input state ρ in (in densitymatrix format) to output state ρ out such that ρ in (cid:55)→ E ( ρ in ) = ρ out = (cid:80) k E k ρ in E † k . E k is called the operation element. By choosingappropriate operation elements the operator-sum representation canbe used to compute the output after applying a gate on a qubit.Likewise, if appropriate Kraus operators are chosen as operationelements, the operator-sum representation can be used to simulate theeffect of different errors on a qubit state. In this paper, we emulatethe noisy quantum-processing-units behavior with gate-error and T1relaxation and T2 dephasing with suitable Kraus operators (listed inFigure 6).
5) Simulation Flow:
Figure 7(a) shows the schematic of thePython-based simulation platform. We use modules from Qutip[24] package to execute matrix operations pertinent to quantumcomputation. To simulate the behavior of a real quantum device, thesimulator takes: (i) the input states of the qubits in density matrixformat, (ii) 1-qubit gate error probabilities for each qubit, (iii) 2-qubit4 deal gate 𝜌 𝑖𝑛
1q and 2q gate error probabilities T1, T2 and gate times Quantum program in native gate-setGate
Error(d.c.) T1 error(a.d.) T2 error(p.d.) 𝜌 𝑜𝑢𝑡 (w/noise) Eigen-
Decomposition
Python -based simulatorRepeat until end of quantum program d.c. = depolarizing channel, a.d. = amplitude damping, p.d. = phase damping
Expectation value calculator (⟨𝜓 𝜎 𝑧 𝜓⟩) Fig. 7. (a) Diagram of the simulation platform and the program flow; (b) 8Qand modeled 9Q-square architecture.Fig. 8. Comparison between fidelities from the simulation model andIBMQX4 real device. gate error probabilities for each allowed qubit pair, (iv) T1 relaxationtimes, (v) T2 dephasing times, (vi) 1-qubit and 2-qubit gate timesand, (vii) a quantum program compiled with native gate-sets of aspecific hardware. We primarily used IBMQX4 quantum processingunits reported specifications [22]. However, it can simulate anotherquantum processor (e.g., Rigetti ASPEN) if appropriate items (ii) -(vii) are fed.The simulator reads the quantum program and executes each gateinstruction. First, an ideal gate is applied to the qubit states followedby the errors in the sequence gate error, T1 and T2 error. Thereal quantum device (e.g., IBMQX4) reports amplitudes of purestates as the output. However, the simulator outputs a density matrix( ρ out ) which contains the result in a possible mixed state. Therefore,the output density matrix is then eigen-decomposed with pure statevectors as eigenvectors. The resulting eigenvalues are the amplitudesof each pure state. For example, if you consider a 2-qubit system,it has 4 possible pure state vectors ( ψ ) i.e. | (cid:105) , | (cid:105) , | (cid:105) and | (cid:105) (each vector is × ). If λ is the eigenvalue, then solving ρ out . | ψ (cid:105) = λ. | ψ (cid:105) will give λ and this operation is the eigen-decomposition. The operation has to be repeated for all the pure statevectors (4 in this case) to get all the corresponding eigenvalues (purestate amplitudes). Finally, decomposed state vectors are fed into theexpectation value calculator to calculate the expectation value of aqubit ( (cid:104) E (cid:105) = (cid:104) ψ | σ z | ψ (cid:105) ).To validate the model, we simulated the 4-layer IRIS classifier(Fig. 13) as the test circuit using our model with IBMQX4 [22] specsand the program compiled in IBM native gate-set. The same circuitwas executed on IBMQX4 on the same day to get real device results.The comparison between model data and real-device data is shown inFigure 8 (IBMQX4 probability of correct output = correct trials/totaltrials) for 12 different inputs. The model exhibits an average error ofabout ≈ . . B. Validation Setup1) Data Sources:
In order to validate the effectiveness of ourproposed training methodology, we have picked, i) 4-bit parityclassification problem (which can be also thought of as a high-fidelity4-qubit parity gate realization problem using
P QC [10]) with 16known inputs/outputs combinations with two output classes (evenand odd parity), and, ii) iris classification which is probably the best- known database in pattern recognition literature. The iris data-setcontains three different classes (Setosa, Versicolour, and Virginica)of 50 samples per class. Each sample has four distinct features. Toconvert the iris classification problem into a binary classification task,we have selected 100 samples from Setosa and Versicolour classes.
2) Evaluation Method:
Although parameterized quantum circuitscan minimize the effects of noise, it cannot suppress it altogether.Therefore, the expectation values cannot be optimized to exactly-1/+1 values for all the inputs during the
P QC training periodwhich indicates that a measurement is not guaranteed to result inthe desired class output (0/1) for a certain input. Thus, the samecircuit is executed multiple times (known as shots in IBMQX) andthe target qubit is measured in each trial to get a distribution orratio of 1s to 0s in the output. For binary classification, a large ratioe.g., > <
1) indicates the input belongs to the class representedby logic ’1’ (’0’).
Example:
A trained parity classifier is executed1024 times on 4-qubits ( Q Q Q Q ) of IBMQX4 with input state Q Q Q Q = 0100 (note the input has odd number of 1s i.e. odd-parity) with Q being the result/target qubit. The execution resultedin a distribution of ‘000 ’: 762 times and ‘000 ’ 262 times. Theratio of 1s to 0s of the target qubit is 0.34 ( < ) which indicatesclass belongs to logic ’0’ or odd parity (alternately, correct output‘0’/incorrect output ‘1’ = 2.9 > ). In an ideal noise-less quantumcomputer, this ratio of 1s to 0s would have been 0. However, a classdecision cannot be taken with confidence when the ratio is closeto 1. In a series of measurements, the goal is to get a high ratiovalue between the correct and the incorrect outputs from a noisydevice. The ratio between the correct and incorrect outputs is also arepresentation of the fidelity of the circuit.
It is to be noted, all the circuit examples presented in this paperhas two phases: (i) parameter optimization phase or the trainingphase and (ii) execution phase or the result phase. We propose aheuristic approach for parameter optimization or training and showthe effectiveness of our method by getting more optimal resultscompared to existing approaches (Section III-A) in the executionphase. V. R
ESULTS AND D ISCUSSIONS
A. Test-circuit: Parity Classifier
The 4-bit binary inputs for the parity classification is encoded tofour qubits using the basis encoding scheme (Section II). Parametric U θ, φ, λ ) gates of IBMQX4 have been used as the parametricgates of the model circuits. The ‘0’ outcomes (odd parity), and ‘1’outcomes (even parity) have been labeled as +1 and -1 respectivelyfor training based on Equation 1 using stochastic gradient descent( SGD ) technique.We have performed the parameter optimization of the modelcircuits using three different strategies, app , app and app described in Section III and tested the performance of the optimizedcircuits in both real quantum computer, IBMQX4 and in simulation.The cost (m = 16 in Equation 1) over the entire input data-setduring the training period ( app and app ) is shown in Figure10(a)&(b). TTNP2L and TTNN2L stand for the cost of two-layerTTN architectures during training for target ideal( p ure) and n oisyhardware respectively. However, it is to be noted that we adopteda simulated hardware-in-the-loop approach to mimic app due to Q B Q A Q C Q D Q B Q A Q C Q D Q A Q B Q C Q D Q A Q B Q C Q D Q A Q B Q C Q D Q A Q B Q C Q D TTN Direct Mappings on IBMQX4 ALT Direct Mappings on IBMQX4 Ψ Ψ Ψ Ψ U ( 𝜽 ,𝝓 ,𝝀 )U ( 𝜽 ,𝝓 ,𝝀 ) U ( 𝜽 ,𝝓 ,𝝀 )U ( 𝜽 ,𝝓 ,𝝀 ) ParametricSub-layer EntanglementSub-layerLayer 1 Ψ Ψ Ψ Ψ U ( 𝜽 ,𝝓 ,𝝀 ) U ( 𝜽 ,𝝓 ,𝝀 )U ( 𝜽 ,𝝓 ,𝝀 )U ( 𝜽 ,𝝓 ,𝝀 ) Parametric
Sub-layer EntanglementSub-layerLayer 1TTN Layer Architecture Alternate Layer Architecture (ALT) 𝑄 𝑇 𝑄 𝑇 (b) (c) Q B Q A Q D Q C Ψ Ψ Ψ Ψ Pauli-X/IdentityGatesState
Preparation
Circuit (a) (e) (f)(d)
Coupling Graph of IBMQX4
Fig. 9. Parity classifier: (a) state preparation circuit, (b) single-layer TTNstructure, (c) single-layer ALT structure.
NISQ computer with ournoisy quantum computer simulation framework (described in SectionIV) and use the error specifications of a respective day to optimizethe
P QC parameters.Note that we have used only 100 iterations of
SGD for all thecircuits over all the training approaches. The terminal cost, in theparameter optimization or training phase, after 100 iterations aresmaller for app (as evident from Figure 10). However, it doesnot indicate that the trained P QC ’s would perform better than theones from app in the execution phase as the noise characteristicsof the real hardware has not been taken into consideration during theoptimization procedure for app . In following paragraphs, we showthat on a real device app will always outperform app which issubstantiated with experiments on a real quantum computer. (a) (b) Fig. 10. Training cost curves over entire parity classifier inputdata-set for (a) app (TTNP1L,TTNP2L,ALTP1L,ALTP2L), (b) app (TTNN1L,TTNN2L,ALTN1L,ALTN2L),. Fig. 11 reports the performance (ratio of correct to incorrectoutputs) of a binary classifier circuit with 1-layer TTN topology(Fig. 9) on IBMQX4. The
P QC generated from the app approachperformed best in terms of the ratio of the correct and incorrectoutcome over 1024 repeated measurements on the given day (theday on which the parameters were optimized) as evident from Figure11 (TTN Noisy). The average of the ratios (TTN Noisy) was found4.92. However, when the same circuit is executed on a differentday ((TTN NoisyDD in Figure 11)), it shows random behavior withsubstantially degraded performance in some cases (average of theratios: 4.02). This trend validates one of our argument against app stated in Section III i.e. parameters optimized at one time may notbe optimal at a different time. The optimized circuit for the app approach performed poorly(average of the ratios: 3.45) over the entire input data-set (TTN Purein Figure 11). From the figure, it is evident that the circuit optimizedwith app consistently gives better performance than TTN Pure andTTN NoisyDD corroborating our claim in Section III. The ratio ofthe correct and incorrect outcome for all possible inputs are signifi-cantly higher (average of the ratios: 4.31) for the app approach. Itis to be noted TTN Pure, TTN NoisyDD and TTN NoisyAvg dataare collected on the same day from IBMQX4.We further substantiate our claim through simulation with the realhardware being substituted with our NISQ computer simulator inSection IV. Two topologies of the parity classifier model circuits( T T N and
ALT ) have been chosen as shown in Figure 9(b)&(c) bothof which satisfies the coupling graph of the IBMQX4 hardware shownin Figure 1(a). For each topology, both single-layer and double-layerflavor is simulated i.e. a total of 4 test circuits are simulated. Thecircuits are optimized with app (TTNP1L, TTNP2L, ALTP1L, andALTP2L) and app (TTNN1L, TTNN2L, ALTN1L, and ALTN2L)to show the superiority of the proposed approach app .Figure 12 shows the aggregate actual cost over the entire in-put data-set for the trained P QC ’s ( app - TTNP1L, TTNP2L,ALTP1L, ALTP2L and app - TTNN1L, TTNN2L, ALTN1L,ALTN2L) for a set of qubit quality metrics data (error specification)of IBMQX4 collected over a 43 days period. The cost here canbe interpreted as a measure of the difference between the ideal(expected) result and the result with noise. The lesser the cost thecloser the result is to expected. The actual cost for the app is U ( 𝜽𝜽 , 𝝓𝝓 , 𝝀𝝀 )U ( 𝜽𝜽 , 𝝓𝝓 , 𝝀𝝀 )StatePreparationCircuitI 𝑈 Z TTN_PureTTN_NoisyTTN_NoisyDDTTN_NoisyAVG
Fig. 11. Ratio of correct and incorrect outputs from 1024 samples for differ-ent inputs for different training approaches collected from IBMQX4 hard-ware (app01 → TTN Noisy, app02 → TTN Pure, app03 → TTN NoisyAVG,TTN NoisyDD is the optimized
P QC in app01 executed on the targethardware in a different day). consistently smaller than the app . For instance, the average costover the entire input data-set for the 43 days period for TTNP1L( app ) is 0.042 which is 23.53% larger than the average cost (0.034)for TTNN1L( app ).Thus, both real computer experiments and simulations support ourproposed P QC parameter optimization technique considering thenoise in real
NISQ devices. We later executed the optimized
P QC ’sfor app (TTNP1L,TTNP2L) and app (TTNN1L,TTNN2L) onIBMQX4 for 100 different times with randomly chosen inputs (1024shots per time) and the cumulative probability ( CP ) distribution ofthe ratio’s of the correct/incorrect outputs ( r ) are shown in Figure15. The higher ratio values for any given cumulative probability for app (e.g. TTNN1L → r = 5.24 for CP = 0.6) than app (e.g.TTNP1L → r = 4.36 for CP = 0.6) in Figure 15 substantiate ourprevious claim that the app optimized P QC (cid:48) s would outperform app on a target quantum hardware. The average value of r for allthe app P QC ’s were found to be 21.91% higher than app forthe TTN parity classifiers. (a) (b) Fig. 12. Cost over the entire parity classification data-set over 43 differentset of values of the qubit quality metrics of IBMQX4 for, (a) TTN structures;(b) ALT structures.
B. Test-circuit: Iris Classifier
We prove our proposal with few more test circuits from IRISclassifier category (Fig. 13). The state preparation circuit has beencoded according to the amplitude encoding scheme presented in [25].We have decomposed the controlled Y-axis rotations to native gatesavailable on IBMQX4 [26]. The four classical features in a single irissample are normalized (x[0:3]) as in Section II-C and then used tocompute the angles ( A ,..., A ) of the state preparation circuit shownin Figure 13(a).6 A Q B A Q B A Q B A Q B A Q B A Q B Ψ Ψ (a) State Preparation Circuit U (A ,𝟎,𝟎 ) U ( 𝑨 ,𝟎,𝟎 ) U (A ,𝟎,𝟎 )U ( 𝝅,𝟎,𝝅 ) U ( 𝑨 ,𝟎,𝟎 ) U ( 𝑨 ,𝟎,𝟎 )U ( 𝝅,𝟎,𝝅 ) (b) Model Circuit (PQC) Q B Q A U ( 𝜽 ,𝝓 ,𝝀 )U ( 𝜽 ,𝝓 ,𝝀 ) U ( 𝜽 ,𝝓 ,𝝀 )U ( 𝜽 ,𝝓 ,𝝀 ) Layer 1 Layer 6 Ψ Ψ Measurement 𝑄 𝑇 (c) Available Direct Mappings on IBMQX4 Entanglement
Sub-layerParametricSub-layer EntanglementSub-layerParametricSub-layer
Fig. 13. Iris classifier: (a) state preparation circuit, (b) the model circuit(
P QC ), (c) available direct mappings on the target IBMQX4 hardware. (a) (b)
Fig. 14. Iris classifier: (a) cost curve over the entire dataset during trainingin app (IRISP4L,IRISP6L) and app (IRISN4L,IRISN6L), (b) cost over43 set of values of the qubit quality metrics of IBMQX4. β = 2 arcsin x [1] (cid:112) x [0] + x [1] , β = 2 arcsin x [3] (cid:112) x [2] + x [3] β = 2 arcsin (cid:112) x [2] + x [3] (cid:112) x [0] + x [1] + x [2] + x [3] A β , A − A − β / , A − A − β / (2)The model circuit is composed of multiple layers of parametric U θ, φ, λ ) gates and CNOT gates shown in Figure 13(b). We haveused two different flavors of the model circuit (4 layers and 6layers) for validation. The circuit has 6 direct mappings availableon IBMQX4 which is shown in Figure 13(c). The samples in theSetosa and Versicolour classes are labeled +1 and -1 respectively fortraining the model circuit.The training is done based on the app (IRISP4L, IRISP6L) andthe app (IRISN4L, IRISN6L) approach with mini-batch gradientdescent optimization scheme (batch size = 5 in Equation 1). The costcurves during the training (100 iterations) are shown in Figure 14(a).In Figure 14(b), we have shown the actual cost (calculated usingour noisy hardware simulation framework) over the entire data-setfor 43 days of data of the qubit quality metrics of IBMQX4. Theactual cost has been consistently smaller for the app approach asevident from Figure 14(b). The average cost over the 43 sets of datafor IRISP6L ( app ) has been found to be 0.56 which is 21.7%larger than the average cost (0.46) for IRISN6L ( app ). We haveexecuted the trained P QC ’s on IBMQX4 hardware for the entire irisdataset and the resulting cumulative probability of the ratio’s of thecorrect and incorrect outputs are shown in Figure 15. The ratio valuesfor app (IRISN4L,IRISN6L) are considerably higher than app (IRISP4L,IRISP6L) for similar values of the cumulative probability.The average value of r for all the app P QC ’s was found to be42.5% higher than app for the iris classifiers.VI. C ONCLUSIONS
We presented the shortcomings of current training approaches forparameterized quantum circuits (
P QC ) and proposed a fully classicaltraining methodology for target
NISQ hardware to address theimpact of temporal variations in qubit quality metrics. We presenta simulation framework to model the circuit behavior on a targetnoisy quantum hardware. We validate our proposed solutions throughcomprehensive simulations and experiments on a real quantum device
Fig. 15. Cumulative density function of the observed ratio’s between thecorrect and incorrect outputs for trained
P QC ’s ( app and app ) onIBMQX4 (100 observations per P QC with randomly chosen inputs and 1024shots per observation). (IBMQX4) of two quantum classifiers built with
P QC . The proposedmethodology can improve the performance of any
P QC basedquantum application on a target
NISQ hardware.R
EFERENCES [1] E. Farhi et al. , “A quantum approximate optimization algorithm,” arXivpreprint arXiv:1411.4028 , 2014.[2] A. Kandala et al. , “Hardware-efficient variational quantum eigensolverfor small molecules and quantum magnets,”
Nature , 2017.[3] J. Romero et al. , “Quantum autoencoders for efficient compression ofquantum data,”
Quantum Science and Technology , 2017.[4] P.-L. Dallaire-Demers et al. , “Quantum generative adversarial networks,”
Physical Review A , vol. 98, no. 1, p. 012324, 2018.[5] Y. Du et al. , “The expressive power of parameterized quantum circuits,” arXiv preprint arXiv:1810.11922 , 2018.[6] M. Schuld et al. , “Circuit-centric quantum classifiers,” arXiv preprintarXiv:1804.00633 , 2018.[7] E. Farhi et al. , “Classification with quantum neural networks on nearterm processors,” arXiv preprint arXiv:1802.06002 , 2018.[8] N. Killoran et al. , “Continuous-variable quantum neural networks,” arXivpreprint arXiv:1806.06871 , 2018.[9] J. Romero et al. , “Variational quantum generators,” arXiv:1901.00848 ,2019.[10] K. Heya et al. , “Variational quantum gate optimization,” arXiv preprintarXiv:1810.12745 , 2018.[11] D. Zhu et al. , “Training of quantum circuits on a hybrid quantumcomputer,” arXiv preprint arXiv:1812.08862 , 2018.[12] V. Leyton-O. et al. , “Robust implementation of generative modeling withparametrized quantum circuits,” arXiv preprint arXiv:1901.08047 , 2019.[13] M. Benedetti et al. , “A generative modeling approach for benchmarkingand training shallow quantum circuits,” arXiv:1801.07686 , 2018.[14] J. Otterbach et al. , “Unsupervised machine learning on a hybrid quantumcomputer,” arXiv preprint arXiv:1712.05771 , 2017.[15] E. Knill et al. , “Randomized benchmarking of quantum gates,”
PhysicalReview A , vol. 77, no. 1, p. 012307, 2008.[16] M. Schuld et al. , “Quantum machine learning in feature hilbert spaces,”
Physical Review Letters , vol. 122, no. 4, p. 040504, 2019.[17] W. Huggins et al. , “Towards quantum machine learning with tensornetworks,” arXiv preprint arXiv:1803.11537 , 2018.[18] L. Cincio et al. , “Multiscale entanglement renormalization ansatz in twodimensions: quantum ising model,”
Physical review letters , 2008.[19] A. Zulehner et al. , “An efficient methodology for mapping quantumcircuits to the ibm qx architectures,”
IEEE TCAD , 2018.[20] M. Schuld et al. , “Evaluating analytic gradients on quantum hardware,” arXiv preprint arXiv:1811.11184 , 2018.[21] G. Barbato et al. , “Features and performance of some outlier detectionmethods,”
Journal of Applied Statistics , 2011.[22] I. B. M. Corporation. Ibm q experience. [Online]. Available:https://quantumexperience.ng.bluemix.net/qx/editor[23] K. Kraus, “States, effects, and operations: Fundamental notions ofquantum theory,”
Springer-Verlag Berlin Heidelberg , 1983.[24] J. J. et al., “Qutip 2: A python framework for the dynamics of openquantum systems,”
Computer Physics Communications , 2013.[25] M. Mottonen et al. , “Transformation of quantum states using uniformlycontrolled rotations,” arXiv preprint quant-ph/0407010 , 2004.[26] M. A. Nielsen and I. Chuang, “Quantum computation and quantuminformation,” 2002., 2004.[26] M. A. Nielsen and I. Chuang, “Quantum computation and quantuminformation,” 2002.