QQuantLib.PE¶
QQuantLib.PE.classical_qpe¶
This module contains necessary functions and classes to implement the classical Quantum Phase Estimation with inverse of the Quantum Fourier Transform. Following references were used:
Brassard, G., Hoyer, P., Mosca, M., & Tapp, A. (2000). Quantum amplitude amplification and estimation. AMS Contemporary Mathematics Series, 305. https://arxiv.org/abs/quant-ph/0005055v1
NEASQC deliverable: D5.1: Review of state-of-the-art for Pricing and Computation of VaR
Author: Gonzalo Ferro Costas & Alberto Manzano Herrero
-
class
tnbs.BTC_02_AE.QQuantLib.PE.classical_qpe.
CQPE
(**kwargs)¶ Bases:
object
Class for using classical Quantum Phase Estimation, with inverse of Quantum Fourier Transformation.
- Parameters
kwars (dictionary) –
dictionary that allows the configuration of the CQPE algorithm: Implemented keys:
- initial_stateQLM Program
QLM Program with the initial Psi state over the Grover-like operator will be applied Only used if oracle is None
- unitary_operatorQLM gate or routine
Grover-like operator which autovalues want to be calculated Only used if oracle is None
- cbits_numberint
number of classical bits for phase estimation
- qpuQLM solver
solver for simulating the resulting circuits
- shotsint
number of shots for quantum job. If 0 exact probabilities will be computed.
-
run
()¶ Creates the quantum phase estimation routine
QQuantLib.PE.iterative_quantum_pe¶
This module contains necessary functions and classes to implement Iterative Quantum Phase Estimation (IQPE). The implementation is based on following paper:
Dobšíček, Miroslav and Johansson, Göran and Shumeiko, Vitaly and Wendin, Göran*. Arbitrary accuracy iterative quantum phase estimation algorithm using a single ancillary qubit: A two-qubit benchmark. Physical Review A 3(76), 2007. https://arxiv.org/abs/quant-ph/0610214
Author: Gonzalo Ferro Costas & Alberto Manzano Herrero
-
class
tnbs.BTC_02_AE.QQuantLib.PE.iterative_quantum_pe.
IQPE
(**kwargs)¶ Bases:
object
Class for using Iterative Quantum Phase Estimation (IQPE) algorithm
- Parameters
kwars (dictionary) –
dictionary that allows the configuration of the ML-QPE algorithm. Implemented keys:
- initial_stateQLM Program
QLM Program withe the initial Psi state over the Grover-like operator will be applied Only used if oracle is None
- unitary_operatorQLM gate or routine
Grover-like operator whose autovalues want to be calculated Only used if oracle is None
- cbits_numberint
number of classical bits for phase estimation
- qpuQLM solver
solver for simulating the resulting circuits
- shotsint
number of shots for quantum job. If 0 exact probabilities will be computed.
- easybool
If True step_iqpe_easy will be used for each step of the algorithm If False step_iqpe will be used for each step.
-
apply_iqpe
()¶ Apply a complete IQPE algorithm
-
property
cbits_number
¶ creating cbits_number property
-
init_iqpe
()¶ Initialize several properties
-
iqpe
(number_of_cbits=None, shots=None)¶ This method apply a workflow for executing a complete IQPE algorithm
- Parameters
number_of_cbits (int (overwrite correspondent property)) – Number of classical bits for storing the phase estimation
shots (int (overwrite correspondent property)) – Number of shots for executing the QLM job
-
static
measure_classical_bits
(result)¶ Post-process intermediate measurements from a QLM result.
- Parameters
result (list list with QLM results) –
- Returns
pdf – contains extracted information from intermediate_measurements from a qlm result. Columns:
- BitStringstr.
String with the bits of the measurements done during simulation of the circuit
- BitIntint.
Integer representation of the BitString
- Phifloat.
Angle representation of the BitString between [0,1].
- Probabilityfloat.
Probability of the measurement of the classical bits.
- Return type
pandas DataFrame
-
static
post_proccess
(input_pdf)¶ This function uses the results property and add it additional columns that are useful for Amplitude Amplification procedure
- Parameters
input_pdf (Pandas DataFrame.) –
- Returns
final_results – DataFrame with complete information about the results
- Return type
Pandas DataFrame
-
restart
()¶ Reinitialize several properties for restart purposes
-
static
run_qprogram
(q_prog, q_aux, shots, linalg_qpu)¶ Executes a complete simulation
- Parameters
q_prog (QLM Program) –
q_aux (QLM qbit) – auxiliary qubit for measuring during all ipe steps
shots (int) – number of shots for simulation
linalg_qpu (QLM solver) –
- Returns
result (QLM result object)
circuit (QLM circuit)
pdf_time (pandas DataFrame) – DataFrame with elapsed time of different parts of the simulation
-
static
step_iqpe
(q_prog, q_gate, q_aux, c_bits, l)¶ Implements a iterative step of the Iterative Phase Estimation (IPE) algorithm.
- Parameters
q_prog (QLM program) – QLM Program where the unitary operator will be applied
q_gate (QLM AbstractGate) – QLM implementation of the unitary operator. We want estimate the autovalue theta of this operator
q_aux (QLM qbit) – auxiliary qubit for IPE. This qbit will be the control for application of the unitary operator to the principal bits of the program. Additionally will be the target qubit for the classical bit controlled rotation. This qubit will be reset at the end of the step.
c_bits (list) – list with the classical bits allocated for phase estimation
l (int) – iteration step of the IPE algorithm
-
static
sumarize
(input_pdf, columns=None)¶ This method summarize the results.
- Parameters
input_pdf (Pandas DataFrame.) –
columns (list) – list with the names of the input DataFrame for summarize
- Returns
final_results – DataFrame with summary results
- Return type
Pandas DataFrame