Skip to content

Allow for multiple clients in cloud service#8

Merged
kt474 merged 14 commits intokt474:iqp-instance-account-optionsfrom
ElePT:cloud-migration
May 27, 2025
Merged

Allow for multiple clients in cloud service#8
kt474 merged 14 commits intokt474:iqp-instance-account-optionsfrom
ElePT:cloud-migration

Conversation

@ElePT
Copy link
Copy Markdown

@ElePT ElePT commented May 15, 2025

Summary

This PR allows to keep track of all instantiated clients in the runtime service instead of overwriting a single client in the "ibm_cloud" path. The mechanism is quite naive (just storing a dictionary of instantiated clients accessible by CRN), I think that this logic should be handled by the RuntimeClient class instead of the QiskitRuntimeService, but as a first approximation at least this implementation unlocks the following functionality:

  • Accessing backends from 2 different instances and then retrieving jobs from the first backend:
service = QiskitRuntimeService(channel="ibm_cloud")
backend_1 = service.backend("ibm_hanoi", instance="CRN_FROM_ACCOUNT_1")
circuit = QuantumCircuit(4,4)
sampler = SamplerV2(backend_1)
job = sampler.run([(circuit)])
job_id = job.job_id()
backend_2 = service.backend("ibm_kingston", instance="CRN_FROM_ACCOUNT_2")
new_job = service.job(job_id)
  • Retrieving a session instantiated with a different instance than the one currently used:
service = QiskitRuntimeService(channel="ibm_cloud")
backend_1 = service.backend("ibm_torino", instance="CRN_FROM_ACCOUNT_1")
circuit = QuantumCircuit(4,4)
with Session(backend_1) as session:
        sampler = SamplerV2(session)
        session_id = session.session_id
        job = sampler.run([(circuit)])
        job_id = job.job_id()
backend_2 = service.backend("ibm_kingston", instance="CRN_FROM_ACCOUNT_2")
new_session = Session.from_id(session_id, service=service)
  • In general, switching between backends from different instances and always having access to submitted jobs and sessions independently of the instance they were created with.

On top of this, the PR clearly establishes a difference between the ibm_cloud channel and the ibm_quantum_platform channel.

Details and comments

Fixes #

@ElePT ElePT force-pushed the cloud-migration branch from a2e5f9c to c27f958 Compare May 15, 2025 11:26
@ElePT ElePT force-pushed the cloud-migration branch from c27f958 to 2d504f7 Compare May 21, 2025 08:54
@ElePT ElePT changed the title Speed up single backend instantiation Allow for multiple clients in cloud service May 21, 2025
@ElePT ElePT force-pushed the cloud-migration branch from 2d504f7 to e7ccb3f Compare May 22, 2025 17:10
@ElePT ElePT marked this pull request as ready for review May 22, 2025 17:13
@ElePT ElePT force-pushed the cloud-migration branch from f71087d to 1048f8d Compare May 22, 2025 17:44
arnaucasau and others added 5 commits May 22, 2025 18:20
* Update links pointing to IQP Classic

* fix long lines
* Confirm they work for job and session retrieval

* Update docstrings to include all channels and clarify when methods are used

* Update deprecation messages to fit docstrings

* Fix unit tests

* Update mocks
@ElePT ElePT force-pushed the cloud-migration branch from 1048f8d to 37c36d4 Compare May 23, 2025 21:19
@ElePT ElePT force-pushed the cloud-migration branch from 3bcfe43 to 0b53076 Compare May 27, 2025 12:25
@kt474 kt474 merged commit cb293b5 into kt474:iqp-instance-account-options May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants