hashberg-io / pauliopt

A Python library to simplify quantum circuits of phase and Pauli gadgets.
https://hashberg-io.github.io/pauliopt/
GNU Affero General Public License v3.0
13 stars 9 forks source link

Converter to and from tket #7

Open y-richie-y opened 1 year ago

y-richie-y commented 1 year ago

Implement a converter between pauliopt and pytket.

pytket is a popular open-sourced quantum compilation library. It can represent Pauli gadgets using PauliExpBox has special compilation passes for these boxes:

There is also phase gadget compilation pass, though there doesn't seem to be an explicit class for representing them:

y-richie-y commented 1 year ago

Bonus: write functions that convert to tket, apply some of the rewrite passes, and convert back to pauliopt.

Zshan0 commented 1 year ago

Do you want the functionality to convert the classes PhaseGadget, OptimizedPhaseCircuit and CXCircuit to pyket.Circuit and apply the passes described here?

daehiff commented 1 year ago

I am really sorry, for the late reply. Take a look at the PauliPolynomial class: https://github.com/sg495/pauliopt/blob/42057f8c971e536d51e70adf8bc9a25c5c7722dd/pauliopt/pauli/pauli_polynomial.py#L7

Could you convert this class into a tket Circuit and apply the optimization passes afterwards?

In general the idea is to provide a reference routing strategy towards the ones we are developing at the moment. So please create a function whit the signature as follows:

def route_using_tket(pp: PauliPolynomial, topology: Topology) -> tket.Circuit:
        ...

A cool extra would be to return our own circuit with a certain gate set! But keep that optional for now.

Regarding your current PR, please note that unit tests should be in: the tests folder and be written within the unittest Framework (I have provided a command in the README and a docker container that can run them. Also, please note, that we don't import qiskit/tket globally, our current dependencies can be sound in our setup.py.

If you want to you can create an option pip install pauliopt[all], which will also install qiskit and tket for compatibility.

Also FYI:

Here is already a code-snippet, that converts our PauliPolynomial towards tket:

https://github.com/sg495/pauliopt/blob/42057f8c971e536d51e70adf8bc9a25c5c7722dd/tests/test_pauli_propagation.py#L33

And in one of my older repositorys, there is a way how you can create tket architectures from edges (note that i didn't use the Topology-object here so it is not STRG+C/V :D

https://github.com/daehiff/divide_fast/blob/0d6600c8fc87b74da1c14d81c11e26f2636d7870/evaluations.py#L198