Skip to content

Commit

Permalink
Add Sycamore23 device (#2547)
Browse files Browse the repository at this point in the history
* Add Sycamore23 device

- 23 qubit subset of the Sycamore 54 qubit layout
- Update cirq/google/devices/known_devices.py

Co-Authored-By: Casey Duckering <cduck@users.noreply.github.com>
  • Loading branch information
dstrain115 and cduck committed Nov 21, 2019
1 parent 2201aa0 commit e76e36a
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 9 deletions.
1 change: 1 addition & 0 deletions cirq/google/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
Foxtail,
SerializableDevice,
Sycamore,
Sycamore23,
XmonDevice,
)

Expand Down
1 change: 1 addition & 0 deletions cirq/google/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
Bristlecone,
Foxtail,
Sycamore,
Sycamore23,
)

from cirq.google.devices.serializable_device import (
Expand Down
25 changes: 25 additions & 0 deletions cirq/google/devices/known_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,28 @@ def _json_dict_(self):
Sycamore = SerializableDevice.from_proto(
proto=SYCAMORE_PROTO,
gate_sets=[gate_sets.SQRT_ISWAP_GATESET, gate_sets.SYC_GATESET])


# Subset of the Sycamore grid with a reduced layout.
_SYCAMORE23_GRID = """
----------
----------
----------
--A-------
-ABC------
ABCDE-----
-CDEFG----
--EFGHI---
---GHI----
----I-----
"""

SYCAMORE23_PROTO = create_device_proto_from_diagram(
_SYCAMORE23_GRID,
[gate_sets.SQRT_ISWAP_GATESET, gate_sets.SYC_GATESET],
_SYCAMORE_DURATIONS_PICOS,
)

Sycamore23 = SerializableDevice.from_proto(
proto=SYCAMORE23_PROTO,
gate_sets=[gate_sets.SQRT_ISWAP_GATESET, gate_sets.SYC_GATESET])
35 changes: 26 additions & 9 deletions cirq/google/devices/known_devices_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import cirq
import cirq.google as cg
import cirq.google.common_serializers as cgc
import cirq.google.devices.known_devices as known_devices


def test_foxtail_qubits():
Expand All @@ -28,7 +29,7 @@ def test_foxtail_qubits():


def test_foxtail_device_proto():
assert str(cirq.google.devices.known_devices.FOXTAIL_PROTO) == """\
assert str(known_devices.FOXTAIL_PROTO) == """\
valid_gate_sets {
name: "xmon"
valid_gates {
Expand Down Expand Up @@ -255,7 +256,7 @@ def test_multiple_gate_sets():
'cz': 11_000,
'meas': 14_141
}
test_proto = cg.devices.known_devices.create_device_proto_from_diagram(
test_proto = known_devices.create_device_proto_from_diagram(
"aa\naa", [cg.gate_sets.XMON, halfPiGateSet], durations_dict)
assert str(test_proto) == """\
valid_gate_sets {
Expand Down Expand Up @@ -385,20 +386,36 @@ def test_json_dict():
'constant': 'cirq.google.Bristlecone',
}

from cirq.google.devices.known_devices import _NamedConstantXmonDevice
with pytest.raises(ValueError, match='xmon device name'):
_NamedConstantXmonDevice._from_json_dict_('the_unknown_fiddler')
known_devices._NamedConstantXmonDevice._from_json_dict_(
'the_unknown_fiddler')


def test_sycamore_device():
q0 = cirq.GridQubit(5, 4)
q1 = cirq.GridQubit(5, 5)
@pytest.mark.parametrize('device', [cg.Sycamore, cg.Sycamore23])
def test_sycamore_devices(device):
q0 = cirq.GridQubit(5, 3)
q1 = cirq.GridQubit(5, 4)
syc = cirq.FSimGate(theta=np.pi / 2, phi=np.pi / 6)(q0, q1)
sqrt_iswap = cirq.FSimGate(theta=np.pi / 4, phi=0)(q0, q1)
device.validate_operation(syc)
device.validate_operation(sqrt_iswap)
assert device.duration_of(syc) == cirq.Duration(nanos=12)
assert device.duration_of(sqrt_iswap) == cirq.Duration(nanos=32)


def test_sycamore_grid_layout():
# Qubits on Sycamore but not on Sycamore23
q0 = cirq.GridQubit(5, 5)
q1 = cirq.GridQubit(5, 6)
syc = cirq.FSimGate(theta=np.pi / 2, phi=np.pi / 6)(q0, q1)
sqrt_iswap = cirq.FSimGate(theta=np.pi / 4, phi=0)(q0, q1)
cg.Sycamore.validate_operation(syc)
cg.Sycamore.validate_operation(sqrt_iswap)
assert cg.Sycamore.duration_of(syc) == cirq.Duration(nanos=12)
assert cg.Sycamore.duration_of(sqrt_iswap) == cirq.Duration(nanos=32)

with pytest.raises(ValueError):
cg.Sycamore23.validate_operation(syc)
with pytest.raises(ValueError):
cg.Sycamore23.validate_operation(sqrt_iswap)


def test_proto_with_waitgate():
Expand Down
1 change: 1 addition & 0 deletions cirq/protocols/json_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ def test_mutually_exclusive_blacklist():
'StateVectorMixin',
'SYC_GATESET',
'Sycamore',
'Sycamore23',
'TextDiagramDrawer',
'ThreeQubitDiagonalGate',
'Timestamp',
Expand Down
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ Functionality specific to quantum hardware and services from Google.
cirq.google.SerializableGateSet
cirq.google.SerializingArg
cirq.google.Sycamore
cirq.google.Sycamore23
cirq.google.SycamoreGate
cirq.google.XmonDevice

Expand Down

0 comments on commit e76e36a

Please sign in to comment.