# Would IBM's “compiler” turn my identity circuit into nothing?

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?

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.