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

Inconsistent results on QVM #1802

Open
2 tasks done
glanzz opened this issue Sep 14, 2024 · 0 comments
Open
2 tasks done

Inconsistent results on QVM #1802

glanzz opened this issue Sep 14, 2024 · 0 comments
Labels
bug 🐛 An issue that needs fixing.

Comments

@glanzz
Copy link

glanzz commented Sep 14, 2024

Pre-Report Checklist

  • I am running the latest versions of pyQuil and the Forest SDK
  • I checked to make sure that this bug has not already been reported

Issue Description

The circuit given below provides invalid output state distribution when run on 9q-square-qvm:

How to Reproduce

Code Snippet

from pyquil import get_qc, Program
def result_dict(resarray):
    res_dict = {}
    for val in resarray:
      key = "".join([str(v) for v in val])
      res_dict[key] = res_dict.get(key, 0) + 1
    return res_dict
  

backend = get_qc("9q-square-qvm")

program = Program('''DECLARE ro BIT[5]
X 1
X 2
X 3
X 4
H 0
CZ 2 1
CNOT 3 0
DAGGER S 2
DAGGER T 0
H 2
CNOT 4 0
S 2
T 0
S 2
CNOT 3 0
H 2
DAGGER T 0
T 3
CNOT 4 0
T 0
CNOT 4 3
H 0
DAGGER T 3
T 4
DAGGER S 0
CNOT 4 3
I 0
H 3
CNOT 1 3
DAGGER T 3
CNOT 4 3
T 3
PRAGMA RESERVE_BLOCK
CNOT 1 3
T 1
DAGGER T 3
CNOT 4 3
CNOT 4 1
T 3
DAGGER T 1
H 3
T 4
CNOT 4 1
SWAP 3 1
H 4
SWAP 3 1
H 4
CNOT 0 4
Y 3
I 3
DAGGER T 4
CNOT 2 4
Y 3
T 4
CNOT 0 4
T 0
DAGGER T 4
CNOT 2 4
CNOT 2 0
T 4
DAGGER T 0
PRAGMA END_RESERVE_BLOCK
T 2
H 4
CNOT 2 0
CONTROLLED Y 1 4
SWAP 0 2
S 1
S 0
S 1
CONTROLLED Y 4 2
S 0
SWAP 1 2
CZ 0 4
H 0
CNOT 4 3
CNOT 1 0
CNOT 4 3
DAGGER T 0
Y 3
CNOT 2 0
I 3
T 0
Y 3
CNOT 1 0
DAGGER T 0
T 1
CNOT 2 0
T 0
CNOT 2 1
H 0
DAGGER T 1
T 2
CNOT 2 1
CCNOT 2 1 0
CZ 4 0
SWAP 1 2
Z 0
Z 1
CONTROLLED Y 4 2
SWAP 0 2
CONTROLLED Y 1 4
CCNOT 2 0 4
SWAP 3 1
I 0
SWAP 3 1
X 2
H 4
S 0
CCNOT 4 1 3
S 2
CCNOT 4 3 0
CZ 1 2
MEASURE 0 ro[0]
MEASURE 1 ro[1]
MEASURE 2 ro[2]
MEASURE 3 ro[3]
MEASURE 4 ro[4]
''')
options = [{}, {'to_native_gates': True, 'optimize': True}]

for i in range(100):
  for option in options:
    SHOTS = 3000
    transpiled_circuit = backend.compile(program, **option)
    job = backend.run(transpiled_circuit.wrap_in_numshots_loop(SHOTS))
    results = result_dict(job.readout_data.get("ro"))
    print(f"I: {i}, Options:: {option}, Results:{results}")

Error Output

