Decoders
- class panqec.decoders.BaseDecoder(code: StabilizerCode, error_model: BaseErrorModel, error_rate: float)
Base class for decoders
- __init__(code: StabilizerCode, error_model: BaseErrorModel, error_rate: float)
- abstract property allowed_codes: List[str] | None
List of codes concerned by the decoders (by id). Takes the value None if all codes are allowed.
Example: [‘Toric2DCode’, ‘Planar2DCode’, ‘RotatedPlanar2DCode’]
- abstract decode(syndrome: ndarray, **kwargs) ndarray
Given a code and a syndrome, returns a correction to apply to the qubits
- Parameters:
syndrome (np.ndarray) – Syndrome as an array of size m, where m is the number of stabilizers. Each element contains 1 if the stabilizer is activated and 0 otherwise
kwargs (dict) – Decoder-specific parameters (implemented by subclasses)
- Returns:
correction – Correction as an array of size 2n (with n the number of qubits) in the binary symplectic format.
- Return type:
np.ndarray
- property id: str
Class name
- abstract property label: str
Label used in plots and result files E.g. ‘Toric 2D Matching’
- abstract property params: dict
List of class arguments (as a dictionary), that can be saved and reused to instantiate the same decoder. It should not include code, error_model and error_rate
Example: {‘num_iterations’: 10}
- class panqec.decoders.BeliefPropagationOSDDecoder(code: StabilizerCode, error_model: BaseErrorModel, error_rate: float, max_bp_iter: int = 1000, channel_update: bool = False, osd_order: int = 10, bp_method: str = 'msl')
- __init__(code: StabilizerCode, error_model: BaseErrorModel, error_rate: float, max_bp_iter: int = 1000, channel_update: bool = False, osd_order: int = 10, bp_method: str = 'msl')
- allowed_codes = None
- decode(syndrome: ndarray, **kwargs) ndarray
Get X and Z corrections given code and measured syndrome.
- property params: dict
List of class arguments (as a dictionary), that can be saved and reused to instantiate the same decoder. It should not include code, error_model and error_rate
Example: {‘num_iterations’: 10}
- update_probabilities(correction: ndarray, px: ndarray, py: ndarray, pz: ndarray, direction: str = 'x->z') ndarray
Update X probabilities once a Z correction has been applied
- class panqec.decoders.MatchingDecoder(code: StabilizerCode, error_model: BaseErrorModel, error_rate: float, error_type: str | None = None, weights: Tuple[ndarray, ndarray] | None = None)
Matching decoder for 2D Toric Code, based on PyMatching
- __init__(code: StabilizerCode, error_model: BaseErrorModel, error_rate: float, error_type: str | None = None, weights: Tuple[ndarray, ndarray] | None = None)
Constructor for the MatchingDecoder class
- Parameters:
code (StabilizerCode) – Code used by the decoder
error_model (BaseErrorModel) – Error model used by the decoder (to find the weights)
error_rate (int, optional) – Error rate used by the decoder (to find the weights)
error_type (str, optional) – Determines which type of errors (X or Z) to decode. Can take the values “X”, “Z”, or None if we want to decode all errors
weights (Tuple[np.ndarray, np.ndarray], optional) – Matching weights for X and Z errors
- decode(syndrome: ndarray, **kwargs) ndarray
Get X corrections given code and measured syndrome.
- property params: dict
List of class arguments (as a dictionary), that can be saved and reused to instantiate the same decoder. It should not include code, error_model and error_rate
Example: {‘num_iterations’: 10}
- class panqec.decoders.MemoryBeliefPropagationDecoder(code: StabilizerCode, error_model: BaseErrorModel, error_rate: float, max_bp_iter: int = 100, alpha: float = 0.4, beta: float = 0)
- __init__(code: StabilizerCode, error_model: BaseErrorModel, error_rate: float, max_bp_iter: int = 100, alpha: float = 0.4, beta: float = 0)
- allowed_codes = None
- decode(syndrome: ndarray, **kwargs) ndarray
Get X and Z corrections given code and measured syndrome.
- property params: dict
List of class arguments (as a dictionary), that can be saved and reused to instantiate the same decoder. It should not include code, error_model and error_rate
Example: {‘num_iterations’: 10}
- class panqec.decoders.RotatedSweepDecoder3D(code: StabilizerCode, error_model: BaseErrorModel, error_rate: float, seed: int = 0, max_rounds: int = 32)
- __init__(code: StabilizerCode, error_model: BaseErrorModel, error_rate: float, seed: int = 0, max_rounds: int = 32)
- decode(syndrome: ndarray, **kwargs) ndarray
Get Z corrections given measured syndrome.
- flip_edge(edge: Tuple, signs: ndarray)
Flip signs at index and update correction.
- get_default_direction()
The default direction when all faces are excited.
- get_face_syndromes(full_syndrome: ndarray) ndarray
Get only the syndromes for the vertex Z stabilizers. Z vertex stabilizers syndromes are discarded for this decoder.
- get_initial_state(syndrome: ndarray) ndarray
Get initial cellular automaton state from syndrome.
- get_sweep_edges(vertex, sweep_direction)
Get coordinates of neighbouring edges in sweep direction.
- get_sweep_faces(vertex, sweep_direction)
Get the coordinates of neighboring faces in sweep direction.
- property params: dict
List of class arguments (as a dictionary), that can be saved and reused to instantiate the same decoder. It should not include code, error_model and error_rate
Example: {‘num_iterations’: 10}
- sweep_move(signs: ndarray, correction: Dict[Tuple, str], sweep_direction: Tuple[int, int, int]) ndarray
Apply the sweep move once along a particular direciton.
- class panqec.decoders.RotatedSweepMatchDecoder(code: StabilizerCode, error_model: BaseErrorModel, error_rate: float, max_rounds=32)
- __init__(code: StabilizerCode, error_model: BaseErrorModel, error_rate: float, max_rounds=32)
- decode(syndrome: ndarray, **kwargs) ndarray
Get X and Z corrections given code and measured syndrome.
- property params: dict
List of class arguments (as a dictionary), that can be saved and reused to instantiate the same decoder. It should not include code, error_model and error_rate
Example: {‘num_iterations’: 10}
- class panqec.decoders.SweepDecoder3D(code: StabilizerCode, error_model: BaseErrorModel, error_rate: float, seed: int = 0, max_sweep_factor: int = 32)
- __init__(code: StabilizerCode, error_model: BaseErrorModel, error_rate: float, seed: int = 0, max_sweep_factor: int = 32)
- decode(syndrome: ndarray, **kwargs) ndarray
Get Z corrections given measured syndrome.
- flip_edge(location: Tuple, signs: ndarray)
Flip signs at index and update correction.
- get_default_direction()
The default direction when all faces are excited.
- get_face_syndromes(full_syndrome: ndarray) ndarray
Get only the syndromes for the vertex Z stabilizers. Z vertex stabilizers syndromes are discarded for this decoder.
- get_initial_state(syndrome: ndarray) ndarray
Get initial cellular automaton state from syndrome.
- property params: dict
List of class arguments (as a dictionary), that can be saved and reused to instantiate the same decoder. It should not include code, error_model and error_rate
Example: {‘num_iterations’: 10}
- sweep_move(signs: ndarray, correction: Dict[Tuple, str]) ndarray
Apply the sweep move once.
- class panqec.decoders.SweepMatchDecoder(code: StabilizerCode, error_model: BaseErrorModel, error_rate: float)
- __init__(code: StabilizerCode, error_model: BaseErrorModel, error_rate: float)
- decode(syndrome: ndarray, **kwargs) ndarray
Get X and Z corrections given code and measured syndrome.
- property params: dict
List of class arguments (as a dictionary), that can be saved and reused to instantiate the same decoder. It should not include code, error_model and error_rate
Example: {‘num_iterations’: 10}
- class panqec.decoders.XCubeMatchingDecoder(code: StabilizerCode, error_model: PauliErrorModel, error_rate: float)
Matching decoder for 2D Toric Code, based on PyMatching
- __init__(code: StabilizerCode, error_model: PauliErrorModel, error_rate: float)
Constructor for the MatchingDecoder class
- Parameters:
code (StabilizerCode) – Code used by the decoder
error_model (PauliErrorModel) – Error model used by the decoder (to find the weights)
error_rate (int, optional) – Error rate used by the decoder (to find the weights)
error_type (str, optional) – Determines which type of errors (X or Z) to decode. Can take the values “X”, “Z”, or None if we want to decode all errors
- decode(syndrome: ndarray, **kwargs) ndarray
Get X corrections given code and measured syndrome.
- property params: dict
List of class arguments (as a dictionary), that can be saved and reused to instantiate the same decoder. It should not include code, error_model and error_rate
Example: {‘num_iterations’: 10}