4

Context

In qiskit, the translation stage of the transpilation "translates (or unrolls) the gates specified in a circuit to the native basis gates of a specified backend." (cf doc)

For that, the generate_translation_passmanager() function accepts 2 options for the method argument :

  • "translator" : applies UnitarySynthesis / HighLevelSynthesis / BasisTranslator
  • "synthesis" : applies UnitarySynthesis / HighLevelSynthesis / Unroll3qOrMore / Collect2qBlocks / Collect1qRuns / ConsolidateBlocks / UnitarySynthesis / HighLevelSynthesis

Importantly :

  • the UnitarySynthesis pass is able to "synthesize gates" by doing approximations. Example : Rz(5π/4) -> Z / T, with the Solovay Kitaev plugin (method = 'sk').
  • the BasisTranslator pass is able to replace gates with equivalent gates in the target basis, using the equivalence library. Example : cy -> Tdg / Tdg / cx / s, after doing a graph search into the equivalence library graph.

Issue

In my case, the desired target basis is clifford + T gate : {cx, h, s, t}, rather than rotations + cx.

Using the "translator" method, I am able to transpile circuits containing rz(theta) gates, but I am unable to transpile circuits that rely on rz(theta) as a target gate in the internals of the BasisTranslator step (e.g. transpiling cz fails if I don't have rz in the target basis).

It seems to me that, just like in this related question (not a duplicate !), a solution would be to

  1. first, do the BasisTranslator pass with rotations in the target basis (even though they are not in the final target basis)
  2. then only, do the UnitarySynthesis pass

Questions

I wonder about the best way to combine the UnitarySynthesis and BasisTranslator passes :

  1. What is the difference between the "translator" and "synthesis" options ? Which one would be best here ?

  2. If using the "translator" method, does it make sense to simply add another UnitarySynthesis pass at the end of the translation pass ? (and if yes, do we even need multiple UnitarySynthesis passes ?)

  3. Is there maybe an even simpler way to do it ? Using other qiskit passes ?

alxthm
  • 71
  • 4

1 Answers1

2
  1. According to qiskit maintainers, "transpile(...., translation_method="synthesis", unitary_synthesis_method="sk") should work but currently doesn't". In the meantime, transpiling to ["u", "cx"] (using either translation_method?) and then calling the SolovayKitaev transpiler pass on the output should work.
  2. According to qiskit maintainers,
    • UnitarySynthesis(method='sk') and SolovayKitaev passes should be equivalent, but using SolovayKitaev directly has less overhead
    • "The SolovayKitaev pass should be the last pass running in the translation stage", and can simply be appended to the default passes
  3. For the moment, it does not seem so.

More details in the related issue on qiskit repository.

alxthm
  • 71
  • 4