pygsti.tools.lindbladtools

Utility functions relevant to Lindblad forms and projections

Module Contents

Functions

create_elementary_errorgen_dual(typ, p[, q, sparse, ...])

Construct a "dual" elementary error generator matrix in the "standard" (matrix-unit) basis.

create_elementary_errorgen_dual_pauli(typ, p[, q, sparse])

Construct a "dual" elementary error generator matrix in the "standard" (matrix-unit) basis.

create_elementary_errorgen(typ, p[, q, sparse])

Construct an elementary error generator as a matrix in the "standard" (matrix-unit) basis.

create_elementary_errorgen_pauli(typ, p[, q, sparse])

Construct an elementary error generator as a matrix in the "standard" (matrix-unit) basis.

create_lindbladian_term_errorgen(typ, Lm[, Ln, sparse])

Construct the superoperator for a term in the common Lindbladian expansion of an error generator.

random_CPTP_error_generator_rates(num_qubits[, ...])

Function for generating a random set of CPTP error generator rates.

pygsti.tools.lindbladtools.create_elementary_errorgen_dual(typ, p, q=None, sparse=False, normalization_factor='auto')

Construct a “dual” elementary error generator matrix in the “standard” (matrix-unit) basis.

The elementary error generator that is dual to the one computed by calling create_elementary_errorgen() with the same argument. This dual element can be used to find the coefficient of the original, or “primal” elementary generator. For example, if A = sum(c_i * E_i), where E_i are the elementary error generators given by create_elementary_errorgen()), then c_i = dot(D_i.conj(), A) where D_i is the dual to E_i.

There are four different types of dual elementary error generators: ‘H’ (Hamiltonian), ‘S’ (stochastic), ‘C’ (correlation), and ‘A’ (active). See arxiv:2103.01928. Each type transforms an input density matrix differently. The action of an elementary error generator L on an input density matrix rho is given by:

Hamiltonian: L(rho) = -1j/(2d^2) * [ p, rho ] Stochastic: L(rho) = 1/(d^2) p * rho * p Correlation: L(rho) = 1/(2d^2) ( p * rho * q + q * rho * p) Active: L(rho) = 1j/(2d^2) ( p * rho * q - q * rho * p)

where d is the dimension of the Hilbert space, e.g. 2 for a single qubit. Square brackets denotes the commutator and curly brackets the anticommutator. L is returned as a superoperator matrix that acts on vectorized density matrices.

Parameters

typ{‘H’,’S’,’C’,’A’}

The type of dual error generator to construct.

pnumpy.ndarray

d-dimensional basis matrix.

qnumpy.ndarray, optional

d-dimensional basis matrix; must be non-None if and only if typ is ‘C’ or ‘A’.

sparsebool, optional

Whether to construct a sparse or dense (the default) matrix.

normalization_factorstr or float, optional (default ‘auto’)

String or float specifying the normalization factor to apply. If a string the options are ‘auto’ and ‘auto_return’, which both use the corresponding (primal) elementary error generator to calculate this automatically and only differ in whether they return this normalization factor. If a float, the reciprocal of the input value is used directly.

Returns

ndarray or Scipy CSR matrix

pygsti.tools.lindbladtools.create_elementary_errorgen_dual_pauli(typ, p, q=None, sparse=False)

Construct a “dual” elementary error generator matrix in the “standard” (matrix-unit) basis. Specialized to p and q being elements of the (unnormalized) pauli basis.

The elementary error generator that is dual to the one computed by calling create_elementary_errorgen() with the same argument. This dual element can be used to find the coefficient of the original, or “primal” elementary generator. For example, if A = sum(c_i * E_i), where E_i are the elementary error generators given by create_elementary_errorgen()), then c_i = dot(D_i.conj(), A) where D_i is the dual to E_i.

There are four different types of dual elementary error generators: ‘H’ (Hamiltonian), ‘S’ (stochastic), ‘C’ (correlation), and ‘A’ (active). See arxiv:2103.01928. Each type transforms an input density matrix differently. The action of an elementary error generator L on an input density matrix rho is given by:

