example_qraise

 1import os, sys
 2from time import sleep
 3
 4# path to access c++ files
 5sys.path.append(os.getenv("HOME"))
 6
 7from cunqa.qutils import getQPUs, qraise, qdrop
 8from cunqa.circuit import CunqaCircuit
 9
10# Raise QPUs (allocates classical resources for the simulation job) and retrieve them using getQPUs
11family = qraise(2, "00:10:00", simulator = "Munich", cloud = True)
12sleep(15)
13
14qpus  = getQPUs(local = False, family = family)
15
16qc = CunqaCircuit(2, 2)
17qc.h(0)
18qc.cx(0, 1)
19qc.measure_all()
20
21qpu = qpus[0]
22qjob = qpu.run(qc, shots = 1000)# non-blocking call
23
24counts = qjob.result.counts
25time = qjob.time_taken
26
27print(f"Result: \n{counts}\n Time taken: {time} s.")
28
29########## Drop the deployed QPUs #
30qdrop(family)