Skip to content

Commit

Permalink
Remove Bristlecone and Foxtail deprecated XmonDevices. (#5483)
Browse files Browse the repository at this point in the history
Before removing XmonDevice outright, remove child classes.
  • Loading branch information
MichaelBroughton authored Jun 16, 2022
1 parent e18e9bc commit 68fcde7
Show file tree
Hide file tree
Showing 18 changed files with 29 additions and 437 deletions.
2 changes: 0 additions & 2 deletions cirq-google/cirq_google/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
)

from cirq_google.devices import (
Bristlecone,
Foxtail,
GoogleNoiseProperties,
GridDevice,
NoiseModelFromGoogleNoiseProperties,
Expand Down
2 changes: 1 addition & 1 deletion cirq-google/cirq_google/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
NoiseModelFromGoogleNoiseProperties,
)

from cirq_google.devices.known_devices import Bristlecone, Foxtail, Sycamore, Sycamore23
from cirq_google.devices.known_devices import Sycamore, Sycamore23

from cirq_google.devices.grid_device import GridDevice

Expand Down
102 changes: 1 addition & 101 deletions cirq-google/cirq_google/devices/known_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Any, Collection, Dict, Optional, Iterable, List, Set, Tuple
from typing import Collection, Dict, Optional, Iterable, List, Set, Tuple

import cirq
from cirq import _compat
from cirq._doc import document
from cirq_google.api import v2
from cirq_google.api.v2 import device_pb2
from cirq_google.devices.serializable_device import SerializableDevice
from cirq_google.devices.xmon_device import _XmonDeviceBase
from cirq_google.serialization import gate_sets, op_serializer, serializable_gate_set

