Stim icon indicating copy to clipboard operation
Stim copied to clipboard

Incorrect qubit coordinate shifting in 'timeslice-svg' plots

Open ChenZhao44 opened this issue 3 months ago • 1 comments

Different orders of instructions in the same tick will result in different timeslice-svg plots. For example, the following code produces the correct time slice plot as expected:

import stim
circ = stim.Circuit("""
QUBIT_COORDS(0.5, 0.5) 1
QUBIT_COORDS(1.5, 0.5) 2
QUBIT_COORDS(2.5, 0.5) 3
QUBIT_COORDS(0.5, 1.5) 4
QUBIT_COORDS(1.5, 1.5) 5
QUBIT_COORDS(2.5, 1.5) 6
QUBIT_COORDS(0.5, 2.5) 7
QUBIT_COORDS(1.5, 2.5) 8
QUBIT_COORDS(2.5, 2.5) 9
QUBIT_COORDS(1.0, 0.0) 10
QUBIT_COORDS(1.0, 1.0) 11
QUBIT_COORDS(2.0, 1.0) 12
QUBIT_COORDS(3.0, 1.0) 13
QUBIT_COORDS(0.0, 2.0) 14
QUBIT_COORDS(1.0, 2.0) 15
QUBIT_COORDS(2.0, 2.0) 16
QUBIT_COORDS(2.0, 3.0) 17

RX 1
RX 2
RX 3
RX 4
RX 5
RX 6
RX 7
RX 8
RX 9
R 10
R 12
R 15
R 17
DEPOLARIZE1(0.001) 1
DEPOLARIZE1(0.001) 2
DEPOLARIZE1(0.001) 3
DEPOLARIZE1(0.001) 4
DEPOLARIZE1(0.001) 5
DEPOLARIZE1(0.001) 6
DEPOLARIZE1(0.001) 7
DEPOLARIZE1(0.001) 8
DEPOLARIZE1(0.001) 9
DEPOLARIZE1(0.001) 10
DEPOLARIZE1(0.001) 12
DEPOLARIZE1(0.001) 15
DEPOLARIZE1(0.001) 17
TICK
""")
circ.diagram('timeslice-svg')

correct

However, when the instructions R/RX and DEPOLARIZE1 are placed alternatively, the time slice will be plotted incorrectly.

import stim
circ = stim.Circuit("""
QUBIT_COORDS(0.5, 0.5) 1
QUBIT_COORDS(1.5, 0.5) 2
QUBIT_COORDS(2.5, 0.5) 3
QUBIT_COORDS(0.5, 1.5) 4
QUBIT_COORDS(1.5, 1.5) 5
QUBIT_COORDS(2.5, 1.5) 6
QUBIT_COORDS(0.5, 2.5) 7
QUBIT_COORDS(1.5, 2.5) 8
QUBIT_COORDS(2.5, 2.5) 9
QUBIT_COORDS(1.0, 0.0) 10
QUBIT_COORDS(1.0, 1.0) 11
QUBIT_COORDS(2.0, 1.0) 12
QUBIT_COORDS(3.0, 1.0) 13
QUBIT_COORDS(0.0, 2.0) 14
QUBIT_COORDS(1.0, 2.0) 15
QUBIT_COORDS(2.0, 2.0) 16
QUBIT_COORDS(2.0, 3.0) 17
RX 1
DEPOLARIZE1(0.001) 1
RX 2
DEPOLARIZE1(0.001) 2
RX 3
DEPOLARIZE1(0.001) 3
RX 4
DEPOLARIZE1(0.001) 4
RX 5
DEPOLARIZE1(0.001) 5
RX 6
DEPOLARIZE1(0.001) 6
RX 7
DEPOLARIZE1(0.001) 7
RX 8
DEPOLARIZE1(0.001) 8
RX 9
DEPOLARIZE1(0.001) 9
R 10
DEPOLARIZE1(0.001) 10
R 12
DEPOLARIZE1(0.001) 12
R 15
DEPOLARIZE1(0.001) 15
R 17
DEPOLARIZE1(0.001) 17
TICK
""")
circ.diagram('timeslice-svg')

incorrect

It seems that every time a noise instruction is plotted, a global coordinate shift will be applied regardless of the type of subsequent instructions. However, coordinate shifting should only occur with noise instructions, not with any other instructions.

Stim version: 1.13.0

ChenZhao44 avatar Apr 19 '24 18:04 ChenZhao44