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

Analytic true hw simulator warning #59

Merged
merged 11 commits into from
Nov 20, 2019

Conversation

antalszava
Copy link
Contributor

Adds a warning for the expectation and variance computations in the case of when the analytic attribute is set to True on hardware simulators.

@codecov
Copy link

codecov bot commented Nov 19, 2019

Codecov Report

Merging #59 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master      #59      +/-   ##
==========================================
+ Coverage   99.71%   99.71%   +<.01%     
==========================================
  Files           8        8              
  Lines         346      352       +6     
==========================================
+ Hits          345      351       +6     
  Misses          1        1
Impacted Files Coverage Δ
pennylane_qiskit/qiskit_device.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34976bc...828a615. Read the comment docs.

from ._version import __version__
from .gates import BasisState, Rot
Copy link
Member

Choose a reason for hiding this comment

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

👍 glad the ordering here has been fixed

"is only supported on statevector backends, not on the {}. "
"The obtained result is based on sampling.".
format(self.backend),
UserWarning)
Copy link
Member

Choose a reason for hiding this comment

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

Should we move the warning to __init__? That way,

  • It doesn't have to be repeated for expval and var,
  • The user will know straight away and can change it, rather than waiting for the qnode to be evaluated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I first went for it to be in the __init__.py. In that case, however, as by default analytic=True is used and there will be warnings raised for sampling on HW simulators


from pennylane_qiskit.qiskit_device import pauli_eigs
from pennylane_qiskit import AerDevice
import pennylane as qml
Copy link
Member

Choose a reason for hiding this comment

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

Should this go below the import numpy line, since it is a third party import

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ran isort on it now and got the following:

import numpy as np
import pytest

import pennylane as qml
from pennylane_qiskit import AerDevice
from pennylane_qiskit.qiskit_device import pauli_eigs

Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -134,6 +134,10 @@ class QiskitDevice(Device, abc.ABC):
operations = set(_operation_map.keys())
observables = {"PauliX", "PauliY", "PauliZ", "Identity", "Hadamard", "Hermitian"}

hw_analytic_warning_message = "The analytic calculation of expectations and variances "\
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created separate warning message for expval and var

@antalszava antalszava merged commit 1bab8ea into master Nov 20, 2019
@antalszava antalszava deleted the analytic_true_hw_simulator_warning branch November 20, 2019 16:10
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.

2 participants