Template decoder¶
-
qsurface.decoders._template.
write_config
(config_dict, path)¶ Writes a configuration file to the path.
-
qsurface.decoders._template.
read_config
(path, config_dict=None)¶ Reads an INI formatted configuration file and parses it to a nested dict
Each category in the INI file will be parsed as a separate nested dictionary. A default
config_dict
can be provided with default values for the parameters. Parameters under the “main” section will be parsed in the main dictionary. All data types will be converted byast.literal_eval()
.- Parameters
- Returns
Parsed dictionary.
- Return type
Examples
Let us look at the following example INI file.
[main] param1 = hello [section] param2 = world param3 = 0.1
This file will be parsed as follows
>>> read_config("config.ini") { "param1": "hello", "section": { "param2": "world", "param3": 0.1 } }
-
qsurface.decoders._template.
init_config
(ini_file, write=False, **kwargs)¶ Reads the default and the user defined INI file.
First, the INI file stored in file directory is read and parsed. If there exists another INI file in the working directory, the attributes defined there are read, parsed and overwrites and default values.
- Parameters
write (bool) – Writes the default configuration to the working direction of the user.
See also
-
class
qsurface.decoders._template.
Sim
(code, check_compatibility=False, **kwargs)¶ Decoder simulation class template.
- Parameters
code (
PerfectMeasurements
) – APerfectMeasurements
orFaultyMeasurements
class from thesim
module of Code types.check_compatibility (
bool
) – Checks compatibility of the decoder with the code class and loaded errors bycheck_compatibility
.
-
compatibility_errors
¶ Compatibility with the various error modules in Error types.
- Type
-
check_compatibility
()¶ Checks compatibility of the decoder with the code class and loaded errors.
-
static
get_neighbor
(ancilla_qubit, key)¶ Returns the neighboring ancilla-qubit of
ancilla_qubit
in the direction ofkey
.- Return type
-
get_neighbors
(ancilla_qubit, loop=False, **kwargs)¶ Returns all neighboring ancillas, including other time instances.
- Parameters
loop (
bool
) – Include neighbors in time that are not chronologically next to each other during decoding within the same instance.
-
correct_edge
(ancilla_qubit, key, **kwargs)¶ Applies a correction.
The correction is applied to the data-qubit located at
ancilla_qubit.parity_qubits[key]
. More specifically, the correction is applied to theEdge
object corresponding to thestate_type
ofancilla_qubit
.- Return type
-
get_syndrome
(find_pseudo=False)¶ Finds the syndrome of the code.
- Parameters
find_pseudo (bool, optional) – If enabled, the lists of syndromes returned are not only
AncillaQubit
objects, but tuples of(ancilla, pseudo)
, wherepseudo
is the closestPseudoQubit
in the boundary of the code.- Return type
Union
[Tuple
[List
[AncillaQubit
],List
[AncillaQubit
]],Tuple
[List
[Tuple
[AncillaQubit
,PseudoQubit
]],List
[Tuple
[AncillaQubit
,PseudoQubit
]]]]- Returns
list – Plaquette operator syndromes.
list – Star operator syndromes.
-
abstract
decode
(*args, **kwargs)¶ Decodes the surface loaded at
self.code
after all ancilla-qubits have been measured.
-
class
qsurface.decoders._template.
Plot
(*args, **kwargs)¶ Decoder plotting class template.
The plotting decoder class requires a surface code object that inherits from
codes._template.plot.PerfectMeasurements
. The template decoder provides theplot_matching_edge
method that is called bycorrect_edge
to visualize the matched edges on the lattice.- Parameters
-
decode
(*args, **kwargs)¶ Decodes the surface loaded at
self.code
after all ancilla-qubits have been measured.
-
correct_edge
(qubit, key, **kwargs)¶ Applies a correction.
The correction is applied to the data-qubit located at
ancilla_qubit.parity_qubits[key]
. More specifically, the correction is applied to theEdge
object corresponding to thestate_type
ofancilla_qubit
.
-
plot_matching_edge
(line=None)¶ Plots the matching edge.
Based on the colors defined in
self.line_color_match
, if aLine2D
object is supplied, the color of the edge is changed. A future change back to its original color is immediately saved infigure.future_dict
.
-
check_compatibility
()¶ Checks compatibility of the decoder with the code class and loaded errors.
-
static
get_neighbor
(ancilla_qubit, key)¶ Returns the neighboring ancilla-qubit of
ancilla_qubit
in the direction ofkey
.- Return type
-
get_neighbors
(ancilla_qubit, loop=False, **kwargs)¶ Returns all neighboring ancillas, including other time instances.
- Parameters
loop (
bool
) – Include neighbors in time that are not chronologically next to each other during decoding within the same instance.
-
get_syndrome
(find_pseudo=False)¶ Finds the syndrome of the code.
- Parameters
find_pseudo (bool, optional) – If enabled, the lists of syndromes returned are not only
AncillaQubit
objects, but tuples of(ancilla, pseudo)
, wherepseudo
is the closestPseudoQubit
in the boundary of the code.- Return type
Union
[Tuple
[List
[AncillaQubit
],List
[AncillaQubit
]],Tuple
[List
[Tuple
[AncillaQubit
,PseudoQubit
]],List
[Tuple
[AncillaQubit
,PseudoQubit
]]]]- Returns
list – Plaquette operator syndromes.
list – Star operator syndromes.