CodeCircuit

class CodeCircuit[source]

Bases: ABC

Abstract class to manage circuits for codes, as well as other fault-tolerant circuits.

A CodeCircuit requires the methods string2nodes, check_nodes and is_cluster_neutral in order to interface with its DecodingGraph and decoders.

Initialization of classes that inherent from CodeCircuit can be done in various ways, depending on the code or code family to be initialized. In all cases, the initialization must define the following attributes:

Parameters:
  • circuit (dict) – A dictionary with circuits as values, and labels (typically strings) as keys.

  • base (string) – used in decoding graph generation.

  • d (int) – Code distance.

  • T (int) – number of syndrome measurement rounds.

Methods

abstract check_nodes(nodes, ignore_extras=False, minimal=False)[source]

Determines whether a given set of nodes are neutral. If so, also determines any additional logical readout qubits that would be flipped by the errors creating such a cluster and how many errors would be required to make the cluster. :type nodes: :param nodes: List of nodes, of the type produced by string2nodes. :type nodes: list :type ignore_extras: :param ignore_extras: If True, undeeded logical and boundary nodes are :type ignore_extras: bool :param ignored.: :type minimal: :param minimal: Whether output should only reflect the minimal error :type minimal: bool :param case.:

Returns:

Whether the nodes independently correspond to a valid set of errors. flipped_logical_nodes (list): List of qubits nodes for logical operators that are flipped by the errors, that were not included in the original nodes. num_errors (int): Minimum number of errors required to create nodes.

Return type:

neutral (bool)

abstract is_cluster_neutral(nodes)[source]

Determines whether or not the cluster is neutral, meaning that one or more errors could have caused the set of nodes (syndrome changes) passed to the method.

Default version here assumes that it is as simple as an an even/odd assessment (as for repetition codes, surface codes, etc). This should be overwritten for more complex codes. It also should be used with care, by only supplying sets of nodes for which the even/odd assessment is valid. :type nodes: :param nodes: :type nodes: dictionary in the form of the return value of string2nodes

abstract string2nodes(string, **kwargs)[source]

Convert output string from circuits into a set of nodes for DecodingGraph. :type string: :param string: Results string to convert. :type string: string :type kwargs: :param kwargs: Any additional keyword arguments. :type kwargs: dict