pygsti.extras.interpygate.core

Defines interpolated gate and factory classes

Module Contents

Classes

custom_interpolator

PhysicalProcess

PhysicalErrorGenerator

OpPhysicalProcess

InterpolatedOpFactory

An object that can generate "on-demand" operators (can be SPAM vecs, etc., as well) for a Model.

InterpolatedDenseOp

TODO: update docstring

InterpolatedQuantityFactory

Creates an InterpolatedQuantityFactory object.

InterpolatedQuantity

Attributes

use_csaps

pygsti.extras.interpygate.core.use_csaps = True
class pygsti.extras.interpygate.core.custom_interpolator(interpolator)
class pygsti.extras.interpygate.core.PhysicalProcess(num_params, process_shape, aux_shape=None, num_params_evaluated_as_group=0)

Bases: _PhysicalBase

abstract create_process_matrix(v, comm=None)
abstract create_process_matrices(v, grouped_v, comm=None)
class pygsti.extras.interpygate.core.PhysicalErrorGenerator(num_params, errorgen_shape, aux_shape=None, num_params_evaluated_as_group=0)

Bases: _PhysicalBase

abstract create_errorgen_matrix(v, comm=None)
abstract create_errorgen_matrices(v, grouped_v, comm=None)
class pygsti.extras.interpygate.core.OpPhysicalProcess(op)

Bases: PhysicalProcess

create_process_matrix(v, comm=None)
class pygsti.extras.interpygate.core.InterpolatedOpFactory(target_factory, argument_indices, base_interpolator, aux_interpolator=None)

Bases: pygsti.modelmembers.operations.opfactory.OpFactory

An object that can generate “on-demand” operators (can be SPAM vecs, etc., as well) for a Model.

It is assigned certain parameter indices (it’s a ModelMember), which definie the block of indices it may assign to its created operations.

The central method of an OpFactory object is the create_op method, which creates an operation that is associated with a given label. This is very similar to a LayerLizard’s function, though a LayerLizard has detailed knowledge and access to a Model’s internals whereas an OpFactory is meant to create a self-contained class of operators (e.g. continuously parameterized gates or on-demand embedding).

This class just provides a skeleton for an operation factory - derived classes add the actual code for creating custom objects.

Parameters

state_spaceStateSpace

The state-space of the operation(s) this factory builds.

evotypeEvotype

The evolution type of the operation(s) this factory builds.

Initialize a new ModelMember

property num_params

Get the number of independent parameters which specify this object.

Returns

int

classmethod create_by_interpolating_physical_process(target_factory, physical_process, argument_ranges, parameter_ranges, argument_indices=None, comm=None, mpi_workers_per_process=1, interpolator_and_args=None, verbosity=0)
create_object(args=None, sslbls=None)

Create the object that implements the operation associated with the given args and sslbls.

Note to developers The difference beween this method and create_op() is that this method just creates the foundational object without needing to setup its parameter indices (a technical detail which connects the created object with the originating factory’s parameters). The base-class create_op method calls create_object and then performs some additional setup on the returned object before returning it itself. Thus, unless you have a reason for implementing create_op it’s often more convenient and robust to implement this function.

Parameters
argslist or tuple

The arguments for the operation to be created. None means no arguments were supplied.

sslblslist or tuple

The list of state space labels the created operator should act on. If None, then these labels are unspecified and should be irrelevant to the construction of the operator (which typically, in this case, has some fixed dimension and no noition of state space labels).

Returns
ModelMember

Can be any type of operation, e.g. a LinearOperator, SPAMVec, Instrument, or POVM, depending on the label requested.

to_vector()

Get this object’s parameters as a 1D array of values.

Returns

numpy.ndarray

from_vector(v, close=False, dirty_value=True)

Initialize this object using a vector of parameters.

Parameters
vnumpy array

The 1D vector of parameters. Length must == num_params()

closebool, optional

Whether v is close to the current parameter vector.

dirty_valuebool, optional

The value to set this object’s “dirty flag” to before exiting this call. This is passed as an argument so it can be updated recursively. Leave this set to True unless you know what you’re doing.

Returns

None

class pygsti.extras.interpygate.core.InterpolatedDenseOp(target_op, base_interpolator, aux_interpolator=None, initial_point=None, frozen_parameter_values=None, frozen_parameter_indices=None)

Bases: pygsti.modelmembers.operations.DenseOperator

TODO: update docstring An operator that behaves like a dense super-operator matrix.

This class is the common base class for more specific dense operators.

Parameters

mxnumpy.ndarray

The operation as a dense process matrix.

basisBasis or {‘pp’,’gm’,’std’} or None

The basis used to construct the Hilbert-Schmidt space representation of this state as a super-operator. If None, certain functionality, such as access to Kraus operators, will be unavailable.

