Header menu logo Encodings

VariationalCircuits Module

Symbolic support for VQE measurement programs and QPE resource estimation.

Provides tools for grouping Hamiltonian terms into qubit-wise commuting measurement bases (reducing the number of measurement circuits needed in VQE), shot-budget estimation, and QPE circuit resource estimation using first-order Trotterization.

Types

Type Description

MeasurementBasis

A measurement basis for simultaneous measurement of commuting Pauli terms.

MeasurementProgram

Complete measurement program for estimating ⟨H⟩.

QPEResourceEstimate

QPE resource estimate for a Hamiltonian simulation circuit.

Functions and values

Function or value Description

estimateShots epsilon hamiltonian

Full Usage: estimateShots epsilon hamiltonian

Parameters:
    epsilon : float - Target precision for the energy estimate.
    hamiltonian : PauliRegisterSequence - The Hamiltonian as a sum of Pauli strings.

Returns: int Estimated number of measurement shots (rounded up).

Estimate total measurement shots needed for precision ε on ⟨H⟩.

Uses the formula: shots ≈ (Σ|cₖ|)² / ε², derived from the variance of the estimator for the expectation value of a sum of Pauli terms.

epsilon : float

Target precision for the energy estimate.

hamiltonian : PauliRegisterSequence

The Hamiltonian as a sum of Pauli strings.

Returns: int

Estimated number of measurement shots (rounded up).

groupCommutingTerms hamiltonian

Full Usage: groupCommutingTerms hamiltonian

Parameters:
Returns: MeasurementProgram A MeasurementProgram describing the grouped bases.

Group Hamiltonian terms into qubit-wise commuting measurement bases.

Uses a greedy algorithm: sort terms by |coefficient| descending, then assign each term to the first compatible group. This is a heuristic — optimal grouping is NP-hard in general.

hamiltonian : PauliRegisterSequence

The Hamiltonian as a sum of Pauli strings.

Returns: MeasurementProgram

A MeasurementProgram describing the grouped bases.

qpeResources precisionBits hamiltonian dt

Full Usage: qpeResources precisionBits hamiltonian dt

Parameters:
    precisionBits : int - Number of ancilla bits for phase readout.
    hamiltonian : PauliRegisterSequence - The Hamiltonian as a sum of Pauli strings.
    dt : float - Trotter time step size.

Returns: QPEResourceEstimate A QPEResourceEstimate with circuit resource counts.

QPE resource estimation for a given precision and Hamiltonian.

Estimates the resources for quantum phase estimation using first-order Trotterization for the controlled-U circuit. The number of controlled-U applications scales as 2^(precisionBits) - 1.

precisionBits : int

Number of ancilla bits for phase readout.

hamiltonian : PauliRegisterSequence

The Hamiltonian as a sum of Pauli strings.

dt : float

Trotter time step size.

Returns: QPEResourceEstimate

A QPEResourceEstimate with circuit resource counts.

qubitWiseCommutes a b

Full Usage: qubitWiseCommutes a b

Parameters:
Returns: bool true if the two registers qubit-wise commute.

Two Pauli operators qubit-wise commute if at each position either both are the same or at least one is I.

a : PauliRegister

First Pauli register.

b : PauliRegister

Second Pauli register.

Returns: bool

true if the two registers qubit-wise commute.

Type something to start searching.