CSSCodeCircuit

class CSSCodeCircuit(code, T, basis='z', round_schedule='zx', noise_model=None)[source]

Bases: CodeCircuit

CodeCircuit class for generic CSS codes.

Parameters:
  • code – A CSS code class which is either

  • StabSubSystemCode (a))

  • methods (b) a class with the following) – ‘x_gauges’ (as a list of list of qubit indices), ‘z_gauges’, ‘x_stabilizers’, ‘z_stabilizers’, ‘logical_x’, ‘logical_z’, ‘n’ (number of qubits),

  • T (int) – Number of syndrome measurement rounds

  • basis (str) – basis for encoding (‘x’ or ‘z’)

  • round_schedule (str) – Order in which to measureme gauge operators (‘zx’ or ‘xz’)

  • noise_model – Pauli noise model used in the construction of noisy circuits.

  • tuple (If a)

  • being (a pnenomological noise model is used with the entries)

  • and (probabity of depolarizing noise on code qubits between rounds)

  • errors (probability of measurement)

  • respectively.

Examples

The QuantumCircuit of a memory experiment for the distance-3 HeavyHEX code >>> from qiskit_qec.codes.hhc import HHC >>> from qiskit_qec.circuits.css_code import CSSCodeCircuit >>> code = CSSCodeCircuit(HHC(3),T=3,basis=’x’,noise_model=(0.01,0.01),round_schedule=’xz’) >>> code.circuit[‘0’]

Methods

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)

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

stim_detectors()[source]

Constructs detectors and logicals required for stim.

Returns:

dictionaries containing a) ‘clbits’, the classical bits (register, index) included in the measurement comparisons b) ‘qubits’, the qubits (list of indices) participating in the stabilizer measurements c) ‘time’, measurement round (int) of the earlier measurements in the detector d) ‘basis’, the pauli basis (‘x’ or ‘z’) of the stabilizers logicals (list[dict]): dictionaries containing a) ‘clbits’, the classical bits (register, index) included in the logical measurement b) ‘basis’, the pauli basis (‘x’ or ‘z’) of the logical

Return type:

detectors (list[dict])

string2nodes(string, **kwargs)[source]

Convert output string from circuits into a set of nodes for DecodingGraph.

Parameters:
  • string (string) – Results string to convert.

  • kwargs (dict) – Any additional keyword arguments. logical (str): Logical value whose results are used (‘0’ as default). all_logicals (bool): Whether to include logical nodes irrespective of value. (False as default).

Returns:

a list of ‘DecodingGraphNode()’s corresponding to the triggered detectors

Return type:

nodes

string2raw_logicals(string)[source]

Converts output string into a list of logical measurement outcomes Logicals are the logical measurements produced by self.stim_detectors()