Skip to content

Commit 42d5add

Browse files
committed
update covalent
1 parent c77125b commit 42d5add

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

database.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
from qiskit_ibm_runtime.program import UserMessenger
1212
from scipy.optimize import dual_annealing
1313
import statistics
14+
from qiskit.compiler import transpile
15+
from qiskit.quantum_info import SparsePauliOp
16+
from qiskit_ibm_runtime import Estimator, QiskitRuntimeService, Session
1417

1518
@ct.electron
1619
def fetch_data(id):
@@ -31,13 +34,28 @@ def fetch_data(id):
3134
return scores
3235

3336
@ct.electron
34-
def predict_trouble(example, parameters = [0.8683269 , 0.39393166, 0.47681407, 0.30033276, 0.97830805, 0.52097628, 0.99194506, 0.92128744, 0.57695905, 0.36047569,0.83097868, 0.47035325]):
37+
@ct.lattice
38+
def predict_trouble(token, example, parameters = [0.8683269 , 0.39393166, 0.47681407, 0.30033276, 0.97830805, 0.52097628, 0.99194506, 0.92128744, 0.57695905, 0.36047569,0.83097868, 0.47035325]):
3539
qc = QuantumCircuit(3)
3640
embed_example(qc, example)
3741
apply_parameters(qc, parameters)
42+
evaluate_circuit(qc, token)
3843
result = run_circuit(qc, Aer.get_backend("aer_simulator"))
3944
return make_prediction(result)
4045

46+
@ct.electron(deps_pip=ct.DepsPip(["qiskit==0.40.0"]))
47+
def evaluate_circuit(qc, token: str):
48+
QiskitRuntimeService.save_account(channel="ibm_quantum",
49+
token=token,
50+
instance="ibm-q-community/mit-hackathon/main",
51+
overwrite=True)
52+
53+
with Session(service=QiskitRuntimeService(), backend="ibm_nairobi"):
54+
estimator = Estimator()
55+
return estimator.run(circuits=qc,
56+
observables=[SparsePauliOp("IZ")],
57+
shots=500).result()
58+
4159

4260
def embed_example(circuit, example):
4361
circuit.rx(np.pi * example[0], 0)

0 commit comments

Comments
 (0)