1
$\begingroup$

I am trying to find the threshold of a surface code for dephasing error using pymatching and stim. I am unable to apply the Z_ERROR onto the qubits using the given format since a surface code will require coordinates of the qubits.

Format: Z_ERROR (probability) qubit_number

Is there something I'm missing in terms of the syntax required to use Z_ERROR on the Stim generated surface code?

$\endgroup$

2 Answers 2

1
$\begingroup$

I am unable to apply the Z_ERROR onto the qubits using the given format since a surface code will require coordinates of the qubits.

For performance reasons, Stim always refers to qubits by a single integer index. What you can do is specify coordinate metadata for your qubits via the QUBIT_COORDS instruction. For example, here's a square of qubits:

QUBIT_COORDS(0, 0) 0
QUBIT_COORDS(0, 1) 1
QUBIT_COORDS(1, 0) 2
QUBIT_COORDS(1, 1) 3

# CZ diagonally across the square, between 0=(0,0) and 3=(1,1)
CZ 0 3

# Phase noise along the bottom of the square
Z_ERROR(0.1) 1 3

The example surface code circuits that Stim can generate via stim.Circuit.generated always include coordinate metadata.

Qubit coordinates don't affect simulations. But they are really useful when debugging and for tools that want to show the circuit or export the circuit into some other format. For example:

$\endgroup$
0
$\begingroup$

assuming you are using the generated sufrace code (rotated/unrotated memory), you can add a phase flip to the data qubits, ancillas, or both, by reading their indices off of where they appear in the circuit. For example, all qubits are initially reset, and all ancillas are measured during the measurement round. For example, calling stim.Circuit.generated('surface_code:rotated_memory_x', distance=3, rounds=10) will give you, among others, the code:

    RX 1 3 5 8 10 12 15 17 19
    R 2 9 11 13 14 16 18 25
    TICK
    H 2 11 16 25
    TICK
    CX 2 3 16 17 11 12 15 14 10 9 19 18
    TICK
    CX 2 1 16 15 11 10 8 14 3 9 12 18
    TICK
    CX 16 10 11 5 25 19 8 9 17 18 12 13
    TICK
    CX 16 8 11 3 25 17 1 9 10 18 5 13
    TICK
    H 2 11 16 25
    TICK
    MR 2 9 11 13 14 16 18 25
  ...

from which you can read off the data qubits (RX 1 3 5 8 10 12 15 17 19) and ancillas (MR 2 9 11 13 14 16 18 25). You can then add the dephasing where needed by using the object model of the circuit.

$\endgroup$
3
  • $\begingroup$ Sorry, I'm new to using Stim, and I am not able to find the documentation regarding the stim.Circuit.generated("surface_code_unrotated_x") function. Could you link the object model here? $\endgroup$ Commented Mar 17, 2022 at 16:45
  • $\begingroup$ The best way to get the documentation of a function is to use the python built in help() function. Another way is to use the ? Prefix before the function signature, which works if you’re using jupyter notebooks $\endgroup$
    – Lior
    Commented Mar 17, 2022 at 17:14
  • $\begingroup$ @Rucchi Reference documentation (such as the list of available methods with descriptions of what they do) is available at stim's github wiki: github.com/quantumlib/Stim/wiki $\endgroup$ Commented Aug 17, 2022 at 13:41

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.