_2_QUBIT_TARGET_SET = "2_qubit_targets"
Expand Down Expand Up @@ -210,103 +207,6 @@ def populate_qubit_pairs_in_device_proto(
new_target.ids.extend(v2.qubit_to_proto_id(q) for q in pair)


_FOXTAIL_GRID = """
AAAAABBBBBB
CCCCCCDDDDD
"""


class _NamedConstantXmonDevice(_XmonDeviceBase):
def __init__(self, constant: str, **kwargs) -> None:
super().__init__(**kwargs)
self._repr = constant

def __repr__(self) -> str:
return self._repr

@classmethod
def _from_json_dict_(cls, constant: str, **kwargs):
_compat._warn_or_error(
f'NamedConstantXmonDevice was used but is deprecated.\n'
f'It will be removed in cirq v0.15.\n'
)
if constant in ['cirq.google.Foxtail', 'cirq_google.Foxtail']:
return Foxtail
if constant in ['cirq.google.Bristlecone', 'cirq_google.Bristlecone']:
return Bristlecone
raise ValueError(f'Unrecognized xmon device name: {constant!r}')

def _json_dict_(self) -> Dict[str, Any]:
return {'constant': self._repr}


Foxtail = _NamedConstantXmonDevice(
'cirq_google.Foxtail',
measurement_duration=cirq.Duration(nanos=4000),
exp_w_duration=cirq.Duration(nanos=20),
exp_11_duration=cirq.Duration(nanos=50),
qubits=_parse_device(_FOXTAIL_GRID)[0],
)
document(
Foxtail,
f"""72 xmon qubit device.
**Qubit grid**:
```
{str(Foxtail)}
```
""",
)

# Duration dict in picoseconds
_DURATIONS_FOR_XMON = {
'cz': 45_000,
'xy': 15_000,
'z': 0,
'meas': 4_000_000, # 1000ns for readout, 3000ns for "ring down"
}

FOXTAIL_PROTO = create_device_proto_from_diagram(
_FOXTAIL_GRID, [gate_sets.XMON], _DURATIONS_FOR_XMON
)

_BRISTLECONE_GRID = """
-----AB-----
----ABCD----
---ABCDEF---
--ABCDEFGH--
-ABCDEFGHIJ-
ABCDEFGHIJKL
-CDEFGHIJKL-
--EFGHIJKL--
---GHIJKL---
----IJKL----
-----KL-----
"""

Bristlecone = _NamedConstantXmonDevice(
'cirq_google.Bristlecone',
measurement_duration=cirq.Duration(nanos=4000),
exp_w_duration=cirq.Duration(nanos=20),
exp_11_duration=cirq.Duration(nanos=50),
qubits=_parse_device(_BRISTLECONE_GRID)[0],
)

document(
Bristlecone,
f"""72 xmon qubit device.
**Qubit grid**:
```
{str(Bristlecone)}
```
""",
)

BRISTLECONE_PROTO = create_device_proto_from_diagram(
_BRISTLECONE_GRID, [gate_sets.XMON], _DURATIONS_FOR_XMON
)

_SYCAMORE_GRID = """
-----AB---
----ABCD--
Expand Down
236 changes: 0 additions & 236 deletions cirq-google/cirq_google/devices/known_devices_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,242 +20,6 @@
import cirq_google.serialization.common_serializers as cgc


def test_foxtail_device_proto():
assert (
str(known_devices.FOXTAIL_PROTO)
== """\
valid_gate_sets {
name: "xmon"
valid_gates {
id: "xy"
number_of_qubits: 1
valid_args {
name: "axis_half_turns"
type: FLOAT
}
valid_args {
name: "half_turns"
type: FLOAT
}
gate_duration_picos: 15000
}
valid_gates {
id: "z"
number_of_qubits: 1
valid_args {
name: "half_turns"
type: FLOAT
}
valid_args {
name: "type"
type: STRING
}
}
valid_gates {
id: "xyz"
number_of_qubits: 1
valid_args {
name: "x_exponent"
type: FLOAT
}
valid_args {
name: "z_exponent"
type: FLOAT
}
valid_args {
name: "axis_phase_exponent"
type: FLOAT
}
}
valid_gates {
id: "cz"
number_of_qubits: 2
valid_args {
name: "half_turns"
type: FLOAT
}
valid_args {
name: "phase_match"
type: STRING
}
gate_duration_picos: 45000
valid_targets: "2_qubit_targets"
}
valid_gates {
id: "meas"
valid_args {
name: "key"
type: STRING
}
valid_args {
name: "invert_mask"
type: REPEATED_BOOLEAN
}
gate_duration_picos: 4000000
valid_targets: "meas_targets"
}
valid_gates {
id: "circuit"
}
}
valid_qubits: "0_0"
valid_qubits: "0_1"
valid_qubits: "0_2"
valid_qubits: "0_3"
valid_qubits: "0_4"
valid_qubits: "0_5"
valid_qubits: "0_6"
valid_qubits: "0_7"
valid_qubits: "0_8"
valid_qubits: "0_9"
valid_qubits: "0_10"
valid_qubits: "1_0"
valid_qubits: "1_1"
valid_qubits: "1_2"
valid_qubits: "1_3"
valid_qubits: "1_4"
valid_qubits: "1_5"
valid_qubits: "1_6"
valid_qubits: "1_7"
valid_qubits: "1_8"
valid_qubits: "1_9"
valid_qubits: "1_10"
valid_targets {
name: "meas_targets"
target_ordering: SUBSET_PERMUTATION
}
valid_targets {
name: "2_qubit_targets"
target_ordering: SYMMETRIC
targets {
ids: "0_0"
ids: "0_1"
}
targets {
ids: "0_0"
ids: "1_0"
}
targets {
ids: "0_1"
ids: "0_2"
}
targets {
ids: "0_1"
ids: "1_1"
}
targets {
ids: "0_2"
ids: "0_3"
}
targets {
ids: "0_2"
ids: "1_2"
}
targets {
ids: "0_3"
ids: "0_4"
}
targets {
ids: "0_3"
ids: "1_3"
}
targets {
ids: "0_4"
ids: "0_5"
}
targets {
ids: "0_4"
ids: "1_4"
}
targets {
ids: "0_5"
ids: "0_6"
}
targets {
ids: "0_5"
ids: "1_5"
}
targets {
ids: "0_6"
ids: "0_7"
}
targets {
ids: "0_6"
ids: "1_6"
}
targets {
ids: "0_7"
ids: "0_8"
}
targets {
ids: "0_7"
ids: "1_7"
}
targets {
ids: "0_8"
ids: "0_9"
}
targets {
ids: "0_8"
ids: "1_8"
}
targets {
ids: "0_9"
ids: "0_10"
}
targets {
ids: "0_9"
ids: "1_9"
}
targets {
ids: "0_10"
ids: "1_10"
}
targets {
ids: "1_0"
ids: "1_1"
}
targets {
ids: "1_1"
ids: "1_2"
}
targets {
ids: "1_2"
ids: "1_3"
}
targets {
ids: "1_3"
ids: "1_4"
}
targets {
ids: "1_4"
ids: "1_5"
}
targets {
ids: "1_5"
ids: "1_6"
}
targets {
ids: "1_6"
ids: "1_7"
}
targets {
ids: "1_7"
ids: "1_8"
}
targets {
ids: "1_8"
ids: "1_9"
}
targets {
ids: "1_9"
ids: "1_10"
}
}
"""
)


def test_create_device_proto_for_irregular_grid():
qubits = cirq.GridQubit.rect(2, 2)
pairs = [
Expand Down
Loading

0 comments on commit 68fcde7

Please sign in to comment.