diff --git a/src/mqt/bench/qiskit_helper.py b/src/mqt/bench/qiskit_helper.py index 04dea5623..814ebeb5b 100644 --- a/src/mqt/bench/qiskit_helper.py +++ b/src/mqt/bench/qiskit_helper.py @@ -11,8 +11,6 @@ from .devices import Device, Gateset from qiskit import transpile -from qiskit.synthesis import generate_basic_approximations -from qiskit.transpiler.passes import SolovayKitaev from .utils import get_openqasm_gates, save_as_qasm @@ -191,12 +189,28 @@ def get_native_gates_level( return True if gateset.gateset_name == "clifford+t": - gateset_without_cx = gateset.gates.copy() - gateset_without_cx.remove("cx") - approx = generate_basic_approximations(gateset_without_cx, depth=3) - skd = SolovayKitaev(recursion_degree=2, basic_approximations=approx) - compiled_without_architecture = skd(qc.decompose(reps=3).remove_final_measurements(inplace=False)) - compiled_without_architecture.measure_all() + from qiskit.converters import circuit_to_dag, dag_to_circuit # noqa: PLC0415 + from qiskit.transpiler.passes.synthesis import SolovayKitaev # noqa: PLC0415 + + # Transpile the circuit to single- and two-qubit gates including rotations + compiled_for_sk = transpile( + qc, + basis_gates=[*gateset.gates, "rx", "ry", "rz"], + optimization_level=opt_level, + seed_transpiler=10, + ) + # Synthesize the rotations to Clifford+T gates + # Measurements are removed and added back after the synthesis to avoid errors in the Solovay-Kitaev pass + pass_ = SolovayKitaev() + new_qc = dag_to_circuit(pass_.run(circuit_to_dag(compiled_for_sk.remove_final_measurements(inplace=False)))) + new_qc.measure_all() + # Transpile once more to remove unnecessary gates and optimize the circuit + compiled_without_architecture = transpile( + new_qc, + basis_gates=gateset.gates, + optimization_level=opt_level, + seed_transpiler=10, + ) else: compiled_without_architecture = transpile( qc, basis_gates=gateset.gates, optimization_level=opt_level, seed_transpiler=10