RepetitionCodeCircuit

class RepetitionCodeCircuit(d, T, xbasis=False, resets=False, delay=None, barriers=False)[source]

Bases: CodeCircuit

RepetitionCodeCircuit class.

Creates the circuits corresponding to a logical 0 and 1 encoded using a repetition code.

Implementation of a distance d repetition code, implemented over T syndrome measurement rounds.

Parameters:
  • d (int) – Number of code qubits (and hence repetitions) used.

  • T (int) – Number of rounds of ancilla-assisted syndrome measurement.

  • xbasis (bool) – Whether to use the X basis to use for encoding (Z basis used by default).

  • resets (bool) – Whether to include a reset gate after mid-circuit measurements.

  • delay (float) – Time (in dt) to delay after mid-circuit measurements (and delay).

  • barriers (bool) – Whether to include barriers between different sections of the code.

Additional information:

No measurements are added to the circuit if T=0. Otherwise T rounds are added, followed by measurement of the code qubits (corresponding to a logical measurement and final syndrome measurement round).

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 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)

get_circuit_list()[source]

Returns circuit list.

circuit_list: self.circuit as a list, with circuit_list[0] = circuit[‘0’] circuit_list[1] = circuit[‘1’]

Return type:

List[QuantumCircuit]

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. :type nodes: :param nodes: :type nodes: list of nodes

partition_outcomes(round_schedule, outcome)[source]

Extract measurement outcomes.

Return type:

Tuple[List[List[int]], List[List[int]], List[int]]

readout()[source]

Readout of all code qubits, which corresponds to a logical measurement as well as allowing for a measurement of the syndrome to be inferred.

string2nodes(string, **kwargs)[source]

Convert output string from circuits into a set of nodes.

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

  • kwargs (dict) – 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:

List of nodes corresponding to to the non-trivial elements in the string.

Return type:

dict

Additional information: Strings are read right to left, but lists* are read left to right. So, we have some ugly indexing code whenever we’re dealing with both strings and lists.

string2raw_logicals(string)[source]

Extracts raw logicals from output string. :type string: :param string: Results string from which to extract logicals :type string: string

Returns:

Raw values for logical operators that correspond to nodes.

Return type:

list

syndrome_measurement(final=False, barrier=False, delay=0)[source]

Application of a syndrome measurement round.

Parameters:
  • final (bool) – Whether to disregard the reset (if applicable) due to this

  • round. (being the final syndrome measurement)

  • barrier (bool) – Boolean denoting whether to include a barrier at the start.

  • delay (float) – Time (in dt) to delay after mid-circuit measurements (and delay).

x(logs=('0', '1'), barrier=False)[source]

Applies a logical x to the circuits for the given logical values.

Parameters:
  • logs (list or tuple) – List or tuple of logical values expressed as strings.

  • barrier (bool) – Boolean denoting whether to include a barrier at the start.