flamingpy.decoders.decoder.check_correction(code, sanity_check=False)[source]

Check whether the error correction has succeded or failed.

Verify that no logical operator has been applied at the end of the recovery. This is achieved by checking that the total parity on the appropriate correlation or gauge surface(s) is even. Such as surface consists of the set of all syndrome qubits (of the kind in code.ec), in a plane of the correct kind (“primal” or “dual”) along a specified direction.

For all-periodic boundaries, total parities of planes along all three directions are compared. For open boundaries, a plane parallel to the primal or dual spatial (x or y) boundary (if the error complex is primal or dual, respectively) is checked. In every case, the first plane along the specified direction of the right type is checked (although this doesn’t matter for the following reason).

Since a logical operator cuts through a set of parallel planes at a single point per plane, we expect parities along all parallel planes to be the same: this is the idea behind sanity_check.

  • code (SurfaceCode) – the qubit QEC code. At the stage this functions is run, the recovery has already been applied, so that code.graph represents the error-corrected graph state.

  • sanity_check (bool) – if True, display the total parity of all parallel correlation surfaces to verify if parity is conserved.


a list of bools indicating whether error

correction succeeded for each complex. If sanity_check is set to True, also output a dictionary between planes and results of the parallel-plane-parity sanity check.

Return type

list or (list, list)




Using FlamingPy


Getting Help

Python API