Now, I'm implementing Matrix product state method with QasmSimulation in Qiskit. following code

enter image description here enter image description here

The problem arise when I set number of qubits. When running it with 27qubits is very fast but, for 24, 25, 26qubits it take too much time. Why it happens?

  • $\begingroup$ What times do you get for 24, 25, 26 qubits? $\endgroup$ – Yael Ben-Haim Sep 20 at 9:32
  • $\begingroup$ 42sec for 23 qubits, 88sec for 24qubits, 207sec for 25qubits, 510sec for 26qubits and 0.2sec for 27 qubits. Also 0.3sec for 28qubits $\endgroup$ – 김동민 Sep 20 at 10:28
  • $\begingroup$ This is indeed very mysterious. I will try to investigate this problem tomorrow. $\endgroup$ – merav-aharoni Sep 20 at 14:16
  • $\begingroup$ please.. I really wonder why $\endgroup$ – 김동민 Sep 21 at 7:02

This has to do with a parameter that switches between algorithms for measurement. Try changing your backend_opts as follows:

backend_opts = {'method':"matrix_product_state", 'mps_sample_measure_qubits_opt':20}

Perhaps we need to change the threshold in the code. I will check this.

| improve this answer | |
  • $\begingroup$ I checked the running time was dramatically reduced with this option. But I still curious about why It happens and what the option 'mps_sample_measure_qubits_opt':20 means. Can you give me more information about it? $\endgroup$ – 김동민 Sep 21 at 7:12
  • $\begingroup$ For the MPS simulator, two algorithms are implemented for measurement. Algorithm1 is efficient for a single shot and can handle a large number of qubits (hundreds). Algorithm 2 is less efficient for a single shot (because it computes the probabilities vector), however it is more efficient when many shots are required (hundreds - thousands). We decide between these two algorithms according to the above threshold (and another threshold for the number of shots). Judging from your example, we should re-examine the default threshold/ $\endgroup$ – merav-aharoni Sep 21 at 9:09
  • $\begingroup$ Oh. I see. I tried 36qubits with 'mps_sample_measure_qubits_opt':20 option, but it takes 7036sec, almost 2hours. But 36qubits with 'mps_sample_measure_qubits_opt':30 option, it takes just 3 sec. Is there difference between number 20 and 30? Could you give me the information link related to two algorithm of MPS? $\endgroup$ – 김동민 Sep 21 at 10:13
  • $\begingroup$ With 36 qubits, my run time is 0.04 sec for 100 shots, and 0.4 sec for 1000 shots. This happens for the default (26) threshold, as well as for 20 or 20. I am running on a Linux server. I don't understand why you are seeing the results you wrote, unless you changed the circuit in some other way. $\endgroup$ – merav-aharoni Sep 21 at 13:15
  • $\begingroup$ Documentation is lacking on these options - I added this request to the issue in GitHub. $\endgroup$ – merav-aharoni Sep 21 at 13:16

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.