# How accurate are Qiskit’s unitary and Statevector simulators for very large circuits?

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?

• I am not an expert, but 10 qubits and a few hundred gates, even non Clifford, shouldn't make the program have any problems. There are a few options though : either you have an error in you circuit (but you checked it), there is a bug in qiskit (which is also possible), your computer is overwhelmed (simulating state-vectors is very resource intensive, and maybe there is something on this side, however 10 qubits is not that much normally) Apr 27 at 7:45
• @BrockenDuck it seems extremely unlikely that there is an error in my code, as I do get the right results for the problematic circuit roughly half of the time. Considering that the unitaries have more than a million entries each, the chances for that happening by luck are astronomical (plus, everything works fine with the other +20 circuits that I tried). Apr 27 at 9:16
• @simulationsareawesome So for the particular problematic circuit $C$, what is different in it (structural wise) compare to the other 19 circuits? What you can also is to compute the case failed case without using qiskit statevector simulator and see for yourself whether the error is from the statevector simulator or the way you generate $C^{\prime}$... Apr 27 at 17:43
• How different are the state vectors when the test fails? np.allclose has fairly tight tolerance by default and it might be worth checking if the failed case passes with relaxed atol and rtol parameters. Apr 27 at 18:37