Skip to content

Move Coupler to cirq_gooogle.ops #6697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cirq-google/cirq_google/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from cirq_google._version import __version__

from cirq_google.devices import (
Coupler,
GoogleNoiseProperties,
GridDevice,
NoiseModelFromGoogleNoiseProperties,
Expand Down Expand Up @@ -56,6 +55,7 @@

from cirq_google.ops import (
CalibrationTag,
Coupler,
FSimGateFamily,
FSimViaModelTag,
InternalGate,
Expand Down
10 changes: 1 addition & 9 deletions cirq-google/cirq_google/api/v2/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import re
from typing import TYPE_CHECKING

import cirq

if TYPE_CHECKING:
import cirq
from cirq_google.ops.coupler import Coupler

GRID_QUBIT_ID_PATTERN = r'^q?(-?\d+)_(-?\d+)$'

Expand All @@ -35,9 +33,6 @@ def qubit_to_proto_id(q: cirq.Qid) -> str:
For `cirq_google.Coupler`s, this id is `c_{qubit0}_{qubit1}` where
qubit0 and qubit1 are the ids for the two Qid in the Coupler.
"""
# Avoid circular import
from cirq_google.devices.coupler import Coupler

if isinstance(q, cirq.GridQubit):
return f'{q.row}_{q.col}'
elif isinstance(q, cirq.NamedQubit):
Expand Down Expand Up @@ -76,9 +71,6 @@ def qubit_from_proto_id(proto_id: str) -> cirq.Qid:
Returns:
A `cirq.Qid` corresponding to the proto id.
"""
# Avoid circular import
from cirq_google.devices.coupler import Coupler

qubit_field = proto_id.split('_')
num_coords = len(qubit_field)
if proto_id[:2] == 'c_':
Expand Down
2 changes: 0 additions & 2 deletions cirq-google/cirq_google/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,4 @@

from cirq_google.devices.known_devices import Sycamore, Sycamore23

from cirq_google.devices.coupler import Coupler

from cirq_google.devices.grid_device import GridDevice
3 changes: 1 addition & 2 deletions cirq-google/cirq_google/devices/grid_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from cirq_google import transformers
from cirq_google.api import v2
from cirq_google.devices import known_devices
from cirq_google.devices.coupler import Coupler
from cirq_google.experimental import ops as experimental_ops


Expand Down Expand Up @@ -623,7 +622,7 @@ def validate_operation(self, operation: cirq.Operation) -> None:
raise ValueError(f'Operation {operation} contains a gate which is not supported.')

for q in operation.qubits:
if isinstance(q, Coupler):
if isinstance(q, ops.Coupler):
if any(qc not in self._metadata.qubit_set for qc in q.qubits):
raise ValueError(f'Qubits on coupler not on device: {q.qubits}.')
if frozenset(q.qubits) not in self._metadata.qubit_pairs:
Expand Down
3 changes: 2 additions & 1 deletion cirq-google/cirq_google/devices/grid_device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import cirq
import cirq_google
from cirq_google.api import v2
from cirq_google.devices import Coupler, grid_device
from cirq_google.devices import grid_device
from cirq_google.ops import Coupler


GRID_HEIGHT = 5
Expand Down
2 changes: 2 additions & 0 deletions cirq-google/cirq_google/ops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

from cirq_google.ops.calibration_tag import CalibrationTag

from cirq_google.ops.coupler import Coupler

from cirq_google.ops.fsim_gate_family import FSimGateFamily

from cirq_google.ops.fsim_via_model_tag import FSimViaModelTag
Expand Down