Plaquette#
- class tqec.plaquette.Plaquette(name, qubits, circuit, mergeable_instructions=<factory>, debug_information=<factory>)[source]#
Bases:
object
Represents a QEC plaquette.
This class stores qubits in the plaquette local coordinate system and a scheduled circuit that should be applied on those qubits to perform the QEC experiment.
By convention, the local plaquette coordinate system is composed of a X-axis pointing to the right and a Y-axis pointing down.
- name#
a unique name for the plaquette. This field is used to compare plaquettes efficiently (two
Plaquette
instances are considered equal if and only if their names are the same) as well as computing a hash value for any plaquette instance. Finally, the name is used to represent aPlaquette
instance as a string.- Type:
str
- qubits#
qubits used by the plaquette circuit, given in the local plaquette coordinate system.
- circuit#
scheduled quantum circuit implementing the computation that the plaquette should represent.
- Type:
tqec.circuit.schedule.circuit.ScheduledCircuit
- mergeable_instructions#
a set of instructions that can be merged. This is useful when merging several plaquettes’ circuits together to remove duplicate instructions.
- Type:
frozenset[str]
- Raises:
TQECException – if the provided circuit uses qubits not listed in qubits.
- Parameters:
name (str)
qubits (PlaquetteQubits)
circuit (ScheduledCircuit)
mergeable_instructions (frozenset[str])
debug_information (PlaquetteDebugInformation)
Methods
__init__
(name, qubits, circuit[, ...])from_dict
(data)Return a plaquette from its dictionary representation.
is_empty
()Check if the plaquette is empty.
project_on_boundary
(projected_orientation)Project the plaquette on boundary and return a new plaquette with the remaining qubits and circuit.
Project the plaquette on the provided qubits and return a new plaquette with the remaining qubits and circuit.
project_on_data_qubits
(data_qubits)Project the plaquette on the provided qubits and return a new plaquette with the remaining qubits and circuit.
Return a hash of
self
that is replicable across OSes and Python runs.to_dict
()Return a dictionary representation of the plaquette.
with_debug_information
(debug_information)Create a copy of
self
with its debug information replaced by the provideddebug_information
.Attributes
num_measurements
Return the number of measurements performed in the circuit representing
self
.num_moments
Return the number of moments in the circuit representing
self
.origin
Return the plaquette origin.
debug_information
Detailed methods
- __init__(name, qubits, circuit, mergeable_instructions=<factory>, debug_information=<factory>)#
- Parameters:
name (str)
qubits (PlaquetteQubits)
circuit (ScheduledCircuit)
mergeable_instructions (frozenset[str])
debug_information (PlaquetteDebugInformation)
- Return type:
None
- is_empty()[source]#
Check if the plaquette is empty.
An empty plaquette is a plaquette that contain empty scheduled circuit.
- Return type:
bool
- project_on_boundary(projected_orientation)[source]#
Project the plaquette on boundary and return a new plaquette with the remaining qubits and circuit.
This method is useful for deriving a boundary plaquette from a integral plaquette.
- Parameters:
projected_orientation (PlaquetteOrientation) – the orientation of the plaquette after the projection.
- Returns:
A new plaquette with projected qubits and circuit. The qubits are updated to only keep the qubits on the side complementary to the provided orientation. The circuit is also updated to only use the kept qubits and empty moments with the corresponding schedules are removed.
- Return type:
- project_on_data_qubit_indices(data_qubits_indices)[source]#
Project the plaquette on the provided qubits and return a new plaquette with the remaining qubits and circuit.
This method is useful for deriving a boundary plaquette from a integral plaquette.
- Parameters:
data_qubits – data-qubit indices that will be kept in the returned plaquette.
data_qubits_indices (list[int])
- Returns:
A new plaquette with projected qubits and circuit. The qubits are updated to only keep the provided
data_qubits_indices
. The circuit is also updated to only use the kept qubits and empty moments with the corresponding schedules are removed.- Return type:
- project_on_data_qubits(data_qubits)[source]#
Project the plaquette on the provided qubits and return a new plaquette with the remaining qubits and circuit.
This method is useful for deriving a boundary plaquette from a integral plaquette.
- Parameters:
data_qubits (list[GridQubit]) – qubits that will be kept in the returned plaquette.
- Returns:
A new plaquette with projected qubits and circuit. The qubits are updated to only keep the provided
data_qubits
. The circuit is also updated to only use the kept qubits and empty moments with the corresponding schedules are removed.- Return type:
- reliable_hash()[source]#
Return a hash of
self
that is replicable across OSes and Python runs.The default
hash
function from Python is not guaranteed to always give the same value from the same input. In particular, with CPython,str
instances are hashed with an additional salt that is randomly picked at each call to the Python executable.This is an issue when trying to store a dictionary involving a plaquette as key and re-use it in subsequent runs or on other machines / OSes.
- Return type:
int