Skip to content

Commit

Permalink
Use lower qpy version between local qiskit and cloud service
Browse files Browse the repository at this point in the history
  • Loading branch information
jesus-talavera-ibm committed Dec 17, 2024
1 parent ed9e770 commit a06f885
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion qiskit_ibm_transpiler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@
}


def _get_qpy_version(qiskit_version: str):
service_qpy_version = QPY_QISKIT_VERSION_MAPPING.get(
qiskit_version, common.QPY_VERSION
)
# Return lower version between local qiskit and service to keep compatibility
return min(common.QPY_VERSION, service_qpy_version)


def get_metrics(qc: QuantumCircuit) -> Dict[str, int]:
"""Returns a dict with metrics from a QuantumCircuit"""
qcd = qc.decompose(reps=3)
Expand Down Expand Up @@ -238,7 +246,7 @@ def get_qpy_from_circuit(
qpy.dump(
input_circ,
output_b,
version=QPY_QISKIT_VERSION_MAPPING.get(qiskit_version, common.QPY_VERSION),
version=_get_qpy_version(qiskit_version),
)
qpy_string = base64.b64encode(output_b.getvalue()).decode("utf-8")
else:
Expand Down

0 comments on commit a06f885

Please sign in to comment.