Skip to content

Commit

Permalink
[WIRES] Make plugin compatible with wires refactor (#37)
Browse files Browse the repository at this point in the history
* implemented new wire management

* fix device

* fix plugin

* Update .github/CHANGELOG.md
  • Loading branch information
mariaschuld authored Aug 6, 2020
1 parent ce69fc0 commit 922c38b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
30 changes: 29 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
...
```
[#37](https://github.com/PennyLaneAI/pennylane-cirq/pull/37)

### Documentation

### Bug fixes
Expand All @@ -14,6 +30,18 @@

This release contains contributions from (in alphabetical order):

Maria Schuld

---

# Release 0.9.1

### Improvements

### Contributors

This release contains contributions from (in alphabetical order):

---

# Release 0.9.0
Expand All @@ -39,7 +67,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

---

Expand Down
7 changes: 5 additions & 2 deletions pennylane_cirq/cirq_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 = {}
Expand Down Expand Up @@ -193,8 +195,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[wire] for wire in operation.wires])
cirq_operation.apply(*[self.qubits[w] for w in device_wires.labels])
)

def apply(self, operations, **kwargs):
Expand Down

0 comments on commit 922c38b

Please sign in to comment.