Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect qubit coordinate shifting in 'timeslice-svg' plots #757

Open
ChenZhao44 opened this issue Apr 19, 2024 · 1 comment
Open

Incorrect qubit coordinate shifting in 'timeslice-svg' plots #757

ChenZhao44 opened this issue Apr 19, 2024 · 1 comment

Comments

@ChenZhao44
Copy link

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

@Strilanc
Copy link
Collaborator

Strilanc commented May 2, 2024

This is because internally everytime it sees an operation happen on a qubit again within one tick, it increments an internal subtick value. That was the fastest safest way to be sure there were no ordering bugs and no ambiguity about the order things are declared in the circuit.

Probably what should be done here is to have a subtick per qubit, and to take the max subtick + 1 of the qubits affected by the operation then set all their subticks to that value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants