Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytket coverage, tests, and passable through run/exec methods #162

Closed
ryanhill1 opened this issue Mar 21, 2023 · 2 comments
Closed

pytket coverage, tests, and passable through run/exec methods #162

ryanhill1 opened this issue Mar 21, 2023 · 2 comments
Assignees

Comments

@ryanhill1
Copy link
Member

  • pytket shared_15 to cirq not working, make revisions to fix.
  • Add other tests (as commented) iswap gate, roundtrip, and circuits with non-contiguous qubit indexing
  • Make sure passing pytket circuit through as argument to device_wrapper.run successfully executes circuit for ibm and amazon braket devices.
@junliangtan1
Copy link
Contributor

junliangtan1 commented Mar 21, 2023

yah, you are right, so pytket qasm doesn't support some gates like iswap, that's why I purposely commented todo, those tests will be added like qiskit after doing a transpiler like braket_cirq, that will take some time, as there is some special gate are not able to direct add_gate from cirq to pytket, so require extra if else statement.
reference: https://github.com/CQCL/pytket-cirq/blob/develop/pytket/extensions/cirq/backends/cirq_convert.py
I also saw the same issue for pyquil as well, which also can be done similarly by define own gate like cirq custom_gates.py.

@ryanhill1
Copy link
Member Author

ryanhill1 commented Mar 21, 2023

@junliangtan1 Gotcha. Yeah we probably want to stay away from implementing anymore custom cirq gates, since that approach isn't very scalable. Instead, if it's the qasm to pytket methods that are breaking for specific gates, we could implement some pre-processing of the qasm string to replace the iswap and other unsupported gates with an equivalent gate decomposition that will be compatible with pytket.

I faced a similar problem with qasm to cirq conversions earlier. Certain qasm strings (mainly ones generated from qiskit circuits) were not compatible with the cirq's default circuit_from_qasm function. So I created a function convert_to_supported_qasm which takes an input qasm string and replaces unsupported gates with equivalent decompositions of other gates which are supported by cirq. So, in addition to increasing the coverage of the cirq parser with our own circuit_from_qasm function, we pass the qasm string through a pre-processing from_qasm function, which removes the barriers and calls the above-mentioned convert_to_supported_qasm function so that everything passed to the parser is able to be processed.

Taking this approach for iswap and other gates for pytket shouldn't be too difficult. Just follow the logic used in qasm_preprocess.py:

  1. Go through each line of the qasm string
  2. Have a conditional looking for "iswap" or other unsupported gate arg e.g. rxx
  3. Write a function that decomposes "iswap" or other unsupported gate into equivalent representation with supported gates e.g. _decompose_rxx_instr
  4. Add the replacement line(s) back to the qasm string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants