3
$\begingroup$

I use different qiskit backends to run my code. Since the maximum number of shots is $2^{13}$, sometimes I need to send the same code several times with a "different ticket". I am wondering if there is an equivalent way to run in the background, similar to the command nohup, to run qiskit code so that it runs all the instances one would like (or waiting in the queue as they are sent!)

$\endgroup$
4
$\begingroup$

All the jobs are sent in a non-blocking way. You can send all your jobs with job = backend.run and recover their results in a fully different session.

In order to fully recover your Job object from a backend, you need the job id (given you are running Qiskit 0.24 or later. See @jyu00's comment)

You can save your job ids like this:

jobs = []
for circuit in circuits:
  job = backend.run
  jobs.append(job.job_id())

Later, when the job is done, you can recover each Job object like this:

provider = IBMQ.load_account()
job = provider.get_backend(backend_name).retrieve_job(job_id)
$\endgroup$
2
  • 2
    $\begingroup$ You actually don't need the the backend name anymore. You can just do provider.backend.retrieve_job(job_id) (requires Qiskit 0.24). This syntax can also be used to retrieve jobs from retired backends. $\endgroup$ – jyu00 May 6 at 12:15
  • $\begingroup$ Great hint! Updating the answer to reflect that. $\endgroup$ – luciano May 6 at 15:09

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.