1
$\begingroup$

Following Decoding Small Surface Codes with Feedforward Neural Networks, I am trying to train a similar neural network decoder with stim.

Decoding is reduced to a classification problem, by decomposing the error $E$ into $$E = SCL$$

where $S$ is a stabilizer, $C$ pure Error, and $L$ logical operator. A pure error decoder is used to find a plausible pure error $C$, and the network should predict the remaining logical operator $L$.

With stim, it is straightforward to sample syndrome measurements and logical observable from the circuit.

It seems that to find the correct logical operator (serving as the training label) given the predicted pure error $C$, syndromes, and logical observable measured at the end of the circuit, I need to access the data qubits, which is not possible based on this answer.

I wanted to double-check if the stim::FrameSimulator suggested in the answer above, is the way to go, or if I misunderstood the training procedure?

$\endgroup$

1 Answer 1

1
$\begingroup$

Stim has various options for outputting the observables in addition to the detection events. For your use case I recommend using stim.CompiledDetectorSampler.sample_write and specifying obs_out_filepath. This will write the detection event data to one file and the observable data to a separate file. The goal of the NN decoder is to predict the observable data from the detection event data.

import stim
circuit: stim.Circuit = ...
sampler: stim.CompiledDetectorSampler = circuit.compile_detector_sampler()
sampler.sample_write(
    shots=1000,
    filepath='symptoms.txt',
    format='01',
    obs_out_filepath='values_to_predict.txt',
    obs_out_format='01',
)
$\endgroup$
6
  • $\begingroup$ Thank you! Maybe it's more a conceptual problem than a problem with stim. What happens if the correction $C$ on the data qubits by the pure error decoder (PED) flips the logical observable? If I understand correctly I don't have access to the underlying data qubits and will therefore not know which logical operator $L$ to apply if the logical qubit gets accidentally flipped by the PED. $\endgroup$
    – jerol
    Jul 18, 2022 at 19:08
  • $\begingroup$ @jerol That's not the decoder's responsibility. It only worries about predicting whether the flip is needed or not. Something else will handle applying the correction. (Note that, in the surface code, the corrections can be applied entirely within the classical postprocessing. Nothing different has to happen on the quantum computer itself. So the concept of "applying the correction" can be weirder than you might have been imagining.) $\endgroup$ Jul 18, 2022 at 19:15
  • $\begingroup$ @jerol If you really want to work with the data measurements, you can sample them and then use stim.Circuit.compile_m2d_converter to convert the measurements to detections/observables. But this extra work won't be achieving anything that makes your decoder better, it's just taking the long way instead of the shortcut. $\endgroup$ Jul 18, 2022 at 19:22
  • $\begingroup$ Thanks again. It wasn't clear to me, that $C$ doesn't provide any additional information given the syndromes. Therefore the decoder only requires the detector output. $\endgroup$
    – jerol
    Jul 18, 2022 at 19:49
  • $\begingroup$ I did some more research and found a similar paper training a NN decoder. In figure 12 (page 9), they compute the logical difference between pure error and data qubit error. So generating detection events and observable wouldn't be enough? $\endgroup$
    – jerol
    Jul 19, 2022 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.