-
Notifications
You must be signed in to change notification settings - Fork 69
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
Qiskit v0.23 updates #112
Qiskit v0.23 updates #112
Conversation
Codecov Report
@@ Coverage Diff @@
## master #112 +/- ##
==========================================
- Coverage 99.25% 97.87% -1.38%
==========================================
Files 7 7
Lines 268 283 +15
==========================================
+ Hits 266 277 +11
- Misses 2 6 +4
Continue to review full report at Codecov.
|
|
||
def test_quantum_circuit_error_by_calling_wrong_parameters(self, recorder): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird diff from GitHub, this test was removed.
It doesn't make too much sense as parameter validation has been added to Qiskit so a string input would not work. Arrays will soon be deprecated too.
if aer_provider: | ||
# Consider the remaining kwargs as keyword arguments to run | ||
self.run_args.update(kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backend_options
seems to be deprecated for the run
method of Aer
backends (e.g. for QasmSimulator)
elif "backend_options" in s.parameters: | ||
# BasicAer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not seem to be the case for BasicAer
though (e.g. QasmSimulatorPy
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the entirety of BasicAer
is deprecated, so might be removed in future updates. This is why the new Aer features are likely not backported
# New Qiskit gates that are not natively supported by PL (identical | ||
# gates exist with a different name) | ||
# TODO: remove the following when gates have been renamed in PennyLane | ||
instruction_name = "U3Gate" if instruction_name == "UGate" else instruction_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I'll convert this into an issue so that we don't forget
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Auxiliary functions for gates subject to deprecation | ||
def U1Gate(theta): | ||
"""Auxiliary function for the ``U1Gate``.""" | ||
return ex.PhaseGate(theta) | ||
|
||
|
||
def U2Gate(phi, lam): | ||
"""Auxiliary function for the ``U2Gate``. | ||
|
||
Uses the equation ``u2(phi, lam) = u(pi/2, phi, lam)``. | ||
""" | ||
return ex.U(np.pi / 2, phi, lam) | ||
|
||
|
||
def U3Gate(theta, phi, lam): | ||
"""Auxiliary function for the ``U3Gate``.""" | ||
return ex.U(theta, phi, lam) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice solution!
elif "backend_options" in s.parameters: | ||
# BasicAer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the entirety of BasicAer
is deprecated, so might be removed in future updates. This is why the new Aer features are likely not backported
def test_quantum_circuit_error_by_passing_wrong_parameters(self, recorder): | ||
"""Tests the load method for a QuantumCircuit raises a QiskitError, | ||
if the wrong type of arguments were passed.""" | ||
def test_qiskit_gates_to_be_deprecated(self, recorder): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good idea. This way, we will know when the gates have been removed due to this test failing :)
Fix failing tests:
Noise models:
Due to a change in the signature of
QasmSimulator.run
,noise_model
is no longer a parameter. A solution using theset_options
method was added as per the examples from Qiskit.A Qiskit
NoiseModel
can be defined for theAer
provider and theQasmSimulator
. The new solution specifically uses this information.Updates:
u3
tou
,u1
top
, andu2(φ,λ)
tou(π/2, φ, λ)
: added thePhaseGate
andUGate
gates. The rest of the gates were left to use the soon to be deprecated gates (such that users would be informed about the deprecation.backend_options
with directkwargs
forAer
Test cases: