I've got a script which tries to create 5 jobs in a session, it submits the jobs via QiskitRuntimeService.run and the options on the jobs specify the alt_algiers backend. However, the jobs are run on the alt_canberra backend.
from qiskit_ibm_runtime import QiskitRuntimeService
QiskitRuntimeService.save_account(
channel="ibm_cloud", token=apikey, instance=crn,
url="https://test.cloud.ibm.com")
service = QiskitRuntimeService()
program_inputs = {'iterations': 1}
# Tag the job for the MCS flow
options = {
"backend": "alt_algiers",
"job_tags": ["proxy_mcs", "use_runtime_workers", "sessions"]
}
print('submitting 5 jobs in a session')
with Session(service=service) as session:
for i in range(5):
print(f'{i+1} submitting session job')
job = session.run(program_id="hello-world",
options=options,
inputs=program_inputs)
print(f"submitted job: {job.job_id()}")
print(f"job results: {job.result()}")
print(f'all jobs run for session {session.session_id}')
The first job created is cdru53vj3bs1jpmpdmfg which ran on alt_canberra, not alt_algiers.
Checking the server logs this is because it looks like the job was sent to the runtime API without a backend specified even though it's in the options passed to run().
My guess this has something to do with the Session constructor in the context manager and how it doesn't have backend supplied, so maybe that's overwriting what's passed to submit the job to run()? From the docs:
I guess that was a surprise to me, is it intentional that it'd overwrite the backend specified in options to the run() method?
Steps to reproduce
see the script above
Expected behavior
I would expect that if the options passed to run() have a backend specified but the Session doesn't, then the backend from options is used when submitting the job rather than Session.backend overwriting it when Session.backend is None.
If this is working as designed and my script is invalid, I'd expect an error when trying to submit the first job in the session because the usage is wrong - an explicit error would be easier to sort out from a user perspective rather than wonder why the backend I specified wasn't used.
Describe the bug
I've got a script which tries to create 5 jobs in a session, it submits the jobs via
QiskitRuntimeService.run
and theoptions
on the jobs specify thealt_algiers
backend. However, the jobs are run on thealt_canberra
backend.The first job created is
cdru53vj3bs1jpmpdmfg
which ran onalt_canberra
, notalt_algiers
.Checking the server logs this is because it looks like the job was sent to the runtime API without a backend specified even though it's in the
options
passed torun()
.My guess this has something to do with the
Session
constructor in the context manager and how it doesn't havebackend
supplied, so maybe that's overwriting what's passed to submit the job torun()
? From the docs:https://qiskit.org/documentation/partners/qiskit_ibm_runtime/stubs/qiskit_ibm_runtime.Session.html#qiskit_ibm_runtime.Session
I guess that was a surprise to me, is it intentional that it'd overwrite the backend specified in
options
to therun()
method?Steps to reproduce
see the script above
Expected behavior
I would expect that if the
options
passed torun()
have a backend specified but theSession
doesn't, then the backend fromoptions
is used when submitting the job rather thanSession.backend
overwriting it whenSession.backend
is None.If this is working as designed and my script is invalid, I'd expect an error when trying to submit the first job in the session because the usage is wrong - an explicit error would be easier to sort out from a user perspective rather than wonder why the backend I specified wasn't used.
Suggested solutions
See above.
Additional Information