From 233927ad48852d3b684ef72cb0c616ad2b7163f7 Mon Sep 17 00:00:00 2001 From: mariaschuld Date: Mon, 15 Jun 2020 20:39:56 +0200 Subject: [PATCH 1/4] implemented new wire management --- .github/CHANGELOG.md | 16 +++++++++++++++- pennylane_cirq/cirq_device.py | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index fae37dc..14fde08 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -16,6 +16,20 @@ This release contains contributions from (in alphabetical order): --- +# Release 0.9.1 + +### Improvements + +Made plugin device compatible with new PennyLane wire management. + +### Contributors + +This release contains contributions from (in alphabetical order): + +Maria Schuld + +--- + # Release 0.9.0 ### New features since last release @@ -39,7 +53,7 @@ This release contains contributions from (in alphabetical order): This release contains contributions from (in alphabetical order): -Theodor Isacsson, Nathan Killoran, Maria Shuld, Antal Száva +Theodor Isacsson, Nathan Killoran, Maria Schuld, Antal Száva --- diff --git a/pennylane_cirq/cirq_device.py b/pennylane_cirq/cirq_device.py index aaefb41..d179d08 100644 --- a/pennylane_cirq/cirq_device.py +++ b/pennylane_cirq/cirq_device.py @@ -194,7 +194,7 @@ def _apply_operation(self, operation): cirq_operation.parametrize(*operation.parameters) self.circuit.append( - cirq_operation.apply(*[self.qubits[wire] for wire in operation.wires]) + cirq_operation.apply(*[self.qubits[reg] for reg in self.wire_map(operation.wires)]) ) def apply(self, operations, **kwargs): From 43de3e7aaf1d2fe97a8f4a1e9a0294db7677191e Mon Sep 17 00:00:00 2001 From: Maria Schuld Date: Wed, 5 Aug 2020 16:53:06 +0200 Subject: [PATCH 2/4] fix device --- pennylane_cirq/cirq_device.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pennylane_cirq/cirq_device.py b/pennylane_cirq/cirq_device.py index 11404c5..f7cce4b 100644 --- a/pennylane_cirq/cirq_device.py +++ b/pennylane_cirq/cirq_device.py @@ -193,8 +193,9 @@ def _apply_operation(self, operation): if cirq_operation: cirq_operation.parametrize(*operation.parameters) + device_wires = self.map_wires(operation.wires) self.circuit.append( - cirq_operation.apply(*[self.qubits[reg] for reg in self.wire_map(operation.wires)]) + cirq_operation.apply(*[self.qubits[w] for w in device_wires.labels]) ) def apply(self, operations, **kwargs): From 8808a427e2bb01e96791fe9b36a7e8753861f673 Mon Sep 17 00:00:00 2001 From: Maria Schuld Date: Wed, 5 Aug 2020 17:01:32 +0200 Subject: [PATCH 3/4] fix plugin --- .github/CHANGELOG.md | 22 ++++++++++++++++++---- pennylane_cirq/cirq_device.py | 4 +++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 14fde08..79ced6c 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -6,6 +6,22 @@ ### Improvements +* Made plugin device compatible with new PennyLane wire management. + + One can now specify any string or number as a custom wire label, + and use these labels to address subsystems on the device: + + ``` python + + dev = qml.device('cirq.simulator', wires=['q1', 'ancilla', 0, 1] + + def circuit(): + qml.Hadamard(wires='q1') + qml.CNOT(wires=[1, 'ancilla']) + ... + ``` + [#XX](https://github.com/PennyLaneAI/pennylane-XX/pull/XX) + ### Documentation ### Bug fixes @@ -14,20 +30,18 @@ This release contains contributions from (in alphabetical order): +Maria Schuld + --- # Release 0.9.1 ### Improvements -Made plugin device compatible with new PennyLane wire management. - ### Contributors This release contains contributions from (in alphabetical order): -Maria Schuld - --- # Release 0.9.0 diff --git a/pennylane_cirq/cirq_device.py b/pennylane_cirq/cirq_device.py index f7cce4b..33e78c0 100644 --- a/pennylane_cirq/cirq_device.py +++ b/pennylane_cirq/cirq_device.py @@ -71,6 +71,8 @@ def __init__(self, wires, shots, analytic, qubits=None): self.circuit = None + device_wires = self.map_wires(self.wires) + if qubits: if wires != len(qubits): raise qml.DeviceError( @@ -81,7 +83,7 @@ def __init__(self, wires, shots, analytic, qubits=None): self.qubits = qubits else: - self.qubits = [cirq.LineQubit(wire) for wire in range(wires)] + self.qubits = [cirq.LineQubit(wire) for wire in device_wires.labels] # Add inverse operations self._inverse_operation_map = {} From c101b5a63d84909538689992a422799a9844ea1e Mon Sep 17 00:00:00 2001 From: Maria Schuld Date: Wed, 5 Aug 2020 17:26:43 +0200 Subject: [PATCH 4/4] Update .github/CHANGELOG.md --- .github/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 79ced6c..e331825 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -20,7 +20,7 @@ qml.CNOT(wires=[1, 'ancilla']) ... ``` - [#XX](https://github.com/PennyLaneAI/pennylane-XX/pull/XX) + [#37](https://github.com/PennyLaneAI/pennylane-cirq/pull/37) ### Documentation