qml.resource.FirstQuantization¶
-
class
FirstQuantization
(n, eta, omega, error=0.0016, charge=0, br=7)[source]¶ Bases:
pennylane.operation.Operation
Estimate the number of non-Clifford gates and logical qubits for a quantum phase estimation algorithm in first quantization using a plane-wave basis.
To estimate the gate and qubit costs for implementing this method, the number of plane waves, the number of electrons and the unit cell volume need to be defined. The costs can then be computed using the functions
gate_cost()
andqubit_cost()
with a target error that has the default value of 0.0016 Ha (chemical accuracy). Atomic units are used throughout the class.- Parameters
n (int) – number of plane waves
eta (int) – number of electrons
omega (float) – unit cell volume
error (float) – target error in the algorithm
charge (int) – total electric charge of the system
br (int) – number of bits for ancilla qubit rotation
Example
>>> n = 100000 >>> eta = 156 >>> omega = 1145.166 >>> algo = FirstQuantization(n, eta, omega) >>> print(algo.lamb, # the 1-Norm of the Hamiltonian >>> algo.gates, # estimated number of non-Clifford gates >>> algo.qubits # estimated number of logical qubits >>> ) 649912.4801542697 1.10e+13 4416
Theory
Following PRX Quantum 2, 040332 (2021) , the target algorithm error, \(\epsilon\), is distributed among four different sources of error using Eq. (131)
\[\epsilon^2 \geq \epsilon_{qpe}^2 + (\epsilon_{\mathcal{M}} + \epsilon_R + \epsilon_T)^2,\]where \(\epsilon_{qpe}\) is the quantum phase estimation error and \(\epsilon_{\mathcal{M}}\), \(\epsilon_R\), and \(\epsilon_T\) are defined in Eqs. (132-134).
Here, we fix \(\epsilon_{\mathcal{M}} = \epsilon_R = \epsilon_T = \alpha \epsilon\) with a default value of \(\alpha = 0.01\) and obtain
\[\epsilon_{qpe} = \sqrt{\epsilon^2 [1 - (3 \alpha)^2]}.\]Note that the user only needs to define the target algorithm error \(\epsilon\). The error distribution takes place inside the functions.
Attributes
Methods
estimation_cost
(n, eta, omega, error[, br, …])Return the number of calls to the unitary needed to achieve the desired error in quantum phase estimation.
gate_cost
(n, eta, omega, error[, br, charge])Return the total number of Toffoli gates needed to implement the first quantization algorithm.
norm
(n, eta, omega, error[, br, charge])Return the 1-norm of a first-quantized Hamiltonian in the plane-wave basis.
qubit_cost
(n, eta, omega, error[, br, charge])Return the number of logical qubits needed to implement the first quantization algorithm.
success_prob
(n, br)Return the probability of success for state preparation.
unitary_cost
(n, eta, omega, error[, br, charge])Return the number of Toffoli gates needed to implement the qubitization unitary operator.
-
static
estimation_cost
(n, eta, omega, error, br=7, charge=0)[source]¶ Return the number of calls to the unitary needed to achieve the desired error in quantum phase estimation.
The expression for computing the cost is taken from Eq. (125) of [PRX Quantum 2, 040332 (2021)].
- Parameters
n (int) – number of plane waves
eta (int) – number of electrons
omega (float) – unit cell volume
error (float) – target error in the algorithm
br (int) – number of bits for ancilla qubit rotation
charge (int) – total electric charge of the system
- Returns
number of calls to unitary
- Return type
int
Example
>>> n = 100000 >>> eta = 156 >>> omega = 1145.166 >>> error = 0.01 >>> estimation_cost(n, eta, omega, error) 102133985
-
static
gate_cost
(n, eta, omega, error, br=7, charge=0)[source]¶ Return the total number of Toffoli gates needed to implement the first quantization algorithm.
The expression for computing the cost is taken from Eq. (125) of [PRX Quantum 2, 040332 (2021)].
- Parameters
n (int) – number of plane waves
eta (int) – number of electrons
omega (float) – unit cell volume
error (float) – target error in the algorithm
br (int) – number of bits for ancilla qubit rotation
charge (int) – total electric charge of the system
- Returns
the number of Toffoli gates needed to implement the first quantization algorithm
- Return type
int
Example
>>> n = 100000 >>> eta = 156 >>> omega = 169.69608 >>> error = 0.01 >>> gate_cost(n, eta, omega, error) 3676557345574
-
static
norm
(n, eta, omega, error, br=7, charge=0)[source]¶ Return the 1-norm of a first-quantized Hamiltonian in the plane-wave basis.
The expressions needed for computing the norm are taken from [PRX Quantum 2, 040332 (2021)]. The norm is computed assuming that amplitude amplification is performed.
- Parameters
n (int) – number of plane waves
eta (int) – number of electrons
omega (float) – unit cell volume
error (float) – target error in the algorithm
br (int) – number of bits for ancilla qubit rotation
charge (int) – total electric charge of the system
- Returns
1-norm of a first-quantized Hamiltonian in the plane-wave basis
- Return type
float
Example
>>> n = 10000 >>> eta = 156 >>> omega = 1145.166 >>> error = 0.001 >>> norm(n, eta, omega, error) 281053.75612801575
Theory
To compute the norm, for numerical convenience, we use the following modified expressions to obtain parameters that contain a sum over \(\frac{1}{\left \| \nu \right \|^k}\) where \(\nu\) denotes an element of the set of reciprocal lattice vectors, \(G_0\), and \(k \in \left \{ 1, 2 \right \}\).
For \(\lambda_{\nu}\) defined in Eq. (25) of PRX Quantum 2, 040332 (2021) as
\[\lambda_{\nu} = \sum_{\nu \in G_0} \frac{1}{\left \| \nu \right \|^2},\]we follow Eq. (F6) of PRX 8, 011044 (2018) and use
\[\lambda_{\nu} = 4\pi \left ( \frac{\sqrt{3}}{2} N^{1/3} - 1 \right) + 3 - \frac{3}{N^{1/3}} + 3 \int_{x=1}^{N^{1/3}} \int_{y=1}^{N^{1/3}} \frac{1}{x^2 + y^2} dydx.\]We also need to compute \(\lambda^{\alpha}_{\nu}\) defined in Eq. (123) of PRX Quantum 2, 040332 (2021)
\[\lambda^{\alpha}_{\nu} = \alpha \sum_{\nu \in G_0} \frac{\left \lceil \mathcal{M}(2^{\mu - 2}) / \left \| \nu \right \|^2 \right \rceil}{\mathcal{M} 2^{2\mu - 4}},\]which we compute here, for \(\alpha = 1\), as
\[\lambda^{1}_{\nu} = \lambda_{\nu} + \epsilon_l,\]where \(\epsilon_l\) is simply defined as the difference of \(\lambda^{1}_{\nu}\) and \(\lambda_{\nu}\). We follow Eq. (113) of PRX Quantum 2, 040332 (2021) to derive an upper bound for its absolute value:
\[|\epsilon_l| \le \frac{4}{2^{n_m}} (7 \times 2^{n_p + 1} + 9 n_p - 11 - 3 \times 2^{-n_p}),\]where \(\mathcal{M} = 2^{n_m}\) and \(n_m\) is defined in Eq. (132) of PRX Quantum 2, 040332 (2021). Finally, for \(p_{\nu}\) defined in Eq. (128) of PRX Quantum 2, 040332 (2021)
\[p_{\nu} = \sum_{\mu = 2}^{n_p + 1} \sum_{\nu \in B_{\mu}} \frac{\left \lceil M(2^{\mu-2} / \left \| \nu \right \|)^2 \right \rceil}{M 2^{2\mu} 2^{n_{\mu} + 1}},\]we use the upper bound from Eq. (29) in arXiv:1807.09802v2 which gives \(p_{\nu} = 0.2398\).
-
static
qubit_cost
(n, eta, omega, error, br=7, charge=0)[source]¶ Return the number of logical qubits needed to implement the first quantization algorithm.
The expression for computing the cost is taken from Eq. (101) of [arXiv:2204.11890v1].
- Parameters
n (int) – number of plane waves
eta (int) – number of electrons
omega (float) – unit cell volume
error (float) – target error in the algorithm
br (int) – number of bits for ancilla qubit rotation
charge (int) – total electric charge of the system
- Returns
number of logical qubits needed to implement the first quantization algorithm
- Return type
int
Example
>>> n = 100000 >>> eta = 156 >>> omega = 169.69608 >>> error = 0.01 >>> qubit_cost(n, eta, omega, error) 4377
-
static
success_prob
(n, br)[source]¶ Return the probability of success for state preparation.
The expression for computing the probability of success is taken from Eqs. (59, 60) of [PRX Quantum 2, 040332 (2021)].
- Parameters
n (int) – number of basis states to create an equal superposition for state preparation
br (int) – number of bits for ancilla qubit rotation
- Returns
probability of success for state preparation
- Return type
float
Example
>>> n = 3 >>> br = 8 >>> success_prob(n, br) 0.9999928850303523
-
static
unitary_cost
(n, eta, omega, error, br=7, charge=0)[source]¶ Return the number of Toffoli gates needed to implement the qubitization unitary operator.
The expression for computing the cost is taken from Eq. (125) of [PRX Quantum 2, 040332 (2021)].
- Parameters
n (int) – number of plane waves
eta (int) – number of electrons
omega (float) – unit cell volume
error (float) – target error in the algorithm
br (int) – number of bits for ancilla qubit rotation
charge (int) – total electric charge of the system
- Returns
the number of Toffoli gates needed to implement the qubitization unitary operator
- Return type
int
Example
>>> n = 100000 >>> eta = 156 >>> omega = 169.69608 >>> error = 0.01 >>> unitary_cost(n, eta, omega, error) 17033