softwareQinc / staq

Full-stack quantum processing toolkit
https://iopscience.iop.org/article/10.1088/2058-9565/ab9359/pdf
MIT License
152 stars 28 forks source link

Question on Evaluating Staq #46

Closed khieta closed 2 years ago

khieta commented 2 years ago

Hi, I'm working on an updated version of our paper on verified optimization of quantum circuits and I'd like to include Staq's results on our benchmarks. What is the best way to evaluate Staq's optimizations (without routing)? I'd like to use the Python interface if possible. I was thinking that I should emulate Staq's -O3 option, which does simplify, rotfold and cnotsynth (per staq/main.cpp#L217), but I don't see a Python binding for the cnotsynth pass. Is there a reason for this?

Additionally, if I wanted to evaluate both optimization and routing, which of Staq's optimizations will preserve connectivity guarantees? (And do you expect the optimizations would have any effect on routed circuits?)

Thanks!

vsoftco commented 2 years ago

adding @meamy

vsoftco commented 2 years ago

@khieta thanks, we'll take a look and get back to you

meamy commented 2 years ago

Hi @khieta!

For cnot re-synthesis, there was no reason other than we missed it. I just pushed an update to the main branch that includes a cnot_resynth wrapper.

For the best way to evaluate staq's optimizations, it somewhat depends on what your primary metric is. -O3 will generally give you circuits with the fewest gates, but if depth is the primary metric you may want to forgo the cnot-resynth pass.

simplify and rotation-fold will both preserve connectivity, but it makes more sense to do rotation-fold before mapping. cnot-resynth will not preserve connectivity, but the default steiner routing algorithm combines cnot-resynth with routing anyway. So, what you probably want to evaluate both optimization and routing is this:

staq --mapping-alg steiner --evaluate-all -i -s -r -s -m

If you want to evaluate the swap router instead, you could just do a -O3 optimize before mapping.

Hope this answers your question!

khieta commented 2 years ago

Thanks for the help!