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]
''')