Used memory-profiler to check why I get memory spikes in what I though were small circuits. The circuit itself is constructed using qiskit.aqua.algorithms.single_sample.shor.shor.Shor, the backend ended up being ibmq_qasm_simulator with the default number of shots (1024).

The results:

Line #    Mem usage    Increment   Line Contents
   302    180.6 MiB    180.6 MiB       @profile
   303                                 def _shors_period_finder(self, job_descriptor: ShorJobDescriptor, fleet: QFleet, shots=None):
   ...    ...            ...
   310    180.6 MiB      0.0 MiB           shor = Shor(N=9, a=4)
   311    324.0 MiB    143.4 MiB           circ = shor.construct_circuit(measurement=True)
   ...    ...            ...
   315    326.1 MiB      2.0 MiB           qcomp = fleet.get_best_backend(circ.n_qubits, job_descriptor.allow_simulator)
   ...    ...            ...
   324    668.9 MiB    342.9 MiB           job = execute(circ, backend=qcomp, shots=shots if shots else 1024)
   ...    ...            ...

Why am I getting the memory spike on line 324?

Is a (9,4) Shor circuit really 143.4MB? Am I using the wrong Shor object?

Or am I just optimistic about the circuits I can construct without this volume of overhead?

  • 1
    $\begingroup$ Are you not receiving a response/result after executing the circuit? You say that it hangs as well. $\endgroup$ Oct 14, 2019 at 15:49
  • $\begingroup$ I've got print statements before and after the execute call, yeah it hangs for at least 10 minutes. Circuit construction also takes over ten seconds $\endgroup$
    – Dori
    Oct 14, 2019 at 21:10
  • 1
    $\begingroup$ I tried running the code that I could from your post. It looks like the circuit being created is fairly large, so the time it takes to create that circuit is not too out of the ordinary. However, when I ran the job on he ibmq_qasm_simulator, it did not take too long. Do you have any more information about the code you are running? $\endgroup$ Oct 15, 2019 at 15:56
  • $\begingroup$ Haven't reproduced the long execution time since yesterday $\endgroup$
    – Dori
    Oct 15, 2019 at 22:08
  • $\begingroup$ Hmm, might have just been a blip in the network during the time you originally were running. Should be fine if you are not experiencing the long wait time anymore. $\endgroup$ Oct 16, 2019 at 13:50


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.