5
$\begingroup$

A little bit of context.

I am currently implementing quantum error-correction code (specifically, surface code and lattice-surgery operations) and I often find myself in the following situation: my implementation does not reach the distance I was expecting it to reach.

The question is then: is the theory incorrect, or is my implementation incorrect?

With the amount of tiny details required to get right in the implementation and the unforgivness of QEC in general to small implementation mistakes, the answer to the above question has always been (for the moment): "my implementation is incorrect and needs to be fixed".


Now about the question: what is the most efficient workflow to fix an implementation of a given quantum error-correction code in stim when it does not reach the expected distance (assuming that the theory is correct and the problem lies in the implementation)?

At the moment, my workflow starts by:

circuit: stim.Circuit = ... # your bugged generation method here with open("circuit.url", "w") as f: f.write(circuit.to_crumble_url()) errors = circuit.shortest_graphlike_error(canonicalize_circuit_errors=True) for error in errors: print("=" * 80) print(error) print("=" * 80) 

Then, I open the Crumble URL saved in circuit.url in my web-browser, manually add the errors that were printed, and try to understand how to fix the issue.

Most of the time, I try to categorize the error mechanism (i.e., the collection of $d < d_\text{expected}$ errors that flips one of the declared observable without triggering any detector) into one of the errors type I already encountered:

  1. One (or more) detector(s) is missing, and adding that detector would make the printed error mechanism detectable.
  2. The error mechanism contains "hook errors" that are not correctly aligned.

The problem is that this process is tedious (adding errors manually in Crumble), error-prone (adding errors manually in Crumble), and I find it hard to categorize an error mechanism.

Does anyone around here have a better process, or maybe improvement(s) to the above process?

EDIT: of course, I cannot compare my implementation to a reference known-to-be-correct implementation, there is no reference implementation that I am aware of.

$\endgroup$

1 Answer 1

4
$\begingroup$

If you find yourself taking a long time to do some repetitive task, try writing code to do part of it. In this case: write a method that takes your stim circuit and an error, and outputs a crumble url with the error marked already. Or custom images that visualize the aspects of the problem relevant to you, like e.g. just showing the spatial location while ignoring time.

For example, if you download the code associated with "How to factor 2048 bit RSA integers with a million noisy qubits", you'll find a directory src/gen containing code related to generating/debugging circuits. In particular there's a method gen.stim_circuit_html_viewer that spits out an html file to look at the circuit. That method automatically finds the shortest graphlike error (or optionally takes one) and includes it in the html viz.

You too can make something as beautiful as, and to be honest probably even more beautiful than, this (from gen's getting started notebook):

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks for the link, I missed that function when looking at the code before. My first step (here) was to see if someone had a better workflow I was not aware of before implementing the tools. Seems like your debugging process is close, which comforts me in the idea that I simply need more visualisation tools. I'll build them, commenting back here when that is done. Thanks :) $\endgroup$ Commented Jun 1 at 8:56
  • $\begingroup$ As promised (but with a little delay), the implementation is here: github.com/tqec/tqec/tree/main/src/tqec/visualisation. One of the resulting visualisation can be seen on this question: quantumcomputing.stackexchange.com/q/44139/1386. $\endgroup$ Commented Aug 16 at 21:27

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.