`Session.close` and `Batch.close` do not close the session and batch on the new IQP
Describe the bug
Session.close and Batch.close do not close the session and the batch.
Steps to reproduce (update) I made a reproducible script https://github.com/Qiskit/qiskit-ibm-runtime/issues/2188#issuecomment-2742082563
In [10]: from qiskit_ibm_runtime import QiskitRuntimeService, Batch
In [11]: service = QiskitRuntimeService(name="...") # new IQP
In [12]: session = Batch.from_id('...', service)
In [13]: session.status()
Out[13]: 'Pending'
In [14]: session.close() # There is no running job
In [15]: session.status()
Out[15]: 'Pending' # expected to be "Closed"
Expected behavior
The status become Closed as same as the conventional IQP.
I tried the same script on the conventional IQP and the status becomes Closed after close().
Suggested solutions
Additional Information
- qiskit-ibm-runtime version: 0.37.0
- qiskit version: 1.4.1
- Python version: 3.12.9
- Operating system: macOS 15.3.2
My understanding is that Session.close() calls this endpoint which just sets the accepting_jobs flag to false. So if there are still are pending jobs in the session, the status will be Pending. Only once there are no more pending jobs will the status update to Closed.
Getting this for both IQP and the new IQP on cloud
I made a script to reproduce the behavior. I confirmed that the behavior on new IQP is different from that on the conventional IQP. The last line of the new IQP is expected to be "Closed" as same as the conventional IQP.
from time import sleep
from qiskit_ibm_runtime import Batch, QiskitRuntimeService, __version__
print(__version__)
for name, iqp in [
("primitives", "conventional IQP"),
("notebooks-internal", "new IQP"),
]:
print(iqp)
service = QiskitRuntimeService(name=name)
backend = service.backend("test_eagle_us-east")
batch = Batch(backend)
sleep(1)
print(batch.status())
print("call close()")
batch.close()
sleep(1)
print(batch.status(), "\n")
0.37.0
conventional IQP
Pending
call close()
Closed
new IQP
Pending
call close()
Pending
The status on the new IQP is also "Pending" (not "Closed") even if close() is called and there is no job.
@francabrera is this an expected discrepancy between the two APIs?
the behaviour should be the same, and is what is being referenced before (the close method in this package marks the session as not accepting new jobs). The time to transition from "pending - not accepting new jobs" to closed is what changes in the new API, which takes longer time to move to the close from "pending - not accepting new jobs", this may change in the future.
The time to transition from "pending - not accepting new jobs" to closed is what changes in the new API, which takes longer time to move to the close from "pending - not accepting new jobs", this may change in the future.
Is this extended transition time included in usage for a session?
Is this extended transition time included in
usagefor a session?
this only happens for workloads created with no jobs on it (as in the Batch example), so there is no usage reported for these workloads
I tried my script https://github.com/Qiskit/qiskit-ibm-runtime/issues/2188#issuecomment-2742082563 today (April 22, 2025), but the issue has not been fixed yet. What is the status of this issue?
0.38.0
conventional IQP
/Users/ima/tasks/5_2025/scripts/2025/runtime/batch.py:12: DeprecationWarning: The "ibm_quantum" channel option is deprecated and will be sunset on 1 July. After this date, ibm_cloud will be the only valid channel. For information on migrating to the new IBM Quantum Platform on the "ibm_cloud" channel, review the migration guide https://quantum.cloud.ibm.com/docs/migration-guides/classic-iqp-to-cloud-iqp .
service = QiskitRuntimeService(name=name)
Pending
call close()
Closed
new IQP
Pending
call close()
Pending
I tried my script #2188 (comment) today (April 22, 2025), but the issue has not been fixed yet. What is the status of this issue?
Issue opened on the server side - multi-channel-scheduler issue 2782
I tried my script on July 3 and the behavior is not updated yet.
0.40.1
new IQP
Pending
call close()
Closed
Are you expecting the Session/Batch to be closed? I think it's working as intended now.
My bad. You are right. It behaves as same as the old IQP now. I close this issue.