UnionFindDecoder

class UnionFindDecoder(code, decoding_graph=None, use_peeling=True, use_is_cluster_neutral=False, growth_unit=0.5)[source]

Bases: ClusteringDecoder

Decoder based on growing clusters around syndrome errors to “convert” them into erasure errors, which can be corrected easily, by the peeling decoder for compatible codes or by the standard HDRG method in general.

To avoid using the peeling decoder, and instead use the standard method for clustering decoders to get corrections, set use_peeling=False. Growth unit is 0.5 by default, but can be changed with growth_unit. To use half the minimum boundarye edge weight for each clustering round, set growth_unit=None.

Methods

cluster(nodes)[source]

Create clusters using the union-find algorithm.

Parameters:
  • nodes (List) – List of non-typical nodes in the syndrome graph,

  • string2nodes. (of the type produced by)

Returns:

Dictionary with the indices of the given node as keys and an integer specifying their cluster as the corresponding value.

Return type:

clusters (dict)

find(u)[source]

Find() function as described in the paper that returns the root of the cluster of a node, including path compression.

Parameters:

u (int) – The index of the node in the decoding graph.

Returns:

The root of the cluster of node u.

Return type:

root (int)

get_corrections(string, clusters)

Turn a set of neutral clusters into corrections.

Parameters:
  • string (str) – Output string of the code

  • clusters (dict) – Dictionary with the indices of the given node

  • corresponding (as keys and an integer specifying their cluster as the)

  • value.

Returns:

A list of integers that are 0 or 1.

Return type:

corrected_logicals (list)

These are the corrected values of the final transversal measurement, in the same form as given by the code’s string2raw_logicals.

neighbouring_edges(node_index)[source]

Returns all of the neighbouring edges of a node in the decoding graph.

Parameters:

node_index (int) – The index of the node in the graph.

Returns:

List of neighbouring edges

In following format:

{
    index of edge in graph,
    index of neighbour node in graph,
    data payload of the edge
}

Return type:

neighbouring_edges (List[Tuple[int, int, DecodingGraphEdge]])

peeling(erasure)[source]

” Runs the peeling decoder on the erasure provided. Assumes that the erasure is one connected component, if not it will run in an infinite loop in the tree construction. It works by first producing a spanning forest of the erasure and then going backwards through the edges of the tree computing the error based on the syndrome. Based on arXiv:1703.01517.

Parameters:

erasure (PyGraph) – subgraph of the syndrome graph that represents the erasure.

Returns:

List of qubit indices on which Pauli errors occurred.

Return type:

errors (List[int])

process(string, predecoder=None)[source]

Process an output string and return corrected final outcomes.

Parameters:
  • string (str) – Output string of the code.

  • predecoder (callable) – Function that takes in and returns

  • nodes (a list of nodes. Used to do preprocessing on the)

  • string. (corresponding to the input)

Returns:

A list of integers that are 0 or 1.

Return type:

corrected_logicals (list)

These are the corrected values of the final logical measurement.