7
$\begingroup$

If I were to create a circuit with the following gate:

$$\tag{1}R_\phi = \begin{bmatrix} 1 & 0 \\ 0 & e^{i \phi} \end{bmatrix},$$

with $\phi$ specified to be equal to 0, then the gate that I am running is just the identity gate, and the circuit is to do nothing to the qubits. Would the IBM hardware actually "run" some gate with some parameter being set as close as possible to 0? Or would IBM's compilers recognize that nothing is to be done, and just not "apply" any gate at all?

While the two cases would ideally be equivalent, in practice the one where "nothing" is done, would be less susceptible to error, which could make a significant difference in the outcomes we observe.

Likewise, if we put two $X$ gates next to each other in a circuit to be run on the IBM hardware, would IBM's compilers notice that the circuit is just the identity circuit, and decide to do nothing rather than apply two gates that cancel each other out?

To what extent does IBM's software and firmware "compile" circuits like this?

$\endgroup$

1 Answer 1

9
$\begingroup$

Any compilation/circuit optimization happens transparently by Qiskit. As a user you have control over what happens via the optimization_level argument passed to transpile(). Setting optimization level high (e.g. level 3) will do more circuit optimizations and setting it low will do little or no optimization (e.g. level 0). The two examples that you provide are straightforward. They will be optimized at optimization level 3 and left alone at optimization level 0.

$\endgroup$
3
  • 1
    $\begingroup$ It seems that the first paragraph contradicts the second one. IBM Q does optimization as you correctly said in second paragraph. However, you also say that it does not change the user's circuit. But it has to do so if an optimization is done. $\endgroup$ Aug 17, 2020 at 8:07
  • 1
    $\begingroup$ @MartinVesely The first paragraph says IBM doesn't optimize stuff. The second paragraph says your computer optimizes it before it sends it to IBM. I think. (Not a quantum scientist, just a random programmer) $\endgroup$
    – user253751
    Aug 17, 2020 at 12:07
  • $\begingroup$ @user253751 Wrong because Qiskit is an IBM compiler, so IBM does optimize stuff. Ali: the last sentence of my question asked whether or not IBM's software (which includes Qiskit) does any optimization, so I agree with Martin that the 2nd paragraph contradicted the first. I gave you a +1 anyway. Thanks to you answering so quickly, if the question and answer get enough upvotes, and if more answers come, this could become a Hot Network Question and bring the site more positive publicity. Since you say "transparently", does that mean I can see the compiled circuit before running the calculation? $\endgroup$ Aug 17, 2020 at 13:46

Your Answer

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

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