2
$\begingroup$

I'm trying to find the threshold for dephasing error on a surface code. I've used the stim.Circuit.generated("surface_code_unrotated_memory_x") function to generate a surface code lattice. To it, I'm appending the Z_ERROR operation with the specified noise and qubits it needs to act on.

However, when I call the count_logical_errors method that I picked up from the getting started tutorial, I get ys = 0.0

Printing the circuit after appending Z_ERROR shows the Z_ERROR is applied. I am not able to figure out why count_logical_errors would return a 0.0

$\endgroup$
2
  • 1
    $\begingroup$ Do you mean you're appending Z_ERROR to the end of the example circuit? That would be appending it after the circuit was done, after all the measurements, so it woudn't be able to affect anything. $\endgroup$ Mar 26, 2022 at 7:06
  • $\begingroup$ Yes I did mean that. I didn't realize the measurements would already be carried out. Is there a different way to get dephasing error onto the surface code circuit? $\endgroup$ Mar 26, 2022 at 13:41

1 Answer 1

1
$\begingroup$

Stim's circuit generation is really just for getting started; it doesn't provide highly detailed options for controlling exactly what kind of noise to apply. There's too many variations in what sorts of noise people want for that to be viable. So you gotta do it yourself, using the power of programming.

Anyways, first you need to decide what specifically you mean by "add dephasing noise". Does the dephasing occur throughout the circuit on all qubits? Between rounds on data qubits? There's lots of little variations in what you might add. Since Stim is a circuit-focused simulator I'm assuming you want noise throughout the circuit on all qubits.

Here's an example method that adds dephasing noise to every qubit throughout the circuit. It does this by looking for TICK instructions, which don't do anything but are included in the example circuits as hints for where layers of the circuit are ending:

import stim

def with_dephasing_before_ticks(
        circuit: stim.Circuit, 
        *, 
        probability: float) -> stim.Circuit:
    n = circuit.num_qubits
    result = stim.Circuit()
    for instruction in circuit:
        if isinstance(instruction, stim.CircuitRepeatBlock):
            result.append(stim.CircuitRepeatBlock(
                repeat_count=instruction.repeat_count,
                body=with_dephasing_before_ticks(instruction.body_copy(),
                                                 probability=probability)))
        elif instruction.name == 'TICK':
            result.append('Z_ERROR', range(n), probability)
            result.append(instruction)
        else:
            result.append(instruction)
    return result

Which we can then test on a generated circuit:

>>> noiseless = stim.Circuit.generated(
...     'surface_code:rotated_memory_x',
...     rounds=10,
...     distance=2)
>>> noisy = with_dephasing_before_ticks(noiseless, probability=0.001)
>>> print(repr(noisy))
stim.Circuit('''
    QUBIT_COORDS(1, 1) 1
    QUBIT_COORDS(2, 0) 2
    QUBIT_COORDS(3, 1) 3
    QUBIT_COORDS(1, 3) 6
    QUBIT_COORDS(2, 2) 7
    QUBIT_COORDS(3, 3) 8
    QUBIT_COORDS(2, 4) 12
    RX 1 3 6 8
    R 2 7 12
    Z_ERROR(0.001) 0 1 2 3 4 5 6 7 8 9 10 11 12
    TICK
    H 2 12
    Z_ERROR(0.001) 0 1 2 3 4 5 6 7 8 9 10 11 12
    TICK
    CX 2 3 8 7
    Z_ERROR(0.001) 0 1 2 3 4 5 6 7 8 9 10 11 12
    TICK
    CX 2 1 3 7
    Z_ERROR(0.001) 0 1 2 3 4 5 6 7 8 9 10 11 12
    TICK
    CX 12 8 6 7
    Z_ERROR(0.001) 0 1 2 3 4 5 6 7 8 9 10 11 12
    TICK
    CX 12 6 1 7
    Z_ERROR(0.001) 0 1 2 3 4 5 6 7 8 9 10 11 12
    TICK
    H 2 12
    Z_ERROR(0.001) 0 1 2 3 4 5 6 7 8 9 10 11 12
    TICK
    MR 2 7 12
    DETECTOR(2, 0, 0) rec[-3]
    DETECTOR(2, 4, 0) rec[-1]
    REPEAT 9 {
        Z_ERROR(0.001) 0 1 2 3 4 5 6 7 8 9 10 11 12
        TICK
        H 2 12
        Z_ERROR(0.001) 0 1 2 3 4 5 6 7 8 9 10 11 12
        TICK
        CX 2 3 8 7
        Z_ERROR(0.001) 0 1 2 3 4 5 6 7 8 9 10 11 12
        TICK
        CX 2 1 3 7
        Z_ERROR(0.001) 0 1 2 3 4 5 6 7 8 9 10 11 12
        TICK
        CX 12 8 6 7
        Z_ERROR(0.001) 0 1 2 3 4 5 6 7 8 9 10 11 12
        TICK
        CX 12 6 1 7
        Z_ERROR(0.001) 0 1 2 3 4 5 6 7 8 9 10 11 12
        TICK
        H 2 12
        Z_ERROR(0.001) 0 1 2 3 4 5 6 7 8 9 10 11 12
        TICK
        MR 2 7 12
        SHIFT_COORDS(0, 0, 1)
        DETECTOR(2, 0, 0) rec[-3] rec[-6]
        DETECTOR(2, 2, 0) rec[-2] rec[-5]
        DETECTOR(2, 4, 0) rec[-1] rec[-4]
    }
    MX 1 3 6 8
    DETECTOR(2, 0, 1) rec[-3] rec[-4] rec[-7]
    DETECTOR(2, 4, 1) rec[-1] rec[-2] rec[-5]
    OBSERVABLE_INCLUDE(0) rec[-2] rec[-4]
''')
$\endgroup$

Your Answer

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

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