HamiltonianPhaseEstimation
class qiskit.algorithms.HamiltonianPhaseEstimation(num_evaluation_qubits, quantum_instance=None, sampler=None)
Bases: object
Run the Quantum Phase Estimation algorithm to find the eigenvalues of a Hermitian operator.
This class is nearly the same as PhaseEstimation
, differing only in that the input in that class is a unitary operator, whereas here the input is a Hermitian operator from which a unitary will be obtained by scaling and exponentiating. The scaling is performed in order to prevent the phases from wrapping around . The problem of estimating eigenvalues of the Hermitian operator is solved by running a circuit representing
where the input state is
and are the eigenvalues of .
Here, is a scaling factor sufficiently large to map positive to and negative to . Each time the circuit is run, one measures a phase corresponding to with probability .
If is a Pauli sum, the bound is computed from the sum of the absolute values of the coefficients of the terms. There is no way to reliably recover eigenvalues from phases very near the endpoints of these intervals. Because of this you should be aware that for degenerate cases, such as , the eigenvalues will be mapped to the same phase, , and so cannot be distinguished. In this case, you need to specify a larger bound as an argument to the method estimate
.
This class uses and works together with PhaseEstimationScale
to manage scaling the Hamiltonian and the phases that are obtained by the QPE algorithm. This includes setting, or computing, a bound on the eigenvalues of the operator, using this bound to obtain a scale factor, scaling the operator, and shifting and scaling the measured phases to recover the eigenvalues.
Note that, although we speak of “evolving” the state according the Hamiltonian, in the present algorithm, we are not actually considering time evolution. Rather, the role of time is played by the scaling factor, which is chosen to best extract the eigenvalues of the Hamiltonian.
A few of the ideas in the algorithm may be found in Ref. [1].
Reference:
[1]: Quantum phase estimation of multiple eigenvalues for small-scale (noisy) experiments
T.E. O’Brien, B. Tarasinski, B.M. Terhal arXiv:1809.09697
qiskit.algorithms.phase_estimators.hamiltonian_phase_estimation.HamiltonianPhaseEstimation.__init__()
’s argument quantum_instance
is deprecated as of qiskit-terra 0.24.0. It will be removed no earlier than 3 months after the release date. Instead, use the sampler
argument. See https://qisk.it/algo_migration for a migration guide.
Parameters
- num_evaluation_qubits (int) – The number of qubits used in estimating the phase. The phase will be estimated as a binary string with this many bits.
- quantum_instance (QuantumInstance |Backend | None) – Deprecated: The quantum instance on which the circuit will be run.
- sampler (BaseSampler | None) – The sampler primitive on which the circuit will be sampled.
Methods
estimate
estimate(hamiltonian, state_preparation=None, evolution=None, bound=None)
Run the Hamiltonian phase estimation algorithm.
Parameters
- hamiltonian (PauliOp |MatrixOp |SummedOp |Pauli |SparsePauliOp |PauliSumOp) – A Hermitian operator. If the algorithm is used with a
Sampler
primitive, the allowed types arePauli
,SparsePauliOp
, andPauliSumOp
. If the algorithm is used with aQuantumInstance
,PauliOp, ``MatrixOp
,PauliSumOp
, andSummedOp
types are allowed. - state_preparation (StateFn |QuantumCircuit |Statevector | None) – The
StateFn
to be prepared, whose eigenphase will be measured. If this parameter is omitted, no preparation circuit will be run and input state will be the all-zero state in the computational basis. - evolution (EvolutionSynthesis |EvolutionBase | None) – An evolution converter that generates a unitary from
hamiltonian
. IfNone
, then the defaultPauliTrotterEvolution
is used. - bound (float | None) – An upper bound on the absolute value of the eigenvalues of
hamiltonian
. If omitted, thenhamiltonian
must be a Pauli sum, or aPauliOp
, in which case a bound will be computed. Ifhamiltonian
is aMatrixOp
, thenbound
may not beNone
. The tighter the bound, the higher the resolution of computed phases.
Returns
HamiltonianPhaseEstimationResult
instance containing the result of the estimation and diagnostic information.
Raises
- TypeError – If
evolution
is not of typeEvolutionSynthesis
when aSampler
is provided. - TypeError – If
hamiltonian
type is notPauli
orSparsePauliOp
orPauliSumOp
when aSampler
is provided. - ValueError – If
bound
isNone
andhamiltonian
is not a Pauli sum, i.e. aPauliSumOp
or aSummedOp
whose terms are of typePauliOp
. - TypeError – If
evolution
is not of typeEvolutionBase
when noSampler
is provided.
Return type