I am aware that each backend in Qiskit has a qubit limit. Across all backends in Aer, the limit is 24. When we employ ibmq_simulators then the the limit increases to 32. My requirement is not simulation but only to benchmark gate counts.

For counting gates I perform the following:

ALL_GATES = ["h", "t", "tdg", "s", "sdg", "cx", "rz"]
self.backend = AerSimulator()
tqc = transpile(
    circuit, self.backend, optimization_level=3, basis_gates=ALL_GATES
return self.skd(tqc)

I want to perform transpilation to get the gates and then decompose them using SolovayKitaev to get gate counts. The backend I use has a qubit limit, is there an alternative backend that does not have any? I do not intend to run these circuits, I just want to get the number of gates.

Edit: I realised that I can remove the backend and run transpile. I hope that this solution is sufficient. If there is an alternative solution please suggest, else I will close the question.


1 Answer 1


You can drop the backend argument from your transpile() call and that will remove the limitation. The backend argument is used to tell the qiskit transpiler that you're targeting a specific backend and it will map your circuit given the constraints expressed in that backend's Target (https://docs.quantum.ibm.com/api/qiskit/qiskit.transpiler.Target). The primary (but not only) constraints the transpiler is concerned with are connectivity and the supported instructions/gates. In the case of selecting an ideal Aer simulator (via AerSimulator()) without any noise there are no connectivity constraints, just the limit in the number of qubits, and the work of the transpiler is solely a function of translating the input circuit's gates to match the basis gates; which for Aer is a much larger superset than ALL_GATES. However, by setting basis_gates as an argument in addition to backend you're overriding that and the transpiler will be ignoring AerSimulator's basis gates. So you can safely remove the backend argument in this case.

It is important to mention here that this isn't a general solution, as for real backends or potentially other simulators this will result in an invalid transpiler output for a given backend. But in the case of using aer like this without a noise model it should work fine. Also, the Target model the backend's use support more involved instruction models like heterogeneous gates on different qubits so this solution is really only applicable to a bare AerSimulator() without any options set.

As an aside the number of qubits limit set on the aer backend should be dynamically set based on the chosen simulation method and the amount of available memory on your system. 24 seems awfully low as a limit though because for a statevector simulation that is ~268 MB of memory and a 25 qubit simulation would require ~537 MB of memory.


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.