Skip to main contentIBM Quantum Documentation Mirror

Bounds

qiskit_addon_slc.bounds

Bound computation functions.

This module provides various functions for computing the error bounds that make up a shaded lightcone.

compute_forward_bounds

compute_forward_bounds(circuit, noise_model_paulis, /, observable, *, evolution_max_terms=1000000, eigval_max_qubits=14, atol=1e-08, atol_simplify=1e-08, atol_eigenvalue=1e-08, **kwargs)

GitHub

Compute the forward-evolved unequal-time commutator bounds.

Starting at the end of the circuit, compute the forward-evolved unequal-time commutator bounds for all Pauli error terms of each noisy layer in the target circuit.

That is, compute [EF,AF]2\| \left[ E_F, A_F \right] \|_2 for all error terms, EFE_F, where AFA_F is the target observable to be measured on circuit.

The error terms, EIE_I, are dictated by noise_model_paulis. This dictionary maps noise model identifiers (samplomatic.InjectNoise.ref) to a list of Pauli error terms. The corresponding terms will be used whenever a BoxOp with a matching InjectNoise annotation is encountered during the iteration over circuit.

Deprecated since version 0.2.0

qiskit_addon_slc.bounds.forward.compute_forward_bounds()’s argument atol is deprecated as of qiskit-addon-slc 0.2.0. It will be removed no earlier than 3 months after the release date. Use atol_simplify and atol_eigenvalue instead.

Parameters

  • circuit (QuantumCircuit) – the target circuit.
  • noise_model_paulis (dict[str, QubitSparsePauliList]) – the Pauli error terms to consider for each noise model.
  • observable (Pauli |PauliList |SparseObservable |SparsePauliOp) – the target observable to be measured at the end of the circuit.
  • evolution_max_terms (int) – the maximum number of operator terms to keep track of during the evolution.
  • eigval_max_qubits (int) – the maximum number of qubits of a commutator for which the eigenvalue will still be attempted to be computed. When this value is exceeded, the bound is approximated via a simpler and more loose triangle inequality.
  • atol (float) – DEPRECATED use atol_simplify and atol_eigenvalue instead!
  • atol_simplify (float) – the absolute tolerance used for trimming terms from the commutator. Loosening this tolerance will result in a greater truncation of the commutator’s terms, rendering the computation of its eigenvalue cheaper but less accurate.
  • atol_eigenvalue (float) – the absolute tolerance used for detecting convergence of the commutator’s eigenvalue. Loosening this tolerance will result in a less accurate eigenvalue as computed by the iterative Davidson eigensolver.
  • kwargs – any additional keyword arguments will be forward to compute_bounds().

Returns

The unequal-time commutator bound.

Raises

NotImplementedError – when the observable contains more than a single Pauli term. If you run into this, you will need to call this function for each target Pauli separately.

Return type

dict[str, PauliLindbladMap]

tighten_with_speed_limit

tighten_with_speed_limit(bounds, circuit, noise_model_paulis, /, observable)

GitHub

Tighten the provided bounds using limits on the speed of information propagation.

Inspired by the ideas behind the Lieb-Robinson bounds, this function leverages limits on the speed of information propagation to tighten previously computed forward-evolved unequal-time commutator bounds (see also compute_forward_bounds()).

Parameters

Returns

A tightened copy of the unequal-time commutator bounds.

Raises

  • NotImplementedError – when the observable contains more than a single Pauli term. If you run into this, you will need to call this function for each target Pauli separately.
  • ValueError – when encountering a gate that acts on more than 2 qubits.

Return type

dict[str, PauliLindbladMap]

compute_backward_bounds

compute_backward_bounds(circuit, noise_model_paulis, /, *, evolution_max_terms=1000000, **kwargs)

GitHub

Compute the backward-evolved unequal-time commutator bounds.

Starting at the beginning of the circuit, compute the backward-evolved unequal-time commutator bounds for all Pauli error terms of each noisy layer in the target circuit.

That is, compute [EI,ρI]1\| \left[ E_I, \rho_I \right] \|_1 (using the Schatten 1-norm aka nuclear norm) for all error terms, EIE_I, where ρI\rho_I is assumed to be the all-zero state, 00\ket{0 \ldots 0}, on all active qubits in circuit.

The error terms, EIE_I, are dictated by noise_model_paulis. This dictionary maps noise model identifiers (samplomatic.InjectNoise.ref) to a list of Pauli error terms. The corresponding terms will be used whenever a BoxOp with a matching InjectNoise annotation is encountered during the iteration over circuit.

Caution

Before computing the bounds, this function removes all Measure operations from circuit. This is required because the circuit is being inverted before being processed in reverse order, which allows the backward evolution to be treated like a forward evolution (in the inverted circuit).

Parameters

  • circuit (QuantumCircuit) – the target circuit.
  • noise_model_paulis (dict[str, QubitSparsePauliList]) – the Pauli error terms to consider for each noise model.
  • evolution_max_terms (int) – the maximum number of operator terms to keep track of during the evolution. (If the operator exceeds this size, the smallest terms are truncated).
  • kwargs – any additional keyword arguments will be forward to compute_bounds().

Returns

The backward-evolved unequal-time commutator bounds.

Return type

dict[str, PauliLindbladMap]

merge_bounds

merge_bounds(circuit, forward_bounds, backward_bounds, /, noise_rates=None, *, is_clifford_circuit=False)

GitHub

