qr = QuantumRegister(2,'qr')
cr = ClassicalRegister(2,'cr')
circ = QuantumCircuit(qr,cr)


provider = IBMQ.get_provider(group = 'open')
backends = provider.get_backend(['ibmqx2', 'ibmq_16_melbourne', 'ibmq_vigo', 'ibmq_ourense'])
job = execute(circ, backend=backends, shots=1024) 
job_monitor(job, interval = 5)

result = job.result()
counts = result.get_counts(circ)

How do I run my quantum code on more than one backend at the same time?


You would need to send a job to each backend you want to run on. For example, if you wanted to send to ibmqx2 and ibmq_ourense you could execute code similar to this:

backend_1 = provider.get_backend('ibmqx2')
backend_2 = provider.get_backend('ibmq_ourense')

job_1 = execute(circuit, backend_1)  # Sends a job to run on ibmqx2
job_2 = execute(circuit, backend_2)  # Sends a job to run on ibmq_ourense

You can then get the results from each job normally:

result_1 = job_1.result().get_counts(circuit)
result_2 = job_2.result().get_counts(circuit)
| improve this answer | |
  • $\begingroup$ Still the job is sent one at a time. I need a way to send all the jobs at the same time $\endgroup$ – user8586 Sep 24 '19 at 16:26
  • $\begingroup$ It will send the jobs one at a time, but within the same script. They will both be put into the queue to be run on those devices. The 2nd job does not need to wait for the first job to finish before it is able to run $\endgroup$ – Matthew Stypulkoski Sep 24 '19 at 17:11
  • $\begingroup$ Is there a way to send all jobs simultaneously? $\endgroup$ – user8586 Sep 24 '19 at 17:24
  • $\begingroup$ In the example I posted, it essentially sends both jobs simultaneously. There will be barely any delay between them being sent. What is the main reason you want to send jobs to multiple backends at the same time? Maybe I can explain it more related to your specific use case. $\endgroup$ – Matthew Stypulkoski Sep 24 '19 at 18:25
  • 1
    $\begingroup$ Thank you for your answers Matthew. I used backend.jobs() to retrieve jobs on a stated backend $\endgroup$ – user8586 Sep 25 '19 at 15:48

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.