parity_decoder¶
Classes for decoding states from parity code space.
- class parityos.encodings.parity_decoder.StateDecoder¶
Bases:
Generic[LogicalQubitT,PhysicalQubitT],ABCA base class for decoding states in a code-space to the original computational space.
- abstractmethod decode(state: PauliBasisState[PhysicalQubitT, Z[Never]]) frozenset[PauliBasisState[LogicalQubitT, Z[Never]]]¶
Decode a physical state to a frozenset of equally likely logical states.
- Parameters:
state – Physical state to decode.
- Returns:
A set of equally likely logical states this physical state encodes.
- class parityos.encodings.parity_decoder.ParityStateDecoder(parity_mapping: ParityMapping[LogicalQubitT, PhysicalQubitT])¶
Bases:
StateDecoder[LogicalQubitT,PhysicalQubitT]A decoder for parity mapping encoded states.
- It offers the following methods for decoding physical states into logical states:
It is possible to use a partial read-out to construct a full physical state, based on the redundant encoding that the Parity architecture offers. This is especially useful if only a limited number of qubits can be read out in the hardware setup, or if the read-out failed on some qubits.
- parity_mapping: ParityMapping[LogicalQubitT, PhysicalQubitT]¶
Mapping between logical and physical qubits based on parities of logical qubit groups.
- decode(state: PauliBasisState[PhysicalQubitT, Z[Never]]) frozenset[PauliBasisState[LogicalQubitT, Z[Never]]]¶
Decode a physical state back to a logical one, it is important that the state contains enough qubits to reconstruct the logical state. If not enough qubits are included, a
ParityOSExceptionwill be raised.- Parameters:
state – Physical state to decode.
- Returns:
frozensetof all equally likely logical states that correspond to the physical state.
- closest_valid_physical_states(state: PauliBasisState[PhysicalQubitT, Z[Never]]) frozenset[PauliBasisState[PhysicalQubitT, Z[Never]]]¶
Construct the most likely physical states that correspond to a physical state which does not necessarily satisfies the constraints.
The resulting states are computed as all valid physical states that are at a Hamming distance
dfrom the original state, withdthe smallest possible distance that yields a non-zero amount of valid physical states.- Parameters:
state – Physical state to correct for errors.
- Returns:
frozensetof possible physical states that satisfy all constraints (and hence are part of the physical code subspace)
- select_reduced_readout_qubits(random_generator: Random | None = None) frozenset[Qubit]¶
Construct a random minimal set of qubits that can be read-out and still be used to recover the full logical states.
Note
When these qubits are used for read-out, no error correction can be applied.
- Parameters:
random_generator – Random number generator. If
None, the default random number generatorrandom.Randomis used. Optional.- Returns:
Random set of qubits that are selected for read-out.
- make_full_state_from_partial(state: PauliBasisState[PhysicalQubitT, Z[Never]], return_incomplete: bool = False) PauliBasisState[QubitT, Z[Never]]¶
Reconstruct a full physical state from a partial one using the parity constraints in
parity_mapping.- Parameters:
state – Partial physical state to extend.
return_incomplete – If
True, return a physical state even if the full state could not be reconstructed. The state returned in that case contains all the qubits that could be deduced.
- Returns:
Full physical state deduced from the parity constraints.
- check_parity(state: PauliBasisState[PhysicalQubitT, Z[Never]]) bool¶
Check whether a state satisfies all the constraints.