4
$\begingroup$

Let's suppose I define a basis gate set and the following circuit.

import qiskit as qk
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit,Aer
backend = Aer.get_backend('unitary_simulator')

basis_gates=['h',"cx",'t']
qreg_q = QuantumRegister(1, 'q')
circuit = QuantumCircuit(qreg_q)
circuit.s(0)
qk.transpile(QT.circuit, backend, basis_gates)

I get the TranspilerError TranspilerError: "Unable to map source basis {('s', 1)} to target basis {'measure', 'h', 'delay', 'snapshot', 'cx', 'barrier', 't', 'reset'} over library <qiskit.circuit.equivalence.EquivalenceLibrary object at 0x14aefb3a1160>."

Why doesn't transpile work, being S gate = TT? It should be able to decompose it, right?

$\endgroup$
2
  • $\begingroup$ I tried different universal sets and I was never able to decompose $S=T^2$, but maybe there is one that allows it. $\endgroup$
    – Mauricio
    May 19 at 8:20
  • $\begingroup$ If one looks at the unitary, they are the same, so it should not depend on the other gates in the set, as long as T is in the set, right? $\endgroup$
    – John Brown
    May 19 at 14:48

1 Answer 1

1
$\begingroup$

The transpile doesn't work because the identity $S = TT$ is not there in the SessionEquivalenceLibrary. You can add an entry manually like this, and your circuit will be transpiled:

from qiskit.circuit.equivalence_library import SessionEquivalenceLibrary as sel
from qiskit.circuit.library import SGate
qc_eq = QuantumCircuit(1)
qc_eq.t(0)
qc_eq.t(0)
s = SGate()
sel.add_equivalence(s, qc_eq)

I assume the identity is not available by default, because it is not essential. Similarly, you won't be able to transpile an $X$ gate in terms of $H$ and $Z$, unless you add an identity $X = HZH$ explicitly to SessionEquivalenceLibrary.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.