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": appliesUnitarySynthesis / HighLevelSynthesis / BasisTranslator"synthesis": appliesUnitarySynthesis / HighLevelSynthesis / Unroll3qOrMore / Collect2qBlocks / Collect1qRuns / ConsolidateBlocks / UnitarySynthesis / HighLevelSynthesis
Importantly :
- the
UnitarySynthesispass is able to "synthesize gates" by doing approximations. Example :Rz(5π/4)->Z / T, with the Solovay Kitaev plugin (method = 'sk'). - the
BasisTranslatorpass 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
- first, do the
BasisTranslatorpass with rotations in the target basis (even though they are not in the final target basis) - then only, do the
UnitarySynthesispass
Questions
I wonder about the best way to combine the UnitarySynthesis and BasisTranslator passes :
What is the difference between the
"translator"and"synthesis"options ? Which one would be best here ?If using the
"translator"method, does it make sense to simply add anotherUnitarySynthesispass at the end of the translation pass ? (and if yes, do we even need multipleUnitarySynthesispasses ?)Is there maybe an even simpler way to do it ? Using other qiskit passes ?