TopologicalComputationGraph#
- class tqec.compile.TopologicalComputationGraph(scalable_qubit_shape, observable_builder, observables=None)[source]#
Bases:
object
Represents a topological computation with
Block
instances.Methods
__init__
(scalable_qubit_shape, ...[, ...])Represents a topological computation with
Block
instances.add_cube
(position, block)add_pipe
(source, sink, block)Add the provided block as a pipe between
source
andsink
.generate_crumble_url
(k[, manhattan_radius, ...])Generate the Crumble URL from the compiled graph.
generate_stim_circuit
(k[, noise_model, ...])Generate the
stim.Circuit
from the compiled graph.Merge layers happening in parallel at each time step.
Detailed methods
- Parameters:
scalable_qubit_shape (PhysicalQubitScalable2D)
observable_builder (ObservableBuilder)
observables (list[AbstractObservable] | None)
- __init__(scalable_qubit_shape, observable_builder, observables=None)[source]#
Represents a topological computation with
Block
instances.- Parameters:
scalable_qubit_shape (PhysicalQubitScalable2D)
observable_builder (ObservableBuilder)
observables (list[AbstractObservable] | None)
- Return type:
None
- add_cube(position, block)[source]#
- Parameters:
position (BlockPosition3D)
block (Block)
- Return type:
None
- add_pipe(source, sink, block)[source]#
Add the provided block as a pipe between
source
andsink
.- Raises:
TQECException – if
source
andsink
are not neighbouring positions.TQECException – if
not source < sink
.TQECException – if there is already a pipe between
source
andsink
.TQECException – if
block
is not a valid pipe (i.e., has not exactly 2 scalable dimensions).
- Parameters:
source (BlockPosition3D)
sink (BlockPosition3D)
block (Block)
- Return type:
None
- generate_crumble_url(k, manhattan_radius=2, detector_database=None, add_polygons=False)[source]#
Generate the Crumble URL from the compiled graph.
- Parameters:
k (int) – scaling factor.
manhattan_radius (int) – Parameter for the automatic computation of detectors. Should be large enough so that flows canceling each other to form a detector are strictly contained in plaquettes that are at most at a distance of
manhattan_radius
from the central plaquette. Detector computation runtime grows with this parameter, so you should try to keep it to its minimum. A value too low might produce invalid detectors.detector_database (DetectorDatabase | None) – existing database of detectors that is used to avoid computing detectors if the database already contains them. Default to None which result in not using any kind of database and unconditionally performing the detector computation.
add_polygons (bool) – whether to include polygons in the Crumble URL. If
True
, the polygons representing the stabilizers will be generated based on the RPNG information of underlying plaquettes and add to the Crumble URL.
- Returns:
a string representing the Crumble URL of the quantum circuit.
- Return type:
str
- generate_stim_circuit(k, noise_model=None, manhattan_radius=2, detector_database=None)[source]#
Generate the
stim.Circuit
from the compiled graph.- Parameters:
k (int) – scale factor of the templates.
noise_models – noise models to be applied to the circuit.
manhattan_radius (int) – radius considered to compute detectors. Detectors are not computed and added to the circuit if this argument is negative.
detector_database (DetectorDatabase | None) – an instance to retrieve from / store in detectors that are computed as part of the circuit generation.
noise_model (NoiseModel | None)
- Returns:
A compiled stim circuit.
- Return type:
Circuit
- to_layer_tree()[source]#
Merge layers happening in parallel at each time step.
This method considers all the layers contained in added blocks (cubes and pipes) and merges them into a sequence of
LayoutLayer
orBaseComposedLayer
wrappingLayoutLayer
instances.- Returns:
A tree representing the topological computation.
The root node of the returned tree is an instance of
SequencedLayers
. Each child of the root node represents the computation happening during one block of time.Each child of the root node is also an instance of
SequencedLayers
.- Return type:
LayerTree