Quantum computing may solve certain problems much faster than classical devices. Examples of such problems include Shor's algorithm, unstructured search problems, and simulation of quantum mechanical systems. The crossover point at which the choice of quantum algorithm versus classical algorithm changes is based on the implementation details of the functions being implemented by the quantum circuits corresponding to the quantum algorithm.
In one example, the present disclosure relates to a processor-implemented method for performing an evaluation of a polynomial corresponding to an input. The method may include determining a polynomial interpolation for a set of sub-intervals corresponding to the input. The method may further include constructing a quantum circuit for performing, in parallel, polynomial evaluation corresponding to each of the set of sub-intervals.
In another example, the present disclosure relates to a processor-implemented method for performing an evaluation of a polynomial corresponding to an input. The method may include determining a polynomial interpolation of an initial degree d for an initial set of sub-intervals corresponding to an input. The method may further include determining whether a required target precision is achievable based on the initial degree d and the set of sub-intervals. The method may further include if the target precision is achievable, then constructing a quantum circuit for performing, in parallel, polynomial evaluation corresponding to each of the set of sub-intervals. The method may further include if the target precision is not achievable, then either incrementing the initial degree d or subdividing the initial set of subintervals into additional intervals until the target precision is achievable and then constructing the quantum circuit.
In yet another example, the present disclosure relates to a processor-implemented method for performing an evaluation of a polynomial corresponding to an input. The method may include for each interval of a set of sub-intervals corresponding to the input, determining whether to perform the evaluation of the polynomial in a first mode or a second mode. The method may further include, in the first mode, performing the evaluation of the polynomial by: determining a polynomial interpolation of at most degree d for a first subset of the set of sub-intervals corresponding to the input, and constructing a quantum circuit for performing polynomial evaluation corresponding to each of the first subset of the set of sub-intervals. The method may further include, in the second mode, performing the evaluation of the polynomial using Newton's method for a second subset of the set of sub-intervals corresponding to the input, wherein the second subset is different from the first subset.
This Summary is provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter. Furthermore, the claimed subject matter is not limited to implementations that solve any or all disadvantages noted in any part of this disclosure.
The present disclosure is illustrated by way of example and is not limited by the accompanying figures, in which like references indicate similar elements. Elements in the figures are illustrated for simplicity and clarity and have not necessarily been drawn to scale.
Examples described in this disclosure relate to evaluating quantum computing circuits in view of the resource costs of a quantum algorithm. Certain examples relate to the problem of implementing numerical operations on a quantum computer. Such operations arise, for instance, in the implementation of classical functions on a superposition of inputs and are omnipresent in the quantum algorithm literature. One example case is the computation of amplitudes from a given subroutine specification. In this case, a need for computing arcsine functions or arcsine functions composed with a square root function arises. In order to facilitate implementation of numerical operations, their testing, and estimation of resource requirements, a quantum software module is implemented. This module allows one to automatically generate quantum circuits for evaluating piecewise smooth functions of inputs that are given in the computational basis. The present disclosure provides details of this module and provides resource estimates for some often-encountered classical functions such as Gaussians, tan h (hyperbolic tangent), and sine/cosine. In addition, the present disclosure describes implementations of inverse square root and arcsine, which may also be used in quantum chemistry and machine learning applications. The provided cost estimates might help to identify and address bottlenecks in future quantum applications. One technique relates to triaging inputs into subintervals, which are evaluated using a circuit for parallel polynomial evaluation.
Certain examples address the implementation of numerical functions such as 1/x, 1/sqrt(x), arcsin(x), sin(x), tan h(x), and in general the implementation of smooth functions via a piece-wise polynomial approximation, followed by functions that are used in specific applications. Some examples combine the evaluation scheme for smooth functions with the inverse square root, which is for instance, applicable to the case of implementation of arcsin(x). Having reversible implementations of these functions available enables more detailed cost analyses of various quantum algorithms such as the HHL algorithm for matrix inversion. Other use cases arise in Quantum Metropolis sampling, Gibbs state preparation and in the widely applicable framework of Quantum Rejection Sampling to transform one or more samples of a given quantum state into a quantum state with potentially different amplitudes, while maintaining relative phases.
Further applications of numerical functions can be anticipated in the quantum machine learning, e.g., threshold functions that need to be evaluated on a superposition of values, e.g., tan h(x) or sigmoid functions. In addition, 1/√{square root over (x)} can be used, e.g., for (re-)normalization of intermediate results. In quantum algorithms for chemistry further examples for numerical functions arise, e.g., for on-the-fly computation of the one- and two-body integrals. There, 1/√{square root over (x)} as well as the evaluation of smooth functions such as Gaussians is needed, and on-the-fly computation of finite element matrix elements often involves the evaluation of smooth functions such as sin(x) and cos(x).
A basic scheme to evaluate a single polynomial on a quantum computer in the computational basis is the classical Homer scheme, which evaluates:
by iteratively performing a multiplication by x, followed by an addition of ai for i∈{d, d−1, . . . , 0}. This may include performing the following operations:
adx+ad−1adx2+ad−1x+ad−2
. . .
adxd+ . . . +a0.
A reversible implementation of this scheme may simply store all intermediate results. At iteration i, the last iterate yi−1 is multiplied by x into a new register yi, followed by an addition by the constant ai. Due to the linear dependence of successive iterates, a pebbling strategy can be employed in order to optimize the space/time trade-offs according to some chosen metric.
Oftentimes, the degree d of the minimax approximation over a domain Ω must be chosen to be very high in order to achieve a certain L∞(Ω)-error. In such cases, it makes sense to partition Ω, i.e., find Ωi such that
and to then perform a case distinction for each input, evaluating a different polynomial for x∈Ωi than for y∈Ωj if i≠j. A straight-forward generalization of this approach to the realm of quantum computing would loop over all subdomains Ωi and, conditioned on a case-distinction or label register l, evaluate the corresponding polynomial. Thus, the cost of this inefficient approach grows linearly with the number of subdomains.
In order to improve upon this approach, one can parallelize the polynomial evaluation if the degree d is constant over the entire domain Ω.
|yl,i−1x|0|l|yl,i−1x|al,i|l (1)
|yl,i−1x+al,i|al,i|l (2)
|yl,i|0|l (3)
enables the evaluation of multiple polynomials in parallel. The impact on the circuit size is minor. This is because, in this example, the depth of the circuit remains unaltered, since the initialization step (1) can be performed while multiplying the previous iterate by yi−1 by x; see
Using reversible pebble games, it is possible to trade the number of registers needed to store the iterates with the depth of the resulting circuit. The parameters are: the number n of bits per register, the total number m of these n-qubit registers, the number r of Homer iterations, and the depth d of the resulting circuit. The trade-space we consider involves m, r, and d. In particular, the optimal circuit depth for a fixed number m of registers and a fixed number r of iterations is determined. In one example, dynamic programming is used to construct the optimal strategies as the dependency graph is just a line which is due to the sequential nature of Homer's method. The optimal number of pebbling steps as a function of m and r can be found in Table 1 below.
In order to enable automatic compilation of a classical oracle used in a quantum algorithm, certain examples use the Remez algorithm as a preferred embodiment to obtain a piece-wise polynomial approximation, which can be implemented using a quantum circuit for parallel polynomial evaluation. This allows one to triage inputs into different sub-intervals and to apply the parallel polynomial evaluation for different polynomials, depending on the particular subinterval the input x falls into. This method works for superposition of input x also.
Step 320 may include determining the best polynomial of degree at most d on each interval using an algorithm for polynomial evaluation. In one example, the Remez algorithm may be used to determine a piecewise polynomial approximation. In order to enable automatic compilation of a classical oracle used in a quantum algorithm, the Remez algorithm can be used in a subroutine to determine a piece-wise polynomial approximation, which can then be implemented using the circuit described later.
In particular, the oracle may be implemented with a given precision, accuracy, and number of available quantum registers (or, equivalently, the polynomial degree d) over a user-specified interval Ω=[a, a+L). The example algorithm proceeds as follows: in a first step, run the Remez algorithm which, given a function ƒ(x) over a domain Ω⊂ and a polynomial degree d, finds the polynomial P(x) which approximates ƒ(x) with minimal L∞(Ω)-error, and check whether the achieved error is low enough. If it is too large, reduce the size of the domain
and check again.
Repeating this procedure and carrying out binary search on the right interval border will eventually lead to the first subdomain Ω1=[a, b1) with the corresponding degree d polynomial achieving the desired accuracy on Ω1. Next, the next subdomain Ω2=[b1, b2) is determined using the same procedure. This is iterated until b1≥b, meaning that all required subdomains and their corresponding polynomials have been determined and ƒ(x) can be implemented using a parallel polynomial evaluation circuit. This algorithm was implemented and then run for various functions, target accuracies, and polynomial degrees in order to determine approximate resource estimates for these parameters.
In one example, the Remez algorithm may be implemented using the circuit in
Table 2 below provides example code corresponding to a function to implement the Remez's algorithm to find a polynomial for a given interval. The code also includes a function to subdivide an interval into subintervals.
Step 330 may include determining the overall precision that is achievable for any input that falls into any interval.
Step 340 may include constructing a quantum circuit for parallel polynomial evaluation of polynomials on each subinterval. After all of the subdomains and the corresponding polynomials have been determined, f(x) may be implemented using the parallel polynomial evaluation circuit shown in
Step 350 may include generating an output, including a quantum circuit for function evaluation of f.
Next, step 430 may include determining the best polynomial interpolation of degree at most d on each interval using an algorithm for polynomial evaluation. In one example, the Remez algorithm may be used to determine a piecewise polynomial. In one example, the Remez algorithm may be implemented using the circuit in
Next, step 440 may include determining whether a target precision is achievable. If not, then the degree of the polynomial may be incremented by 1, as shown in step 450. If yes, then step 460 may include constructing a quantum circuit for polynomial evaluation of each polynomial on each subinterval. After all of the subdomains and the corresponding polynomials have been determined, f(x) may be implemented using the parallel polynomial evaluation circuit shown in
Next, step 470 may include generating an output, including a quantum circuit for evaluation of the function f.
Next, step 530 may include determining the best polynomial interpolation of degree at most d on each interval using an algorithm for polynomial evaluation. In one example, the Remez algorithm may be used to determine a piecewise polynomial approximation. In one example, the Remez algorithm may be implemented using the circuit in
Next, step 540 may include determining whether a target precision is achievable. If not, then the intervals may be further subdivided, as shown in step 550. Table 3 below provides an example of code for interval partitioning functions, such as sin(x), arcsin(x), tan h(x), exp(x) etc.
If yes, then step 560 may include constructing a quantum circuit for polynomial evaluation of each polynomial on each subinterval. After all of the subdomains and the corresponding polynomials have been determined, f(x) may be implemented using the parallel polynomial evaluation circuit shown in
Next, step 570 may include generating an output, including a quantum circuit for evaluation of the function f.
While
In step 620, for each interval, a system (e.g., quantum computing system 710 of
In step 630, the system may evaluate whether with respect to the next interval, interpolation or Newton's method should be used. In the case of interpolation, as part of step 640, a quantum circuit for the polynomial evaluation may be determined. Any of the techniques described earlier may be used as part of this step.
In the case of application of the Newton-Raphson method, in step 650, the number of rounds of Newton's method may be determined. Next, in step 660, an initial constant for the Newton's method may be determined. Next, in step 670, a space-optimized circuit for the Newton's method may be constructed. This step may include access to an application of a pebbling strategy to reversibly compute programs with linear dependency graphs 665. In one example, as part of the Newton-Raphson method, the pebbling technique may be used to conserve space while using the parallel polynomial circuit shown in
Once all of the intervals are completed, as determined in step 680, the output, including the circuit for approximation of function f, may be provided.
With continued reference to
For quantum chemistry or machine learning applications, non-smooth functions are also required. As an example, the inverse square root can be used in both examples, namely for the calculation of the Coulomb potential and to determine the reciprocal when employing HHL for quantum machine learning.
In classical computing, inverse square roots appear in computer graphics and the term “fast inverse square root” is often used: it labels the procedure to approximate the inverse square root using bit-operations on the floating-point representation of the input. The code ultimately performs a Newton-Raphson iteration in order to improve upon a pretty accurate initial guess, which it finds using afore-mentioned bit-operations. Loosely speaking, the bit-operations consist of a bit-shift to divide the exponent by two in order to approximate the square root, followed by a subtraction of this result from a magic number, effectively negating the exponent and correcting the mantissa, which was also shifted together with the exponent. The magic number can be chosen using an auto-tuning procedure and varies depending on the objective function being used. This provides an extremely good initial guess for the Newton iteration at very low cost.
In an example implementation, a similar procedure is used to compute the inverse square root using fixed-point arithmetic. While the floating-point representation is not used, a low-cost initial guess is found, which allows for a small number of Newton iterations to be sufficient (i.e., 2-4 iterations). This includes determining the position of the first one in the bit-representation of the input, followed by an initialization which involves a case distinction on the magic number to use. The three constants were tuned such that the error peaks near powers of two in
5] using m∈{2,3,4} Newton iterations and corresponding bit sizes n∈{25,35,54}. The fixed-point position is p=12, in order to ensure that no overflow occurs for small inputs. One can clearly observe that an entire Newton iteration can be saved when aiming for a given L∞-error.
Arcsine may be implemented as a combination of polynomial evaluation and (inverse) square root. Approximating the arcsine using only a polynomial allows for a good approximation in [0,0.5], but not near 1 (where it diverges). The Cephes math library may remedy this problem by adding a case distinction, employing a “double-angle identity” for x≥0.5. This may require computing the square root, which can be achieved by first calculating the inverse square root, followed by
A resulting error plot from the implementation of the arcsine function is shown in
Note that certain applications may allow to a trade-off between the error in the arcsine with, e.g., probability of success by rescaling the input such that the arcsine needs to be computed only for values in [0,0.5]. This would allow one to remove the case-distinction and the subsequent calculation of the square root. As a result, one could evaluate the arcsine at a cost that is similar to the implementation costs of sin/cos. Estimates for the Toffoli and qubit counts for this case are shown in Table 4 below.
In fixed-point arithmetic, one represents numbers x using n bits as
where xi∈{0,1} is the i-th bit of the binary representation of x, and the point position p denotes the number of binary digits to the left of the binary point. We choose both the total number of bits n and the point position p to be constant over the course of a computation. As a consequence, over- and underflow errors are introduced, while keeping the required bit-size from growing with each operation.
Unless indicated otherwise, a fixed-point addition implementation is used, which keeps the bit-size constant. This amounts to allowing over- and underflow, while keeping the registers from growing with each operation. Multiplication can be performed by repeated-addition-and-shift, which can be seen from
x·y=xn−12n−1y+ . . . +x020y
where x=Σixi2i with xi∈{0,1} denotes the binary expansion of the n-bit number x. Thus, for i∈{0, . . . , n−1}, 2i−(n−p)y is added to the result register (which is initially zero) if xi=1. This can be implemented using n controlled additions on 1, 2, . . . , n bits if one allows for pre-truncation. Instead of computing the 2n-bit result and copying out the first n bits before uncomputing the multiplication again, the additions can be executed on a subset of the qubits, ignoring all bits beyond the scope of the n-bit result. Thus, each addition introduces an error of at most
Since there are (at most) n such additions, the total error is
a factor n larger than using the costly approach mentioned above.
Negative multipliers are dealt with by substituting the controlled addition by a controlled subtraction when conditioning on the most significant bit because it has negative weight wMSB=−2n−1 in two's-complement notation. The multiplicand is assumed to be positive throughout, which removes the need for conditional inversions of input and output (for every multiplication), thus tremendously reducing the size of circuits that require many multiplications such as, e.g., polynomial evaluation.
The square of a number can be calculated using the same approach as for multiplication. Yet, one can save (almost) an entire register by only copying out the bit being conditioned on prior to performing the controlled addition. Then the bit can be reset using another CNOT gate, followed by copying out the next bit and performing the next controlled addition. The gate counts are identical to performing
|x|0|0|x|x|0|x|x|x2|x|x2|0,
while allowing to save n−1 qubits.
Next, resource estimates for polynomial evaluation are described. The evaluation of a degree d polynomial requires an initial multiplication ad·x, an addition of ad−1, followed by d−1 multiply-accumulate instructions. The total number of Toffoli gates is thus equal to the cost of d multiply-accumulate instructions. Furthermore, d+1 registers are required for holding intermediate and final result(s) if no in-place adder is used for the last iteration (and no non-trivial pebbling strategy is applied). Other strategies may be employed in order to reduce the number of ancilla registers, at the cost of a larger gate count, see Tables 5-8 for examples of resource estimates for a number of functions.
Note that all multiplications can be carried out assuming x>0, i.e. x can be conditionally inverted prior to the polynomial evaluation (and the pseudo-sign bit is copied out). The sign is then absorbed into the coefficients. Before adding ai into the yi−1x-register, it is inverted conditioned on the sign-bit of x being set if the coefficient corresponds to an odd power. This is done because it is cheaper to implement a fixed-point multiplier, which can only deal with yi−1 being negative.
The Toffoli gate count of multiplying two n-bit numbers is
if one uses the controlled addition circuit by Takahashi et al., which requires 3n+3 Toffoli gates to (conditionally) add two n-bit numbers. The subsequent addition can be implemented using the addition circuit by Takahashi et al., featuring 2n−1 Toffoli gates. Thus, the total cost of a fused multiply-accumulate instruction is
Tfma(n,p)=3/2n2+3np+7/2n−3p2+3p−1.
Therefore, the total Toffoli count for evaluating a degree d polynomial is
Tpoly(n,d,p)=3/2n2d+3npd+7/2nd−3p2d+3pd−d.
Evaluating M polynomials in parallel for piecewise polynomial approximation requires only
additional qubits (since one n-qubit register is required to perform the addition in the last iteration, which is no longer just a constant) and
-controlled NOT gates, which can be performed in parallel with the multiplication. This increases the circuit size by
Textra(M)=2M(4┌log2M┐−8)
Toffoli gates per multiply-accumulate instruction, since a k-controlled NOT can be achieved using 4(k−2) Toffoli gates and k−2 dirty ancilla qubits, which are readily available in this construction.
The label register l can be computed using 1 comparator per subinterval by:
Ii=[ai,ai
The comparator stores its output into one extra qubit, flipping it to 1 if x≤ai+1. The label register is then incremented from i−1 to i, conditioned on this output qubit still being 0 (indicating that x>ai). Incrementing l can be achieved using CNOT gates applied to the qubits that correspond to ones in the bit-representation of (i−1)⊕i. Finally, the comparator output qubit is uncomputed again. This procedure is carried out M times for i=0, . . . , M−1 and requires 1 additional qubit. The number of extra Toffoli gates for this label initialization is
Tlabel(M,n)=M·2Tcmp(n)=4M n,
where, as a comparator, we use the CARRY-circuit, which needs 2n Toffoli gates to compare a classical value to a quantum register, and another 2n to uncompute the output and intermediate changes to the n required dirty ancilla qubits.
In total, the parallel polynomial evaluation circuit thus requires
Toffoli gates and
The inverse square root, i.e.,
can be computed efficiently using Newton's method. The iteration looks as follows:
where a is the input and
if the initial guess is sufficiently close to the true solution.
In some examples, finding a good initial guess
for Newton's zero-finding routine is useful for (fast) convergence. A crude approximation which turns out to be sufficient is the following:
where
can be determined by finding the first “1” when traversing the bit-representation of a from left to right (MSB to LSB). While the space requirement for {tilde over (x)}0 is in
such a representation would be impractical for the first Newton round. Furthermore, noting that the first iteration on {tilde over (x)}=2k leads to
one can directly choose this x0 as the initial guess.
The preparation of x0 can be achieved using (n−1)+n+1 ancilla qubits, which must be available due to the space requirements of the subsequent Newton steps. The one ancilla qubit is used as a flag indicating whether the first “1” from the left has already been encountered. For each iteration i∈{n−1, . . . , 1, 0}, one determines whether the bit ai is 1 and stores this result ri in one of the n work qubits, conditioned on the flag being unset.
Then, conditioned on ri=1, the flag is flipped, indicating that the first “1” has been found. If ri=1, the x0-register is initialized to the value in (4) as follows: using CNOTs, the x0-register can be initialized to the value 1.5 shifted by
where p denotes the binary point position of the input, followed by subtracting the (3k−1)-shifted input a from x0, which may require up to n−1 ancilla qubits.
In order to improve the quality of the first guess for numbers close to 2k for some k∈, one can tune the constant 1.5 in ( ) i.e., turn it into a function C(k) of the exponent k. This increases the overall cost of calculating x0 merely by a few CNOT gates but allows to save an entire Newton iteration even when only distinguishing three cases, namely
The Newton iteration may include computing xn+1 from xn by
which can be achieved as shown in Table 9 below:
The circuit of one such Newton iteration is depicted in
can be computed by multiplying this intermediate result by xn using MUL 1150. All temporary results may then be cleared by running the appropriate operations in reversed order (using SQR 1190, MUL 1170, SET 1180, and ADD 1160).
Therefore, for m Newton iterations, this requires m+3 n-qubit registers if no pebbling is done on the Newton iterates, i.e., if all xi are kept in memory until the last Newton iteration has been completed.
Computing the initial guess for the fast inverse square root requires n controlled additions of two n-bit numbers plus 2n Toffoli gates for checking/setting the flag (and uncomputing it again). Thus, the Toffoli count for the initial guess is
Tinit(n)=nTcadd(n)+2n=3n
Each Newton iteration features squaring, a multiplication, a subtraction, a final multiplication (yielding the next iterate), and then an uncomputation of the three intermediate results. In total, 5 multiplications and 2 additions are employed (of which 2 multiplications and 1 addition are run in reverse), which yields the Toffoli count
The number of Toffoli gates for the entire Newton procedure (without un-computing the iterates) for m iterations thus reads
Since each Newton iteration requires 3 ancilla registers (which are cleaned up after each round) to produce the next iterate, the total number of qubits is n(m+4), where one register holds the initial guess x0.
Note that this is an upper bound on the required number of both qubits and Toffoli gates. Since Newton converges quadratically, there is no need to perform full additions and multiplications at each iteration. Rather, the number of bits n used for the fixed point representation should be an (increasing) function of the Newton iteration.
The square root can be calculated using
i.e., at a cost of an additional multiplication into a new register. Note that this new register would be required anyway when copying out the result and running the entire computation in reverse, in order to clear registers holding intermediate results. Thus, the total number of logical qubits remains unchanged.
While sin (x) and cos (x) may be easily approximated using, e.g., polynomials as described, their inverses are not. The main difficulty arises near ±1, where
diverges.
Therefore, an alternative representation of arcsin (x) for larger values of x is used, e.g.,
Applying the double-argument identity to the last expression yields
a very useful identity which was already used in a classical math library called Cephes. The interval is again partitioned, using a minimax polynomial to approximate arcsin (x) for x∈[0,0.5), and the transformation in (6) for x∈[0.5,1].
The inverse square root implementation is used to compute √{square root over (z)} for
which satisfies z∈[0,0.25], for x∈[0.5,1]. Therefore, the fixed point position has to be chosen large, as the inverse square root diverges for small x. The multiplication by x after this computation takes care of the singularity and, since most bits of low-significance of
will cause underflow for small x, a shifted version of the inverse square root can be computed. This optimization reduces the number of extra bits required during the evaluation of the inverse square root.
In many applications, evaluating arcsin (x) only on the interval [0,0.5] may be sufficient. In such cases, the cost is much lower since this can be achieved using our parallel polynomial evaluation circuit. The Toffoli counts for this case are noted in Table 4.
In one example, the Arcsine is implemented as a combination of polynomial evaluation and the inverse square root to extend the polynomial approximation on [0,0.5] to the entire domain [0,1] employing the double-argument identity above.
First, the (pseudo) sign-bit of x is copied out and x is conditionally inverted (modulo two's-complement) to ensure x≥0. Since there are plenty of registers available, this can be achieved by conditionally initializing an extra register to 1 and then using a normal adder to increment
Since x∈[0,1], one can determine whether x<0.5 using just one Toffoli gate (and 4 NOT gates). The result of this comparison is stored in an ancilla qubit denoted by a. z=(1−x)/2 can be computed using an adder (run in reverse) acting on x shifted by one and a new register, after having initialized it to 0.5 using a NOT gate.
Then, conditioned on ā (i.e., on a being 0), this result is copied into the polynomial input register pin and, conditioned on a, x is squared into pin. After having applied the polynomial evaluation circuit shown in
Then, the result of the polynomial evaluation is multiplied by either √{square root over (z)} or x, which can be achieved using 2n controlled swaps and one multiplier. The final transformation of the result consists of an initialization to π/2 followed by a subtraction, both conditioned on ā, and a copy conditioned on a. Finally, the initial conditional inversion of x can be undone after having (conditionally) inverted the output.
Following this procedure, the Toffoli count for this arcsine implementation on n-bit numbers using m Newton iterations for calculating √{square root over (z)} and a degree-d polynomial to approximate arcsin (x) on [0,0.5] can be written as
where Tinv(n) denotes the Toffoli count for computing the two's-complement of an n-bit number and Tcsquare(n,p)=T
All circuits were implemented at the gate level and tested using a reversible simulator extension to LIQUiD.
A summary of the required resource for implementing tan h (x), exp (−x2), and sin (x) can be found in Tables 5-8. For each function, one set of parameters was implemented reversibly at the level of Toffoli gates in order to verify the proposed circuits.
The convergence of the reversible fast inverse square root implementation with the number of Newton iterations are shown in
For all practical purposes, choosing between 3 and 5 Newton iterations should be sufficient. The effect of tuning the constants in the initial guess (see Eqn. 5) can be seen when comparing
Tuning the initial guess results in almost uniform convergence, which saves an entire Newton iteration for a given L∞-error.
The square root converges better than the inverse square root for small values, which can be expected, since
has a regularizing effect for small x. The error after m Newton iterations when using n bits for the fixed point representation is depicted in
instead of just optimizing for the inverse square root itself.
The example implementation of Arcsine uses both the polynomial evaluation and square root subroutines. The oscillatory behavior which can be seen in
which was accounted for by calculating a shifted version of the inverse square root.
While this saves a few qubits (to the left of the binary point), the reduced number of qubits to the right of the binary point fail to resolve the numbers as well, which manifests itself by bit-noise for x>0.5 in
In conclusion, the present disclosure relates to a processor-implemented method for performing an evaluation of a polynomial corresponding to an input. The method may include determining a polynomial interpolation for a set of sub-intervals corresponding to the input. The method may further include constructing a quantum circuit for performing, in parallel, polynomial evaluation corresponding to each of the set of sub-intervals.
The method may further comprise determining an overall achievable precision for any input value that falls into any of the set of intervals. The method may further comprise partitioning the input into the set of sub-intervals by determining whether an input value falls into any of the set of sub-intervals and labeling the input value using a label indicative of one of the set of sub-intervals, where the sub-intervals may be chosen by pre-processing the input.
The polynomial evaluation may be performed in a nested fashion. The polynomial evaluation may be performed by applying a gate to load a next set of coefficients into a quantum register, while multiplying a previous set of coefficients by a variable to produce an output, and then adding the next set of coefficients to the output.
In another example, the present disclosure relates to a processor-implemented method for performing an evaluation of a polynomial corresponding to an input. The method may include determining a polynomial interpolation of an initial degree d for an initial set of sub-intervals corresponding to an input. The method may further include determining whether a required target precision is achievable based on the initial degree d and the set of sub-intervals. The method may further include if the target precision is achievable, then constructing a quantum circuit for performing, in parallel, polynomial evaluation corresponding to each of the set of sub-intervals. The method may further include if the target precision is not achievable, then either incrementing the initial degree d or subdividing the initial set of subintervals into additional intervals until the target precision is achievable and then constructing the quantum circuit.
The method may further include partitioning the input into the initial set of sub-intervals by determining whether an input value falls into any of the initial set of sub-intervals and labeling the input value using a label indicative of one of the initial set of sub-intervals. The initial set of sub-intervals may be chosen by pre-processing the input.
The polynomial evaluation may be performed in a nested fashion. The polynomial evaluation may be performed by applying a gate to load a next set of coefficients into a quantum register, while multiplying a previous set of coefficients by a variable to produce an output, and then adding the next set of coefficients to the output.
The input may be divided into the initial set of sub-intervals to reduce an approximation error associated with the polynomial evaluation. At least a subset of the initial set of intervals may be fused together to reduce a quantum cost associated with the polynomial evaluation.
In yet another example, the present disclosure relates to a processor-implemented method for performing an evaluation of a polynomial corresponding to an input. The method may include for each interval of a set of sub-intervals corresponding to the input, determining whether to perform the evaluation of the polynomial in a first mode or a second mode. The method may further include, in the first mode, performing the evaluation of the polynomial by: determining a polynomial interpolation of at most degree d for a first subset of the set of sub-intervals corresponding to the input, and constructing a quantum circuit for performing polynomial evaluation corresponding to each of the first subset of the set of sub-intervals. The method may further include, in the second mode, performing the evaluation of the polynomial using Newton's method for a second subset of the set of sub-intervals corresponding to the input, wherein the second subset is different from the first subset.
The method may further include determining an overall achievable precision for any input value that falls into any of the set of intervals. The method may further include partitioning the input into the set of sub-intervals by determining whether an input value falls into any of the set of sub-intervals and labeling the input value using a label indicative of one of the set of sub-intervals.
The polynomial evaluation may be performed by applying a gate to load a next set of coefficients into a quantum register, while multiplying a previous set of coefficients by a variable to produce an output, and then adding the next set of coefficient with the output. The iterations corresponding to the Newton's method may be implemented using a result of a pebbling strategy to meet a resource requirement corresponding to the quantum circuit. The resource requirement may be a number of available qubits corresponding to the quantum circuit. The resource requirement may be a circuit depth corresponding to the quantum circuit.
It is to be understood that the methods, modules, and components depicted herein are merely exemplary. Alternatively, or in addition, the functionally described herein can be performed, at least in part, by one or more hardware logic components. For example, and without limitation, illustrative types of hardware logic components that can be used include Field-Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application-Specific Standard Products (ASSPs), System-on-a-Chip systems (SOCs), Complex Programmable Logic Devices (CPLDs), etc. In an abstract, but still definite sense, any arrangement of components to achieve the same functionality is effectively “associated” such that the desired functionality is achieved. Hence, any two components herein combined to achieve a particular functionality can be seen as “associated with” each other such that the desired functionality is achieved, irrespective of architectures or inter-medial components. Likewise, any two components so associated can also be viewed as being “operably connected,” or “coupled,” to each other to achieve the desired functionality.
The functionality associated with some examples described in this disclosure can also include instructions stored in a non-transitory media. The term “non-transitory media” as used herein refers to any media storing data and/or instructions that cause a machine to operate in a specific manner. Exemplary non-transitory media include non-volatile media and/or volatile media. Non-volatile media include, for example, a hard disk, a solid-state drive, a magnetic disk or tape, an optical disk or tape, a flash memory, an EPROM, NVRAM, PRAM, or other such media, or networked versions of such media. Volatile media include, for example, dynamic memory, such as, DRAM, SRAM, a cache, or other such media. Non-transitory media is distinct from, but can be used in conjunction with transmission media. Transmission media is used for transferring data and/or instruction to or from a machine. Exemplary transmission media include coaxial cables, fiber-optic cables, copper wires, and wireless media, such as radio waves.
Furthermore, those skilled in the art will recognize that boundaries between the functionality of the above described operations are merely illustrative. The functionality of multiple operations may be combined into a single operation, and/or the functionality of a single operation may be distributed in additional operations. Moreover, alternative embodiments may include multiple instances of a particular operation, and the order of operations may be altered in various other embodiments.
Although the disclosure provides specific examples, various modifications and changes can be made without departing from the scope of the disclosure as set forth in the claims below. Accordingly, the specification and figures are to be regarded in an illustrative rather than a restrictive sense, and all such modifications are intended to be included within the scope of the present disclosure. Any benefits, advantages, or solutions to problems that are described herein with regard to a specific example are not intended to be construed as a critical, required, or essential feature or element of any or all the claims.
Furthermore, the terms “a” or “an,” as used herein, are defined as one or more than one. Also, the use of introductory phrases such as “at least one” and “one or more” in the claims should not be construed to imply that the introduction of another claim element by the indefinite articles “a” or “an” limits any particular claim containing such introduced claim element to inventions containing only one such element, even when the same claim includes the introductory phrases “one or more” or “at least one” and indefinite articles such as “a” or “an.” The same holds true for the use of definite articles.
Unless stated otherwise, terms such as “first” and “second” are used to arbitrarily distinguish between the elements such terms describe. Thus, these terms are not necessarily intended to indicate temporal or other prioritization of such elements.
This application claims the benefit of U.S. Provisional Application No. 62/676,539, filed May 25, 2018, titled “EVALUATING QUANTUM COMPUTING CIRCUITS IN VIEW OF THE RESOURCE COSTS OF A QUANTUM ALGORITHM,” the entire contents of which are hereby incorporated herein by reference.
Number | Name | Date | Kind |
---|---|---|---|
20170194930 | Wiebe | Jul 2017 | A1 |
Entry |
---|
Bhaskar, et al., “Quantum Algorithms and Circuits for Scientific Computing”, in Journal of Quantum Information & Computation, vol. 16, Issue 3, Nov. 30, 2015, 43 Pages. |
Haner, et al., “Optimizing Quantum Circuits for Arithmetic”, in Repository of arXiv:1805.12445, May 31, 2018, 12 Pages. |
Munoz-Coreas, et al., “T-count and Qubit Optimized Quantum Circuit Design of the Non-Restoring Square Root Algorithm”, in ACM Journal on Emerging Technologies in Computing Systems,vol. 14, Issue 3, Oct. 23, 2018, 19 Pages. |
“International Search Report and Written Opinion Issued in PCT Application No. PCT/US2019/031941”, dated Sep. 25, 2019, 16 Pages. |
Romm, et al., “The Computer Method of Variable Piecewise Polynomial Approximation of Functions and Solutions of Ordinary Differential Equations”, in Journal of Cybernetics and Systems Analysis, vol. 49, Issue 3, May 1, 2013, pp. 409-423. |
Ylostalo, Jyri, “Function Approximation Using Polynomials”, in Proceedings of the IEEE Signal Processing Magazine, vol. 23, Issue 5, Oct. 9, 2006, pp. 99-102. |
“Cephes Mathematical Library”, Retrieved from https://web.archive.org/web/20180318171211/http://www.moshier.net/, Mar. 18, 2018, 9 Pages. |
Babbush, et al., “Exponentially more precise quantum simulation of fermions in second quantization”, in Journal of Physics, vol. 18, Issue 3, Mar. 24, 2016, 18 Pages. |
Barenco, et al., “Elementary gates for quantum computation”, in Journal of Physical Review A, vol. 52, Issue 5, Nov. 1, 1995, pp. 1-31. |
Bennett, Charles H., “Time space trade-offs for reversible computation”, in Journal of SIAM Journal on Computing, vol. 18, Issue 4, Aug. 1989, pp. 766-776. |
Bradshaw, Travis, “Quake-III-Arena”, Retrieved from https://github.com/id-Software/Quake-III-Arena/blob/master/code/game/q_math.c, Feb. 1, 2012, 18 Pages. |
Chan, Siu Man., “Pebble games and complexity”, in Proceedings of Electrical Engineering and Computer Science, vol. 9, No. 3, Jan. 1, 2013, pp. 1-68. |
Chiang, et al., “Efficient circuits for quantum walks”, in Journal of Quantum Information and Computation, vol. 10, Issue 5-6, May 2010, pp. 1-15. |
Draper, Thomas G., “Addition on a quantum computer”, Retrieved from https://arxiv.org/pdf/quant-ph/0008033, Aug. 7, 2000, pp. 1-8. |
Green, et al., “Quipper: a scalable quantum programming language”, in Proceedings of ACM SIGPLAN Conference on Programming Language Design and Implementation, vol. 48, Issue 6, Jun. 16, 2013, 10 Pages. |
Haner, et al., “A software methodology for compiling quantum programs”, in Journal of Computing Research Repository, Apr. 2016, pp. 1-15. |
Haner, et al., “Factoring using 2n + 2 qubits with toffoli-based modular multiplication”, in Computing Research Repository, Nov. 23, 2016, 12 Pages. |
Haner, et al., “High performance emulation of quantum circuits”, in Proceedings of the International Conference for High Performance Computing, Networking, Storage and Analysis, Nov. 13, 2016, 9 Pages. |
Harrow, et al., “Quantum algorithm for linear systems of equations”, in Journal of Physical Review Letter, vol. 103, No. 15, Oct. 7, 2009, pp. 1-15. |
Javadiabhari, et al., “Scaffcc: a framework for compilation and analysis of quantum computing programs”, in Proceedings of the 11th ACM Conference on Computing Frontiers, May 20, 2014, 10 Pages. |
Knill, Emmanuel, “An analysis of Bennett's pebble game”, in Journal of Computing Research Repository, Aug. 1995, pp. 1-15. |
Knuth, Donald E., “Evaluation of polynomials by computer”, in Journal of Communications of the ACM, vol. 5, Issue 12, Dec. 1, 1962, pp. 595-599. |
Lomont, Chris, “Fast inverse square root”, in Technical Report, Feb. 28, 2003, pp. 1-12. |
Ozols, et al., “Quantum rejection sampling”, in Journal ACM Transactions on Computation Theory (TOCT)—Special issue on innovations in theoretical computer science, vol. 5, Issue 3, Aug. 2013, 33 Pages. |
Parent, et al., “Reversible circuit compilation with space constraints”, in Journal of Computing Research Repository, Oct. 2015, pp. 1-32. |
Poulin, et al., “Sampling from the thermal quantum Gibbs state and evaluating partition functions with a quantum computer”, in Journal of Physical Review Letters, vol. 103, Issue 22, Nov. 24, 2009, pp. 1-7. |
Reiher, et al., “Elucidating reaction mechanisms on quantum computers”, Retrieved from https://arxiv.org/pdf/1605.03590, May 11, 2016, pp. 1-18. |
Remez., Eugene Y., “Sur la determination des polynomes dapproximation de degre donnee”, in Journal of Communications in Mathematical Sciences, vol. 10, Issue 4163, Sep. 13, 2016. |
Scherer, et al., “Concrete resource analysis of the quantum linear-system algorithm used to compute the electromagnetic scattering cross section of a 2d target”, in Journal of Quantum Information Processing, vol. 16 Issue 3, Jan. 25, 2017, 65 Pages. |
Shor, Peter W., “Algorithms for quantum computation: Discrete logarithms and factoring”, in Proceedings of 35th Annual Symposium on Foundations of Computer Science, Nov. 20, 1994, pp. 124-134. |
Steiger, “ProjectQ: an open source software framework for quantum computing”, Retrieved from https://arxiv.org/abs/1612.08091, Dec. 23, 2016, pp. 1-11. |
Takahashi, et al., “A quantum circuit for shor's factoring algorithm using 2n+ 2 qubits”, in Journal of Quantum Information & Computation, vol. 6, Issue 2, Mar. 1, 2006, pp. 1-16. |
Takahashi, et al., “Quantum addition circuits and unbounded fan-out”, Retrieved from http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.765.7470&rep=rep1&type=pdf, Oct. 14, 2009, pp. 1-17. |
Temme, et al., “Quantum Metropolis Sampling”, in Journal of Nature, vol. 471, Issue 7336, Mar. 2011, pp. 1-32. |
Wakerly, John F., “Digital Design”, in Publication of Prentice-Hall, vol. 3, 2000, pp. 1-830. |
Wecker, et al., “LIQUi A Software Design Architecture and Domain-Specific Language for Quantum Computing”, Retrieved From https://arxiv.org/pdf/1402.4467, Feb. 18, 2014, 14 Pages. |
Number | Date | Country | |
---|---|---|---|
20190361675 A1 | Nov 2019 | US |
Number | Date | Country | |
---|---|---|---|
62676539 | May 2018 | US |