Qiskit / qiskit-ibm-runtime

IBM Client for Qiskit Runtime
https://docs.quantum.ibm.com/api/qiskit-ibm-runtime
Apache License 2.0
157 stars 155 forks source link

Job never finishes #1917

Open Caddy8 opened 1 month ago

Caddy8 commented 1 month ago

Describe the bug Job never finishes when using EstimatorV2 with a parametrized circuit, custom gates and pulse calibrations.

Steps to reproduce This is a simple example to reproduce this error:

from qiskit import QuantumCircuit, pulse, transpile
from qiskit.circuit import Gate, Parameter
from qiskit.pulse.library import Gaussian
from qiskit_ibm_runtime import QiskitRuntimeService, EstimatorV2 as Estimator
from qiskit.quantum_info import SparsePauliOp

service = QiskitRuntimeService(channel="ibm_quantum")
backend = service.least_busy(operational=True, simulator=False)
estimator = Estimator(mode=backend)

print(backend)

Second block:

parameters = [Parameter(f'{i}') for i in range(3)]

circ = QuantumCircuit(1, 1)
custom_gate = Gate('my_custom_gate', 1, [parameters[0], parameters[1], parameters[2]])
circ.append(custom_gate, [0])
circ.measure(0, 0)

circ.draw('mpl')

def pulse_builder(a,b,c):
    with pulse.build(backend, name='custom') as my_schedule:
        pulse.play(Gaussian(duration=a, amp=b, sigma=c), pulse.drive_channel(0))
    return my_schedule

circ.add_calibration('my_custom_gate', [0], pulse_builder(parameters[0], parameters[1], parameters[2]), [parameters[0], parameters[1], parameters[2]])

circ = transpile(circ)

circ.draw('mpl', idle_wires=False)

Last block:

hamiltonian = SparsePauliOp.from_list(
    [("Y", -0.3980), ("Z", -0.0113), ("X", 0.1810)]
)
Params = [64,0.2,8]
pub = (circ, [hamiltonian], [Params])
result = estimator.run([pub]).result()

Expected behavior This should return a result and not remain in the 'running' state 'forever'. I waited for several minutes until I cancelled the job. This job should only take a couple of seconds.

Suggested solutions

Additional Information This problem does not occur if I use the SamplerV2 instead of the EstimatorV2. This does not throw a python error.

kt474 commented 1 month ago

Hi @Caddy8

I ran your code snippets without any issues. Since you're running a job on real hardware there's a good chance that your job was in queue waiting to run. You can check the status of your jobs here https://quantum.ibm.com/workloads

Caddy8 commented 1 month ago

Hi @kt474 Thank you on the update in this topic. I checked the status of my job on [https://quantum.ibm.com/workloads] and I meant the 'running' state on that website under 'Status timeline' after 'Pending' was completed. I have attached a screenshot of this job running for over 2 minutes (it started 7:10 pm and at the time of the screenshot it was 7:13 pm) with the added line of code estimator.options.default_shots=10 so that the job should take practically not time. Just to be sure I also ran the code without that added line and again the job does not finish. (Screenshot also attached, this has the pending time of nearly 9 minutes.)

Bildschirmfoto 2024-09-17 um 19 13 12 Bildschirmfoto 2024-09-17 um 19 26 47
kt474 commented 1 month ago

Ah sorry, I can replicate your issue now. I'll follow up with the appropriate team