evotypeEvotype or str

The evolution type. The special value “default” is equivalent to specifying the value of pygsti.evotypes.Evotype.default_evotype.

state_spaceStateSpace, optional

The state space for this operation. If None a default state space with the appropriate number of qubits is used.

Attributes

basenumpy.ndarray

Direct access to the underlying process matrix data.

Initialize a new LinearOperator

property num_params

Get the number of independent parameters which specify this object.

Returns

int

classmethod create_by_interpolating_physical_process(target_op, physical_process, parameter_ranges=None, parameter_points=None, comm=None, mpi_workers_per_process=1, interpolator_and_args=None, verbosity=0)
to_vector()

Get this object’s parameters as a 1D array of values.

Returns

numpy.ndarray

from_vector(v, close=False, dirty_value=True)

Initialize this object using a vector of parameters.

Parameters
vnumpy array

The 1D vector of parameters. Length must == num_params()

closebool, optional

Whether v is close to the current parameter vector.

dirty_valuebool, optional

The value to set this object’s “dirty flag” to before exiting this call. This is passed as an argument so it can be updated recursively. Leave this set to True unless you know what you’re doing.

Returns

None

abstract transform_inplace(S)

Update operation matrix O with inv(s) * O * s.

Generally, the transform function updates the parameters of the operation such that the resulting operation matrix is altered as described above. If such an update cannot be done (because the operation parameters do not allow for it), ValueError is raised.

In this particular case any transform of the appropriate dimension is possible, since all operation matrix elements are parameters.

Parameters
sGaugeGroupElement

A gauge group element which specifies the “s” matrix (and it’s inverse) used in the above similarity transform.

Returns

None

class pygsti.extras.interpygate.core.InterpolatedQuantityFactory(fn_to_interpolate, qty_shape=(), parameter_ranges=None, parameter_points=None, num_params_to_evaluate_as_group=0, interpolator_and_args=None)

Bases: object

Creates an InterpolatedQuantityFactory object.

These objects are used to create InterpolatedQuantity objects, which hold interpolated quantities, using multiple processors.

Parameters

fn_to_interpolatefunction

The function to interpolate, which usually takes considerable resources to evaluate. If num_params_to_evaluate_as_group == 0 then the expected function definition is: def fn_to_interpolate(point, comm). The point argument is an array that specifies values of all the parameters, and comm is an MPI communicator. If num_params_to_evaluate_as_group > 0 then the function’s definition must be def fn_to_interpolate(point, grouped_axial_pts, comm). The point argument then omits values for the final num_params_to_evaluate_as_group parameters, which are instead specified by arrays of values within the list grouped_axial_pts.

qty_shapetuple

The shape of the quantity that is being interpolated. This is the shape of the array returned by fn_to_interpolate if num_params_to_evaluate_as_group == 0. In general, the shape of the array returned by fn_to_interpolate is qty_shape preceded by the number of values in each of the num_params_to_evaluate_as_group groups. An empty tuple means a floating point value.

parameter_rangeslist, optional

A list of elements that each specify the values a parameter ranges over. If the elements are tuples, they should be of the form (min_value, max_value, num_points) to specify a set of equally spaced num_points points. If the elements are numpy.ndarray objects, then they specify the values directly, e.g. array([0, 0.1, 0.4, 1.0, 5.0]). If parameter_ranges is specified, parameter_points must be left as None.

parameter_pointslist or numpy.ndarray, optional

A list or array of parameter-space points, which can be used instead of parameter_ranges to specify a non-rectangular grid of points. Each element is an array of real values specifying a single point in parameter space (the length of each element must be the same, and sets the number of parameters). If parameter_points is used, then num_params_to_evaluate_as_group must be 0.

num_params_to_evaluate_as_groupint, optional

The number of parameter ranges, counted back from the last one, that should be passed to fn_to_interpolate as an entire range of values, i.e. via the grouped_axial_pts argument.

interpolator_and_argstuple or string, optional

Optionally a 2-tuple of an interpolation class and argument dictionary. If None, the default of (csaps.NdGridCubicSmoothingSpline, {‘shape’, self.qty__shape}) is used. If csaps is not available, then (scipy.interpolate.LinearNDInterpolator, {‘rescale’: True}) is used instead. A linear interpolator can be specified explicitly by linear and the default spline interpolator may be explicitly specified by spline.

compute_data(comm=None, mpi_workers_per_process=1, verbosity=0)
build(comm=None, mpi_workers_per_process=1, verbosity=0)
class pygsti.extras.interpygate.core.InterpolatedQuantity(interpolators, parameter_ranges)

Bases: object

property qty_shape
property num_params
abstract classmethod from_file(filename)
abstract write(filename)