Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precision and shots are not consistent for EstimatorV2 #1749

Open
hJaffaliColibritd opened this issue Jun 14, 2024 · 1 comment
Open

Precision and shots are not consistent for EstimatorV2 #1749

hJaffaliColibritd opened this issue Jun 14, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@hJaffaliColibritd
Copy link

hJaffaliColibritd commented Jun 14, 2024

In the new version of the EstimatorV2, we can't anymore give the shots for the experiment, but rather the required precision. I think first that this is a mistake, you may need to let the choice to the user if he needs to perform an experiment with a very specific number of shots for specific reasons. Moreover, the required precision and the final precision may not be the same, while if we use shots, we are sure that the right number of shots will be performed.

Anyway, if we try to manually set the precision to have a corresponding number of shots, this will also not work. If we use the relation given in this line

shots = int(np.ceil(1.0 / pub.precision**2))
, by setting the precision to precision = 1/np.sqrt(required_shots), if we do the math we will exactly retrieve that shots=required_shots.

However, for some reasons, when we run some jobs online with the EstimatorV2, and we check the number of shots in the metadata, it is not exactly the same. For instance, for a number of shots required of 1234, we find out that 1280 were performed. This is maybe due to the fact that the reached precision is not the same as the required precision, or due to some truncation or rounding in the decimal part of precision.

I suggest that you put back the possibility to precise directly the number of shots, and let alo the precision option.

  • qiskit-ibm-runtime version: 0.23.0
  • Python version: 3.9.5
  • Operating system: Windows 10 Professionnel
@hJaffaliColibritd hJaffaliColibritd added the bug Something isn't working label Jun 14, 2024
@hJaffaliColibritd hJaffaliColibritd changed the title Precision and shots are not consistent Precision and shots are not consistent for EstimatorV2 Jun 14, 2024
@ihincks
Copy link
Collaborator

ihincks commented Jun 14, 2024

Please see the option called default_shots here, it may be what you are looking for.

However, it also may not be exactly what you are looking for, and something that we could do a better job at documenting: if you are using twirling, either or both of gates/measurements, then it splits the provided shots, either via precision or default_shots, up into num_randomizations random circuits, and performs num_shots_per_randomization shots on each. If the number of shots is not divisible by the number of randomizations, then it will overshoot the total number of shots by the smallest amount possible. This is likely for a number like 1234. If you want exact control, then you can specify num_randomizations and num_shots_per_randomization exactly in the twirling options, or you can turn off twirling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants