Skip to content

Commit

Permalink
Merge pull request #36 from dlyongemallo/expose_qiskit_plugin
Browse files Browse the repository at this point in the history
Add a flag to optionally run the benchmark as a Qiskit plugin rather than with a standalone pass manager.
  • Loading branch information
dlyongemallo authored Apr 7, 2024
2 parents da65b86 + f63f454 commit 90cd827
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions benchmarking/run_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@
from zxpass import ZXPass


zxpass = ZXPass()
pass_manager = PassManager(zxpass)
pass_manager = PassManager(ZXPass())


def _benchmark(subdir: str, circuit_name: str) -> Tuple[float, float, float]:
def _benchmark(subdir: str, circuit_name: str, as_plugin: bool = False) -> Tuple[float, float, float]:
print(f"Circuit name: {circuit_name}")

qc = QuantumCircuit.from_qasm_file(f"QASMBench/{subdir}/{circuit_name}/{circuit_name}.qasm")
opt_qc = transpile(qc, basis_gates=['u3', 'cx'], optimization_level=3)
zx_qc = pass_manager.run(qc)
if as_plugin:
zx_qc = transpile(qc, optimization_method="zxpass", optimization_level=3)
else:
zx_qc = pass_manager.run(qc)

print(f"Size - original: {qc.size()}, "
f"optimized: {opt_qc.size()} ({qc.size() / opt_qc.size():.2f}), "
Expand Down

0 comments on commit 90cd827

Please sign in to comment.