Closed garrison closed 1 year ago
I believe 0.12.1 resolved this issue. This is same with https://github.com/Qiskit/qiskit-aer/issues/1754.
I confirmed this code works with 0.12.1.
from qiskit import QuantumCircuit
from qiskit_aer.primitives import Sampler
qc = QuantumCircuit(1, 1)
qc.x(0)
qc.measure(0, 0)
sampler = Sampler(run_options={"shots": 1.5})
job = sampler.run(qc)
job.result()
Informations
What is the current behavior?
Setting the
shots
of aSampler
to afloat
results in it failing, but not until the job is executed.Steps to reproduce the problem
What is the expected behavior?
The code above fails on the final line, but it could fail sooner, when the
Sampler
is created withshots
set to a float.This is creating a usability issue for us in the circuit-knitting-toolbox, where users often do some math to determine a suitable shots count. If they forget to round the value and convert it to an
int
, they currently get the above error when they go to execute the circuit using the toolbox. We've found that because the error comes then from deep inside the circuit-knitting-toolbox, the user is typically unaware that their own error caused it.Suggested solutions
Check the type of
shots
when the sampler is constructed. Don't wait untilresult()
is called on the job. Provide a clear error message when it is a float.