LayoutLayer#

class tqec.compile.blocks.LayoutLayer(layers, element_shape)[source]#

Bases: BaseLayer

A layer gluing several other layers together on a 2-dimensional grid.

Parameters:
  • layers (dict[LayoutPosition2D, BaseLayer]) – a mapping from positions on the 2-dimensional space to blocks implementing the circuit that should be present at that position. The mapping is expected to represent a connected computation.

  • element_shape (PhysicalQubitScalable2D) – scalable shape (in qubit coordinates) of each entry in the provided layers.

Raises:

Methods

__init__(layers, element_shape)

A layer gluing several other layers together on a 2-dimensional grid.

get_temporal_layer_on_border(border)

shape(k)

Returns the 2-dimensional shape of the object for the given k.

timesteps(k)

Returns the number of timesteps needed to implement the object for the provided scaling parameter k.

to_circuit(k)

Return the quantum circuit representing the layer.

to_template_and_plaquettes()

Return an equivalent representation of self with a template and some plaquettes.

with_spatial_borders_trimmed(borders)

Returns self with the provided spatial borders removed.

with_temporal_borders_replaced(...)

Returns self with the provided temporal borders replaced.

Attributes

bounds

Get the top-left and bottom-right corners of the bounding box of self.

element_shape

layers

scalable_shape

Returns the 2-dimensional shape of the object as an exact expression that can then be used to compute the shape for any value of k.

scalable_timesteps

Returns the number of timesteps needed to implement the object as an exact expression that can then be used to compute the number of timesteps for any value of k.

trimmed_spatial_borders

Detailed methods

__init__(layers, element_shape)[source]#

A layer gluing several other layers together on a 2-dimensional grid.

Parameters:
  • layers (dict[LayoutPosition2D, BaseLayer]) – a mapping from positions on the 2-dimensional space to blocks implementing the circuit that should be present at that position. The mapping is expected to represent a connected computation.

  • element_shape (PhysicalQubitScalable2D) – scalable shape (in qubit coordinates) of each entry in the provided layers.

Raises:
Return type:

None

get_temporal_layer_on_border(border)#
Parameters:

border (TemporalBlockBorder)

Return type:

BaseLayer

shape(k)#

Returns the 2-dimensional shape of the object for the given k.

Parameters:

k (int) – scaling parameter.

Returns:

the 2-dimensional shape of the object for the given k.

Return type:

PhysicalQubitShape2D

timesteps(k)#

Returns the number of timesteps needed to implement the object for the provided scaling parameter k.

Parameters:

k (int) – scaling parameter.

Returns:

the number of timesteps needed to implement the object for the provided scaling parameter k.

Return type:

int

to_circuit(k)[source]#

Return the quantum circuit representing the layer.

Parameters:

k (int) – scaling factor.

Returns:

quantum circuit representing the layer.

Return type:

ScheduledCircuit

to_template_and_plaquettes()[source]#

Return an equivalent representation of self with a template and some plaquettes.

Raises:

NotImplementedError – if not all layers composing self are instances of PlaquetteLayer.

Returns:

a tuple (template, plaquettes) that is ready to be used with generate_circuit() to obtain the quantum circuit representing self.

Return type:

tuple[LayoutTemplate, Plaquettes]

with_spatial_borders_trimmed(borders)[source]#

Returns self with the provided spatial borders removed.

Parameters:

borders (Iterable[SpatialBlockBorder]) – spatial borders to remove.

Returns:

a copy of self with the provided borders removed.

Return type:

LayoutLayer

with_temporal_borders_replaced(border_replacements)#

Returns self with the provided temporal borders replaced.

Parameters:
  • borders – a mapping from temporal borders to replace to their replacement. A value of None as a replacement means that the border is removed.

  • border_replacements (Mapping[TemporalBlockBorder, BaseLayer | None])

Returns:

a copy of self with the provided borders replaced, or None if replacing the provided borders from self result in an empty temporal footprint.

Return type:

BaseLayer | None