loom_shor_code.code_factory.shor_code

Copyright 2024 Entropica Labs Pte Ltd

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class loom_shor_code.code_factory.shor_code.ShorCode(*args, **kwargs)[source]

Bases: Block

A sub-class of Block that represents a Shor code block.

classmethod create(lattice, unique_label=None, position=(0,), skip_validation=False)[source]

Create datablock of Shor Code as a Block object. The Shor Code is a [[9, 1, 3]] quantum error-correcting CSS code, resulting from the concatenation of two repetition codes. There are two X stabilizers of weight 6, and six Z stabilizers of weight 2. We implement a naive syndrome extraction scheme, where measure all X stabilizers first and all the Z stabilizers later. We choose to embed the code in a linear lattice, where the logical operators are defined on all the data qubits.

Parameters:
  • lattice (Lattice) – Lattice on which the block is defined. The qubit indices depend on the type of lattice.

  • unique_label (str, optional) – Label for the block. It must be unique among all blocks in the initial CRD. If no label is provided, a unique label is generated automatically using the uuid module.

  • position (tuple[int], optional) – Position of the top left boundary of the block on the lattice, by default (0,).

  • skip_validation (bool, optional) – Skip validation of the block object, by default False.

Returns:

Block object for the Shor Code.

Return type:

Block

static generate_syndrome_extraction_circuits(pauli)[source]

Construct a syndrome extraction circuit for the given Pauli operator. We chose the convention of measuring all X stabilizers first and then all Z, thus, appropriate idling steps are added depending on the type of Pauli operator.

Parameters:

pauli (str) – The Pauli operator as a string.

Returns:

syndrome_circuit – The syndrome extraction circuit for the given Pauli operator.

Return type:

SyndromeCircuit

rename(name)[source]

Return a copy of the Block with the new name.

Return type:

ShorCode

shift(position, new_label=None)[source]

Return a copy of the Block where all qubit coordinates are shifted by a given position.

Parameters:
  • position (tuple[int, ...]) – Vector by which the block should be shifted

  • new_label (str | None, optional) – New label for the block. If None, the same label is used.

Returns:

A new Block with the shifted qubit coordinates.

Return type:

Block

stabilizer_to_circuit: dict[str, str] = FieldInfo(annotation=dict[str, str], required=False, default_factory=dict, validate_default=True)
property stabilizers_labels: dict[str, dict[str, tuple[int, ...]]]

Builds a dictionary associating stabilizers, via their uuid, with a set of labels defined through a dictionary. Inside Block, this is generically populated with the space coordinates of the stabilizer check, corresponding to the ancilla which measures each stabilizer.

This functionality can be leveraged to later provide these labels to Syndromes and Detectors associated with a given Stabilizer.

Returns:

Dictionary associating stabilizer uuids with their labels.

Return type:

dict[str, dict[str, tuple[int, …]]]

syndrome_circuits: tuple[SyndromeCircuit, ...] = FieldInfo(annotation=tuple[SyndromeCircuit, ...], required=False, default_factory=tuple, validate_default=True)
unique_label: str = FieldInfo(annotation=str, required=False, default_factory=<lambda>)
uuid: str = FieldInfo(annotation=str, required=False, default_factory=<lambda>, validate_default=True)