I: 0, Options:: {}, Results:{'01111': 3000}
I: 0, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 1, Options:: {}, Results:{'01111': 3000}
I: 1, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 2, Options:: {}, Results:{'01111': 3000}
I: 2, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 3, Options:: {}, Results:{'01111': 3000}
I: 3, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 4, Options:: {}, Results:{'01111': 3000}
I: 4, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 5, Options:: {}, Results:{'01111': 3000}
I: 5, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 6, Options:: {}, Results:{'01111': 3000}
I: 6, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 7, Options:: {}, Results:{'01111': 3000}
I: 7, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 8, Options:: {}, Results:{'01111': 3000}
I: 8, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 9, Options:: {}, Results:{'01111': 3000}
I: 9, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 10, Options:: {}, Results:{'01111': 3000}
I: 10, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 11, Options:: {}, Results:{'01111': 3000}
I: 11, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 12, Options:: {}, Results:{'01111': 3000}
I: 12, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 13, Options:: {}, Results:{'01111': 3000}
I: 13, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 14, Options:: {}, Results:{'01111': 3000}
I: 14, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 15, Options:: {}, Results:{'01111': 3000}
I: 15, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 16, Options:: {}, Results:{'01111': 3000}
I: 16, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 17, Options:: {}, Results:{'01111': 3000}
I: 17, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 18, Options:: {}, Results:{'01111': 3000}
I: 18, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 19, Options:: {}, Results:{'01111': 3000}
I: 19, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 20, Options:: {}, Results:{'01111': 3000}
I: 20, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 21, Options:: {}, Results:{'01111': 3000}
I: 21, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 22, Options:: {}, Results:{'01111': 3000}
I: 22, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 23, Options:: {}, Results:{'01111': 3000}
I: 23, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 24, Options:: {}, Results:{'01111': 3000}
I: 24, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 25, Options:: {}, Results:{'01111': 3000}
I: 25, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 26, Options:: {}, Results:{'01111': 3000}
I: 26, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 27, Options:: {}, Results:{'01111': 3000}
I: 27, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 28, Options:: {}, Results:{'01111': 3000}
I: 28, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 29, Options:: {}, Results:{'01111': 3000}
I: 29, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 30, Options:: {}, Results:{'01111': 3000}
I: 30, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 31, Options:: {}, Results:{'01111': 3000}
I: 31, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 32, Options:: {}, Results:{'01111': 3000}
I: 32, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 33, Options:: {}, Results:{'01111': 3000}
I: 33, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 34, Options:: {}, Results:{'01111': 3000}
I: 34, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 35, Options:: {}, Results:{'01111': 3000}
I: 35, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 36, Options:: {}, Results:{'01111': 3000}
I: 36, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 37, Options:: {}, Results:{'01111': 3000}
I: 37, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 38, Options:: {}, Results:{'01111': 3000}
I: 38, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 39, Options:: {}, Results:{'01111': 3000}
I: 39, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 40, Options:: {}, Results:{'01111': 3000}
I: 40, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 41, Options:: {}, Results:{'01111': 3000}
I: 41, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 42, Options:: {}, Results:{'01111': 3000}
I: 42, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 43, Options:: {}, Results:{'01111': 3000}
I: 43, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 44, Options:: {}, Results:{'01111': 3000}
I: 44, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 45, Options:: {}, Results:{'01111': 3000}
I: 45, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 46, Options:: {}, Results:{'01111': 3000}
I: 46, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 47, Options:: {}, Results:{'01111': 3000}
I: 47, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 48, Options:: {}, Results:{'01111': 3000}
I: 48, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 49, Options:: {}, Results:{'01111': 3000}
I: 49, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 50, Options:: {}, Results:{'01111': 3000}
I: 50, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 51, Options:: {}, Results:{'01111': 3000}
I: 51, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 52, Options:: {}, Results:{'01111': 3000}
I: 52, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 53, Options:: {}, Results:{'01111': 3000}
I: 53, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 54, Options:: {}, Results:{'01111': 3000}
I: 54, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 55, Options:: {}, Results:{'01111': 3000}
I: 55, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 56, Options:: {}, Results:{'01111': 3000}
I: 56, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 57, Options:: {}, Results:{'01111': 3000}
I: 57, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 58, Options:: {}, Results:{'01111': 3000}
I: 58, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 59, Options:: {}, Results:{'01111': 3000}
I: 59, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 60, Options:: {}, Results:{'01111': 3000}
I: 60, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 61, Options:: {}, Results:{'01111': 3000}
I: 61, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 62, Options:: {}, Results:{'01111': 3000}
I: 62, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 63, Options:: {}, Results:{'01111': 3000}
I: 63, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 64, Options:: {}, Results:{'01111': 3000}
I: 64, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01100': 587, '01111': 105, '01011': 609, '11000': 603, '11011': 77, '11111': 583, '01000': 95, '11100': 102, '00100': 8, '10100': 57, '00101': 20, '00001': 46, '00000': 57, '10101': 51}
I: 65, Options:: {}, Results:{'01111': 3000}
I: 65, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 66, Options:: {}, Results:{'01111': 3000}
I: 66, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 67, Options:: {}, Results:{'01111': 3000}
I: 67, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 68, Options:: {}, Results:{'01111': 3000}
I: 68, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 69, Options:: {}, Results:{'01111': 3000}
I: 69, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 70, Options:: {}, Results:{'01100': 614, '11000': 594, '10101': 55, '11111': 634, '01111': 93, '01011': 574, '11011': 81, '00100': 12, '00001': 46, '10100': 53, '00000': 51, '11100': 96, '00101': 19, '01000': 76, '10001': 1, '10000': 1}
I: 70, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 71, Options:: {}, Results:{'01111': 3000}
I: 71, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 72, Options:: {}, Results:{'01111': 3000}
I: 72, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 73, Options:: {}, Results:{'01111': 3000}
I: 73, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 74, Options:: {}, Results:{'01111': 3000}
I: 74, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 75, Options:: {}, Results:{'01111': 3000}
I: 75, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 76, Options:: {}, Results:{'01111': 3000}
I: 76, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 77, Options:: {}, Results:{'01111': 3000}
I: 77, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 78, Options:: {}, Results:{'01111': 3000}
I: 78, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 79, Options:: {}, Results:{'01111': 3000}
I: 79, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 80, Options:: {}, Results:{'01111': 3000}
I: 80, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 81, Options:: {}, Results:{'01111': 3000}
I: 81, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 82, Options:: {}, Results:{'01111': 3000}
I: 82, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 83, Options:: {}, Results:{'01011': 601, '11111': 609, '01100': 615, '11000': 633, '11100': 93, '00000': 52, '01000': 91, '10100': 51, '01111': 73, '00001': 43, '00100': 10, '10101': 38, '11011': 75, '00101': 16}
I: 83, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 90, '01011': 564, '11000': 639, '01100': 618, '00101': 17, '11111': 578, '11100': 98, '00001': 70, '11011': 98, '00000': 37, '10100': 45, '01000': 76, '10101': 61, '00100': 8, '10001': 1}
I: 84, Options:: {}, Results:{'01111': 3000}
I: 84, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 85, Options:: {}, Results:{'01111': 3000}
I: 85, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 86, Options:: {}, Results:{'01111': 3000}
I: 86, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 87, Options:: {}, Results:{'01111': 3000}
I: 87, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 88, Options:: {}, Results:{'01111': 3000}
I: 88, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 89, Options:: {}, Results:{'01111': 3000}
I: 89, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 90, Options:: {}, Results:{'01111': 3000}
I: 90, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 91, Options:: {}, Results:{'01111': 3000}
I: 91, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 92, Options:: {}, Results:{'11000': 618, '01100': 651, '01011': 587, '11111': 603, '10100': 40, '01000': 59, '11011': 85, '10101': 44, '00000': 51, '11100': 96, '00100': 15, '01111': 87, '00001': 47, '00101': 16, '10001': 1}
I: 92, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 93, Options:: {}, Results:{'01111': 3000}
I: 93, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 94, Options:: {}, Results:{'01111': 3000}
I: 94, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 95, Options:: {}, Results:{'01111': 3000}
I: 95, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}
I: 96, Options:: {}, Results:{'01111': 3000}
I: 96, Options:: {'to_native_gates': True, 'optimize': True}, Results:{'01111': 3000}

Environment Context

Operating System:

Python Version (python -V): 3.11

Quilc Version (quilc --version): 1.23.0

QVM Version (qvm --version): 1.17.1

Python Environment Details (pip freeze or conda list):

pyquil==4.14.0
@glanzz glanzz added the bug 🐛 An issue that needs fixing. label Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue that needs fixing.
Projects
None yet
Development

No branches or pull requests

1 participant