Hamiltonian: L(rho) = -1j/(2d^2) * [ p, rho ] Stochastic: L(rho) = 1/(d^2) p * rho * p Correlation: L(rho) = 1/(2d^2) ( p * rho * q + q * rho * p) Active: L(rho) = 1j/(2d^2) ( p * rho * q - q * rho * p)

where d is the dimension of the Hilbert space, e.g. 2 for a single qubit. Square brackets denotes the commutator and curly brackets the anticommutator. L is returned as a superoperator matrix that acts on vectorized density matrices.

Parameters

typ{‘H’,’S’,’C’,’A’}

The type of dual error generator to construct.

pnumpy.ndarray

d-dimensional basis matrix.

qnumpy.ndarray, optional

d-dimensional basis matrix; must be non-None if and only if typ is ‘C’ or ‘A’.

sparsebool, optional

Whether to construct a sparse or dense (the default) matrix.

Returns

ndarray or Scipy CSR matrix

pygsti.tools.lindbladtools.create_elementary_errorgen(typ, p, q=None, sparse=False)

Construct an elementary error generator as a matrix in the “standard” (matrix-unit) basis.

There are four different types of elementary error generators: ‘H’ (Hamiltonian), ‘S’ (stochastic), ‘C’ (correlation), and ‘A’ (active). See arxiv:2103.01928. Each type transforms an input density matrix differently. The action of an elementary error generator L on an input density matrix rho is given by:

Hamiltonian: L(rho) = -1j * [ p, rho ] Stochastic: L(rho) = p * rho * p - rho Correlation: L(rho) = p * rho * q + q * rho * p - 0.5 {{p,q}, rho} Active: L(rho) = 1j( p * rho * q - q * rho * p + 0.5 {[p,q], rho} )

Square brackets denotes the commutator and curly brackets the anticommutator. L is returned as a superoperator matrix that acts on vectorized density matrices.

Parameters

typ{‘H’,’S’,’C’,’A’}

The type of error generator to construct.

pnumpy.ndarray

d-dimensional basis matrix.

qnumpy.ndarray, optional

d-dimensional basis matrix; must be non-None if and only if typ is ‘C’ or ‘A’.

sparsebool, optional

Whether to construct a sparse or dense (the default) matrix.

Returns

ndarray or Scipy CSR matrix

pygsti.tools.lindbladtools.create_elementary_errorgen_pauli(typ, p, q=None, sparse=False)

Construct an elementary error generator as a matrix in the “standard” (matrix-unit) basis. Specialized to the case where p and q are elements of the (unnormalized) pauli basis.

There are four different types of elementary error generators: ‘H’ (Hamiltonian), ‘S’ (stochastic), ‘C’ (correlation), and ‘A’ (active). See arxiv:2103.01928. Each type transforms an input density matrix differently. The action of an elementary error generator L on an input density matrix rho is given by:

Hamiltonian: L(rho) = -1j * [ p, rho ] Stochastic: L(rho) = p * rho * p - rho Correlation: L(rho) = p * rho * q + q * rho * p - 0.5 {{p,q}, rho} Active: L(rho) = 1j( p * rho * q - q * rho * p + 0.5 {[p,q], rho} )

Square brackets denotes the commutator and curly brackets the anticommutator. L is returned as a superoperator matrix that acts on vectorized density matrices.

Parameters

typ{‘H’,’S’,’C’,’A’}

The type of error generator to construct.

pnumpy.ndarray

d-dimensional basis matrix.

qnumpy.ndarray, optional

d-dimensional basis matrix; must be non-None if and only if typ is ‘C’ or ‘A’.

sparsebool, optional

Whether to construct a sparse or dense (the default) matrix.

Returns

ndarray or Scipy CSR matrix

pygsti.tools.lindbladtools.create_lindbladian_term_errorgen(typ, Lm, Ln=None, sparse=False)

Construct the superoperator for a term in the common Lindbladian expansion of an error generator.

Mathematically, for d-dimensional matrices Lm and Ln, this routine constructs the d^2-dimension Lindbladian matrix L whose action is given by:

L(rho) = -i [Lm, rho] ` (when `typ == ‘H’)

or

L(rho) = Ln*rho*Lm^dag - 1/2(rho*Lm^dag*Ln + Lm^dag*Ln*rho) (typ == ‘O’)

