evmckinney9 / transpile_benchy

Collection of existing quantum circuit transpilation benchmarking tools
MIT License
2 stars 2 forks source link

[Feature Request]: Refactor runner #12

Closed evmckinney9 closed 1 year ago

evmckinney9 commented 1 year ago

Feature Description and Why

The logic of runners has become a mess. See https://github.com/Pitt-JonesLab/virtual-swap/blob/main/src/virtual_swap/pass_managers.py for proof.

Refactor this eventually :)

Additional Details / Helpful Resources

I originally wrote it so to minimize dag to circuit conversions, the pre-,main-,post- process stages only modify the pass manager but all run sequentially in the run function. I think this is harder for maintainability so we should instead just run the pass mangers separately.

evmckinney9 commented 1 year ago

Example of broken code in main.ipynb

File [~/transpile_benchy/src/transpile_benchy/benchmark.py:167](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/evm9/transpile_benchy/src/notebooks/~/transpile_benchy/src/transpile_benchy/benchmark.py:167), in Benchmark._try_transpilation(self, transpiler, circuit)
    162     return None
    164 self.logger.debug(
    165     f"Running transpiler {transpiler.name} on circuit {circuit.name}"
    166 )
--> 167 transpiler.reset()
    168 transpiled_circuit = transpiler.run(circuit)
    169 if transpiled_circuit is None:

AttributeError: 'Trivial_Basic' object has no attribute 'reset'

This error is due to a change I was forced to make so that pre_process() would run every time following initialization. Calling reset forced it to reinitialize and populate the pass manager with pre- and main- passes. This issue was because the runner only has one pass manager instead of separate pass managers for each stage.