1

I am trying to do decoding in presence of measurement error and bit-flip error for the repetition code. In the PyMatching version 0.2.2 https://pypi.org/project/PyMatching/0.2.3/ it mentions that

To decode instead in the presence of measurement errors, each stabiliser measurement is repeated L times, and decoding then takes place over a 3D matching graph (see Section IV B of this paper), which can be constructed directly from the check matrix H using:

m = Matching(H, repetitions=L)

and then decoded from an m by L numpy array syndrome z using:

c = m.decode(z)

I tried this for an example case with H as the repetition code syndrome

import numpy as np
from pymatching import *

N = 10 # number of qubits H = np.zeros((N-1,N),dtype = int) for i in range(N-1): H[i,i] = 1 H[i,i+1] = 1

and syndrome histroy

z = array([[0, 1, 1, 0, 0, 0, 0, 0, 0],
   [0, 1, 1, 0, 0, 1, 0, 0, 0],
   [1, 1, 1, 0, 0, 1, 1, 1, 0],
   [1, 0, 0, 0, 1, 0, 1, 0, 0],
   [1, 0, 0, 0, 1, 1, 0, 1, 1],
   [1, 0, 0, 0, 0, 0, 1, 1, 1],
   [1, 0, 0, 0, 0, 1, 1, 1, 1],
   [1, 0, 0, 0, 0, 1, 1, 0, 0],
   [1, 0, 0, 0, 0, 0, 0, 0, 1],
   [1, 0, 0, 0, 0, 0, 0, 0, 0]])

but I am not getting the correct corrections. The weird thing is, even if I take no measurement error and bit-flip error and just repeat the syndrome, I get the wrong results so I think, I am doing something incorrect. Please help me with this.

Himanshu
  • 215
  • 1
  • 10

1 Answers1

1

As per the documentation, Matching.decode takes a syndrome array z which is read as if z[i,j] is the "the difference (modulo 2) between the measurement of stabiliser i in time step j+1 and time step j ".

This means that the row z[i,:] represents the detection events of the $i$-th stabilizer through time, not the syndrome at timestep $i$.

Using m.decode(z.T) will yield the correct correction [0 0 1 0 0 0 1 0 0 0].

Under the hood, pymatching does not check the shape (m,n) of z, only the number of values in z i.e. m*n (see the function _syndrome_array_to_detection_events in this file, at line 190).

AG47
  • 1,575
  • 3
  • 16