pygsti.extras.interpygate
Interpygate Sub-package
Submodules
Package Contents
Classes
TODO: update docstring |
|
An object that can generate "on-demand" operators (can be SPAM vecs, etc., as well) for a Model. |
Functions
|
Returns an explicit column-vector representation of a square matrix, obtained by reading |
|
A function that vectorizes a process in the basis of matrix units, sorted first |
|
A function to compute the process matrix for a quantum channel given a function |
- class pygsti.extras.interpygate.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.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
- target_op
- base_interpolator
- aux_interpolator = 'None'
- aux_info = 'None'
- 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)
- 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.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
- target_factory
- base_interpolator
- aux_interpolator = 'None'
- num_factory_args
- 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.
- 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
- pygsti.extras.interpygate.vec(matrix)
Returns an explicit column-vector representation of a square matrix, obtained by reading from the square matrix in column-major order.
- Args:
matrix (list,numpy.ndarray): NxN matrix
- Returns:
numpy.ndarray: N^2x1 dimensional column vector
- Raises:
ValueError: If the input matrix is not square.
- pygsti.extras.interpygate.unvec(vectorized)
A function that vectorizes a process in the basis of matrix units, sorted first by column, then row.
- Args:
vectorized (list,numpy.ndarray): Nx1 matrix or N-dimensional vector
- Returns:
numpy.ndarray: NxN dimensional column vector
- Raises:
ValueError: If the length of the input is not a perfect square
- pygsti.extras.interpygate.run_process_tomography(state_to_density_matrix_fn, n_qubits=1, comm=None, verbose=False, basis='pp', time_dependent=False, opt_args=None)
A function to compute the process matrix for a quantum channel given a function that maps a pure input state to an output density matrix.
- Args:
- state_to_density_matrix_fn(function: array -> array)
The function that computes the output density matrix from an input pure state.
- n_qubits(int, optional, default 1)
The number of qubits expected by the function. Defaults to 1.
- comm(MPI.comm object, optional)
An MPI communicator object for parallel computation. Defaults to local comm.
- verbose(bool, optional, default False)
How much detail to send to stdout
- basis(str, optional, default ‘pp’)
The basis in which to return the process matrix
- time_dependent(bool, optional, default False )
If the process is time dependent, then expect the density matrix function to return a list of density matrices, one at each time point.
- opt_args(dict, optional)
Optional keyword arguments for state_to_density_matrix_fn
- Returns:
- numpy.ndarray
The process matrix representation of the quantum channel in the basis specified by ‘basis’. If ‘time_dependent’=True, then this will be an array of process matrices.