From a8fb1bda4d8592467de5aa7cd2d8815eea9711fb Mon Sep 17 00:00:00 2001 From: lillian542 <38584660+lillian542@users.noreply.github.com> Date: Wed, 24 Apr 2024 15:03:12 -0400 Subject: [PATCH 1/5] Install PL dev intead of PL stable on CI (#516) * install PL dev intead of PL stable on CI * trigger ci * also a couple of other places --- .github/workflows/tests.yml | 4 ++++ .github/workflows/tests_qiskit_1.yml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c5d43a89a..3703508a6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,6 +29,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install git+https://github.com/PennyLaneAI/pennylane.git pip install -r requirements-ci-legacy.txt pip install wheel pytest pytest-cov pytest-mock flaky --upgrade pip freeze @@ -70,13 +71,16 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install git+https://github.com/PennyLaneAI/pennylane.git pip install -r requirements-ci-legacy.txt pip install wheel pytest pytest-cov pytest-mock pytest-benchmark flaky --upgrade + pip freeze - name: Install Plugin run: | python setup.py bdist_wheel pip install dist/PennyLane*.whl + pip freeze - name: Run tests run: | diff --git a/.github/workflows/tests_qiskit_1.yml b/.github/workflows/tests_qiskit_1.yml index 103abf4ef..1ad3c3b53 100644 --- a/.github/workflows/tests_qiskit_1.yml +++ b/.github/workflows/tests_qiskit_1.yml @@ -29,6 +29,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install git+https://github.com/PennyLaneAI/pennylane.git pip install -r requirements-ci.txt pip install wheel pytest pytest-cov pytest-mock flaky --upgrade pip freeze @@ -67,6 +68,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install git+https://github.com/PennyLaneAI/pennylane.git pip install -r requirements-ci.txt pip install wheel pytest pytest-cov pytest-mock pytest-benchmark flaky --upgrade From 214cc32f2a3611a6a07f8606af4be2942efcb048 Mon Sep 17 00:00:00 2001 From: Austin Huang <65315367+austingmhuang@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:23:21 -0400 Subject: [PATCH 2/5] Install PL dev intead of PL stable on CI (#516) (#518) * install PL dev intead of PL stable on CI * trigger ci * also a couple of other places Co-authored-by: lillian542 <38584660+lillian542@users.noreply.github.com> --- .github/workflows/tests.yml | 4 ++++ .github/workflows/tests_qiskit_1.yml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c5d43a89a..3703508a6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,6 +29,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install git+https://github.com/PennyLaneAI/pennylane.git pip install -r requirements-ci-legacy.txt pip install wheel pytest pytest-cov pytest-mock flaky --upgrade pip freeze @@ -70,13 +71,16 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install git+https://github.com/PennyLaneAI/pennylane.git pip install -r requirements-ci-legacy.txt pip install wheel pytest pytest-cov pytest-mock pytest-benchmark flaky --upgrade + pip freeze - name: Install Plugin run: | python setup.py bdist_wheel pip install dist/PennyLane*.whl + pip freeze - name: Run tests run: | diff --git a/.github/workflows/tests_qiskit_1.yml b/.github/workflows/tests_qiskit_1.yml index 103abf4ef..1ad3c3b53 100644 --- a/.github/workflows/tests_qiskit_1.yml +++ b/.github/workflows/tests_qiskit_1.yml @@ -29,6 +29,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install git+https://github.com/PennyLaneAI/pennylane.git pip install -r requirements-ci.txt pip install wheel pytest pytest-cov pytest-mock flaky --upgrade pip freeze @@ -67,6 +68,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install git+https://github.com/PennyLaneAI/pennylane.git pip install -r requirements-ci.txt pip install wheel pytest pytest-cov pytest-mock pytest-benchmark flaky --upgrade From 15931507ea3de081f6165ff41937ef78cae4dbce Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Thu, 25 Apr 2024 14:48:58 -0400 Subject: [PATCH 3/5] Delete ds store --- .DS_Store | Bin 8196 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 0622312c937da06b2686d5d54f1dbed3a15b3700..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHM%We}f6g_TJ5zz`of<*u!W(kW#>K~*f0V0)$2>X)9P^#ud9xdIV+4B$l0^i39 z&b_uOduAepDxpf)k$onfd#W1gOy&K1jN(^J^yq}0UvE?wcXz4JP4&zofu0k=o zI(dnj!?Y~MF)9!hC@LVe`wj+J;}qkdewPo@0ekb8Hl^<28D4VsHC~{DBfKFtF)8qV z58wT}IMj96fY$)<1LBRlGtUXGrl;_n3zE zTPHdDUE0eIyLiqOdU($ro?;rZRGIIdGBwP(!j!K|>ewfyIL2q)^%=+9&LIl<{QG!& z#Xl7znG3wsHhL-NQ{#YN Date: Thu, 25 Apr 2024 15:33:34 -0400 Subject: [PATCH 4/5] import change --- pennylane_qiskit/converter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane_qiskit/converter.py b/pennylane_qiskit/converter.py index 76e4d5744..ff0d816f8 100644 --- a/pennylane_qiskit/converter.py +++ b/pennylane_qiskit/converter.py @@ -21,7 +21,6 @@ import numpy as np from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister -from pennylane_qiskit.qiskit_device import QISKIT_OPERATION_MAP from qiskit.converters import circuit_to_dag, dag_to_circuit from qiskit.circuit import Parameter, ParameterExpression, ParameterVector from qiskit.circuit import Measure, Barrier, ControlFlowOp, Clbit @@ -35,6 +34,7 @@ import pennylane as qml import pennylane.ops as pennylane_ops +from pennylane_qiskit.qiskit_device import QISKIT_OPERATION_MAP inv_map = {v.__name__: k for k, v in QISKIT_OPERATION_MAP.items()} From f0c6dc94d30abb377161f045a6f3b59829bac7a4 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Thu, 25 Apr 2024 17:54:35 -0400 Subject: [PATCH 5/5] black --- tests/test_base_device.py | 27 ++++++++++++++++----------- tests/test_qiskit_device.py | 20 ++++++++++---------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/tests/test_base_device.py b/tests/test_base_device.py index 9e486de3c..a66461b49 100644 --- a/tests/test_base_device.py +++ b/tests/test_base_device.py @@ -86,7 +86,8 @@ def run(self, *args, **kwargs): @property def target(self): return self._target - + + class MockedBackendLegacy(BackendV1): def __init__(self, num_qubits=10, name="mocked_backend_legacy"): self._configuration = Configuration(num_qubits, backend_name=name) @@ -106,6 +107,7 @@ def run(self, *args, **kwargs): def options(self): return self._options + class MockSession: def __init__(self, backend, max_time=None): self.backend = backend @@ -135,6 +137,7 @@ def options_for_testing(): options.resilience_level = 1 return options + class TestSupportForV1andV2: """Tests compatibility with BackendV1 and BackendV2""" @@ -149,30 +152,32 @@ def test_v1_and_v2_mocked(self, backend): """Test that device initializes with no error mocked""" dev = QiskitDevice2(wires=10, backend=backend, use_primitives=True) assert dev._backend == backend - - @pytest.mark.skip(reason="Fake backends do not have attribute _service, should address in (SC 55725)") + @pytest.mark.skip( + reason="Fake backends do not have attribute _service, should address in (SC 55725)" + ) @pytest.mark.parametrize( - "backend", - [ - FakeManila(), - FakeManilaV2(), - ] + "backend", + [ + FakeManila(), + FakeManilaV2(), + ], ) def test_v1_and_v2_manila(self, backend): """Test that device initializes with no error with V1 and V2 backends by Qiskit""" dev = QiskitDevice2(wires=5, backend=backend, use_primitives=True) - + @qml.qnode(dev) def circuit(x): qml.RX(x, wires=[0]) qml.CNOT(wires=[0, 1]) return qml.sample(qml.PauliZ(0)) - - res = circuit(np.pi/2) + + res = circuit(np.pi / 2) assert isinstance(res, np.ndarray) assert np.shape(res) == (1024,) + class TestDeviceInitialization: def test_compile_backend_kwarg(self): """Test that the compile_backend is set correctly if passed, and the main diff --git a/tests/test_qiskit_device.py b/tests/test_qiskit_device.py index 5aec93c91..5f136e00a 100644 --- a/tests/test_qiskit_device.py +++ b/tests/test_qiskit_device.py @@ -5,7 +5,7 @@ from pennylane_qiskit import AerDevice from pennylane_qiskit.qiskit_device import QiskitDevice from qiskit_aer import noise -from qiskit.providers import BackendV1, BackendV2 +from qiskit.providers import BackendV1, BackendV2 from qiskit_ibm_runtime.fake_provider import FakeManila, FakeManilaV2 from unittest.mock import Mock from qiskit_ibm_runtime.options import Options @@ -92,25 +92,25 @@ def test_v1_and_v2_mocked(self, backend): """Test that device initializes with no error mocked""" dev = qml.device("qiskit.remote", wires=10, backend=backend, use_primitives=True) assert dev._backend == backend - + @pytest.mark.parametrize( - "backend", - [ - FakeManila(), - FakeManilaV2(), - ] + "backend", + [ + FakeManila(), + FakeManilaV2(), + ], ) def test_v1_and_v2_manila(self, backend): """Test that device initializes with no error with V1 and V2 backends by Qiskit""" dev = qml.device("qiskit.remote", wires=5, backend=backend, use_primitives=True) - + @qml.qnode(dev) def circuit(x): qml.RX(x, wires=[0]) qml.CNOT(wires=[0, 1]) return qml.sample(qml.PauliZ(0)) - - res = circuit(np.pi/2) + + res = circuit(np.pi / 2) assert isinstance(res, np.ndarray) assert np.shape(res) == (1024,)