Skip to content

Commit

Permalink
enable qiskit object export als legacy feature
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeisel committed Jan 12, 2024
1 parent 936a1ee commit c447e61
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/model/circuit_response.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import codecs
import pickle


from datetime import datetime
import marshmallow as ma
from app.model.encoding_request import (
Expand All @@ -20,7 +24,10 @@


def export_circuit(circuit, input):
if (
# THIS OPTION MAY LEAD TO INCOMPATIBLE EXPORT WITH DIFFERENT QISKIT VERSIONS AND IS NOT RECOMMENDED
if input.circuit_format == "qiskit":
codecs.encode(pickle.dumps(circuit), "base64").decode(),
elif (
hasattr(input, "parameterized") and input.parameterized
) or input.circuit_format == "openqasm3":
return qiskit.qasm3.dumps(circuit)
Expand Down
1 change: 1 addition & 0 deletions app/services/algorithms/knapsack_qaoa_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ def create_circuit(cls, values, weights, max_weights, p, betas, gammas):
qaoa = QAOA(reps=p)
qaoa_qc = qaoa.construct_circuit(angles, operator)[0]
qaoa_qc = qaoa_qc.decompose(reps=100)
qaoa_qc.measure_all()
return qaoa_qc

0 comments on commit c447e61

Please sign in to comment.