pygsti.models.stencillabel
Stencil label classes and supporting functions.
Module Contents
Classes
A generalization of a simple tuple of state space labels. |
|
A stencil label that is a single state space label tuple. |
|
A stencil label that is explicitly a set of multiple state space label tuples. |
|
A stencil label that expands into all the length-k combinations of a larger set of state space labels. |
|
A stencil label specifying all length-k combinations of the labels within a radius of some "base" label(s). |
- class pygsti.models.stencillabel.StencilLabel(local_state_space=None)
Bases:
object
A generalization of a simple tuple of state space labels.
A
StencilLabel
can be a simple tuple of absolute state space labels, but it can also contain special labels identifying the target labels of a gate (@<int>) and qubit-graph directions relative to target labels, e.g. @0+left. Furthermore, a stencil label can expand into multiple state-space label tuples, e.g. the 2-tuples of all the qubit-graph edges.Parameters
- local_state_spaceStateSpace
A manually supplied local state space for this label, which is returned by
create_local_state_space()
instead of generating a local state space.
- local_state_space
- classmethod cast(obj)
Convert an object into a stencil label if it isn’t already.
Parameters
- objobject
The object to convert.
Returns
StencilLabel
- abstract compute_absolute_sslbls(qubit_graph, state_space, target_lbls)
Creates a list of all the state space label tuples this stencil label expands into.
To perform the expansion, the qubit graph of the relevant processor is required, along with the target state space labels, which determine where the stencil is placed on the qubit graph. The returned list of tuples contains absolute state space labels, meaning that they are labels in state_space and do not use any special directives.
Parameters
- qubit_graphQubitGraph
The qubit graph of the relevant processor, used to resolve any special stencil labels.
- state_spaceStateSpace
The state space for the entire processor. This specifies what the state space labels are.
- target_lblstuple
The target state space labels, specifying where the stencil is placed on the qubit graph before being expanded into absolute state space labels.
Returns
- list
The state space label tuples this stencil label expands into, e.g. [(‘Q0’,’Q1’), (‘Q1’,’Q2’)].
- create_local_state_space(entire_state_space)
Creates a “local” state space for an operator indexed using this stencil label.
When creating operator objects, a stencil label specifies where to place (embed) operators on some subset of the entire space. When these to-be-embedded operations are constructed, they need to be supplied with a state space that just corresponds to the sub-space where they act – a “local” state space. A stencil label expands into one or more state space label tuples, and this function constructs a single local state space that is appropriate for any and all of these tuples (i.e. what is returned by
compute_absolute_sslbls()
), and that is therefore appropriate for constructing the to-be-embedded operation. Importantly, this function can be called without knowing where this stencil label will be placed, that is, it doesn’t require a “target labels” argument.Parameters
- entire_state_spaceStateSpace
The entire state space of the relevant processor, specifying the state space labels and information about them.
Returns
StateSpace
- class pygsti.models.stencillabel.StencilLabelTuple(stencil_sslbls)
Bases:
StencilLabel
A stencil label that is a single state space label tuple.
This is the simplest type of stencil labels, and almost the same as just a tuple of state space labels. It may contain, however, special stencil directives like ‘@<num>’ and direction labels.
Parameters
- stencil_sslblstuple
A tuple of state space labels. May contain special stencil directives.
- sslbls
- compute_absolute_sslbls(qubit_graph, state_space, target_lbls)
Creates a list of all the state space label tuples this stencil label expands into.
- class pygsti.models.stencillabel.StencilLabelSet(stencil_sslbls_set)
Bases:
StencilLabel
A stencil label that is explicitly a set of multiple state space label tuples.
A
StencilLabelSet
stencil label simply expands into the list/set of state space label tuples used to construct it. It may contain special stencil directives, and is essentially just a list or tuple ofStencilLabelTuple
objects.Parameters
- stencil_sslbls_setlist or tuple or set
A collection of the individual state space label tuples that this stencil label expands into. May contain special stencil directives.
- sslbls_set
- compute_absolute_sslbls(qubit_graph, state_space, target_lbls)
Creates a list of all the state space label tuples this stencil label expands into.
- class pygsti.models.stencillabel.StencilLabelAllCombos(possible_sslbls, num_to_choose, connected=False)
Bases:
StencilLabel
A stencil label that expands into all the length-k combinations of a larger set of state space labels.
For example, if num_to_choose = 2 and possible_sslbls = [1,2,3] then this stencil label would expand into the pairs: [(1,2), (2,3), (1,3)]. Optionally, the tuples can be restricted to only those that form a connected sub-graph of the qubit graph (eliminating (1,3) in our example if the qubits were in a 1-2-3 chain).
Parameters
- possible_sslblslist or tuple
The set of possible state space labels to take combinations of.
- num_to_chooseint
The number of possible state space labels to choose when forming each state space label tuple.
- connectedbool, optional
If True, restrict combinations to those that form a connected subgraph of the qubit graph.
- possible_sslbls
- num_to_choose
- connected
- compute_absolute_sslbls(qubit_graph, state_space, target_lbls)
Creates a list of all the state space label tuples this stencil label expands into.
- class pygsti.models.stencillabel.StencilLabelRadiusCombos(base_sslbls, radius, num_to_choose, connected=False)
Bases:
StencilLabel
A stencil label specifying all length-k combinations of the labels within a radius of some “base” label(s).
This stencil label depends heavily on the qubit graph. It expands to all length-num_to_choose combinations of the qubit graphy nodes (state space labels) that lie within radius edge traversals of any of the node labels in base_sslbls. If connected=True then the combinations are further filtered so that they must form connected subgraphs of the qubit graph.
Parameters
- base_sslblstuple
The state space labels that form the “center” of the possible labels
- radiusint
The maximum number of edge traversals (along the qubit graph) used to define the “radius” of labels about the base labels.
- num_to_chooseint
The number of possible state space labels in each combination of the labels within the radius of possible labels. This stencil label expands into potentially many state space label tuples all of this length.
- connectedbool, optional
If True, restrict combinations to those that form a connected subgraph of the qubit graph.
- base_sslbls
- radius
- num_to_choose
- connected
- compute_absolute_sslbls(qubit_graph, state_space, target_lbls)
Creates a list of all the state space label tuples this stencil label expands into.