tqec icon indicating copy to clipboard operation
tqec copied to clipboard

WIP: Add detector automation but without anti-commute grouping

Open inmzhang opened this issue 1 year ago • 0 comments

This is a very basic attempt to adress #199. I tried to implement the proposal by Austin at the level of stim instead of cirq because I want this part of work can be applied to other stim-based projects more easily. The main pipeline can be splitted into the following steps:

  1. Split the stim.Circuit into fragments. By design, a fragment is the sub-circuit of a single error correction round with related resets/measurements collapsing operations.
  2. Use a strategy similar to that Craig Gideny used in the midout paper source code to compile each fragment. When compiling the fragment, the boundary stabilizers are constructed and matched to form the detectors. Note that I haven't implement anticommute grouping as proposed by Austin yet.

Currently, there are some problems in the codebase as far as I can notice and remember:

  1. The structure of the round-based error correction circuit is not well-tested. The boundary of a fragment is identified by the collapsing moments, which tried to deal with the consequtive measurements/resets moments and the circuit repeat block, this part is error-prone.
  2. At the early stage, I thought a boundary stabilizer with trivial stabilizer(all pauli operator is Identity) should alway form a detector by itself. However, consider a simplest circuit R -- MR -- M, the second detector should be DETECTOR rec[-1][-2] instead of DETECTOR rec[-1]. Though the two definitions seem equivalent when multiplying the first detector into it, there are critical differences when decoding the circuits. Thus I always try to match the boundary stabilizers between two consequtive fragments even when the weight of the stabilizer is zero.
  3. Currently, the detector annotation for the simple r=1 repetition code circuit will fail. Consider the following circuit: 图片, if we allow resets on data qubits to generate the boundary stabilizers, it might generate detectors unwanted. Maybe we can forbid resets on some specific set of qubits to generate end stabilizers to handle it. However, when the circuit gets more complex, the forbiden set can be changed over the circuit(e.g. the wiggling/sliding circuit in http://arxiv.org/abs/2302.02192). I did not have a good solution to this yet.
  4. Though the performance of the code and algorithm is not optimized, it already took around 14s to run the tests for 80 small circuits in the test cases. Note that the unimplemented anticommute grouping step might increase the time further significantly. We might need to start considering whether we should implement this in pure Python.
  5. I have passed the tests for the surface code circuits generated by stim. In my plan, I would like to test it more on the various circuits in this paper. Currently I have only included a single circuit in the directory extra_test_circuits for anticommute grouping test purpose(so it should fail for now).

Ideally, I would have completed the remaining tasks and submitted a finalized PR. However, I'm quite occupied these days and I'm not sure when I will be able to finish this. Therefore, I'm submitting it as a draft and would appreciate any help from the community to improve, refactor or even complete it.

inmzhang avatar May 11 '24 10:05 inmzhang