qbraid_algorithms.qpe
Quantum Phase Estimation (QPE)
Quantum Phase Estimation (QPE)
This module provides an implementation of the Quantum Phase Estimation (QPE) algorithm, a fundamental quantum algorithm for estimating eigenvalues of unitary operators. QPE is central to many quantum algorithms including Shor’s algorithm, HHL algorithm, and quantum simulation, providing exponential precision improvement over classical methods. The algorithm uses controlled unitary operations and the quantum Fourier transform to extract phase information with high precision, enabling efficient eigenvalue computation for quantum systems and linear algebra applications.
FORMULATION
Problem: Given a unitary operator \(U\) and eigenstate \(|u\rangle\) such that \(U|u\rangle = e^{2\pi i \varphi}|u\rangle\), estimate the phase \(\varphi\).
Algorithm Steps:
Initialization: Prepare \(n\) ancilla qubits in superposition and eigenstate:
\(|\psi_0\rangle = \frac{1}{\sqrt{2^n}} \sum_{j=0}^{2^n-1} |j\rangle \otimes |u\rangle\)
Controlled Unitary Evolution: Apply controlled \(U^{2^k}\) operations:
\(|\psi_1\rangle = \frac{1}{\sqrt{2^n}} \sum_{j=0}^{2^n-1} e^{2\pi i \varphi j} |j\rangle \otimes |u\rangle\)
Inverse QFT: Apply IQFT to ancilla register:
\(|\psi_2\rangle = |\tilde{\varphi}\rangle \otimes |u\rangle\)
Measurement: Measure ancilla to obtain \(n\)-bit approximation \(\tilde{\varphi}\)
Precision: With \(n\) ancilla qubits, QPE estimates \(\varphi\) to \(n\)-bit precision with high probability:
\(|\varphi - \tilde{\varphi}| \leq \frac{1}{2^n}\)
Success Probability: For exact phases representable in \(n\) bits, success probability is 1. For general phases, success probability \(\geq \frac{4}{\pi^2} \approx 0.405\).
Circuit Depth: Requires \(O(n^2)\) gates and \(O(n)\) applications of controlled-\(U^{2^k}\) operations.
Classes
PhaseEstimationLibrary(*args, **kwargs)Library to implement phase estimation circuits directly related to classical phase estimation algorithms.
Functions
generate_program(unitary_filepath, psi_filepath)Load the Quantum Phase Estimation (QPE) program as a pyqasm module.
save_to_qasm(unitary_filepath[, num_qubits, ...])Creates a QPE subroutine module with user-defined unitary and number of qubits.
get_result(counts)Extract the eigenvalue from Quantum Phase Estimation measurement counts.