You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if a circuit has no measurements (but with classical wires), the reference Sampler raises an exception Some classical bits are not used for measurements.
QiskitError: 'Some classical bits are not used for measurements. the number of classical bits (3), the used classical bits (set()).'
It makes sense to convert this Error into a warning and return the state of all the classical wires. The reference implementation might assume that the initial state of the classical wires is 0 (this needs to be documented) and return {'000':1}. This would allow to partially measure a circuit. That is, if a not all the wires are measured, it could still run (with the warning, since that might not be intended)
ValueError: The 0-th circuit does not have any classical bit. Sampler requires classical bits, plus measurements on the desired qubits.
Again, here would probably make sense to run (converting this exception into a warning) and return {}. Because the case for "this is probably a user-error" in this context is stronger, maybe keeping the error makes sense (as a QiskitError instead?). I dump it here for completeness.
The text was updated successfully, but these errors were encountered:
As for the first one, we introduced the error 'Some classical bits are not used..." for the simplicity of the implementation. There seem to be some complicated corner cases according to the following discussion though I don't remember the details. @ikkoham may remember it. https://github.com/Qiskit/qiskit/pull/7780/files#r833295071
This error message is included only for the reference implementation Sampler. BaseSampler does not have it.
As for the second one, we check measurements at BaseSampler. So, the validation is done by Sampler of qiskit-ibm-runtime too.
If we allow a circuit with no measurements to run, users can submit the job containing both circuits w/ and w/o measurements, wait for a queue (can be a long time), and receive an empty result for the circuits w/o measurements. I don't have a strong opinion of early error message or empty result for circuits w/o measurements.
#10642 changes the error message of the first code example: ValueError: The 0-th circuit does not have Measure instruction. Without measurements, the circuit cannot be sampled from.
For the second one, that issue comment is all. Thank you @t-imamichi.
@blakejohnson raises a good point on the reference implementation for the Sampler in https://github.com/Qiskit/qiskit/pull/10584/files#r1294545780 . Let's move that conversation here.
When a circuit does not have measurements:
Currently, if a circuit has no measurements (but with classical wires), the reference
Sampler
raises an exceptionSome classical bits are not used for measurements.
It makes sense to convert this Error into a warning and return the state of all the classical wires. The reference implementation might assume that the initial state of the classical wires is
0
(this needs to be documented) and return{'000':1}
. This would allow to partially measure a circuit. That is, if a not all the wires are measured, it could still run (with the warning, since that might not be intended)This does not work currently:
When a circuit does not have classical wires:
Currently, if a circuit has no classical bits, the reference Sampler raises an exception
circuit does not have any classical bit
:Again, here would probably make sense to run (converting this exception into a warning) and return
{}
. Because the case for "this is probably a user-error" in this context is stronger, maybe keeping the error makes sense (as aQiskitError
instead?). I dump it here for completeness.The text was updated successfully, but these errors were encountered: