{'fraction_non_alphanumeric': 0.02727775146060319, 'fraction_numerical': 0.010263698089373125, 'mean_word_length': 4.329896907216495, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Automated Test Pattern Generation for Quantum Circuits

This work extends a general method used to test classical circuits to quantum circuits. Gate internal errors are address using a discrete fault model. Fault models to represent unwanted nearest neighbor entanglement as well as unwanted qubit rotation are presented. When witnessed, the faults we model are probabilistic, but there is a set of tests with the highest probability of detecting a discrete repetitive fault. A method of probabilistic set covering to identify the minimal set of tests is introduced. A large part of our work consisted of writing a software package that allows us to compare various fault models and test strategies for quantum networks.


INTRODUCTION
Quantum information theory approaches computation by thinking of all physical phenomena as computations, with each measurable outcome of a computation as a system observable [1]. The past quarter century fostered an electronics revolution-with the most recent strides enabling the control of bi-state particles that can be used to represent bits of information [2]. The laws of quantum mechanics predict computational devices leading to speed increases over their classical counterparts [3]. Quantum system reliability is a very real problem [4]. Likewise, system verification has recently received quite a bit of attention [5]. Just as the EDA (Electronic Design and Automation) community began to dominate the testing of classical circuits around the 1960's [6], this paper begins to extend these classical test methods to quantum circuits. The reason it has taken so long to adapt classical testing methods to quantum circuits is because of the difference from classical test.
Currently experimental physicists have only begun to experience a need to research optimized testing methods due to the small qubit (quantum bit) count of current quantum circuits [7]. Much like in the early days of classical logic, experimentalists test using a process known as state tomography [8]-essentially brute force-where the number of tests is supper exponential in the number of qubits. In this work we consider quantum circuits that implement binary gates and oracles-we concern ourselves with the logical testing of quantum circuits. This means that we will inspect the logical data processed by the quantum network and compare this data with expected values allowing us to make a judgment on a circuit's logical functionality-after all we measure only binary information from a qubit even though its quantum modes of operation reside in the vastness of Hilbert Space.
The relatively slow rate of progress realizing quantum circuits causes some to consider our idea of fast testing a bit premature. On the other hand, we can say that in NMR it takes months to fine tune the sequence of pulses necessary to implement a simple universal gate to function properly [9], and much of this time is spent testing. Therefore, improvements over current testing methods would foster development towards a quantum information processing system.
Classically test set generation relies on a fault model, this means that you limit the errors to those that are most likely. In this work, we consider internal quantum gate faults such as unwanted qubit rotations and unwanted entanglement. In practice, the choice of the fault model will be determined by a particular quantum Biamonte, Jacob D.
circuit technology, but our model is general enough to cover a wide range of fault types. Often faults in quantum circuits are constant in space and time [10], this could be thought of as a presence of an unwanted field. However to simplify our approach in this introductory work, we limit our discussion to discrete faults occurring in the timed operations forming a quantum circuit. Faults other than local decoherence have been studied recently. Kak [11] addressed the problems in initialization of quantum computers, Shenvi et al addressed the Grover search under the impact of noise [12], and Bettelli modelled the impact of non-ideal operations on decoherence [13].
We proceed now to Section 2 where we present the necessary background in quantum mechanics to read the paper. This is followed by Section 3 where the error models and fault table generation method is presented. In Section 3.1 our method to generate test plans based on a given quantum fault table is presented, this is followed by Section 3.2 where our set covering algorithm is formalized. Section 4 concludes the paper by a discussion of the validity of this approach based on the data generated by QuFault, our quantum test set generation software package. In this paper we often omit normalization factors and represent |+ as |0 + |1 and |− as |0 − |1 for clarity.

BACKGROUND
In quantum computing the bi-state subatomic-particles used to store data are called qubits. Just like in classical computing, information is processed by gates, however in most quantum computing architectures a gate is an operator that acts on the state space of a system, an example of such an operator is an electromagnetic pulse in NMR [8]. This can become confusing to the electrical engineer who thinks of gates as those occupying space, with information represented by that of a signal acted on in the course of time. In quantum computing however, gates act on qubits that contain information and occupy space. A qubit takes continuous values in space with time, making information processing capabilities with qubits intriguing as one can place a single qubit in a superposition of classical states. Yet when a qubit is measured, its complex state is destroyed leaving the system in a single eigenstate, and returning an eigenvalue of an observable. The gates in quantum computing are represented as unitary operators, and the state of a quantum circuit is described as a unit vector in a Hilbert Space.
To define a qubit one must specify an orthonormal vector space to both describe the system, and give reference to measurement operations. The state of a single qubit is represented as a point on the sphere (for pure states) formed in a Hilbert space of 4 dimensions. We can make a measurement along our choice of the orthonormal x, y or z axis. The outcome of a measurement will be plus or minus one, the eigenvalues of an observable. The z axis is what is known as the computational basis, and is generally implied when communicating ideas about quantum computing, like when we describe the state of the following system: |Ψ = α |0 + β |1 , where |0 = (1 0) T and |1 = (0 1) T . The weights alpha and beta combined with the Eigenstates |0 and |1 form an orthonormal basis, where αα * + ββ * = 1. The x axis (Also known as the plus minus basis) is used sometimes in quantum computing to describe qubits. Typically the plus minus basis is denoted as |+ and |− . One can express this new basis in terms of the computational basis as, |+ = |0 +|1 If we examine Equation 1 in more detail we will notice that a qubit has what is called both amplitude and phase -where the e −φ term represents the qubit phase. The amplitude corresponds to the probability of measuring the system to be found in a given eigenstate. In the computational basis we can not detect phase, and furthermore an operator acting on a qubit will rotate the phase based on the eigenvalues of the operator. However, phase can be detected from the plus minus basis, and we note that phase is imperative in quantum algorithms [8].
The operators given in Equations 9, 10 and 11, from a basis space for measurement, as well as gates that preform unitary evolution in quantum computing. When we substitute values of θ = 2π into Equations 9, 10 and φ = 2π into Equation 11 we obtain what is known as the Pauli matrices given in Equations 2, 3 and 4.
Observe, that the eigenvalues of each of the Pauli matrices are plus or minus one and that each eigenvector can represent an axis of a Hilbert Space used to describe a single qubit. The size of the Hilbert space used to represent the state of any quantum system expands dimensionally via the tensor product [14]. The state space of an n qubit quantum computational system corresponds to 2 n dimensions, and a given state vector in that space can be in 2 n different states at any given time, where a classical computational system can reside in only a single state. Linear combinations of the Pauli Matrices can be used to create other useful gates, such as the Hadamard gate whose unitary matrix is given in Equation 5.
We now have the building blocks needed to represent simple quantum computations. To represent a quantum computation we must initialize a qubit into a certain state before we act on that qubit to process information. For example, typically we rotate the state of a qubit such that it will be "+1" in the computational basis before computation. In other words the state of our system is described as |Ψ = |0 and the inner product between the positive z axis and the state of our qubit is the unit value " + 1". After we initialize our qubit we can act on it with a Hardmard operation, such as: This operation mapped our system into what is known as a superposition of states, both possible eigenstates in time. We can now use projective measurement and project the state of our system onto the computational basis using the σ z observable. We can calculate the expectation value of this observable as follows: Biamonte, Jacob D.
This means that if we measure our system from the computational basis infinitely many times we will get value "+1" half of the time and value "-1" the other half of the time and the average is 0. If we instead made a measurement of the expectation value of the σ x observable we would have obtained the following, The measurement outcome is what is referred to as 'sharp' in σ x since it will always yield value +1.
This section concludes the provided background information on quantum computation. It is designed as an overview but we refer the reader to [1], as well as [14] and [8] for more depth of subject coverage.

MODELLING ERRORS
Traditionally the Test Generation Problem is thought of as the generation of a sequence of tests (test set), that when applied to a circuit and compared with the circuit's output, will determine that the circuit is correct or will determine that it contains one or more faults [15]. In other words, testing is the checking of functionality, and running the ideal test set amounts to sufficient system verification with the smallest possible number of tests [6].
For simplification, in this paper we assume what is called in binary testing the single fault model [6], where only one fault is allowed in the entire circuit. In classical test you first determine what output the circuit should generate under certain conditions and then find out what the circuit generate if certain errors were present, such as output a |001 instead of a |101 ten percent of the time with input vector |000 . In this work we consider 'what if ' cases, where a model of the error is placed into a circuit and the new erroneous output is calculated and stored-for later comparison. We then use software to find the smallest set of tests that can detect these errors to a certain level of validation, referred to as . For the quantum case this table contains fractions that represent probabilities of different outcomes, as will be seen in section 3.1. To that order, we must distinguish between a probabilistic fault and a deterministic fault that is observed probabilistically. When we wrote this paper we coined these faults "quantum faults" in order to better distinguish them from their classical counterparts.
The Hamiltonian of the spin system that models Ising type interactions is given by,Ĥ = i,α α iα σ iα + i,j J ij σ iα σ jα . The spin Hamiltonian governs the ideal operation of a quantum circuit. It contains a term for individual bitwise operations, R i,α (θ) = e − φ 2 σ iα and an interaction (Ising term) J ij (φ) = e − φ 2 σ iα σ jα to allow entanglement between qubits. Similar forms of this equation are relevant for any quantum computer. For our purposes, in the time dilation of pulses governed by the Hamiltonian, we assume an additional term representing a small error. The resulting impact in the presence of this error manifests its self in the form of changing the probability amplitudes of the possible outcomes, thus there is an altered chance for a particular outcome in measurement. A fault present in the state vector representing the system takes one of two forms, the first being the observation or (measurement/detection), and the second being the lack of observation.
Another difficulty detecting errors in quantum circuits is due to an error in the phase of the qubit. In the computational basis we can not detect phase because the eigenvectors of phase errors are the eigenvectors of the computational basis. The eigenvalues of a fault impacting the phase of a qubit will rotate the phase based on the eigenvalues of the fault. The interesting fault model of gate removal originates from Hayes et al who applied it to remove entire gates such as Toffoli gates in reversible circuits [16]. We believe however that this model is more adequate to single pulses and not gates composed of many pulses. Thus, a permutation circuit can become non-permutating as the result of a fault. The fault model presented here assumes that the machine is firing pulses, and that these could contain errors themselves, or another unwanted interaction changes the state of a qubit. The impact these faults have on the state of a qubit must be below a bound that is acceptable if the machine is going to function as expected. For example, a short or long pulse or a refocusing error in NMR can result in unwanted qubit rotations. This fault can be modelled in the simplest terms with a single qubit rotation operator about the x, y and z axis. If we consider the circuit shown in Figure 1 as a sequence of stages with each Biamonte, Jacob D.
stage defined as a gate that does not commute with both nearest neighbors, then the circuit shown in Figure 1 has 5 stages. We can assume certain faults between any of the stages or internal to the stages themselves in the circuit, in Figure 1 the locations of possible faults are represented by placing an " × " on the wire. Figure 1. Toffoli gate made with smaller gates, the next level below this is machine dependent pulses. For a better explanation of this gate we refer the reader to [8].
We model the faults impacting the gate shown in Figure 1 by replacing each " × " with a fault model represented by a matrix. The circuits transfer matrix is then recalculated and stored for later comparison. We calculate the probability outcomes for all inputs of a good circuit based on the unitary transfer matrix of a circuit, we then store this in the fault table. For each fault model in our library and for each " × " in the circuit, we insert the matrix representing the fault in place of the " × " and recalculate the transfer matrix of the circuit. We then store the difference in the probabilities of the correct circuit response for a given input and the altered circuit response under a given fault. We find the input test set that reveals these faults with the highest probability using the probabilistic set covering method from Section 3.1. This method is general enough to work with many fault models. Quantum error correcting codes are typically designed to correct from insertions of the gates given in Equations 9, 10 and 11. This fault model has been used by [12] as well as several other papers.
We can also use the tensor product to expand any number of these single bit operators to show a simple case where a fault spreads out and impacts other bits in the circuit. The table shown in Figure 2 was generated using the fault models given in Equations 9, 10 and 11. Repeating rows and columns were grouped for clarity, and |+ = |0 + |1 and |− = |0 − |1 . Each entry in the table corresponds to the probability of detecting a given fault represented by Column label f n . Equations 9, 10, and 11 correspond to single bit rotations. The angle of this rotation is given as θ in Equations 9 and 10 and φ in Equation 11. So if we we can represent the margin of error as some ε, we observe that |θ| 4π = ε 100 , and solving for θ gives us, θ = ±επ 25 . If ε is substituted into Equations 9, 10 or 11 than it can be thought of as a margin or percentage of error. For the Toffoli gate shown in Figure 1, we set ε to be 25, and then we use our software package QuFault to generate the fault table from Figure 2.

Input
Test

GC is the operator corresponding to a faultless circuit, BC is the operator corresponding the the impact of a given fault. Each entry in the fault table is the magnitude of the difference between GC and BC.
To detect phase errors we need to use inputs of type: |+ = |0 + |1 and |− = |0 − |1 . One of the more interesting fault models that we used in this study represents unwanted amounts of entanglement. This fault model given in Figure 3 can model both the addition of unwanted entanglement and the removal of wanted entanglement. The amount of entanglement (the tangle τ ) can be determined and adjusted using the Haar measure. the Haar measure is a well known metric used to calculate entanglement discussed in any advanced text on quantum mechanics. In Figure 4 we present a fault table generated by QuFault using unwanted entanglement as the fault model, in this case the Haar measure was set to τ = 1, or maximum tangle. Input Test   Figure 3. Here the values of θ = π/2 and φ = π making Figure 3 become the well known operator used to create Bell states.

Quantized Set covering
Because of the fractions that occur in quantum fault Tables 2 and 4, it is clear that traditional set covering will not work. In order to detect the greatest number of faults with each test, we must introduce a new kind of set covering.
We represent by a n an entry in the quantum fault table, it represents the probability that given row (test) covers given column (fault), 0 ≤ a n ≤ 1. It is clear that the traditional set covering problem of a fault table is a special case where ∀a n , a n ∈ {0, 1} n . The quantum set covering problem is now formulated differing from the classical case with the addition of positive fractional entries, arising from the nature of quantum measurement. This modification in problem formulation makes the concept of full coverage in general not achievable for testing quantum circuits, unless we specify a bound used as an accuracy cut off. Given the Table from Figure 5, for every selected set of rows one can calculate the probability of detecting fault f a . Assume that rows T a , T a+1 and T a+2 have been selected as a (quasi)-solution to the probabilistic set covering problem being a sub-problem of quantum set covering. Then the probability of detecting fault f a is P (f a ) = P (a 1 ) + (1 − P (a 1 )) · P (b 1 ) + (1 − (1 − P (a 1 )) · (1 − P (b 1 )) · P (c 1 ). If the probability of detecting fault f a is above a certain "accuracy level" for each column, then the set of tests is a solution. If not, one can select other tests or repeat some tests T j k times to increase the probability until we reach the desired assurance. Assume that in column f r only test T 1 has entry higher than 0, and that this value is 3/4 . Observe that by repeating this test three times we get the probability P (f r ) of detecting fault f r defined by P (f r )= 3 4 + 1 4 · 3 4 + 1 4 · 3 4 · 3 4 = 3 4 + 15 64 . We increased thus the fault detection probability by 15/64 by repeating the test three times. The techniques presented above are used in quantum set covering. In many cases the quantum fault table has a high percent of columns with "1's" thus can be highly reduced by using classical set covering approaches based on dominance and equivalence [6].
T n P (n 1 ) P (n 2 ) P (n 3 ) P (n n ) Figure 5. Arbitrary Fault Table with Columns as faults and Rows as tests and entries representing the probability of a given test detecting a given fault.

Quantum set covering formulation
The Quantum Set Covering Problem is formulated as follows. Given is a covering table in which rows correspond to tests and columns to faults. The value p in the entry on the intersection of the row R and column C means that test R detects fault C with probability p. Value 1 in the entry on the intersection of row R and column C means probability 1 or that R is a deterministic test for C.  c(n − 1)) · a n . Definition 1. Two tests (rows) R i and R j of a Quantum Fault Dominated rows can be removed. In a group of equivalent rows, all but one can be removed. The algorithm below takes into account the "row equivalence" and "row domination" defined as Definition 1 and Definition 2 above, differing Biamonte, Jacob D. from standard set covering algorithms. The classical set covering algorithm is a special case of quantum set covering, thus the Definitions 1 and 2 still hold for standard set covering, but not vice versa.
Definition 3. Assurance of column C j with respect to set RR of rows is the sum of products of probabilities c ij (n) taken for all rows R j from RR (as illustrated in 3.1 for P (f a ) for rows T a , T a+1 and T a+2 .) The "achieved assurance" of a column is the assurance for the set R of rows selected to the solution. The total assurance is the sum of achieved column assurances calculated for all columns and for the set of selected rows from the solution (including the rows selected at stages 1-3 of the algorithm below). Our heuristic greedy algorithm to solve the Quantum Set Covering Problem applied to the original Fault Table (Table S1) is as follows.
Quantum Set Covering Algorithm: Start from a given Quantum Fault Table S1.
1: Remove all dominated rows and select one row in each group of equivalent rows. Create Table S2.
2: Find a solution SOL1 (using any known set covering algorithm) to the subset of the table composed of all columns that have at least one "1" in them and their respective rows. Remove from Table S2 the rows from SOL1 and columns that are covered in SOL1. Remove dominated rows and select one row in each group of equivalent rows. Create Table S3.
3: Assume given accuracy acc (0,1). It can be different for each column C m , denoted by column accuracy accm. 4: Create a vector of 0's the column length equal to S3, denoted this vector COL. Table Reduction: I. Define x as the number of entries in each row in S2.

Process of
II. Calculate the inner product between COL and S2, II. Select the row in S2 as a test, where the inner product between COL and S2 is maximum.
III. Recalculate the entries of COL using Rule 1.
IV. For each of the x entries in COL: if COL x remove entry x from COL and S3.
V. Repeat Process while x > 0.
VI. Determine if the classical solution was dominated in the other selected tests.
The condition of satisfying accuracy acc j for each column is a good termination condition because it is satisfiable (from problem formulation there always exist some subset of rows that satisfies this condition). In addition, the search uses the cost function which is the maximal total assurance, based on the amount of information gained by a potential test. The total assurance is calculated for the set of selected rows from the solution (including the rows selected at stages 1-3). Whenever a new value of the total assurance is found, if it is larger than the previously stored value, the corresponding solution is retained together with its total assurance. This way, when the search is completed, the last solution has the maximum value of the total assurance among all solutions that satisfy the termination condition of all "column accuracies" acc j . The final solution is the union of SOL1 and SOL2. In [19] the notion of probabilistic set-covering is introduced as the generation of a random binary vector and the covering constraint has to be satisfied with some prescribed probability. Although there is certain similarity, our "quantum set covering problem" is quite different. Some ideas of [19] can be however used to create other algorithms for our problem.

CONCLUSIONS, COMPARISONS AND FUTURE WORK
We addressed the problem of generating test patterns for quantum circuits. We presented an algorithm to minimize the number of tests for quantum circuits based on an extension of the classical set covering algorithm. The presented method represents a possible solution to the problem of quantum test set generation. The weakness of the method lies in validation of the fault model. Although repetitive faults seem very possible in a quantum information processing system, faults may well be constant in time and space. More generalized fault models specific to quantum computing technology must be addressed by the Quantum EDA community, QEDA. This will be the direction of the authors future research. A somewhat obvious fact we noted in this work is that short fat channels are easier to test than long skinny ones. We noticed also that when taking a cross section of 4 bits and generating random stages, the number of tests to verify the network grows as a log with the number of stages.
Biamonte, Jacob D.  Figure 6. Comparison on the number of tests needed for some common circuits.