diff --git a/CHANGELOG.md b/CHANGELOG.md index 434169d68..2d98a9452 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,19 +1,17 @@ -# Release 0.6.0-dev +# Release 0.6.0 ### New features since last release -### Breaking changes - -### Improvements - -### Documentation - -### Bug fixes +* All Qiskit devices now support tensor observables using the + `return expval(qml.PauliZ(0) @ qml.Hermitian(A, [1, 2]))` + syntax introduced in PennyLane v0.6. ### Contributors This release contains contributions from (in alphabetical order): +Josh Izaac + --- # Release 0.5.1 diff --git a/pennylane_qiskit/_version.py b/pennylane_qiskit/_version.py index 36b932532..06f187ba5 100644 --- a/pennylane_qiskit/_version.py +++ b/pennylane_qiskit/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.6.0-dev" +__version__ = "0.6.0" diff --git a/pennylane_qiskit/qiskit_device.py b/pennylane_qiskit/qiskit_device.py index 1fb02da85..9d68cbe98 100644 --- a/pennylane_qiskit/qiskit_device.py +++ b/pennylane_qiskit/qiskit_device.py @@ -119,8 +119,8 @@ class QiskitDevice(Device, abc.ABC): Default value is ``True``. """ name = "Qiskit PennyLane plugin" - pennylane_requires = ">=0.5.0" - version = "0.5.0" + pennylane_requires = ">=0.6.0" + version = "0.6.0" plugin_version = __version__ author = "Xanadu" diff --git a/requirements.txt b/requirements.txt index 913ae17a7..0863534ec 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ qiskit>=0.12 -PennyLane>=0.5.0 +PennyLane>=0.6.0 numpy diff --git a/setup.py b/setup.py index 6eb9d77a6..631be038b 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ requirements = [ "qiskit>=0.12", - "pennylane>=0.5.0", + "pennylane>=0.6.0", "numpy" ] diff --git a/tests/conftest.py b/tests/conftest.py index 7d020fd8d..b7c7091d2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,3 @@ -from collections import namedtuple import pytest import numpy as np @@ -54,6 +53,3 @@ def _device(n): return request.param(wires=n, backend=backend, shots=shots, analytic=analytic) return _device - - -Tensor = namedtuple("Tensor", ["name", "wires", "parameters", "return_type"]) diff --git a/tests/test_expval.py b/tests/test_expval.py index 4a2980514..57ffec984 100644 --- a/tests/test_expval.py +++ b/tests/test_expval.py @@ -3,7 +3,7 @@ import numpy as np import pennylane as qml -from conftest import U, U2, A, Tensor +from conftest import U, U2, A np.random.seed(42) @@ -181,7 +181,7 @@ def test_paulix_pauliy(self, theta, phi, varphi, device, shots, tol): dev.apply("CNOT", wires=[1, 2], par=[]) dev._obs_queue = [ - Tensor(["PauliX", "PauliY"], [[0], [2]], [[], []], qml.operation.Expectation) + qml.PauliX(0, do_queue=False) @ qml.PauliY(2, do_queue=False) ] dev.pre_measure() @@ -200,7 +200,7 @@ def test_pauliz_identity(self, theta, phi, varphi, device, shots, tol): dev.apply("CNOT", wires=[1, 2], par=[]) dev._obs_queue = [ - Tensor(["PauliZ", "Identity", "PauliZ"], [[0], [1], [2]], [[], [], []], qml.operation.Expectation) + qml.PauliZ(0, do_queue=False) @ qml.Identity(1, do_queue=False) @ qml.PauliZ(2, do_queue=False) ] dev.post_apply() @@ -221,7 +221,7 @@ def test_pauliz_hadamard(self, theta, phi, varphi, device, shots, tol): dev.apply("CNOT", wires=[1, 2], par=[]) dev._obs_queue = [ - Tensor(["PauliZ", "Hadamard", "PauliY"], [[0], [1], [2]], [[], [], []], qml.operation.Expectation) + qml.PauliZ(0, do_queue=False) @ qml.Hadamard(1, do_queue=False) @ qml.PauliY(2, do_queue=False) ] dev.pre_measure() @@ -248,7 +248,9 @@ def test_hermitian(self, theta, phi, varphi, device, shots, tol): ] ) - dev._obs_queue = [Tensor(["PauliZ", "Hermitian"], [[0], [1, 2]], [[], [A]], qml.operation.Expectation)] + dev._obs_queue = [ + qml.PauliZ(0, do_queue=False) @ qml.Hermitian(A, [1, 2], do_queue=False) + ] dev.pre_measure() res = dev.expval(["PauliZ", "Hermitian"], [[0], [1, 2]], [[], [A]]) @@ -283,7 +285,7 @@ def test_hermitian_hermitian(self, theta, phi, varphi, device, shots, tol): ) dev._obs_queue = [ - Tensor(["Hermitian", "Hermitian"], [[0], [1, 2]], [[A1], [A2]], qml.operation.Expectation) + qml.Hermitian(A1, 0, do_queue=False) @ qml.Hermitian(A2, [1, 2], do_queue=False) ] dev.pre_measure() @@ -313,7 +315,7 @@ def test_hermitian_identity_expectation(self, theta, phi, varphi, device, shots, dev.apply("RY", wires=[1], par=[phi]) dev.apply("CNOT", wires=[0, 1], par=[]) - dev._obs_queue = [Tensor(["Hermitian", "Identity"], [[0], [1]], [[A], []], qml.operation.Expectation)] + dev._obs_queue = [qml.Hermitian(A, 0, do_queue=False) @ qml.Identity(1, do_queue=False)] dev.pre_measure() res = dev.expval(["Hermitian", "Identity"], [[0], [1]], [[A], []]) diff --git a/tests/test_sample.py b/tests/test_sample.py index c7470655f..065914512 100644 --- a/tests/test_sample.py +++ b/tests/test_sample.py @@ -5,7 +5,7 @@ from pennylane_qiskit import AerDevice, BasicAerDevice -from conftest import U, U2, A, Tensor +from conftest import U, U2, A np.random.seed(42) @@ -134,13 +134,13 @@ def test_paulix_pauliy(self, theta, phi, varphi, device, shots, tol): dev.apply("CNOT", wires=[1, 2], par=[]) dev._obs_queue = [ - Tensor(["PauliX", "PauliY"], [[0], [2]], [[], []], qml.operation.Sample) + qml.PauliX(0, do_queue=False) @ qml.PauliY(2, do_queue=False) ] - # for idx in range(len(dev._obs_queue)): - # dev._obs_queue[idx].return_type = qml.operation.Sample + for idx in range(len(dev._obs_queue)): + dev._obs_queue[idx].return_type = qml.operation.Sample - res = dev.pre_measure() + dev.pre_measure() s1 = dev.sample(["PauliX", "PauliY"], [[0], [2]], [[], [], []]) @@ -172,13 +172,13 @@ def test_pauliz_hadamard(self, theta, phi, varphi, device, shots, tol): dev.apply("CNOT", wires=[1, 2], par=[]) dev._obs_queue = [ - Tensor(["PauliZ", "Hadamard", "PauliY"], [[0], [1], [2]], [[], [], []], qml.operation.Sample) + qml.PauliZ(0, do_queue=False) @ qml.Hadamard(1, do_queue=False) @ qml.PauliY(2, do_queue=False) ] - # for idx in range(len(dev._obs_queue)): - # dev._obs_queue[idx].return_type = qml.operation.Sample + for idx in range(len(dev._obs_queue)): + dev._obs_queue[idx].return_type = qml.operation.Sample - res = dev.pre_measure() + dev.pre_measure() s1 = dev.sample(["PauliZ", "Hadamard", "PauliY"], [[0], [1], [2]], [[], [], []]) @@ -216,12 +216,14 @@ def test_hermitian(self, theta, phi, varphi, device, shots, tol): ] ) - dev._obs_queue = [Tensor(["PauliZ", "Hermitian"], [[0], [1, 2]], [[], [A]], qml.operation.Sample)] + dev._obs_queue = [ + qml.PauliZ(0, do_queue=False) @ qml.Hermitian(A, [1, 2], do_queue=False) + ] - # for idx in range(len(dev._obs_queue)): - # dev._obs_queue[idx].return_type = qml.operation.Sample + for idx in range(len(dev._obs_queue)): + dev._obs_queue[idx].return_type = qml.operation.Sample - res = dev.pre_measure() + dev.pre_measure() s1 = dev.sample(["PauliZ", "Hermitian"], [[0], [1, 2]], [[], [A]]) diff --git a/tests/test_var.py b/tests/test_var.py index 80b870bcf..5e25dd186 100644 --- a/tests/test_var.py +++ b/tests/test_var.py @@ -5,7 +5,7 @@ from pennylane_qiskit import AerDevice, BasicAerDevice -from conftest import U, U2, A, Tensor +from conftest import U, U2, A np.random.seed(42) @@ -76,7 +76,7 @@ def test_paulix_pauliy(self, theta, phi, varphi, device, shots, tol): dev.apply("CNOT", wires=[1, 2], par=[]) dev._obs_queue = [ - Tensor(["PauliX", "PauliY"], [[0], [2]], [[], []], qml.operation.Variance) + qml.PauliX(0, do_queue=False) @ qml.PauliY(2, do_queue=False) ] dev.pre_measure() @@ -103,7 +103,7 @@ def test_pauliz_hadamard(self, theta, phi, varphi, device, shots, tol): dev.apply("CNOT", wires=[1, 2], par=[]) dev._obs_queue = [ - Tensor(["PauliZ", "Hadamard", "PauliY"], [[0], [1], [2]], [[], [], []], qml.operation.Variance) + qml.PauliZ(0, do_queue=False) @ qml.Hadamard(1, do_queue=False) @ qml.PauliY(2, do_queue=False) ] dev.pre_measure() @@ -136,9 +136,8 @@ def test_hermitian(self, theta, phi, varphi, device, shots, tol): ] ) - dev._obs_queue = [Tensor(["PauliZ", "Hermitian"], [[0], [1, 2]], [[], [A]], qml.operation.Variance)] + dev._obs_queue = [qml.PauliZ(0, do_queue=False) @ qml.Hermitian(A, [1, 2], do_queue=False)] dev.pre_measure() - res = dev.var(["PauliZ", "Hermitian"], [[0], [1, 2]], [[], [A]]) expected = (