where rho is a density matrix. L is returned as a superoperator matrix that acts on a vectorized density matrices.

Parameters

typ{‘H’, ‘O’}

The type of error generator to construct.

Lmnumpy.ndarray

d-dimensional basis matrix.

Lnnumpy.ndarray, optional

d-dimensional basis matrix.

sparsebool, optional

Whether to construct a sparse or dense (the default) matrix.

Returns

ndarray or Scipy CSR matrix

pygsti.tools.lindbladtools.random_CPTP_error_generator_rates(num_qubits, errorgen_types=('H', 'S', 'C', 'A'), max_weights=None, H_params=(0.0, 0.01), SCA_params=(0.0, 0.01), error_metric=None, error_metric_value=None, relative_HS_contribution=None, fixed_errorgen_rates=None, sslbl_overlap=None, label_type='global', seed=None, qubit_labels=None)

Function for generating a random set of CPTP error generator rates.

Parameters

num_qubitsint

Number of qubits the error generator acts upon.

errorgen_typestuple of str, optional (default(‘H’, ‘S’, ‘C’, ‘A’))

Tuple of strings designating elementary error generator types to include in this basis. Note that due to the CP constraint, certain values are not allowed, and any tuple containing ‘C’ or ‘A’ terms must also include ‘S’.

max_weightsdict, optional (default None)

An optional dictionary specifying the maximum weight for each of the elementary error generator types, with keys given by the strings ‘H’, ‘S’, ‘C’ and ‘A’. If None then there is no maximum weight. If specified, any error generator types without entries will have no maximum weight associated with them.

H_paramstuple of floats, optional (default (0.,.01))

Mean and standard deviation parameters for a normal distribution from which the H rates will be sampled. Note that specifying a non-zero value for the mean with generator_infidelity set to a non-trivial value is not supported, and will raise an error.

SCA_paramstuple of floats, optional (default (0.,.01))

Mean and standard deviation parameters for a normal distribution from which the entries of the matrix used in the construction of the S, C and A rates will be construction is sampled. Note that specifying a non-zero value for the mean with generator_infidelity set to a non-trivial value is not supported, and will raise an error.

error_metricstr, optional (default None)

An optional string, used in conjunction with the error_metric_value kwarg which specifies which metric to use in setting the sampled channel’s overall error rate. If None, no target value for the channel’s overall error rate is used. Currently supported options include:

  • ‘generator_infidelity’

  • ‘total_generator_error’

error_metric_valuefloat, optional (default None)

An float between 0 and 1 which gives the target value of the error metric specified in ‘error_metric’ for the channel induced by the randomly produced error generator. If None then no target value is used and the returned error generator will have a random generator infidelity.

relative_HS_contributiontuple, optional (default None)

An optional tuple, used in conjunction with the generator_infidelity kwarg, specifying the relative contributions of the H and S error generators to the generator infidelity. The values in this tuple should sum to 1. The first entry corresponds to the H sector, and the second the S sector.

sslbl_overlaplist of sslbls, optional (default None)

A list of state space labels corresponding to qudits the support of an error generator must overlap with (i.e. the support must include at least one of these qudits) in order to be included in this basis.

fixed_errorgen_ratesdict, optional (default None)

An optional dictionary whose keys are LocalElementaryErrorgenLabel objects, and whose values are error generator rates. When specified, the rates in this dictionary will override any randomly selected values in the final returned error generator rate dictionary. The inclusion of these rates is performed independently of any of the kwargs which otherwise control the weight and allowed types of the error generators in this model. If specifying fixed C and A rates it is possible for the final error generator to be non-CP.

label_typestr, optional (default ‘global’)

String which can be either ‘global’ or ‘local’, indicating whether to return a dictionary with keys which are GlobalElementaryErrorgenLabel or LocalElementaryErrorgenLabel objects respectively.

seedint, optional (default None)

An optional integer used in seeding the RNG.

qubit_labelslist or int or str, optional (default None)

An optional list of qubit labels upon which the error generator should act. Only utilized when returning global labels.

Returns

Dictionary of error generator coefficient labels and rates