Recently, I used the transpile() function with the level 3 preset pass manager to compile a very long and complex circuit on a real device coupling map. I was curious to see how much the depth of the circuit would increase due to the inevitable swaps. The result was quite strange, the depth of the transpiled circuit was an order of magnitude lower than the original circuit.

When I drew the transpiled circuit I found that it was composed of some strange multi-qubit gates labeled as 'unitary' (see picture below), while most of the two-qubits gates from the original circuit were gone.


I was wondering what these unitaries could mean.


1 Answer 1


The point of the transplier is not only to map circuits to backends, but also to optimize the circuit to reduce the number of gates it contains so that the results you receive will (hopefully) be better. This is done through a series of optimizations, provided by things called transpiler passes. There is more information about them here.

A unitary in this case is quantum gate which can be represented by a matrix. You could try calling to_matrix() on this gate so you can see what action it is performing. It may have been formed by combining several gates into one. The 0 and 1 labels show which qubits it is acting on.

  • $\begingroup$ I understand that these uniatries are represented as matrices, I wonder if such a matrix will be executed at once on a real device or whether it will still need to be decomposed as it is not included in the standard set [u1, u2, u3, cx]. $\endgroup$
    – DavideFrr
    Nov 20, 2019 at 14:00
  • $\begingroup$ It will need to be decomposed. You could print the qasm of the circuit to see the decomposition $\endgroup$
    – met927
    Nov 20, 2019 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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