diff --git a/docs/api/migration-guides/_toc.json b/docs/api/migration-guides/_toc.json index ab6c765eb1d..41ac470b4b9 100644 --- a/docs/api/migration-guides/_toc.json +++ b/docs/api/migration-guides/_toc.json @@ -23,6 +23,23 @@ } ] }, + { + "title": "Qiskit Runtime 0.20 changes", + "children": [ + { + "title": "V2 primitives", + "url": "/api/migration-guides/v2-primitives" + }, + { + "title": "Sessions", + "url": "/api/migration-guides/sessions" + }, + { + "title": "qiskit_ibm_provider to qiskit_ibm_runtime", + "url": "/api/migration-guides/qiskit-runtime-from-provider" + } + ] + }, { "title": "Qiskit 0.44 changes", "children": [ diff --git a/docs/api/migration-guides/sessions.mdx b/docs/api/migration-guides/sessions.mdx new file mode 100644 index 00000000000..f719321401f --- /dev/null +++ b/docs/api/migration-guides/sessions.mdx @@ -0,0 +1,41 @@ +--- +title: Execution mode changes +description: Learn about the changes to execution modes (sessions, batch, and single jobs) + +--- + + + +# Execution mode changes + +Jobs can be run as single jobs, sessions, or in a batch. + +## Sessions + +Sessions are designed for iterative workloads to avoid queueing delays between each iteration. When running a session, you have near exclusive access to the backend. With this release, sessions are now thread safe. That is, you can run multiple workloads within a session. + +### Example: Run two VQE algorithms in a session by using threading + +```python +from concurrent.futures import ThreadPoolExecutor + +def minimize_thread(estimator, method): + minimize(cost_func, x0, args=(ansatz, hamiltonian, estimator), method=method) + +with Session(backend=backend), ThreadPoolExecutor() as executor: + estimator1 = Estimator(options={"job_tags": ["cobyla"]}) + estimator2 = Estimator(options={"job_tags": ["nelder-mead"]}) + + cobyla_result = executor.submit(minimize_thread, estimator1, "cobyla").result() + nelder_mead_result = executor.submit(minimize_thread, estimator2, "nelder-mead").result() +``` + +### Extended sessions + +Prior to this release, sessions were terminated after the active window, as shown in the following image. + +![This image shows four jobs. Between each is the interactive TTL (time to live). The active window starts when the first job starts and ends after the last job is completed. After the final job completes, the active window ends and the session terminates.](/images/api/qiskit-ibm-runtime/SessionTTL.png 'Figure 1: Session behavior prior to extended sessions') + +With extended sessions, the session pauses after the active window ends. The session is resumed if more session jobs exit the queue. + +[This image shows multiple sets of jobs. Within each set, and between each job, is the interactive TTL (time to live). The active window starts when the first job starts and ends after the last job is completed. After the final job of the first set of jobs completes, the active window ends and the session is paused. Another set of jobs then starts and jobs continue in a similar manner.](/images/api/qiskit-ibm-runtime/SessionTTL.png 'Figure 2: Extended sessions') diff --git a/public/images/api/qiskit-ibm-runtime/ExtendedSession.png b/public/images/api/qiskit-ibm-runtime/ExtendedSession.png new file mode 100644 index 00000000000..40d9470d5ce Binary files /dev/null and b/public/images/api/qiskit-ibm-runtime/ExtendedSession.png differ diff --git a/public/images/api/qiskit-ibm-runtime/SessionTTL.png b/public/images/api/qiskit-ibm-runtime/SessionTTL.png new file mode 100644 index 00000000000..1ba1d3170b3 Binary files /dev/null and b/public/images/api/qiskit-ibm-runtime/SessionTTL.png differ