Merge forward and backward bounds.

The layer at which the switch from using backward bounds to using forward bounds takes place will be the same for all qubits. It is determined by taking into account the provided learned noise_rates. If these are not provided, uniform noise rates are assumed. While this is an unrealistic assumption, previewing the merged bounds may still be useful.

Parameters

Returns

The merged bounds.

Raises

  • ValueError – when both provided bounds are None.
  • KeyError – when the bounds contain an InjectNoise.modifier_ref key which does not occur in the target circuit or whose InjectNoise.ref is not found.
  • ValueError – if the noise model Pauli terms whose bounds are computed for a given InjectNoise.modifier_ref do not match between the forward_bounds and backward_bounds.
  • NotImplementedError – when is_clifford_circuit is True.

Return type

dict[str, PauliLindbladMap] | None

compute_local_scales

compute_local_scales(circuit, bounds, /, noise_rates, *, sampling_cost_budget=inf, bias_tolerance=0.0)

GitHub

Computes the local_scales argument to a Samplex.

This local_scales argument is used to specify which individual error terms to mitigate.

Either the sampling_cost_budget or bias_tolerance must be specified. The former puts an upper bound on the sampling cost while the latter puts an upper bound on the remaining bias to tolerate.

Note

If the order of Pauli terms in bounds and noise_rates do not match, the output of this function will assume the order set forth by noise_rates in order to ensure that the scales are compatible with the rates that will also be provided to the QuantumProgram.

Parameters

Returns

  • the local_scales dictionary to be provided as the direct input to the samplomatic.samplex.Samplex.inputs().
  • the sampling cost overhead (γ2\gamma^2) required to perform the sampling of local_scales.
  • the remaining bias on expectation values computed with these bounds.

Return type

A tuple of length 3, the items of which are

Raises

  • ValueError – if non-default values are provided for both, the sampling_cost_budget and bias_tolerance.
  • KeyError – if noise_rates is missing an entry for any noise model identifier (InjectNoise.ref) encountered in circuit.

This module also contains some lower level functions which are usually not accessed by an end-user directly, but may prove useful for additional development on top of this package.

compute_bounds

compute_bounds(circuit, noise_model_paulis, light_cone, norm_fn, *, backwards, max_num_boxes=None, num_processes=1, timeout=None)

GitHub

Computes the unequal time commutator bounds.

Given a circuit with BoxOp instructions with InjectNoise annotations and a mapping of noise model identifiers (InjectNoise.ref) to list of Pauli error terms (noise_model_paulis), this function computes the unequal time commutator bounds (the details of which are implemented by norm_fn). In doing so, it only considers gates that lie within the light-cone of the observable (initialized by light_cone). These computed bounds form the basis of the shaded light-cone.

Since this function performs a long-running computation, it gracefully handles KeyboardInterrupt exceptions, allowing the user to interrupt the computation at an arbitrary point in time and still obtain the results that have been computed up to that point.

Parameters

  • circuit (QuantumCircuit) – the target circuit.
  • noise_model_paulis (dict[str, QubitSparsePauliList]) – the Pauli error terms to consider for each noise model.
  • light_cone (LightCone) – the initialized and stateful LightCone tracker.
  • norm_fn (Callable[[Pauli, RotationGates], CommutatorBounds]) – the function implementing the specific unequal time commutator.
  • backwards (bool) – whether to iterate over the circuit in reverse.
  • max_num_boxes (int | None) – the maximum number of boxes for which to compute bounds. Bounds for any additional boxes will be given the trivial upper bound value of 2.02.0.
  • num_processes (int) – the number of parallel processes to use.
  • timeout (float | None) – an optional timeout (in seconds) after which all remaining layers are filled with trivial numerical bounds of 2.0. Note, that this is not a strict timeout and the layer being processed at the time of reaching this timeout will complete normally.

Returns

The computed unequal time commutator bounds.

Return type

dict[str, PauliLindbladMap]

CommutatorBounds

class CommutatorBounds(commutator_bound, truncation_bias, fallback_to_tri_ineq)

GitHub

Bases: NamedTuple

A dataclass to store metadata about the computed commutator bounds.

Create new instance of CommutatorBounds(commutator_bound, truncation_bias, fallback_to_tri_ineq)

Parameters

  • commutator_bound (float)
  • truncation_bias (float)
  • fallback_to_tri_ineq (bool)

commutator_bound

Type: float

The bound on the commutator.

This bound will be computed in different means depending on the application. For example, backward bounds will compute the nuclear norm (Schatten 1-norm) while forward bounds are typically computed using the spectral norm (Schatten infinity-norm).

If the norm computation exceeds specified difficulty limits, it will be abandoned in favor of a simpler bound based on the triangle inequality, which is indicated by fallback_to_tri_ineq being set to True.

This value may be NaN when the computation of the commutor bound was aborted. This can happen when the truncation_bias already exceeds the theoretical bound of 2.0.

fallback_to_tri_ineq

Type: bool

Whether commutator_bound was computed “loosely” using a simple triangle inequality.

min

min()

GitHub

Returns the minimum bound encoded by this metadata.

The minimal bound is the smaller of the sum of commutator_bound and truncation_bias or the theoretical bound of 2.0.

The value of 2.0 is used because a Pauli observable bounded on the range [-1, +1] cannot be biased by more than 2.0.

Return type

float

truncation_bias

Type: float

The bias on the bound due to truncation of the commutator.