extended_real_quantum_ae

This module contains the eRQAE class. Given a quantum oracle operator, this class estimates the amplitude of a given target state using an extension of the RQAE where the use can guide the evolution of the amplification and the failure at each step of the algorithm by providing a schedule.

Original RQAE papper:

Manzano, A., Musso, D., Leitao, A. Real Quantum Amplitude Estimation EPJ Quantum Technol. 10, 2 (2023) https://doi.org/10.1140/epjqt/s40507-023-00159-0

Author: Gonzalo Ferro Costas & Alberto Manzano Herrero

class QQuantLib.AE.extended_real_quantum_ae.eRQAE(oracle: qat.lang.AQASM.QRoutine, target: list, index: list, **kwargs)

Class for extended Real Quantum Amplitude Estimation (RQAE) 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

  • qpu (kwargs, QLM solver) – solver for simulating the resulting circuits

  • epsilon (kwargs, int) – precision

  • gamma (kwargs, float) – accuracy

  • 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.

Parameters:
  • n_samples (int) – number of samples

  • gamma (float) – accuracy

Return type:

length of the confidence interval

static compute_info(ratio: float = 2, epsilon: float = 0.01, gamma: float = 0.05, **kwargs)

This function computes theoretical values of the IQAE algorithm.

Parameters:
  • ratio (float) – amplification ratio/policy

  • epsilon (float) – precision

  • gamma (float) – accuracy

Returns:

info – python dictionary with the computed information

Return type:

dict

static display_information(ratio: float = 2, epsilon: float = 0.01, gamma: float = 0.05, **kwargs)

This function displays information of the properties of the method for a given set of parameters

Parameters:
  • ratio (float) – amplification ratio/policy

  • epsilon (float) – precision

  • gamma (float) – accuracy

erqae(epsilon: float = 0.01, gamma: float = 0.05, schedule_k: list = [], schedule_gamma: list = [])

Implments the extended RQAE algorithm. The result is an estimation of the desired amplitude with precision epsilon and accuracy gamma.

Parameters:
  • epsilon (int) – precision

  • gamma (float) – accuracy

  • schedule_k (list) – list with the amplification schedule

  • schedule_gamma (list) – list with the confidence schedule

Returns:

  • amplitude_min (float) – lower bound for the amplitude to be estimated

  • amplitude_max (float) – upper bound for the amplitude to be estimated

first_step(shift: float, shots: int, gamma: float)

This function implements the first step of the RQAE paper. The result is a first estimation of the desired amplitude.

Parameters:
  • shift (float) – shift for the first iteration

  • shots (int) – number of measurements

  • gamma (float) – accuracy

Returns:

  • amplitude_min (float) – lower bound for the amplitude to be estimated

  • amplitude_max (float) – upper bound for the amplitude to be estimated

property index

creating index property

property oracle

creating oracle property

run()

run method for the class.

Returns:

amplitude estimation parameter

Return type:

self.ae

run_step(shift: float, shots: int, gamma: float, k: int)

This function implements a step of the RQAE paper. The result is a refined estimation of the desired amplitude.

Parameters:
  • shift (float) – shift for the first iteration

  • shots (int) – number of measurements

  • gamma (float) – accuracy

  • k (int) – number of amplifications

Returns:

  • amplitude_min (float) – lower bound for the amplitude to be estimated

  • amplitude_max (float) – upper bound for the amplitude to be estimated

property shifted_oracle

creating shifted_oracle property

property target

creating target property

QQuantLib.AE.extended_real_quantum_ae.schedule_exponential_constant(epsilon=0.01, gamma=0.05, ratio=2)

Schedule for an exponential amplification schedule and a constant gamma schedule

Parameters:
  • epsilon (float) – Desired error for the estimation

  • gamma (float) – confidence level: it will be expected that the probability of getting an error higher than epsilon will be lower than alpha

  • ratio (float) – amplification ratio

Returns:

  • k_list (list) – Schedule for the amplification at each step of the extended RQAE (Grover operator applications)

  • gamma_list (list) – Schedule for the confidence at each step of the extended RQAE

QQuantLib.AE.extended_real_quantum_ae.schedule_exponential_exponential(epsilon, gamma, ratio_epsilon, ratio_gamma)

Schedule for an exponential amplification schedule and a exponential gamma schedule

Parameters:
  • epsilon (float) – Desired error for the estimation

  • gamma (float) –

    confidence level: it will be expected that the probability

    of getting an error higher than epsilon will be lower than alpha

  • ratio_epsilon (float) –

    amplification ratio (ratio for setting the k at each step).

    Only positive ratios.

  • ratio_gamma (float) –

    ratio for selecting the gamma at each step of the extended RQAE

    ratios can be positive or negative

Returns:

  • k_list (list) – Schedule for the amplification at each step of the extended RQAE (Grover operator applications)

  • gamma_list (list) – Schedule for the confidence at each step of the extended RQAE

QQuantLib.AE.extended_real_quantum_ae.schedule_linear_constant(epsilon, gamma, slope_epsilon)

Schedule for a lineal amplification schedule and a lineal gamma schedule

Parameters:
  • epsilon (float) – Desired error for the estimation

  • gamma (float) – confidence level: it will be expected that the probability of getting an error higher than epsilon will be lower than alpha

  • slope_epsilon (float) – amplification slope (slope for setting the k at each step). Only positive slope.

  • slope_gamma (float) – slope for selecting the gamma at each step of the extended RQAE slope can be positive or negative

Returns:

  • k_list (list) – Schedule for the amplification at each step of the extended RQAE (Grover operator applications)

  • gamma_list (list) – Schedule for the confidence at each step of the extended RQAE

QQuantLib.AE.extended_real_quantum_ae.schedule_linear_linear(epsilon, gamma, slope_epsilon, slope_gamma)

Schedule for a lineal amplification schedule and a lineal gamma schedule

Parameters:
  • epsilon (float) – Desired error for the estimation

  • gamma (float) – confidence level: it will be expected that the probability of getting an error higher than epsilon will be lower than alpha

  • slope_epsilon (float) – amplification slope (slope for setting the k at each step). Only positive slope.

  • slope_gamma (float) – slope for selecting the gamma at each step of the extended RQAE slope can be positive or negative

Returns:

  • k_list (list) – Schedule for the amplification at each step of the extended RQAE (Grover operator applications)

  • gamma_list (list) – Schedule for the confidence at each step of the extended RQAE

QQuantLib.AE.extended_real_quantum_ae.select_schedule(erqae_schedule, epsilon, gamma)

Scheduler selector.

Parameters:
  • erqae_schedule (dict) – Dictionary with configuration for scheduler

  • epsilon (float) – Desired error for the estimation

  • gamma (float) – confidence level: it will be expected that the probability of getting an error higher than epsilon will be lower than alpha

Returns:

  • k_list (list) – Schedule for the amplification at each step of the extended RQAE (Grover operator applications)

  • gamma_list (list) – Schedule for the confidence at each step of the extended RQAE