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

Qiskit v0.23 updates #112

Merged
merged 10 commits into from
Oct 20, 2020
Merged

Qiskit v0.23 updates #112

merged 10 commits into from
Oct 20, 2020

Conversation

antalszava
Copy link
Contributor

@antalszava antalszava commented Oct 19, 2020

Fix failing tests:

  • Converter (due to a new validation in Qiskit, error is raised from there)
  • Noise model extraction

Noise models:

Due to a change in the signature of QasmSimulator.run, noise_model is no longer a parameter. A solution using the set_options method was added as per the examples from Qiskit.

A Qiskit NoiseModel can be defined for the Aer provider and the QasmSimulator. The new solution specifically uses this information.

Updates:

  • Change u3 to u, u1 to p, and u2(φ,λ) to u(π/2, φ, λ): added the PhaseGate and UGate 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.
  • Replace backend_options with direct kwargs for Aer

Test cases:

  • Write a test for the noise model
  • Write tests for the auxiliary function operations

@codecov
Copy link

codecov bot commented Oct 19, 2020

Codecov Report

Merging #112 into master will decrease coverage by 1.37%.
The diff coverage is 80.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
pennylane_qiskit/qiskit_device.py 97.41% <78.94%> (-2.59%) ⬇️
pennylane_qiskit/converter.py 100.00% <100.00%> (ø)

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 972d11e...5f71da1. Read the comment docs.


def test_quantum_circuit_error_by_calling_wrong_parameters(self, recorder):
Copy link
Contributor Author

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.

Comment on lines +189 to +191
if aer_provider:
# Consider the remaining kwargs as keyword arguments to run
self.run_args.update(kwargs)
Copy link
Contributor Author

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)

Comment on lines +193 to +194
elif "backend_options" in s.parameters:
# BasicAer
Copy link
Contributor Author

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).

Copy link
Member

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

@antalszava antalszava requested a review from josh146 October 20, 2020 04:08
@josh146 josh146 marked this pull request as ready for review October 20, 2020 06:00
# 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
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

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

Comment on lines +36 to +52
# 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)
Copy link
Member

Choose a reason for hiding this comment

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

Very nice solution!

Comment on lines +193 to +194
elif "backend_options" in s.parameters:
# BasicAer
Copy link
Member

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):
Copy link
Member

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 :)

tests/test_converter.py Outdated Show resolved Hide resolved
@josh146 josh146 merged commit bd0f9e2 into master Oct 20, 2020
@josh146 josh146 deleted the qiskit_v0.23_fixes branch October 20, 2020 06:18
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