-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirstProgram.py
More file actions
31 lines (27 loc) · 783 Bytes
/
firstProgram.py
File metadata and controls
31 lines (27 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from pyquil import Program, get_qc
from pyquil.gates import *
from pyquil.quilbase import Declare
from pyquil.api import local_forest_runtime
prog = Program(
Declare("ro", "BIT", 2),
Z(0),
CNOT(0, 1),
MEASURE(0, ("ro", 0)),
MEASURE(1, ("ro", 1)),
).wrap_in_numshots_loop(10)
with local_forest_runtime():
qvm = get_qc('9q-square-qvm')
bitstrings = qvm.run(qvm.compile(prog)).readout_data.get("ro")
#Construct a Bell State program
p = Program(
Declare("ro", "BIT", 2),
H(0),
CNOT(0, 1),
MEASURE(0, ("ro", 0)),
MEASURE(1, ("ro", 1)),
).wrap_in_numshots_loop(10)
#Run the program on a QVM
qc = get_qc('9q-square-qvm')
result = qc.run(qc.compile(p)).readout_data.get("ro")
print(result[0])
print(result[1])