pygsti.extras.interpygate.core

Defines interpolated gate and factory classes

Module Contents

Classes

_PhysicalBase

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

InterpolatedQuantity

Functions

_split(n, a, cast_to_array=True)

_flatten(x)

pygsti.extras.interpygate.core._split(n, a, cast_to_array=True)
pygsti.extras.interpygate.core._flatten(x)
class pygsti.extras.interpygate.core._PhysicalBase(num_params, item_shape, aux_shape=None, num_params_evaluated_as_group=0)

Bases: object

abstract create_aux_info(self, v, comm=None)
abstract create_aux_infos(self, v, grouped_v, comm=None)
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(self, v, comm=None)
abstract create_process_matrices(self, 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(self, v, comm=None)
abstract create_errorgen_matrices(self, v, grouped_v, comm=None)
class pygsti.extras.interpygate.core.OpPhysicalProcess(op)

Bases: PhysicalProcess

create_process_matrix(self, 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_space (StateSpace) – The state-space of the operation(s) this factory builds.

  • evotype (Evotype) – The evolution type of the operation(s) this factory builds.

classmethod create_by_interpolating_physical_process(cls, 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(self, 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 :method:`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
  • args (list or tuple) – The arguments for the operation to be created. None means no arguments were supplied.

  • sslbls (list 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.

property num_params(self)

Get the number of independent parameters which specify this object.

Returns

int

to_vector(self)

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

Returns

numpy.ndarray

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

Initialize this object using a vector of parameters.

Parameters
  • v (numpy array) – The 1D vector of parameters. Length must == num_params()

  • close (bool, optional) – Whether v is close to the current parameter vector.

  • dirty_value (bool, 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
  • mx (numpy.ndarray) – The operation as a dense process matrix.

  • evotype (Evotype or str) – The evolution type. The special value “default” is equivalent to specifying the value of pygsti.evotypes.Evotype.default_evotype.

  • state_space (StateSpace, optional) – The state space for this operation. If None a default state space with the appropriate number of qubits is used.

base

Direct access to the underlying process matrix data.

Type

numpy.ndarray

classmethod create_by_interpolating_physical_process(cls, target_op, physical_process, parameter_ranges=None, parameter_points=None, comm=None, mpi_workers_per_process=1, interpolator_and_args=None, verbosity=0)
property num_params(self)

Get the number of independent parameters which specify this object.

Returns

int

to_vector(self)

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

Returns

numpy.ndarray

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

Initialize this object using a vector of parameters.

Parameters
  • v (numpy array) – The 1D vector of parameters. Length must == num_params()

  • close (bool, optional) – Whether v is close to the current parameter vector.

  • dirty_value (bool, 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(self, 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

s (GaugeGroupElement) – 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

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

Bases: object

abstract classmethod from_file(cls, filename)
property qty_shape(self)
property num_params(self)
__call__(self, v)
abstract write(self, filename)