iterative_quantum_ae
This module contains the IQAE class. Given a quantum oracle operator, this class estimates the probability of a given target state using the Iterative Quantum Amplitude Estimation algorithm based on the paper:
Grinko, D., Gacon, J., Zoufal, C. et al. Iterative Quantum Amplitude Estimation npj Quantum Inf 7, 52 (2021). https://doi.org/10.1038/s41534-021-00379-1
Author: Gonzalo Ferro Costas & Alberto Manzano Herrero
- class QQuantLib.AE.iterative_quantum_ae.IQAE(oracle: qat.lang.AQASM.QRoutine, target: list, index: list, **kwargs)
Class for Iterative Quantum Amplitude Estimation (IQAE) algorithm
- Parameters:
oracle (QLM gate) – QLM gate with the Oracle for implementing the Grover operator
target (list of ints) – python list with the target for the amplitude estimation
index (list of ints) – qubits which mark the register to do the amplitude estimation
kwargs (dictionary) – dictionary that allows the configuration of the IQAE algorithm: Implemented keys:
qpu (kwargs, QLM solver) – solver for simulating the resulting circuits
epsilon (kwargs, float) – precision
alpha (kwargs, float) – accuracy
shots (kwargs, int) – number of measurements on each iteration
mcz_qlm (kwargs, bool) – for using or not QLM implementation of the multi controlled Z gate
- static chebysev_bound(n_samples: int, gamma: float)
Computes the length of the confidence interval for a given number of samples n_samples and an accuracy gamma:
\[\epsilon = \dfrac{1}{\sqrt{2N}}\log\left(\dfrac{2}{\gamma} \ \right)\]- Parameters:
n_samples (int) – number of samples
gamma (float) – accuracy
- Returns:
length of the confidence interval
- Return type:
float
- static compute_info(epsilon: float = 0.01, shots: int = 100, alpha: float = 0.05)
This function computes theoretical values of the IQAE algorithm.
- Parameters:
epsilon (float) – precision
alpha (float) – accuracy
shots (int) – number of measurements on each iteration
- Returns:
info – python dictionary with the computed information
- Return type:
dict
- static display_information(epsilon: float = 0.01, shots: int = 100, alpha: float = 0.05)
This function displays information of the properties of the method for a given set of parameters
- Parameters:
epsilon (float) – precision
alpha (float) – accuracy
shots (int) – number of measurements on each iteration
- static find_next_k(k: int, theta_lower: float, theta_upper: float, flag: bool, ratio: float = 2)
This is an implementation of Algorithm 2 from the IQAE paper. This function computes the next suitable k.
- Parameters:
k (int) – number of times to apply the grover operator to the quantum circuit
theta_lower (float) – lower bound for the estimation of the angle
theta_upper (float) – upper bound for the estimation of the angle
flag (bool) – flag to keep track of weather we are in the upper or lower half pane
ratio (float) – ratio of amplifications between consecutive iterations
- Returns:
k (int) – number of times to apply the grover operator to the quantum circuit
flag (bool) – flag to keep track of weather we are in the upper or lower half pane
- property index
creating index property
- static invert_sector(a_min: float, a_max: float, flag: bool = True)
This function inverts the expression:
\[a = \dfrac{1-\cos(\theta)}{2}\]for a pair of bounds (a_min,a_max). The result belongs to the domain (0,2pi)
- Parameters:
a_min (float) – lower bound
a_max (float) – upper bound
flag (bool) – flag to keep track of weather we are in the upper or lower half pane
- Returns:
theta_min (float) – lower bound for the associated angle
theta_max (float) – upper bound for the associated angle
- iqae(epsilon: float = 0.01, shots: int = 100, alpha: float = 0.05)
This function implements Algorithm 1 from the IQAE paper. The result is an estimation of the desired probability with precision at least epsilon and accuracy at least alpha.
- Parameters:
epsilon (float) – precision
alpha (float) – accuracy
shots (int) – number of measurements on each iteration
- Returns:
a_l (float) – lower bound for the probability to be estimated
a_u (float) – upper bound for the probability to be estimated
- property oracle
creating oracle property
- quantum_step(k)
Create the quantum routine needed for the iqae step
- Parameters:
k (int) – number of Grover operator applications
- Returns:
routine – qlm routine for the iqae step
- Return type:
qlm routine
- run()
run method for the class.
- Returns:
amplitude estimation parameter
- Return type:
self.ae
- property target
creating target property