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

Add error message for shot vectors for QiskitDevice #576

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

austingmhuang
Copy link
Contributor

As mentioned by @CatalinaAlbornoz in issue #575, there's a bug that's ultimately related to qiskit.aer not supporting shot vectors (@albi3ro). While the functionality is still not supported, in this PR, we add a more useful error message to capture this behaviour.

This error message already exists in the new device API so there's no additional work on that front.

@austingmhuang austingmhuang linked an issue Jul 12, 2024 that may be closed by this pull request
Copy link

codecov bot commented Jul 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (a295ece) to head (aa7aa42).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #576   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            9         9           
  Lines          867       869    +2     
=========================================
+ Hits           867       869    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -326,3 +326,16 @@ def barrier_func():
res = barrier_func()
assert barrier_func.tape.operations[0] == qml.Barrier([0, 1])
assert np.allclose(res, dev.batch_execute([barrier_func.tape]), atol=0)


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use @pytest.mark.parametrize.

Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may also need to update the setter for shots.

If you do:

dev.shots = (10,100,100)

Do you get an error? This is what is used for dynamic shots.

We should double check that bug #575 actually provides an informative error message now.

@austingmhuang
Copy link
Contributor Author

austingmhuang commented Jul 30, 2024

You may also need to update the setter for shots.

If you do:

dev.shots = (10,100,100)

Do you get an error? This is what is used for dynamic shots.

We should double check that bug #575 actually provides an informative error message now.

dev.shots = (10, 100, 100)

Does not raise an error for qiskit.aer since it does not have a setter for shots (inherits from the legacy device).
Seems like the error message doesn't show up for #575 when using qiskit.aer.


I tried using qiskit.remote with AerSimulator instead. This does raise an error for dev.shots=(10, 100, 100) but for the example in #575 the error message does not show up. Not sure how to proceed.

@austingmhuang austingmhuang requested a review from albi3ro July 30, 2024 18:54
@albi3ro
Copy link
Contributor

albi3ro commented Jul 30, 2024

You may also need to update the setter for shots.
If you do:

dev.shots = (10,100,100)

Do you get an error? This is what is used for dynamic shots.
We should double check that bug #575 actually provides an informative error message now.

dev.shots = (10, 100, 100)

Does not raise an error for qiskit.aer since it does not have a setter for shots (inherits from the legacy device). Seems like the error message doesn't show up for #575 when using qiskit.aer.

I tried using qiskit.remote with AerSimulator instead. This does raise an error for dev.shots=(10, 100, 100) but for the example in #575 the error message does not show up. Not sure how to proceed.

We may need to define a shots setter to add some validation is a shot vector is attempted to be set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] qml.ShotAdaptiveOptimizer doesn’t work with qiskit.aer
3 participants