Background: I wrote a code that takes a Qiskit circuit C as an input and outputs a random circuit C’ such that C and C’ have the same unitaries. I tested my code using Qiskit’s Statevector simulator and Qiskit’s unitary simulator (using np.allclose). I tested over 20 circuits of various sizes, all passed the tests successfully, EXCEPT for one circuit, where sometimes I get the same unitaries and state vectors and sometimes I don’t. The circuit is quite large, with 10 qubits, 20 CNOT’s and a bunch of non-Clifford gates. The random output for this circuit can be incredibly large (e.g., more than 300 layers and a ridiculous number of CNOT’s). I’m pretty sure that there’s no error in my code, which leads me to ask:
Question: is there a certain size/complexity threshold of a circuit beyond which Qiskit’s unitary and Statevector simulators might return inaccurate results? In case that this never happens, is there any other explanation for the peculiar behavior that I described?