From c9a7330db2143be822142446908ec979b372b732 Mon Sep 17 00:00:00 2001 From: Michael Broughton Date: Tue, 14 Dec 2021 16:30:54 -0800 Subject: [PATCH 1/5] working device removal without contrib. --- cirq-aqt/cirq_aqt/aqt_sampler.py | 3 +- cirq-aqt/cirq_aqt/aqt_sampler_test.py | 36 +- cirq-aqt/cirq_aqt/aqt_simulator_test.py | 8 +- cirq-core/cirq/circuits/circuit.py | 125 +- cirq-core/cirq/circuits/circuit_dag.py | 40 +- cirq-core/cirq/circuits/circuit_dag_test.py | 36 +- cirq-core/cirq/circuits/circuit_test.py | 109 +- cirq-core/cirq/circuits/frozen_circuit.py | 39 +- .../cirq/circuits/frozen_circuit_test.py | 27 + .../cirq/contrib/acquaintance/devices_test.py | 2 +- .../protocols/json_test_data/Circuit.json | 15 +- .../json_test_data/Circuit.json_inward | 205 ++ .../json_test_data/Circuit.repr_inward | 23 + .../json_test_data/CircuitOperation.json | 15 +- .../json_test_data/FrozenCircuit.json | 15 +- .../json_test_data/FrozenCircuit.json_inward | 231 ++ .../json_test_data/FrozenCircuit.repr_inward | 23 + cirq-core/cirq/testing/devices_test.py | 6 +- cirq-core/cirq/testing/sample_circuits.py | 13 +- .../cirq/testing/sample_circuits_test.py | 9 + cirq-google/cirq_google/api/v1/programs.py | 20 +- .../cirq_google/api/v1/programs_test.py | 21 +- cirq-google/cirq_google/engine/engine.py | 1 - cirq-google/cirq_google/engine/engine_test.py | 15 +- .../json_test_data/CalibrationLayer.json | 5 +- .../cirq.google.QuantumExecutable.json | 5 +- .../cirq.google.QuantumExecutable.json_inward | 873 ++++++ .../cirq.google.QuantumExecutable.repr_inward | 72 + .../cirq.google.QuantumExecutableGroup.json | 15 +- ....google.QuantumExecutableGroup.json_inward | 2654 +++++++++++++++++ ....google.QuantumExecutableGroup.repr_inward | 221 ++ .../optimizers/optimize_for_sycamore.py | 12 +- .../optimizers/optimize_for_sycamore_test.py | 11 + .../optimizers/optimize_for_xmon.py | 20 +- .../optimizers/optimize_for_xmon_test.py | 30 +- .../serialization/gate_sets_test.py | 37 +- .../serialization/serializable_gate_set.py | 20 +- .../serializable_gate_set_test.py | 32 - cirq-pasqal/cirq_pasqal/pasqal_device_test.py | 21 +- .../cirq_pasqal/pasqal_noise_model_test.py | 4 +- cirq-pasqal/cirq_pasqal/pasqal_sampler.py | 13 +- .../cirq_pasqal/pasqal_sampler_test.py | 20 +- 42 files changed, 4828 insertions(+), 274 deletions(-) create mode 100644 cirq-core/cirq/protocols/json_test_data/Circuit.json_inward create mode 100644 cirq-core/cirq/protocols/json_test_data/Circuit.repr_inward create mode 100644 cirq-core/cirq/protocols/json_test_data/FrozenCircuit.json_inward create mode 100644 cirq-core/cirq/protocols/json_test_data/FrozenCircuit.repr_inward create mode 100644 cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.json_inward create mode 100644 cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.repr_inward create mode 100644 cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.json_inward create mode 100644 cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.repr_inward diff --git a/cirq-aqt/cirq_aqt/aqt_sampler.py b/cirq-aqt/cirq_aqt/aqt_sampler.py index c05ccb7fad8..c557ba3707f 100644 --- a/cirq-aqt/cirq_aqt/aqt_sampler.py +++ b/cirq-aqt/cirq_aqt/aqt_sampler.py @@ -198,11 +198,10 @@ def run_sweep( # TODO: Use measurement name from circuit. # Github issue: https://github.com/quantumlib/Cirq/issues/2199 meas_name = 'm' - assert isinstance(program.device, cirq.IonDevice) trial_results = [] # type: List[cirq.Result] for param_resolver in cirq.to_resolvers(params): id_str = uuid.uuid1() - num_qubits = len(program.device.qubits) + num_qubits = len(program.all_qubits()) json_str = self._generate_json(circuit=program, param_resolver=param_resolver) results = self._send_json( json_str=json_str, id_str=id_str, repetitions=repetitions, num_qubits=num_qubits diff --git a/cirq-aqt/cirq_aqt/aqt_sampler_test.py b/cirq-aqt/cirq_aqt/aqt_sampler_test.py index b5a9fd48d2d..416f15effdb 100644 --- a/cirq-aqt/cirq_aqt/aqt_sampler_test.py +++ b/cirq-aqt/cirq_aqt/aqt_sampler_test.py @@ -105,8 +105,8 @@ def test_aqt_sampler_error_handling(): max_angle = np.pi repetitions = 10 sampler = AQTSampler(remote_host="http://localhost:5000", access_token='testkey') - device, qubits = get_aqt_device(1) - circuit = cirq.Circuit(cirq.X(qubits[0]) ** theta, device=device) + _, qubits = get_aqt_device(1) + circuit = cirq.Circuit(cirq.X(qubits[0]) ** theta) sweep = cirq.Linspace(key='theta', start=0.1, stop=max_angle / np.pi, length=num_points) with pytest.raises(RuntimeError): _results = sampler.run_sweep(circuit, params=sweep, repetitions=repetitions) @@ -117,10 +117,10 @@ def test_aqt_sampler_empty_circuit(): max_angle = np.pi repetitions = 1000 num_qubits = 4 - device, _qubits = get_aqt_device(num_qubits) + _, _qubits = get_aqt_device(num_qubits) sampler = AQTSamplerLocalSimulator() sampler.simulate_ideal = True - circuit = cirq.Circuit(device=device) + circuit = cirq.Circuit() sweep = cirq.Linspace(key='theta', start=0.1, stop=max_angle / np.pi, length=num_points) with pytest.raises(RuntimeError): _results = sampler.run_sweep(circuit, params=sweep, repetitions=repetitions) @@ -141,8 +141,8 @@ def test_aqt_sampler(): max_angle = np.pi repetitions = 10 sampler = AQTSampler(remote_host="http://localhost:5000", access_token='testkey') - device, qubits = get_aqt_device(1) - circuit = cirq.Circuit(cirq.X(qubits[0]) ** theta, device=device) + _, qubits = get_aqt_device(1) + circuit = cirq.Circuit(cirq.X(qubits[0]) ** theta) sweep = cirq.Linspace(key='theta', start=0.1, stop=max_angle / np.pi, length=num_points) results = sampler.run_sweep(circuit, params=sweep, repetitions=repetitions) excited_state_probs = np.zeros(num_points) @@ -160,10 +160,15 @@ def test_aqt_sampler_sim(): max_angle = np.pi repetitions = 1000 num_qubits = 4 - device, qubits = get_aqt_device(num_qubits) + _, qubits = get_aqt_device(num_qubits) sampler = AQTSamplerLocalSimulator() sampler.simulate_ideal = True - circuit = cirq.Circuit(cirq.X(qubits[3]) ** theta, device=device) + circuit = cirq.Circuit( + cirq.X(qubits[3]) ** theta, + cirq.X(qubits[0]),cirq.X(qubits[0]), + cirq.X(qubits[1]),cirq.X(qubits[1]), + cirq.X(qubits[2]),cirq.X(qubits[2]), + ) circuit.append(cirq.PhasedXPowGate(phase_exponent=0.5, exponent=-0.5).on(qubits[0])) circuit.append(cirq.PhasedXPowGate(phase_exponent=0.5, exponent=0.5).on(qubits[0])) sweep = cirq.Linspace(key='theta', start=0.1, stop=max_angle / np.pi, length=num_points) @@ -179,10 +184,14 @@ def test_aqt_sampler_sim_xtalk(): max_angle = np.pi repetitions = 100 num_qubits = 4 - device, qubits = get_aqt_device(num_qubits) + _, qubits = get_aqt_device(num_qubits) sampler = AQTSamplerLocalSimulator() sampler.simulate_ideal = False - circuit = cirq.Circuit(cirq.X(qubits[0]), cirq.X(qubits[3]), cirq.X(qubits[2]), device=device) + circuit = cirq.Circuit( + cirq.X(qubits[0]), + cirq.X(qubits[1]), cirq.X(qubits[1]), + cirq.X(qubits[3]), + cirq.X(qubits[2])) sweep = cirq.Linspace(key='theta', start=0.1, stop=max_angle / np.pi, length=num_points) _results = sampler.run_sweep(circuit, params=sweep, repetitions=repetitions) @@ -190,9 +199,12 @@ def test_aqt_sampler_sim_xtalk(): def test_aqt_sampler_ms(): repetitions = 1000 num_qubits = 4 - device, qubits = get_aqt_device(num_qubits) + _, qubits = get_aqt_device(num_qubits) sampler = AQTSamplerLocalSimulator() - circuit = cirq.Circuit(device=device) + circuit = cirq.Circuit( + cirq.Z.on_each(*qubits), + cirq.Z.on_each(*qubits) + ) for _dummy in range(9): circuit.append(cirq.XX(qubits[0], qubits[1]) ** 0.5) circuit.append(cirq.Z(qubits[0]) ** 0.5) diff --git a/cirq-aqt/cirq_aqt/aqt_simulator_test.py b/cirq-aqt/cirq_aqt/aqt_simulator_test.py index 04418a0afd1..dfb68857e4f 100644 --- a/cirq-aqt/cirq_aqt/aqt_simulator_test.py +++ b/cirq-aqt/cirq_aqt/aqt_simulator_test.py @@ -30,8 +30,8 @@ def test_simulator_no_circ(): def test_ms_crosstalk_n_noise(): num_qubits = 4 noise_mod = AQTNoiseModel() - device, qubits = get_aqt_device(num_qubits) - circuit = cirq.Circuit(device=device) + _, qubits = get_aqt_device(num_qubits) + circuit = cirq.Circuit() circuit.append(cirq.XX(qubits[1], qubits[2]) ** 0.5) for moment in circuit.moments: noisy_moment = noise_mod.noisy_moment(moment, qubits) @@ -49,8 +49,8 @@ def test_ms_crosstalk_n_noise(): def test_x_crosstalk_n_noise(): num_qubits = 4 noise_mod = AQTNoiseModel() - device, qubits = get_aqt_device(num_qubits) - circuit = cirq.Circuit(device=device) + _, qubits = get_aqt_device(num_qubits) + circuit = cirq.Circuit() circuit.append(cirq.Y(qubits[1]) ** 0.5) circuit.append(cirq.Z(qubits[1]) ** 0.5) circuit.append(cirq.X(qubits[1]) ** 0.5) diff --git a/cirq-core/cirq/circuits/circuit.py b/cirq-core/cirq/circuits/circuit.py index baa558dc175..4b05bc6634e 100644 --- a/cirq-core/cirq/circuits/circuit.py +++ b/cirq-core/cirq/circuits/circuit.py @@ -20,10 +20,13 @@ """ import abc +import contextlib import enum import html import itertools import math +import re +import warnings from collections import defaultdict from typing import ( AbstractSet, @@ -50,7 +53,7 @@ import numpy as np import cirq._version -from cirq import devices, ops, protocols, value, qis +from cirq import _compat, devices, ops, protocols, value, qis from cirq.circuits._bucket_priority_queue import BucketPriorityQueue from cirq.circuits.circuit_operation import CircuitOperation from cirq.circuits.insert_strategy import InsertStrategy @@ -67,6 +70,19 @@ CIRCUIT_TYPE = TypeVar('CIRCUIT_TYPE', bound='AbstractCircuit') INT_TYPE = Union[int, np.integer] +_DEVICE_DEP_MESSAGE = 'Attaching devices to circuits will no longer be supported.' + + +@contextlib.contextmanager +def _block_overlapping_dep(): + with warnings.catch_warnings(): + warnings.filterwarnings( + action='ignore', + category=DeprecationWarning, + message=f'(.|\n)*{re.escape(_DEVICE_DEP_MESSAGE)}(.|\n)*', + ) + yield + class Alignment(enum.Enum): # Stop when left ends are lined up. @@ -134,7 +150,10 @@ def freeze(self) -> 'cirq.FrozenCircuit': if isinstance(self, FrozenCircuit): return self - return FrozenCircuit(self, strategy=InsertStrategy.EARLIEST, device=self.device) + + if self._device == cirq.UNCONSTRAINED_DEVICE: + return FrozenCircuit(self, strategy=InsertStrategy.EARLIEST) + return FrozenCircuit(self, strategy=InsertStrategy.EARLIEST, device=self._device) def unfreeze(self, copy: bool = True) -> 'cirq.Circuit': """Creates a Circuit from this circuit. @@ -144,7 +163,10 @@ def unfreeze(self, copy: bool = True) -> 'cirq.Circuit': """ if isinstance(self, Circuit): return Circuit.copy(self) if copy else self - return Circuit(self, strategy=InsertStrategy.EARLIEST, device=self.device) + + if self._device == cirq.UNCONSTRAINED_DEVICE: + return Circuit(self, strategy=InsertStrategy.EARLIEST) + return Circuit(self, strategy=InsertStrategy.EARLIEST, device=self._device) def __bool__(self): return bool(self.moments) @@ -152,7 +174,7 @@ def __bool__(self): def __eq__(self, other): if not isinstance(other, AbstractCircuit): return NotImplemented - return tuple(self.moments) == tuple(other.moments) and self.device == other.device + return tuple(self.moments) == tuple(other.moments) and self._device == other._device def _approx_eq_(self, other: Any, atol: Union[int, float]) -> bool: """See `cirq.protocols.SupportsApproximateEquality`.""" @@ -160,7 +182,7 @@ def _approx_eq_(self, other: Any, atol: Union[int, float]) -> bool: return NotImplemented return ( cirq.protocols.approx_eq(tuple(self.moments), tuple(other.moments), atol=atol) - and self.device == other.device + and self._device == other._device ) def __ne__(self, other) -> bool: @@ -236,7 +258,7 @@ def __repr__(self) -> str: args = [] if self.moments: args.append(_list_repr_with_indented_item_lines(self.moments)) - if self.device != devices.UNCONSTRAINED_DEVICE: + if self._device != devices.UNCONSTRAINED_DEVICE: args.append(f'device={self.device!r}') return f'cirq.{cls_name}({", ".join(args)})' @@ -1305,11 +1327,11 @@ def save_qasm( self._to_qasm_output(header, precision, qubit_order).save(file_path) def _json_dict_(self): - return protocols.obj_to_dict_helper(self, ['moments', 'device']) + return protocols.obj_to_dict_helper(self, ['moments']) @classmethod - def _from_json_dict_(cls, moments, device, **kwargs): - return cls(moments, strategy=InsertStrategy.EARLIEST, device=device) + def _from_json_dict_(cls, moments, **kwargs): + return cls(moments, strategy=InsertStrategy.EARLIEST) def zip( *circuits: 'cirq.AbstractCircuit', align: Union['cirq.Alignment', str] = Alignment.LEFT @@ -1655,6 +1677,12 @@ class Circuit(AbstractCircuit): independent 'factors' of the original Circuit. """ + @_compat.deprecated_parameter( + deadline='v0.15', + fix=_DEVICE_DEP_MESSAGE, + parameter_desc='device', + match=lambda args, kwargs: 'device' in kwargs, + ) def __init__( self, *contents: 'cirq.OP_TREE', @@ -1680,10 +1708,18 @@ def __init__( self.append(contents, strategy=strategy) @property + @_compat.deprecated( + deadline='v0.15', + fix=_DEVICE_DEP_MESSAGE, + ) def device(self) -> devices.Device: return self._device @device.setter + @_compat.deprecated( + deadline='v0.15', + fix=_DEVICE_DEP_MESSAGE, + ) def device(self, new_device: 'cirq.Device') -> None: new_device.validate_circuit(self) self._device = new_device @@ -1692,12 +1728,18 @@ def __copy__(self) -> 'Circuit': return self.copy() def copy(self) -> 'Circuit': - copied_circuit = Circuit(device=self._device) + if self._device == cirq.UNCONSTRAINED_DEVICE: + copied_circuit = Circuit() + else: + copied_circuit = Circuit(device=self._device) copied_circuit._moments = self._moments[:] return copied_circuit def _with_sliced_moments(self, moments: Iterable['cirq.Moment']) -> 'Circuit': - new_circuit = Circuit(device=self.device) + if self._device == cirq.UNCONSTRAINED_DEVICE: + new_circuit = Circuit() + else: + new_circuit = Circuit(device=self._device) new_circuit._moments = list(moments) return new_circuit @@ -1737,8 +1779,8 @@ def __iadd__(self, other): def __add__(self, other): if isinstance(other, type(self)): if ( - devices.UNCONSTRAINED_DEVICE not in [self._device, other.device] - and self._device != other.device + devices.UNCONSTRAINED_DEVICE not in [self._device, other._device] + and self._device != other._device ): raise ValueError("Can't add circuits with incompatible devices.") elif not isinstance(other, (ops.Operation, Iterable)): @@ -1769,6 +1811,8 @@ def __imul__(self, repetitions: INT_TYPE): def __mul__(self, repetitions: INT_TYPE): if not isinstance(repetitions, (int, np.integer)): return NotImplemented + if self._device == cirq.UNCONSTRAINED_DEVICE: + return Circuit(self._moments * int(repetitions)) return Circuit(self._moments * int(repetitions), device=self._device) def __rmul__(self, repetitions: INT_TYPE): @@ -1794,10 +1838,17 @@ def __pow__(self, exponent: int) -> 'Circuit': if inv_moment is NotImplemented: return NotImplemented inv_moments.append(inv_moment) + + if self._device == cirq.UNCONSTRAINED_DEVICE: + return cirq.Circuit(inv_moments) return cirq.Circuit(inv_moments, device=self._device) __hash__ = None # type: ignore + @_compat.deprecated( + deadline='v0.15', + fix=_DEVICE_DEP_MESSAGE, + ) def with_device( self, new_device: 'cirq.Device', @@ -1813,15 +1864,16 @@ def with_device( Returns: The translated circuit. """ - return Circuit( - [ - ops.Moment( - operation.transform_qubits(qubit_mapping) for operation in moment.operations - ) - for moment in self._moments - ], - device=new_device, - ) + with _block_overlapping_dep(): + return Circuit( + [ + ops.Moment( + operation.transform_qubits(qubit_mapping) for operation in moment.operations + ) + for moment in self._moments + ], + device=new_device, + ) def tetris_concat( *circuits: 'cirq.AbstractCircuit', align: Union['cirq.Alignment', str] = Alignment.LEFT @@ -1837,6 +1889,12 @@ def zip( zip.__doc__ = AbstractCircuit.zip.__doc__ + @_compat.deprecated_parameter( + deadline='v0.15', + fix=_DEVICE_DEP_MESSAGE, + parameter_desc='new_device', + match=lambda args, kwargs: 'new_device' in kwargs, + ) def transform_qubits( self, qubit_map: Union[Dict['cirq.Qid', 'cirq.Qid'], Callable[['cirq.Qid'], 'cirq.Qid']], @@ -1845,10 +1903,6 @@ def transform_qubits( ) -> 'cirq.Circuit': """Returns the same circuit, but with different qubits. - Note that this method does essentially the same thing as - `cirq.Circuit.with_device`. It is included regardless because there are - also `transform_qubits` methods on `cirq.Operation` and `cirq.Moment`. - Args: qubit_map: A function or a dict mapping each current qubit into a desired new qubit. @@ -1869,9 +1923,17 @@ def transform_qubits( transform = lambda q: qubit_map.get(q, q) # type: ignore else: raise TypeError('qubit_map must be a function or dict mapping qubits to qubits.') - return self.with_device( - new_device=self.device if new_device is None else new_device, qubit_mapping=transform - ) + + op_list = [ + ops.Moment(operation.transform_qubits(transform) for operation in moment.operations) + for moment in self._moments + ] + + if new_device is None and self._device == devices.UNCONSTRAINED_DEVICE: + return Circuit(op_list) + + with _block_overlapping_dep(): + return Circuit(op_list, device=self._device if new_device is None else new_device) def _prev_moment_available(self, op: 'cirq.Operation', end_moment_index: int) -> Optional[int]: last_available = end_moment_index @@ -2285,8 +2347,9 @@ def _resolve_parameters_(self, resolver: 'cirq.ParamResolver', recursive: bool) resolved_operations = _resolve_operations(moment.operations, resolver, recursive) new_moment = ops.Moment(resolved_operations) resolved_moments.append(new_moment) - resolved_circuit = Circuit(resolved_moments, device=self.device) - return resolved_circuit + if self._device == devices.UNCONSTRAINED_DEVICE: + return Circuit(resolved_moments) + return Circuit(resolved_moments, device=self._device) @property def moments(self): diff --git a/cirq-core/cirq/circuits/circuit_dag.py b/cirq-core/cirq/circuits/circuit_dag.py index 33250aaeec6..0700162c0cd 100644 --- a/cirq-core/cirq/circuits/circuit_dag.py +++ b/cirq-core/cirq/circuits/circuit_dag.py @@ -17,7 +17,7 @@ import functools import networkx -from cirq import ops, devices +from cirq import _compat, ops, devices from cirq.circuits import circuit if TYPE_CHECKING: @@ -70,6 +70,12 @@ class CircuitDag(networkx.DiGraph): disjoint_qubits = staticmethod(_disjoint_qubits) + @_compat.deprecated_parameter( + deadline='v0.15', + fix=circuit._DEVICE_DEP_MESSAGE, + parameter_desc='device', + match=lambda args, kwargs: 'device' in kwargs or len(args) == 4, + ) def __init__( self, can_reorder: Callable[['cirq.Operation', 'cirq.Operation'], bool] = _disjoint_qubits, @@ -92,7 +98,15 @@ def __init__( """ super().__init__(incoming_graph_data) self.can_reorder = can_reorder - self.device = device + self._device = device + + @property + @_compat.deprecated( + deadline='v0.15', + fix=circuit._DEVICE_DEP_MESSAGE, + ) + def device(self) -> devices.Device: + return self._device @staticmethod def make_node(op: 'cirq.Operation') -> Unique: @@ -100,20 +114,32 @@ def make_node(op: 'cirq.Operation') -> Unique: @staticmethod def from_circuit( - circuit: circuit.Circuit, + qcircuit: circuit.Circuit, can_reorder: Callable[['cirq.Operation', 'cirq.Operation'], bool] = _disjoint_qubits, ) -> 'CircuitDag': + if qcircuit._device == devices.UNCONSTRAINED_DEVICE: + return CircuitDag.from_ops(qcircuit.all_operations(), can_reorder=can_reorder) return CircuitDag.from_ops( - circuit.all_operations(), can_reorder=can_reorder, device=circuit.device + qcircuit.all_operations(), can_reorder=can_reorder, device=qcircuit._device ) @staticmethod + @_compat.deprecated_parameter( + deadline='v0.15', + fix=circuit._DEVICE_DEP_MESSAGE, + parameter_desc='device', + match=lambda args, kwargs: 'device' in kwargs, + ) def from_ops( *operations: 'cirq.OP_TREE', can_reorder: Callable[['cirq.Operation', 'cirq.Operation'], bool] = _disjoint_qubits, device: devices.Device = devices.UNCONSTRAINED_DEVICE, ) -> 'CircuitDag': - dag = CircuitDag(can_reorder=can_reorder, device=device) + if device == devices.UNCONSTRAINED_DEVICE: + dag = CircuitDag(can_reorder=can_reorder) + else: + dag = CircuitDag(can_reorder=can_reorder, device=device) + for op in ops.flatten_op_tree(operations): dag.append(cast(ops.Operation, op)) return dag @@ -185,8 +211,10 @@ def all_qubits(self): return frozenset(q for node in self.nodes for q in node.val.qubits) def to_circuit(self) -> circuit.Circuit: + if self._device == devices.UNCONSTRAINED_DEVICE: + return circuit.Circuit(self.all_operations(), strategy=circuit.InsertStrategy.EARLIEST) return circuit.Circuit( - self.all_operations(), strategy=circuit.InsertStrategy.EARLIEST, device=self.device + self.all_operations(), strategy=circuit.InsertStrategy.EARLIEST, device=self._device ) def findall_nodes_until_blocked( diff --git a/cirq-core/cirq/circuits/circuit_dag_test.py b/cirq-core/cirq/circuits/circuit_dag_test.py index 5422cc2adfc..99d34f5dc39 100644 --- a/cirq-core/cirq/circuits/circuit_dag_test.py +++ b/cirq-core/cirq/circuits/circuit_dag_test.py @@ -66,6 +66,21 @@ def test_init(): assert list(dag.edges()) == [] +def test_init_device_deprecated(): + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + dag = cirq.CircuitDag(device=cirq.UNCONSTRAINED_DEVICE) + + +def test_device_deprecated(): + dag = cirq.CircuitDag() + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + dev = dag.device + + def test_append(): q0 = cirq.LineQubit(0) dag = cirq.CircuitDag() @@ -99,6 +114,14 @@ def test_from_ops(): assert [(n1.val, n2.val) for n1, n2 in dag.edges()] == [(cirq.X(q0), cirq.Y(q0))] +def test_from_ops_device_deprecated(): + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + q0 = cirq.LineQubit(0) + dag = cirq.CircuitDag.from_ops(cirq.X(q0), cirq.Y(q0), device=cirq.UNCONSTRAINED_DEVICE) + + def test_from_circuit(): q0 = cirq.LineQubit(0) circuit = cirq.Circuit(cirq.X(q0), cirq.Y(q0)) @@ -109,17 +132,6 @@ def test_from_circuit(): assert sorted(circuit.all_qubits()) == sorted(dag.all_qubits()) -def test_from_circuit_with_device(): - q0 = cirq.GridQubit(5, 5) - circuit = cirq.Circuit(cirq.X(q0), cirq.Y(q0), device=cirq.UNCONSTRAINED_DEVICE) - dag = cirq.CircuitDag.from_circuit(circuit) - assert networkx.dag.is_directed_acyclic_graph(dag) - assert dag.device == circuit.device - assert len(dag.nodes()) == 2 - assert [(n1.val, n2.val) for n1, n2 in dag.edges()] == [(cirq.X(q0), cirq.Y(q0))] - assert sorted(circuit.all_qubits()) == sorted(dag.all_qubits()) - - def test_to_empty_circuit(): circuit = cirq.Circuit() dag = cirq.CircuitDag.from_circuit(circuit) @@ -213,13 +225,11 @@ def test_larger_circuit(): cirq.CZ(q0, q1), cirq.T(q3), strategy=cirq.InsertStrategy.EARLIEST, - device=cirq.UNCONSTRAINED_DEVICE, ) dag = cirq.CircuitDag.from_circuit(circuit) assert networkx.dag.is_directed_acyclic_graph(dag) - assert circuit.device == dag.to_circuit().device # Operation order within a moment is non-deterministic # but text diagrams still look the same. desired = """ diff --git a/cirq-core/cirq/circuits/circuit_test.py b/cirq-core/cirq/circuits/circuit_test.py index 58018f0d955..3052c79cae6 100644 --- a/cirq-core/cirq/circuits/circuit_test.py +++ b/cirq-core/cirq/circuits/circuit_test.py @@ -23,6 +23,7 @@ import cirq import cirq.testing +from unittest import mock from cirq import circuits from cirq import ops from cirq.testing.devices import ValidatingTestDevice @@ -91,6 +92,7 @@ def test_alignment(): assert repr(cirq.Alignment.RIGHT) == 'cirq.Alignment.RIGHT' +@mock.patch.dict(os.environ, clear='CIRQ_TESTING') def test_insert_moment_types(): x = cirq.NamedQubit('x') @@ -139,12 +141,10 @@ def test_equality(circuit_cls): # Default is empty. Iterables get listed. eq.add_equality_group( circuit_cls(), - circuit_cls(device=cirq.UNCONSTRAINED_DEVICE), circuit_cls([]), circuit_cls(()), ) eq.add_equality_group(circuit_cls([cirq.Moment()]), circuit_cls((cirq.Moment(),))) - eq.add_equality_group(circuit_cls(device=FOXY)) # Equality depends on structure and contents. eq.add_equality_group(circuit_cls([cirq.Moment([cirq.X(a)])])) @@ -174,10 +174,6 @@ def test_equality(circuit_cls): @pytest.mark.parametrize('circuit_cls', [cirq.Circuit, cirq.FrozenCircuit]) def test_approx_eq(circuit_cls): - class TestDevice(cirq.Device): - def validate_operation(self, operation: cirq.Operation) -> None: - pass - a = cirq.NamedQubit('a') b = cirq.NamedQubit('b') @@ -205,6 +201,15 @@ def validate_operation(self, operation: cirq.Operation) -> None: atol=1e-6, ) + +@mock.patch.dict(os.environ, clear='CIRQ_TESTING') +@pytest.mark.parametrize('circuit_cls', [cirq.Circuit, cirq.FrozenCircuit]) +def test_approx_eq_device_deprecated(circuit_cls): + class TestDevice(cirq.Device): + def validate_operation(self, operation: cirq.Operation) -> None: + pass + + a = cirq.NamedQubit('a') assert not cirq.approx_eq( circuit_cls([cirq.Moment([cirq.X(a)])]), circuit_cls([cirq.Moment([cirq.X(a)])], device=TestDevice()), @@ -346,6 +351,10 @@ def test_radd_op_tree(circuit_cls): [cirq.Moment([cirq.X(a)]), cirq.Moment([cirq.Y(b)])] ) + +@mock.patch.dict(os.environ, clear='CIRQ_TESTING') +@pytest.mark.parametrize('circuit_cls', [cirq.Circuit, cirq.FrozenCircuit]) +def test_radd_op_tree_device_deprecated(circuit_cls): # Preserves device. c = circuit_cls(device=FOXY) c2 = [] + c @@ -401,6 +410,10 @@ def test_repr(circuit_cls): ])""" ) + +@mock.patch.dict(os.environ, clear='CIRQ_TESTING') +@pytest.mark.parametrize('circuit_cls', [cirq.Circuit, cirq.FrozenCircuit]) +def test_repr_device_deprecated(circuit_cls): c = circuit_cls(device=FOXY) cirq.testing.assert_equivalent_repr(c) assert repr(c) == f'cirq.{circuit_cls.__name__}(device={repr(FOXY)})' @@ -626,7 +639,8 @@ def test_concatenate(): _ = c + 'a' -def test_concatenate_with_device(): +@mock.patch.dict(os.environ, clear='CIRQ_TESTING') +def test_concatenate_with_device_deprecated(): fox = cirq.Circuit(device=FOXY) cone = cirq.Circuit(device=BCONE) unr = cirq.Circuit() @@ -646,8 +660,9 @@ def test_concatenate_with_device(): assert len(cone) == 0 +@mock.patch.dict(os.environ, clear='CIRQ_TESTING') @pytest.mark.parametrize('circuit_cls', [cirq.Circuit, cirq.FrozenCircuit]) -def test_with_device(circuit_cls): +def test_with_device_logic_deprecated(circuit_cls): c = circuit_cls(cirq.X(cirq.LineQubit(0))) c2 = c.with_device(FOXY, lambda e: cirq.GridQubit(e.x, 0)) @@ -673,7 +688,17 @@ def test_with_device(circuit_cls): _ = c.with_device(BCONE) -def test_set_device(): +@pytest.mark.parametrize('circuit_cls', [cirq.Circuit, cirq.FrozenCircuit]) +def test_with_device_deprecated(circuit_cls): + c = circuit_cls() + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + _ = c.with_device(FOXY) + + +@mock.patch.dict(os.environ, clear='CIRQ_TESTING') +def test_set_device_deprecated(): c = cirq.Circuit(cirq.X(cirq.LineQubit(0))) assert c.device is cirq.UNCONSTRAINED_DEVICE @@ -905,7 +930,8 @@ def test_insert_moment(): assert c.operation_at(qubit, actual_index) == operation[0] -def test_insert_validates_all_operations_before_inserting(): +@mock.patch.dict(os.environ, clear='CIRQ_TESTING') +def test_insert_validates_all_operations_before_inserting_deprecated(): a, b = cirq.GridQubit(0, 0), cirq.GridQubit(1, 1) c = cirq.Circuit(device=FOXY) operations = [cirq.Z(a), cirq.CZ(a, b)] @@ -3622,6 +3648,7 @@ def test_insert_operations_errors(): circuit._insert_operations(operations, insertion_indices) +@mock.patch.dict(os.environ, clear='CIRQ_TESTING') def test_validates_while_editing(): c = cirq.Circuit(device=FOXY) @@ -3640,7 +3667,8 @@ def test_validates_while_editing(): c.insert(0, cirq.CZ(cirq.GridQubit(0, 0), cirq.GridQubit(1, 0))) -def test_respects_additional_adjacency_constraints(): +@mock.patch.dict(os.environ, clear='CIRQ_TESTING') +def test_respects_additional_adjacency_constraints_deprecated(): c = cirq.Circuit(device=FOXY) c.append(cirq.CZ(cirq.GridQubit(0, 0), cirq.GridQubit(0, 1))) c.append( @@ -3658,7 +3686,8 @@ def test_respects_additional_adjacency_constraints(): ) -def test_commutes_past_adjacency_constraints(): +@mock.patch.dict(os.environ, clear='CIRQ_TESTING') +def test_commutes_past_adjacency_constraints_deprecated(): c = cirq.Circuit( [ cirq.Moment(), @@ -3683,7 +3712,8 @@ def test_commutes_past_adjacency_constraints(): ) -def test_decomposes_while_appending(): +@mock.patch.dict(os.environ, clear='CIRQ_TESTING') +def test_decomposes_while_appending_deprecated(): c = cirq.Circuit(device=FOXY) c.append(cirq.TOFFOLI(cirq.GridQubit(0, 0), cirq.GridQubit(0, 1), cirq.GridQubit(1, 0))) cirq.testing.assert_allclose_up_to_global_phase( @@ -4109,7 +4139,6 @@ def test_pow_valid_only_for_minus_1(circuit_cls): forward = circuit_cls((cirq.X ** 0.5)(a), (cirq.Y ** -0.2)(b), cirq.CZ(a, b)) backward = circuit_cls((cirq.CZ ** (-1.0))(a, b), (cirq.X ** (-0.5))(a), (cirq.Y ** (0.2))(b)) - cirq.testing.assert_same_circuits(cirq.pow(forward, -1), backward) with pytest.raises(TypeError, match='__pow__'): cirq.pow(forward, 1) @@ -4119,12 +4148,26 @@ def test_pow_valid_only_for_minus_1(circuit_cls): cirq.pow(forward, -2.5) +@mock.patch.dict(os.environ, clear='CIRQ_TESTING') @pytest.mark.parametrize('circuit_cls', [cirq.Circuit, cirq.FrozenCircuit]) -def test_device_propagates(circuit_cls): +def test_device_propagates_deprecated(circuit_cls): c = circuit_cls(device=moment_and_op_type_validating_device) assert c[:].device is moment_and_op_type_validating_device +def test_device_get_set_deprecated(): + c = cirq.Circuit() + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + c.device = FOXY + + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + assert c.device is FOXY + + @pytest.mark.parametrize('circuit_cls', [cirq.Circuit, cirq.FrozenCircuit]) def test_moment_groups(circuit_cls): qubits = [cirq.GridQubit(x, y) for x in range(8) for y in range(8)] @@ -4171,6 +4214,7 @@ def test_moments_property(circuit_cls): assert c.moments[1] == cirq.Moment([cirq.Y(q)]) +@mock.patch.dict(os.environ, clear='CIRQ_TESTING') @pytest.mark.parametrize('circuit_cls', [cirq.Circuit, cirq.FrozenCircuit]) def test_json_dict(circuit_cls): q0, q1 = cirq.LineQubit.range(2) @@ -4180,7 +4224,6 @@ def test_json_dict(circuit_cls): moments = tuple(moments) assert c._json_dict_() == { 'moments': moments, - 'device': cirq.UNCONSTRAINED_DEVICE, } @@ -4278,6 +4321,21 @@ def test_init_contents(circuit_cls): circuit_cls() +@pytest.mark.parametrize('circuit_cls', [cirq.Circuit, cirq.FrozenCircuit]) +def test_init_deprecated(circuit_cls): + a, b = cirq.GridQubit.rect(1, 2) + + # Moments are not subject to insertion rules. + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + c = circuit_cls( + cirq.Moment([cirq.X(a)]), + cirq.Moment([cirq.X(b)]), + device=FOXY, + ) + + def test_transform_qubits(): a, b, c = cirq.LineQubit.range(3) original = cirq.Circuit( @@ -4301,10 +4359,21 @@ def test_transform_qubits(): with pytest.raises(TypeError, match='must be a function or dict'): _ = original.transform_qubits('bad arg') - # Device - original = cirq.Circuit(device=FOXY) - assert original.transform_qubits(lambda q: q).device is FOXY - assert original.transform_qubits(lambda q: q, new_device=BCONE).device is BCONE + +def test_transform_qubits_deprecated_device(): + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + original = cirq.Circuit(device=FOXY) + + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + assert original.transform_qubits(lambda q: q).device is FOXY + + with cirq.testing.assert_deprecated('new_device', deadline='v0.15', count=2): + # count one for new_device and count one for accessing .device. + assert original.transform_qubits(lambda q: q, new_device=BCONE).device is BCONE @pytest.mark.parametrize('circuit_cls', [cirq.Circuit, cirq.FrozenCircuit]) diff --git a/cirq-core/cirq/circuits/frozen_circuit.py b/cirq-core/cirq/circuits/frozen_circuit.py index 7deefe2f7e7..90e6ab9c577 100644 --- a/cirq-core/cirq/circuits/frozen_circuit.py +++ b/cirq-core/cirq/circuits/frozen_circuit.py @@ -27,11 +27,15 @@ import numpy as np -from cirq import devices, ops, protocols, value +from cirq import _import, _compat, devices, ops, protocols, value + +circuit = _import.LazyLoader("circuit", globals(), "cirq.circuits.circuit") + from cirq.circuits import AbstractCircuit, Alignment, Circuit from cirq.circuits.insert_strategy import InsertStrategy from cirq.type_workarounds import NotImplementedType + if TYPE_CHECKING: import cirq @@ -44,6 +48,12 @@ class FrozenCircuit(AbstractCircuit, protocols.SerializableByKey): the `freeze` and `unfreeze` methods from AbstractCircuit. """ + @_compat.deprecated_parameter( + deadline='v0.15', + fix=circuit._DEVICE_DEP_MESSAGE, + parameter_desc='device', + match=lambda args, kwargs: 'device' in kwargs, + ) def __init__( self, *contents: 'cirq.OP_TREE', @@ -63,9 +73,14 @@ def __init__( together. device: Hardware that the circuit should be able to run on. """ - base = Circuit(contents, strategy=strategy, device=device) + if device == devices.UNCONSTRAINED_DEVICE: + base = Circuit(contents, strategy=strategy) + else: + with circuit._block_overlapping_dep(): + base = Circuit(contents, strategy=strategy, device=device) + self._moments = tuple(base.moments) - self._device = base.device + self._device = base._device # These variables are memoized when first requested. self._num_qubits: Optional[int] = None @@ -82,11 +97,15 @@ def moments(self) -> Sequence['cirq.Moment']: return self._moments @property + @_compat.deprecated( + deadline='v0.15', + fix=circuit._DEVICE_DEP_MESSAGE, + ) def device(self) -> devices.Device: return self._device def __hash__(self): - return hash((self.moments, self.device)) + return hash((self.moments, self._device)) # Memoized methods for commonly-retrieved properties. @@ -169,16 +188,24 @@ def __pow__(self, other) -> 'FrozenCircuit': return NotImplemented def _with_sliced_moments(self, moments: Iterable['cirq.Moment']) -> 'FrozenCircuit': - new_circuit = FrozenCircuit(device=self.device) + if self._device == devices.UNCONSTRAINED_DEVICE: + new_circuit = FrozenCircuit() + else: + new_circuit = FrozenCircuit(device=self._device) new_circuit._moments = tuple(moments) return new_circuit + @_compat.deprecated( + deadline='v0.15', + fix=circuit._DEVICE_DEP_MESSAGE, + ) def with_device( self, new_device: 'cirq.Device', qubit_mapping: Callable[['cirq.Qid'], 'cirq.Qid'] = lambda e: e, ) -> 'FrozenCircuit': - return self.unfreeze().with_device(new_device, qubit_mapping).freeze() + with circuit._block_overlapping_dep(): + return self.unfreeze().with_device(new_device, qubit_mapping).freeze() def _resolve_parameters_( self, resolver: 'cirq.ParamResolver', recursive: bool diff --git a/cirq-core/cirq/circuits/frozen_circuit_test.py b/cirq-core/cirq/circuits/frozen_circuit_test.py index 1fcd099ab71..1065a121cf6 100644 --- a/cirq-core/cirq/circuits/frozen_circuit_test.py +++ b/cirq-core/cirq/circuits/frozen_circuit_test.py @@ -47,6 +47,33 @@ def test_freeze_and_unfreeze(): assert fcc is not f +def test_init_device_deprecated(): + q = cirq.LineQubit(0) + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + a = cirq.FrozenCircuit(cirq.X(q), device=cirq.UNCONSTRAINED_DEVICE) + + +def test_device_deprecated(): + q = cirq.LineQubit(0) + a = cirq.FrozenCircuit(cirq.X(q)) + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + b = a.device + + +def test_with_device_deprecated(): + q = cirq.LineQubit(0) + a = cirq.FrozenCircuit(cirq.X(q)) + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + # one for frozencircuit.with_device and one for circuit.with_device. + b = a.with_device(cirq.UNCONSTRAINED_DEVICE) + + def test_immutable(): q = cirq.LineQubit(0) c = cirq.FrozenCircuit(cirq.X(q), cirq.H(q)) diff --git a/cirq-core/cirq/contrib/acquaintance/devices_test.py b/cirq-core/cirq/contrib/acquaintance/devices_test.py index 17842978e54..d53b1cc3e50 100644 --- a/cirq-core/cirq/contrib/acquaintance/devices_test.py +++ b/cirq-core/cirq/contrib/acquaintance/devices_test.py @@ -37,5 +37,5 @@ def test_get_acquaintance_size(): with pytest.raises(TypeError): cca.get_acquaintance_size(3) - circuit = cirq.Circuit(device=cca.UnconstrainedAcquaintanceDevice) + circuit = cirq.Circuit() cca.get_acquaintance_size(circuit) diff --git a/cirq-core/cirq/protocols/json_test_data/Circuit.json b/cirq-core/cirq/protocols/json_test_data/Circuit.json index ac467a20390..b6d3e24041a 100644 --- a/cirq-core/cirq/protocols/json_test_data/Circuit.json +++ b/cirq-core/cirq/protocols/json_test_data/Circuit.json @@ -113,10 +113,7 @@ } ] } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } + ] }, { "cirq_type": "Circuit", @@ -167,10 +164,7 @@ } ] } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } + ] }, { "cirq_type": "Circuit", @@ -197,9 +191,6 @@ } ] } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } + ] } ] \ No newline at end of file diff --git a/cirq-core/cirq/protocols/json_test_data/Circuit.json_inward b/cirq-core/cirq/protocols/json_test_data/Circuit.json_inward new file mode 100644 index 00000000000..ac467a20390 --- /dev/null +++ b/cirq-core/cirq/protocols/json_test_data/Circuit.json_inward @@ -0,0 +1,205 @@ +[ + { + "cirq_type": "Circuit", + "moments": [ + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "MeasurementGate", + "num_qubits": 5, + "key": "0,1,2,3,4", + "invert_mask": [] + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + }, + { + "cirq_type": "LineQubit", + "x": 1 + }, + { + "cirq_type": "LineQubit", + "x": 2 + }, + { + "cirq_type": "LineQubit", + "x": 3 + }, + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + } + ] + } + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } + }, + { + "cirq_type": "Circuit", + "moments": [ + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CCXPowGate", + "exponent": 1, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + }, + { + "cirq_type": "LineQubit", + "x": 1 + }, + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "XPowGate", + "exponent": 0.123, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + } + ] + } + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } + }, + { + "cirq_type": "Circuit", + "moments": [ + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "XPowGate", + "exponent": { + "cirq_type": "sympy.Symbol", + "name": "theta" + }, + "global_shift": 0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + } + ] + } + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } + } +] \ No newline at end of file diff --git a/cirq-core/cirq/protocols/json_test_data/Circuit.repr_inward b/cirq-core/cirq/protocols/json_test_data/Circuit.repr_inward new file mode 100644 index 00000000000..b4bad10bee8 --- /dev/null +++ b/cirq-core/cirq/protocols/json_test_data/Circuit.repr_inward @@ -0,0 +1,23 @@ +[cirq.Circuit([ + cirq.Moment( + cirq.H(cirq.LineQubit(0)), + cirq.H(cirq.LineQubit(1)), + cirq.H(cirq.LineQubit(2)), + cirq.H(cirq.LineQubit(3)), + cirq.H(cirq.LineQubit(4)), + ), + cirq.Moment( + cirq.MeasurementGate(5, '0,1,2,3,4', ()).on(cirq.LineQubit(0), cirq.LineQubit(1), cirq.LineQubit(2), cirq.LineQubit(3), cirq.LineQubit(4)), + ), +]), cirq.Circuit([ + cirq.Moment( + cirq.TOFFOLI(cirq.LineQubit(0), cirq.LineQubit(1), cirq.LineQubit(2)), + ), + cirq.Moment( + (cirq.X**0.123).on(cirq.LineQubit(0)), + ), +]), cirq.Circuit([ + cirq.Moment( + (cirq.X**sympy.Symbol('theta')).on(cirq.LineQubit(0)), + ), +])] \ No newline at end of file diff --git a/cirq-core/cirq/protocols/json_test_data/CircuitOperation.json b/cirq-core/cirq/protocols/json_test_data/CircuitOperation.json index 73b77c264db..e0632b172c8 100644 --- a/cirq-core/cirq/protocols/json_test_data/CircuitOperation.json +++ b/cirq-core/cirq/protocols/json_test_data/CircuitOperation.json @@ -118,10 +118,7 @@ } ] } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } + ] } }, { @@ -149,10 +146,7 @@ } ] } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } + ] } }, { @@ -183,10 +177,7 @@ } ] } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } + ] } }, [ diff --git a/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.json b/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.json index 02e4cf78a6b..9e2f6722311 100644 --- a/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.json +++ b/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.json @@ -115,10 +115,7 @@ } ] } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } + ] } }, { @@ -173,10 +170,7 @@ } ] } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } + ] } }, { @@ -207,10 +201,7 @@ } ] } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } + ] } }, [ diff --git a/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.json_inward b/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.json_inward new file mode 100644 index 00000000000..02e4cf78a6b --- /dev/null +++ b/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.json_inward @@ -0,0 +1,231 @@ +{ + "cirq_type": "_ContextualSerialization", + "object_dag": [ + { + "cirq_type": "_SerializedContext", + "key": 1, + "obj": { + "cirq_type": "FrozenCircuit", + "moments": [ { "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "MeasurementGate", + "num_qubits": 5, + "key": "0,1,2,3,4", + "invert_mask": [] + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + }, + { + "cirq_type": "LineQubit", + "x": 1 + }, + { + "cirq_type": "LineQubit", + "x": 2 + }, + { + "cirq_type": "LineQubit", + "x": 3 + }, + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + } + ] + } + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } + } + }, + { + "cirq_type": "_SerializedContext", + "key": 2, + "obj": { + "cirq_type": "FrozenCircuit", + "moments": [ + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CCXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + }, + { + "cirq_type": "LineQubit", + "x": 1 + }, + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "XPowGate", + "exponent": 0.123, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + } + ] + } + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } + } + }, + { + "cirq_type": "_SerializedContext", + "key": 3, + "obj": { + "cirq_type": "FrozenCircuit", + "moments": [ + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "XPowGate", + "exponent": { + "cirq_type": "sympy.Symbol", + "name": "theta" + }, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + } + ] + } + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } + } + }, + [ + { + "cirq_type": "_SerializedKey", + "key": 1 + }, + { + "cirq_type": "_SerializedKey", + "key": 2 + }, + { + "cirq_type": "_SerializedKey", + "key": 3 + } + ] + ] +} \ No newline at end of file diff --git a/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.repr_inward b/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.repr_inward new file mode 100644 index 00000000000..0bc98a8f705 --- /dev/null +++ b/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.repr_inward @@ -0,0 +1,23 @@ +[cirq.FrozenCircuit([ + cirq.Moment( + cirq.H(cirq.LineQubit(0)), + cirq.H(cirq.LineQubit(1)), + cirq.H(cirq.LineQubit(2)), + cirq.H(cirq.LineQubit(3)), + cirq.H(cirq.LineQubit(4)), + ), + cirq.Moment( + cirq.MeasurementGate(5, '0,1,2,3,4', ()).on(cirq.LineQubit(0), cirq.LineQubit(1), cirq.LineQubit(2), cirq.LineQubit(3), cirq.LineQubit(4)), + ), +]), cirq.FrozenCircuit([ + cirq.Moment( + cirq.TOFFOLI(cirq.LineQubit(0), cirq.LineQubit(1), cirq.LineQubit(2)), + ), + cirq.Moment( + (cirq.X**0.123).on(cirq.LineQubit(0)), + ), +]), cirq.FrozenCircuit([ + cirq.Moment( + (cirq.X**sympy.Symbol('theta')).on(cirq.LineQubit(0)), + ), +])] \ No newline at end of file diff --git a/cirq-core/cirq/testing/devices_test.py b/cirq-core/cirq/testing/devices_test.py index 49d57d080cb..6d28232ea4c 100644 --- a/cirq-core/cirq/testing/devices_test.py +++ b/cirq-core/cirq/testing/devices_test.py @@ -11,8 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import os import pytest - +from unittest import mock import cirq from cirq.testing.devices import ValidatingTestDevice @@ -62,7 +63,8 @@ def test_validating_locality(): ) -def test_autodecompose(): +@mock.patch.dict(os.environ, clear='CIRQ_TESTING') +def test_autodecompose_deprecated(): dev = ValidatingTestDevice( allowed_qubit_types=(cirq.LineQubit,), allowed_gates=( diff --git a/cirq-core/cirq/testing/sample_circuits.py b/cirq-core/cirq/testing/sample_circuits.py index 0dcd4f83a74..f235858a7cc 100644 --- a/cirq-core/cirq/testing/sample_circuits.py +++ b/cirq-core/cirq/testing/sample_circuits.py @@ -13,19 +13,25 @@ # limitations under the License. from typing import TYPE_CHECKING -from cirq import ops, circuits, devices +from cirq import _compat, ops, circuits, devices if TYPE_CHECKING: import cirq +@_compat.deprecated_parameter( + deadline='v0.15', + fix='The returned circuit will no longer include a device object.', + parameter_desc='device', + match=lambda args, kwargs: 'device' in kwargs or len(args) == 4, +) def nonoptimal_toffoli_circuit( q0: 'cirq.Qid', q1: 'cirq.Qid', q2: 'cirq.Qid', device: devices.Device = devices.UNCONSTRAINED_DEVICE, ) -> circuits.Circuit: - return circuits.Circuit( + ret = circuits.Circuit( ops.Y(q2) ** 0.5, ops.X(q2), ops.CNOT(q1, q2), @@ -55,5 +61,6 @@ def nonoptimal_toffoli_circuit( ops.CNOT(q0, q1), ops.Y(q2) ** 0.5, ops.X(q2), - device=device, ) + ret._device = device + return ret diff --git a/cirq-core/cirq/testing/sample_circuits_test.py b/cirq-core/cirq/testing/sample_circuits_test.py index b7f75ddcbf6..71459c81950 100644 --- a/cirq-core/cirq/testing/sample_circuits_test.py +++ b/cirq-core/cirq/testing/sample_circuits_test.py @@ -22,3 +22,12 @@ def test_nonoptimal_toffoli_circuit(): cirq.unitary(cirq.TOFFOLI(q0, q1, q2)), atol=1e-7, ) + +def test_nonoptimal_toffoli_circuit_device_deprecated(): + q0, q1, q2 = cirq.LineQubit.range(3) + with cirq.testing.assert_deprecated('no longer include a device', deadline='v0.15'): + cirq.testing.assert_allclose_up_to_global_phase( + cirq.testing.nonoptimal_toffoli_circuit(q0, q1, q2, cirq.UNCONSTRAINED_DEVICE).unitary(), + cirq.unitary(cirq.TOFFOLI(q0, q1, q2)), + atol=1e-7, + ) diff --git a/cirq-google/cirq_google/api/v1/programs.py b/cirq-google/cirq_google/api/v1/programs.py index 0b5fd34c44d..c6a575378d2 100644 --- a/cirq-google/cirq_google/api/v1/programs.py +++ b/cirq-google/cirq_google/api/v1/programs.py @@ -166,16 +166,28 @@ def circuit_as_schedule_to_protos(circuit: cirq.Circuit) -> Iterator[operations_ yield op_proto +@cirq._compat.deprecated_parameter( + deadline='v0.15', + fix='The returned circuit will no longer include a device object.', + parameter_desc='device', + match=lambda args, kwargs: 'device' in kwargs or len(args) > 1, +) def circuit_from_schedule_from_protos( - device: 'cirq_google.XmonDevice', - ops: Iterable[operations_pb2.Operation], + *args ) -> cirq.Circuit: - """Convert protos into a Circuit for the given device.""" + """Convert protos into a Circuit.""" + if len(args) == 2: + device, ops = args[0], args[1] + else: + ops = args[0] result = [] for op in ops: xmon_op = xmon_op_from_proto(op) result.append(xmon_op) - return cirq.Circuit(result, device=device) + ret = cirq.Circuit(result) + if len(args) == 2: + ret._device = device + return ret def pack_results(measurements: Sequence[Tuple[str, np.ndarray]]) -> bytes: diff --git a/cirq-google/cirq_google/api/v1/programs_test.py b/cirq-google/cirq_google/api/v1/programs_test.py index 2efabbb50b3..95ff94afe2e 100644 --- a/cirq-google/cirq_google/api/v1/programs_test.py +++ b/cirq-google/cirq_google/api/v1/programs_test.py @@ -11,11 +11,13 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +import os import numpy as np import pytest import sympy +from unittest import mock + import cirq import cirq_google as cg import cirq_google.api.v1.programs as programs @@ -32,14 +34,27 @@ def test_protobuf_round_trip(): circuit = cirq.Circuit( [cirq.X(q) ** 0.5 for q in device.qubits], [cirq.CZ(q, q2) for q in [cirq.GridQubit(0, 0)] for q2 in device.neighbors_of(q)], - device=device, ) protos = list(programs.circuit_as_schedule_to_protos(circuit)) - s2 = programs.circuit_from_schedule_from_protos(device, protos) + s2 = programs.circuit_from_schedule_from_protos(protos) assert s2 == circuit +def test_protobuf_round_trip_device_deprecated(): + device = cg.Foxtail + circuit = cirq.Circuit( + [cirq.X(q) ** 0.5 for q in device.qubits], + [cirq.CZ(q, q2) for q in [cirq.GridQubit(0, 0)] for q2 in device.neighbors_of(q)], + ) + circuit._device = device + + protos = list(programs.circuit_as_schedule_to_protos(circuit)) + with cirq.testing.assert_deprecated('no longer include a device', deadline='v0.15'): + s2 = programs.circuit_from_schedule_from_protos(device, protos) + assert s2 == circuit + + def make_bytes(s: str) -> bytes: """Helper function to convert a string of digits into packed bytes. diff --git a/cirq-google/cirq_google/engine/engine.py b/cirq-google/cirq_google/engine/engine.py index 2beec954b0d..68a26278cc2 100644 --- a/cirq-google/cirq_google/engine/engine.py +++ b/cirq-google/cirq_google/engine/engine.py @@ -634,7 +634,6 @@ def _serialize_program( ) -> any_pb2.Any: if not isinstance(program, cirq.AbstractCircuit): raise TypeError(f'Unrecognized program type: {type(program)}') - program.device.validate_circuit(program) if self.context.proto_version == ProtoVersion.V2: program = gate_set.serialize(program) diff --git a/cirq-google/cirq_google/engine/engine_test.py b/cirq-google/cirq_google/engine/engine_test.py index cd848da175e..ecc4e4cdc46 100644 --- a/cirq-google/cirq_google/engine/engine_test.py +++ b/cirq-google/cirq_google/engine/engine_test.py @@ -392,21 +392,8 @@ def test_run_circuit(client): client.get_job_result.called_once_with() -def test_circuit_device_validation_fails(): - circuit = cirq.Circuit(device=cg.Foxtail) - - # Purposefully create an invalid Circuit by fiddling with internal bits. - # This simulates a failure in the incremental checks. - circuit._moments.append(cirq.Moment([cirq.Z(cirq.NamedQubit("dorothy"))])) - engine = cg.Engine(project_id='project-id') - with pytest.raises(ValueError, match='Unsupported qubit type'): - engine.run_sweep(program=circuit, gate_set=cg.XMON) - with pytest.raises(ValueError, match='Unsupported qubit type'): - engine.create_program(circuit, gate_set=cg.XMON) - - def test_no_gate_set(): - circuit = cirq.Circuit(device=cg.Sycamore) + circuit = cirq.Circuit() engine = cg.Engine(project_id='project-id') with pytest.raises(ValueError, match='No gate set'): engine.run(program=circuit) diff --git a/cirq-google/cirq_google/json_test_data/CalibrationLayer.json b/cirq-google/cirq_google/json_test_data/CalibrationLayer.json index 44934e78477..e884d09d166 100644 --- a/cirq-google/cirq_google/json_test_data/CalibrationLayer.json +++ b/cirq-google/cirq_google/json_test_data/CalibrationLayer.json @@ -22,10 +22,7 @@ } ] } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } + ] }, "args": { "type": "full", diff --git a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.json b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.json index 5710d73d654..6ee36ec4696 100644 --- a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.json +++ b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.json @@ -839,10 +839,7 @@ } ] } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } + ] } }, { diff --git a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.json_inward b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.json_inward new file mode 100644 index 00000000000..5710d73d654 --- /dev/null +++ b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.json_inward @@ -0,0 +1,873 @@ +{ + "cirq_type": "_ContextualSerialization", + "object_dag": [ + { + "cirq_type": "_SerializedContext", + "key": 1, + "obj": { + "cirq_type": "FrozenCircuit", + "moments": [ + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 8 + }, + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 7 + }, + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 6 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + }, + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 6 + }, + { + "cirq_type": "LineQubit", + "x": 5 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + }, + { + "cirq_type": "LineQubit", + "x": 8 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 7 + } + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CZPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 6 + }, + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliX", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 1 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + }, + { + "cirq_type": "LineQubit", + "x": 5 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + }, + { + "cirq_type": "LineQubit", + "x": 8 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 7 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 5 + }, + { + "cirq_type": "LineQubit", + "x": 6 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 9 + }, + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 7 + }, + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 6 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + }, + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 8 + } + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 6 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 5 + }, + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 8 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + }, + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 1 + } + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + }, + { + "cirq_type": "LineQubit", + "x": 5 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 6 + }, + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + }, + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 8 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + }, + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 5 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + }, + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 7 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 6 + }, + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + }, + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 8 + }, + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 7 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + }, + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 9 + }, + { + "cirq_type": "LineQubit", + "x": 6 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliX", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 9 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliX", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 7 + } + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 0 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 6 + }, + { + "cirq_type": "LineQubit", + "x": 8 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + }, + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + } + ] + } + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } + } + }, + { + "cirq_type": "cirq.google.QuantumExecutable", + "circuit": { + "cirq_type": "_SerializedKey", + "key": 1 + }, + "measurement": { + "cirq_type": "cirq.google.BitstringsMeasurement", + "n_repetitions": 10 + }, + "params": [], + "spec": { + "cirq_type": "cirq.google.KeyValueExecutableSpec", + "executable_family": "cirq_google.algo_benchmarks.example", + "key_value_pairs": [ + [ + "name", + "example-program" + ] + ] + }, + "problem_topology": null, + "initial_state": null + } + ] +} \ No newline at end of file diff --git a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.repr_inward b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.repr_inward new file mode 100644 index 00000000000..74bb8e19f5b --- /dev/null +++ b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.repr_inward @@ -0,0 +1,72 @@ +cirq_google.QuantumExecutable(circuit=cirq.FrozenCircuit([ + cirq.Moment( + cirq.SWAP(cirq.LineQubit(8), cirq.LineQubit(1)), + cirq.ISWAP(cirq.LineQubit(7), cirq.LineQubit(3)), + cirq.S(cirq.LineQubit(6)), + ), + cirq.Moment( + cirq.CNOT(cirq.LineQubit(3), cirq.LineQubit(0)), + cirq.CNOT(cirq.LineQubit(6), cirq.LineQubit(5)), + cirq.CNOT(cirq.LineQubit(1), cirq.LineQubit(8)), + cirq.Z(cirq.LineQubit(7)), + ), + cirq.Moment( + cirq.T(cirq.LineQubit(2)), + cirq.CZ(cirq.LineQubit(6), cirq.LineQubit(9)), + cirq.X(cirq.LineQubit(1)), + cirq.H(cirq.LineQubit(4)), + cirq.CNOT(cirq.LineQubit(0), cirq.LineQubit(5)), + ), + cirq.Moment( + cirq.SWAP(cirq.LineQubit(3), cirq.LineQubit(8)), + cirq.Z(cirq.LineQubit(7)), + cirq.T(cirq.LineQubit(4)), + cirq.CNOT(cirq.LineQubit(5), cirq.LineQubit(6)), + cirq.T(cirq.LineQubit(1)), + cirq.CNOT(cirq.LineQubit(9), cirq.LineQubit(0)), + ), + cirq.Moment( + cirq.CNOT(cirq.LineQubit(7), cirq.LineQubit(3)), + cirq.T(cirq.LineQubit(6)), + cirq.CNOT(cirq.LineQubit(4), cirq.LineQubit(1)), + cirq.Z(cirq.LineQubit(8)), + ), + cirq.Moment( + cirq.Y(cirq.LineQubit(6)), + cirq.SWAP(cirq.LineQubit(5), cirq.LineQubit(0)), + cirq.H(cirq.LineQubit(9)), + cirq.S(cirq.LineQubit(4)), + cirq.S(cirq.LineQubit(8)), + cirq.SWAP(cirq.LineQubit(3), cirq.LineQubit(2)), + cirq.Y(cirq.LineQubit(1)), + ), + cirq.Moment( + cirq.ISWAP(cirq.LineQubit(3), cirq.LineQubit(5)), + cirq.ISWAP(cirq.LineQubit(6), cirq.LineQubit(2)), + cirq.SWAP(cirq.LineQubit(4), cirq.LineQubit(0)), + cirq.T(cirq.LineQubit(8)), + cirq.CNOT(cirq.LineQubit(1), cirq.LineQubit(9)), + ), + cirq.Moment( + cirq.H(cirq.LineQubit(5)), + cirq.SWAP(cirq.LineQubit(0), cirq.LineQubit(3)), + cirq.Z(cirq.LineQubit(7)), + cirq.ISWAP(cirq.LineQubit(6), cirq.LineQubit(9)), + cirq.CNOT(cirq.LineQubit(1), cirq.LineQubit(2)), + ), + cirq.Moment( + cirq.SWAP(cirq.LineQubit(8), cirq.LineQubit(2)), + cirq.Y(cirq.LineQubit(7)), + cirq.CNOT(cirq.LineQubit(3), cirq.LineQubit(0)), + cirq.CNOT(cirq.LineQubit(9), cirq.LineQubit(6)), + ), + cirq.Moment( + cirq.X(cirq.LineQubit(9)), + cirq.T(cirq.LineQubit(1)), + cirq.X(cirq.LineQubit(7)), + cirq.Z(cirq.LineQubit(0)), + cirq.ISWAP(cirq.LineQubit(6), cirq.LineQubit(8)), + cirq.ISWAP(cirq.LineQubit(3), cirq.LineQubit(4)), + cirq.T(cirq.LineQubit(2)), + ), +]), measurement=cirq_google.BitstringsMeasurement(n_repetitions=10), params=(), spec=cirq_google.KeyValueExecutableSpec(executable_family='cirq_google.algo_benchmarks.example', key_value_pairs=(('name', 'example-program'),)), problem_topology=None, initial_state=None) diff --git a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.json b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.json index 7a01a7f9a47..577b2507e5d 100644 --- a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.json +++ b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.json @@ -881,10 +881,7 @@ } ] } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } + ] } }, { @@ -1769,10 +1766,7 @@ } ] } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } + ] } }, { @@ -2567,10 +2561,7 @@ } ] } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } + ] } }, { diff --git a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.json_inward b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.json_inward new file mode 100644 index 00000000000..7a01a7f9a47 --- /dev/null +++ b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.json_inward @@ -0,0 +1,2654 @@ +{ + "cirq_type": "_ContextualSerialization", + "object_dag": [ + { + "cirq_type": "_SerializedContext", + "key": 1, + "obj": { + "cirq_type": "FrozenCircuit", + "moments": [ + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + }, + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 7 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 6 + }, + { + "cirq_type": "LineQubit", + "x": 8 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 5 + }, + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + }, + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliX", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 5 + } + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 3 + } + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 9 + } + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 1 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CZPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + }, + { + "cirq_type": "LineQubit", + "x": 7 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 8 + }, + { + "cirq_type": "LineQubit", + "x": 6 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 6 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 9 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 5 + }, + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 7 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + }, + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 4 + } + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 7 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 9 + }, + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 5 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 2 + }, + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliX", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 3 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 6 + }, + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliX", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 0 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 7 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 8 + }, + { + "cirq_type": "LineQubit", + "x": 5 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + }, + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 8 + }, + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 6 + }, + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 5 + }, + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + }, + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 6 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 2 + }, + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliX", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 8 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 7 + }, + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 9 + }, + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 7 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CZPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 8 + }, + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CZPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 6 + }, + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 6 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + }, + { + "cirq_type": "LineQubit", + "x": 8 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 5 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 7 + }, + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + } + ] + } + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } + } + }, + { + "cirq_type": "_SerializedContext", + "key": 2, + "obj": { + "cirq_type": "FrozenCircuit", + "moments": [ + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 2 + }, + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 0 + } + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliX", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 4 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 7 + }, + { + "cirq_type": "LineQubit", + "x": 8 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 5 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 0 + } + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 6 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + }, + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 7 + }, + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliX", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 7 + } + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 3 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 6 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + }, + { + "cirq_type": "LineQubit", + "x": 5 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 8 + }, + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliX", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 9 + } + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 2 + } + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliX", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 3 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CZPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 5 + }, + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliX", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 6 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 7 + }, + { + "cirq_type": "LineQubit", + "x": 8 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 7 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + }, + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 6 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 5 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + }, + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 8 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CZPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 5 + }, + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 7 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 8 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 5 + }, + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + }, + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 7 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + }, + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 5 + }, + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 6 + } + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 5 + } + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliX", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 7 + } + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 1 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 9 + }, + { + "cirq_type": "LineQubit", + "x": 8 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + }, + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + }, + { + "cirq_type": "LineQubit", + "x": 5 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CZPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 8 + }, + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + } + ] + } + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } + } + }, + { + "cirq_type": "_SerializedContext", + "key": 3, + "obj": { + "cirq_type": "FrozenCircuit", + "moments": [ + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 4 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + }, + { + "cirq_type": "LineQubit", + "x": 7 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliX", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 5 + } + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 9 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 8 + } + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 6 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 2 + }, + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + }, + { + "cirq_type": "LineQubit", + "x": 5 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 2 + }, + { + "cirq_type": "LineQubit", + "x": 8 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + }, + { + "cirq_type": "LineQubit", + "x": 6 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 8 + }, + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CZPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + }, + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliX", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 1 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 6 + }, + { + "cirq_type": "LineQubit", + "x": 7 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CZPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + }, + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + }, + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 9 + }, + { + "cirq_type": "LineQubit", + "x": 8 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 7 + }, + { + "cirq_type": "LineQubit", + "x": 6 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CZPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + }, + { + "cirq_type": "LineQubit", + "x": 5 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 9 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.5, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 5 + }, + { + "cirq_type": "LineQubit", + "x": 6 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 6 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 5 + }, + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 8 + }, + { + "cirq_type": "LineQubit", + "x": 1 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 7 + }, + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ZPowGate", + "exponent": 0.25, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 7 + }, + { + "cirq_type": "LineQubit", + "x": 5 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CZPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 3 + }, + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 9 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 1 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 7 + }, + { + "cirq_type": "LineQubit", + "x": 6 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + }, + { + "cirq_type": "LineQubit", + "x": 2 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliY", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 5 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "SwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 0 + }, + { + "cirq_type": "LineQubit", + "x": 8 + } + ] + } + ] + }, + { + "cirq_type": "Moment", + "operations": [ + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CXPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 9 + }, + { + "cirq_type": "LineQubit", + "x": 5 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "ISwapPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 1 + }, + { + "cirq_type": "LineQubit", + "x": 6 + } + ] + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "CZPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 4 + }, + { + "cirq_type": "LineQubit", + "x": 7 + } + ] + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 2 + } + }, + { + "cirq_type": "SingleQubitPauliStringGateOperation", + "pauli": { + "cirq_type": "_PauliZ", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubit": { + "cirq_type": "LineQubit", + "x": 0 + } + }, + { + "cirq_type": "GateOperation", + "gate": { + "cirq_type": "HPowGate", + "exponent": 1.0, + "global_shift": 0.0 + }, + "qubits": [ + { + "cirq_type": "LineQubit", + "x": 8 + } + ] + } + ] + } + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } + } + }, + { + "cirq_type": "cirq.google.QuantumExecutableGroup", + "executables": [ + { + "cirq_type": "cirq.google.QuantumExecutable", + "circuit": { + "cirq_type": "_SerializedKey", + "key": 1 + }, + "measurement": { + "cirq_type": "cirq.google.BitstringsMeasurement", + "n_repetitions": 10 + }, + "params": [], + "spec": { + "cirq_type": "cirq.google.KeyValueExecutableSpec", + "executable_family": "cirq_google.algo_benchmarks.example", + "key_value_pairs": [ + [ + "name", + "example-program-0" + ] + ] + }, + "problem_topology": null, + "initial_state": null + }, + { + "cirq_type": "cirq.google.QuantumExecutable", + "circuit": { + "cirq_type": "_SerializedKey", + "key": 2 + }, + "measurement": { + "cirq_type": "cirq.google.BitstringsMeasurement", + "n_repetitions": 10 + }, + "params": [], + "spec": { + "cirq_type": "cirq.google.KeyValueExecutableSpec", + "executable_family": "cirq_google.algo_benchmarks.example", + "key_value_pairs": [ + [ + "name", + "example-program-1" + ] + ] + }, + "problem_topology": null, + "initial_state": null + }, + { + "cirq_type": "cirq.google.QuantumExecutable", + "circuit": { + "cirq_type": "_SerializedKey", + "key": 3 + }, + "measurement": { + "cirq_type": "cirq.google.BitstringsMeasurement", + "n_repetitions": 10 + }, + "params": [], + "spec": { + "cirq_type": "cirq.google.KeyValueExecutableSpec", + "executable_family": "cirq_google.algo_benchmarks.example", + "key_value_pairs": [ + [ + "name", + "example-program-2" + ] + ] + }, + "problem_topology": null, + "initial_state": null + } + ] + } + ] +} \ No newline at end of file diff --git a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.repr_inward b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.repr_inward new file mode 100644 index 00000000000..6038a348d18 --- /dev/null +++ b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.repr_inward @@ -0,0 +1,221 @@ +cirq_google.QuantumExecutableGroup(executables=(cirq_google.QuantumExecutable(circuit=cirq.FrozenCircuit([ + cirq.Moment( + cirq.SWAP(cirq.LineQubit(4), cirq.LineQubit(9)), + cirq.Y(cirq.LineQubit(7)), + cirq.CNOT(cirq.LineQubit(6), cirq.LineQubit(8)), + cirq.ISWAP(cirq.LineQubit(5), cirq.LineQubit(1)), + cirq.CNOT(cirq.LineQubit(0), cirq.LineQubit(3)), + ), + cirq.Moment( + cirq.X(cirq.LineQubit(5)), + cirq.Y(cirq.LineQubit(3)), + cirq.Z(cirq.LineQubit(9)), + cirq.Z(cirq.LineQubit(1)), + cirq.S(cirq.LineQubit(2)), + cirq.S(cirq.LineQubit(0)), + cirq.CZ(cirq.LineQubit(4), cirq.LineQubit(7)), + cirq.SWAP(cirq.LineQubit(8), cirq.LineQubit(6)), + ), + cirq.Moment( + cirq.H(cirq.LineQubit(6)), + cirq.Z(cirq.LineQubit(9)), + cirq.ISWAP(cirq.LineQubit(5), cirq.LineQubit(1)), + cirq.Z(cirq.LineQubit(7)), + cirq.H(cirq.LineQubit(2)), + cirq.ISWAP(cirq.LineQubit(0), cirq.LineQubit(3)), + cirq.Y(cirq.LineQubit(4)), + ), + cirq.Moment( + cirq.H(cirq.LineQubit(1)), + cirq.S(cirq.LineQubit(7)), + cirq.CNOT(cirq.LineQubit(9), cirq.LineQubit(3)), + cirq.T(cirq.LineQubit(0)), + cirq.T(cirq.LineQubit(5)), + ), + cirq.Moment( + cirq.T(cirq.LineQubit(1)), + cirq.SWAP(cirq.LineQubit(2), cirq.LineQubit(4)), + cirq.X(cirq.LineQubit(3)), + cirq.H(cirq.LineQubit(9)), + ), + cirq.Moment( + cirq.SWAP(cirq.LineQubit(6), cirq.LineQubit(1)), + cirq.X(cirq.LineQubit(0)), + cirq.H(cirq.LineQubit(7)), + cirq.SWAP(cirq.LineQubit(8), cirq.LineQubit(5)), + cirq.SWAP(cirq.LineQubit(4), cirq.LineQubit(9)), + ), + cirq.Moment( + cirq.T(cirq.LineQubit(0)), + cirq.SWAP(cirq.LineQubit(8), cirq.LineQubit(9)), + cirq.ISWAP(cirq.LineQubit(6), cirq.LineQubit(4)), + cirq.CNOT(cirq.LineQubit(5), cirq.LineQubit(3)), + ), + cirq.Moment( + cirq.CNOT(cirq.LineQubit(1), cirq.LineQubit(3)), + cirq.S(cirq.LineQubit(6)), + cirq.ISWAP(cirq.LineQubit(2), cirq.LineQubit(9)), + cirq.X(cirq.LineQubit(8)), + cirq.CNOT(cirq.LineQubit(7), cirq.LineQubit(0)), + ), + cirq.Moment( + cirq.ISWAP(cirq.LineQubit(9), cirq.LineQubit(2)), + cirq.Z(cirq.LineQubit(7)), + cirq.H(cirq.LineQubit(3)), + cirq.T(cirq.LineQubit(0)), + cirq.CZ(cirq.LineQubit(8), cirq.LineQubit(1)), + cirq.CZ(cirq.LineQubit(6), cirq.LineQubit(4)), + ), + cirq.Moment( + cirq.Y(cirq.LineQubit(6)), + cirq.S(cirq.LineQubit(1)), + cirq.ISWAP(cirq.LineQubit(0), cirq.LineQubit(8)), + cirq.Y(cirq.LineQubit(5)), + cirq.CNOT(cirq.LineQubit(7), cirq.LineQubit(4)), + ), +]), measurement=cirq_google.BitstringsMeasurement(n_repetitions=10), params=(), spec=cirq_google.KeyValueExecutableSpec(executable_family='cirq_google.algo_benchmarks.example', key_value_pairs=(('name', 'example-program-0'),)), problem_topology=None, initial_state=None), cirq_google.QuantumExecutable(circuit=cirq.FrozenCircuit([ + cirq.Moment( + cirq.SWAP(cirq.LineQubit(2), cirq.LineQubit(3)), + cirq.H(cirq.LineQubit(1)), + cirq.H(cirq.LineQubit(9)), + cirq.Y(cirq.LineQubit(0)), + cirq.X(cirq.LineQubit(4)), + cirq.ISWAP(cirq.LineQubit(7), cirq.LineQubit(8)), + ), + cirq.Moment( + cirq.S(cirq.LineQubit(5)), + cirq.Z(cirq.LineQubit(0)), + cirq.Y(cirq.LineQubit(6)), + cirq.CNOT(cirq.LineQubit(4), cirq.LineQubit(3)), + cirq.SWAP(cirq.LineQubit(7), cirq.LineQubit(1)), + cirq.S(cirq.LineQubit(9)), + ), + cirq.Moment( + cirq.X(cirq.LineQubit(7)), + cirq.Y(cirq.LineQubit(3)), + cirq.H(cirq.LineQubit(4)), + cirq.T(cirq.LineQubit(6)), + cirq.SWAP(cirq.LineQubit(0), cirq.LineQubit(5)), + cirq.CNOT(cirq.LineQubit(8), cirq.LineQubit(1)), + cirq.X(cirq.LineQubit(9)), + ), + cirq.Moment( + cirq.Z(cirq.LineQubit(2)), + cirq.X(cirq.LineQubit(3)), + cirq.CZ(cirq.LineQubit(5), cirq.LineQubit(1)), + cirq.S(cirq.LineQubit(4)), + cirq.X(cirq.LineQubit(6)), + cirq.ISWAP(cirq.LineQubit(7), cirq.LineQubit(8)), + ), + cirq.Moment( + cirq.H(cirq.LineQubit(7)), + cirq.ISWAP(cirq.LineQubit(4), cirq.LineQubit(0)), + cirq.S(cirq.LineQubit(3)), + cirq.Y(cirq.LineQubit(6)), + cirq.S(cirq.LineQubit(1)), + cirq.T(cirq.LineQubit(2)), + cirq.T(cirq.LineQubit(5)), + ), + cirq.Moment( + cirq.CNOT(cirq.LineQubit(4), cirq.LineQubit(9)), + cirq.S(cirq.LineQubit(1)), + cirq.T(cirq.LineQubit(3)), + cirq.Y(cirq.LineQubit(8)), + cirq.CZ(cirq.LineQubit(5), cirq.LineQubit(2)), + ), + cirq.Moment( + cirq.Z(cirq.LineQubit(7)), + cirq.H(cirq.LineQubit(8)), + cirq.ISWAP(cirq.LineQubit(5), cirq.LineQubit(9)), + cirq.H(cirq.LineQubit(0)), + cirq.CNOT(cirq.LineQubit(1), cirq.LineQubit(4)), + ), + cirq.Moment( + cirq.H(cirq.LineQubit(7)), + cirq.CNOT(cirq.LineQubit(1), cirq.LineQubit(0)), + cirq.CNOT(cirq.LineQubit(5), cirq.LineQubit(4)), + ), + cirq.Moment( + cirq.H(cirq.LineQubit(3)), + cirq.Y(cirq.LineQubit(6)), + cirq.Z(cirq.LineQubit(5)), + cirq.X(cirq.LineQubit(7)), + cirq.Z(cirq.LineQubit(1)), + cirq.S(cirq.LineQubit(2)), + cirq.CNOT(cirq.LineQubit(9), cirq.LineQubit(8)), + cirq.H(cirq.LineQubit(4)), + ), + cirq.Moment( + cirq.ISWAP(cirq.LineQubit(1), cirq.LineQubit(0)), + cirq.SWAP(cirq.LineQubit(4), cirq.LineQubit(5)), + cirq.CZ(cirq.LineQubit(8), cirq.LineQubit(9)), + ), +]), measurement=cirq_google.BitstringsMeasurement(n_repetitions=10), params=(), spec=cirq_google.KeyValueExecutableSpec(executable_family='cirq_google.algo_benchmarks.example', key_value_pairs=(('name', 'example-program-1'),)), problem_topology=None, initial_state=None), cirq_google.QuantumExecutable(circuit=cirq.FrozenCircuit([ + cirq.Moment( + cirq.Y(cirq.LineQubit(4)), + cirq.SWAP(cirq.LineQubit(1), cirq.LineQubit(7)), + cirq.X(cirq.LineQubit(5)), + cirq.Y(cirq.LineQubit(9)), + cirq.H(cirq.LineQubit(0)), + cirq.Y(cirq.LineQubit(8)), + cirq.Y(cirq.LineQubit(6)), + cirq.SWAP(cirq.LineQubit(2), cirq.LineQubit(3)), + ), + cirq.Moment( + cirq.ISWAP(cirq.LineQubit(1), cirq.LineQubit(5)), + cirq.S(cirq.LineQubit(4)), + cirq.SWAP(cirq.LineQubit(2), cirq.LineQubit(8)), + ), + cirq.Moment( + cirq.SWAP(cirq.LineQubit(0), cirq.LineQubit(6)), + cirq.CNOT(cirq.LineQubit(8), cirq.LineQubit(4)), + cirq.CZ(cirq.LineQubit(3), cirq.LineQubit(1)), + ), + cirq.Moment( + cirq.X(cirq.LineQubit(1)), + cirq.ISWAP(cirq.LineQubit(6), cirq.LineQubit(7)), + cirq.CZ(cirq.LineQubit(0), cirq.LineQubit(9)), + ), + cirq.Moment( + cirq.ISWAP(cirq.LineQubit(3), cirq.LineQubit(1)), + cirq.CNOT(cirq.LineQubit(9), cirq.LineQubit(8)), + cirq.SWAP(cirq.LineQubit(7), cirq.LineQubit(6)), + cirq.CZ(cirq.LineQubit(0), cirq.LineQubit(5)), + cirq.S(cirq.LineQubit(4)), + ), + cirq.Moment( + cirq.T(cirq.LineQubit(2)), + cirq.Y(cirq.LineQubit(9)), + cirq.S(cirq.LineQubit(3)), + cirq.SWAP(cirq.LineQubit(5), cirq.LineQubit(6)), + ), + cirq.Moment( + cirq.H(cirq.LineQubit(6)), + cirq.H(cirq.LineQubit(0)), + cirq.CNOT(cirq.LineQubit(5), cirq.LineQubit(9)), + cirq.H(cirq.LineQubit(3)), + cirq.ISWAP(cirq.LineQubit(8), cirq.LineQubit(1)), + cirq.ISWAP(cirq.LineQubit(7), cirq.LineQubit(2)), + ), + cirq.Moment( + cirq.T(cirq.LineQubit(0)), + cirq.ISWAP(cirq.LineQubit(7), cirq.LineQubit(5)), + cirq.CZ(cirq.LineQubit(3), cirq.LineQubit(9)), + ), + cirq.Moment( + cirq.H(cirq.LineQubit(9)), + cirq.Y(cirq.LineQubit(1)), + cirq.ISWAP(cirq.LineQubit(7), cirq.LineQubit(6)), + cirq.ISWAP(cirq.LineQubit(4), cirq.LineQubit(2)), + cirq.Y(cirq.LineQubit(5)), + cirq.SWAP(cirq.LineQubit(0), cirq.LineQubit(8)), + ), + cirq.Moment( + cirq.CNOT(cirq.LineQubit(9), cirq.LineQubit(5)), + cirq.ISWAP(cirq.LineQubit(1), cirq.LineQubit(6)), + cirq.CZ(cirq.LineQubit(4), cirq.LineQubit(7)), + cirq.Z(cirq.LineQubit(2)), + cirq.Z(cirq.LineQubit(0)), + cirq.H(cirq.LineQubit(8)), + ), +]), measurement=cirq_google.BitstringsMeasurement(n_repetitions=10), params=(), spec=cirq_google.KeyValueExecutableSpec(executable_family='cirq_google.algo_benchmarks.example', key_value_pairs=(('name', 'example-program-2'),)), problem_topology=None, initial_state=None))) diff --git a/cirq-google/cirq_google/optimizers/optimize_for_sycamore.py b/cirq-google/cirq_google/optimizers/optimize_for_sycamore.py index 125f21620d7..a97cdb8b73b 100644 --- a/cirq-google/cirq_google/optimizers/optimize_for_sycamore.py +++ b/cirq-google/cirq_google/optimizers/optimize_for_sycamore.py @@ -111,7 +111,12 @@ def _gate_product_tabulation_cached( else: raise NotImplementedError(f"Gate tabulation not supported for {optimizer_type}") - +@cirq._compat.deprecated_parameter( + deadline='v0.15', + fix=cirq.circuits.circuit._DEVICE_DEP_MESSAGE, + parameter_desc='new_device', + match=lambda args, kwargs: 'new_device' in kwargs, +) def optimized_for_sycamore( circuit: cirq.Circuit, *, @@ -163,8 +168,9 @@ def optimized_for_sycamore( for optimizer in opts: optimizer(copy) - return cirq.Circuit( + ret = cirq.Circuit( (op.transform_qubits(qubit_map) for op in copy.all_operations()), strategy=cirq.InsertStrategy.EARLIEST, - device=new_device or copy.device, ) + ret._device = new_device or copy._device + return ret diff --git a/cirq-google/cirq_google/optimizers/optimize_for_sycamore_test.py b/cirq-google/cirq_google/optimizers/optimize_for_sycamore_test.py index cc383ca145f..e8fcecb8f2e 100644 --- a/cirq-google/cirq_google/optimizers/optimize_for_sycamore_test.py +++ b/cirq-google/cirq_google/optimizers/optimize_for_sycamore_test.py @@ -116,3 +116,14 @@ def test_one_q_matrix_gate(): assert cg.SYC_GATESET.is_supported_operation(op) # single qubit gates shared between gatesets, so: assert cg.SQRT_ISWAP_GATESET.is_supported_operation(op) + + +def test_assert_new_device_deprecated(): + u = cirq.testing.random_special_unitary(2) + q = cirq.LineQubit(0) + circuit0 = cirq.Circuit(cirq.MatrixGate(u).on(q)) + circuit_iswap = cg.optimized_for_sycamore(circuit0, optimizer_type='sqrt_iswap') + with cirq.testing.assert_deprecated(cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15'): + circuit_iswap = cg.optimized_for_sycamore(circuit0, optimizer_type='sqrt_iswap', + new_device=cg.Foxtail) + diff --git a/cirq-google/cirq_google/optimizers/optimize_for_xmon.py b/cirq-google/cirq_google/optimizers/optimize_for_xmon.py index 3cb0bc1141c..37098dffa3d 100644 --- a/cirq-google/cirq_google/optimizers/optimize_for_xmon.py +++ b/cirq-google/cirq_google/optimizers/optimize_for_xmon.py @@ -21,17 +21,21 @@ import cirq_google +@cirq._compat.deprecated_parameter( + deadline='v0.15', + fix=cirq.circuits.circuit._DEVICE_DEP_MESSAGE, + parameter_desc='new_device', + match=lambda args, kwargs: 'new_device' in kwargs, +) def optimized_for_xmon( circuit: cirq.Circuit, new_device: Optional['cirq_google.XmonDevice'] = None, qubit_map: Callable[[cirq.Qid], cirq.GridQubit] = lambda e: cast(cirq.GridQubit, e), allow_partial_czs: bool = False, ) -> cirq.Circuit: - if allow_partial_czs: - return optimized_for_sycamore( - circuit, new_device=new_device, qubit_map=qubit_map, optimizer_type='xmon_partial_cz' - ) - else: - return optimized_for_sycamore( - circuit, new_device=new_device, qubit_map=qubit_map, optimizer_type='xmon' - ) + optimizer_type = 'xmon_partial_cz' if allow_partial_czs else 'xmon' + ret = optimized_for_sycamore( + circuit, qubit_map=qubit_map, optimizer_type=optimizer_type + ) + ret._device = new_device or circuit._device + return ret \ No newline at end of file diff --git a/cirq-google/cirq_google/optimizers/optimize_for_xmon_test.py b/cirq-google/cirq_google/optimizers/optimize_for_xmon_test.py index 1507a8870f9..a672cdeecf3 100644 --- a/cirq-google/cirq_google/optimizers/optimize_for_xmon_test.py +++ b/cirq-google/cirq_google/optimizers/optimize_for_xmon_test.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +import os import pytest import cirq @@ -21,6 +21,7 @@ assert_circuits_with_terminal_measurements_are_equivalent, ) +from unittest import mock @pytest.mark.parametrize( 'n,d', @@ -57,38 +58,15 @@ def test_ccz(): assert_circuits_with_terminal_measurements_are_equivalent(before, after, atol=1e-4) -def test_adjacent_cz_get_split_apart(): - before = cirq.Circuit( - [ - cirq.Moment( - [ - cirq.CZ(cirq.GridQubit(0, 0), cirq.GridQubit(0, 1)), - cirq.CZ(cirq.GridQubit(1, 0), cirq.GridQubit(1, 1)), - ] - ) - ] - ) - - after = cg.optimized_for_xmon(before, new_device=cg.Foxtail) - - assert after == cirq.Circuit( - [ - cirq.Moment([cirq.CZ(cirq.GridQubit(0, 0), cirq.GridQubit(0, 1))]), - cirq.Moment([cirq.CZ(cirq.GridQubit(1, 0), cirq.GridQubit(1, 1))]), - ], - device=cg.Foxtail, - ) - - def test_remap_qubits(): before = cirq.Circuit([cirq.Moment([cirq.CZ(cirq.LineQubit(0), cirq.LineQubit(1))])]) after = cg.optimized_for_xmon( - before, new_device=cg.Foxtail, qubit_map=lambda q: cirq.GridQubit(q.x, 0) + before, qubit_map=lambda q: cirq.GridQubit(q.x, 0) ) assert after == cirq.Circuit( - [cirq.Moment([cirq.CZ(cirq.GridQubit(0, 0), cirq.GridQubit(1, 0))])], device=cg.Foxtail + [cirq.Moment([cirq.CZ(cirq.GridQubit(0, 0), cirq.GridQubit(1, 0))])] ) diff --git a/cirq-google/cirq_google/serialization/gate_sets_test.py b/cirq-google/cirq_google/serialization/gate_sets_test.py index f7d3b0f865c..211ec593b40 100644 --- a/cirq-google/cirq_google/serialization/gate_sets_test.py +++ b/cirq-google/cirq_google/serialization/gate_sets_test.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +import os from typing import Dict import numpy as np import pytest @@ -22,7 +22,7 @@ import cirq import cirq_google as cg from cirq_google.api import v2 - +from unittest import mock def op_proto(json_dict: Dict) -> v2.program_pb2.Operation: op = v2.program_pb2.Operation() @@ -355,7 +355,8 @@ def test_deserialize_circuit(): assert cg.XMON.deserialize(serialized) == circuit -def test_deserialize_schedule(): +@mock.patch.dict(os.environ, clear='CIRQ_TESTING') +def test_deserialize_schedule_device_deprecated(): q0 = cirq.GridQubit(4, 4) q1 = cirq.GridQubit(4, 5) circuit = cirq.Circuit( @@ -381,9 +382,39 @@ def test_deserialize_schedule(): ] ), ) + print('WTF', cg.XMON.deserialize(serialized, cg.Bristlecone)) assert cg.XMON.deserialize(serialized, cg.Bristlecone) == circuit +def test_deserialize_schedule(): + q0 = cirq.GridQubit(4, 4) + q1 = cirq.GridQubit(4, 5) + circuit = cirq.Circuit( + cirq.CZ(q0, q1), cirq.X(q0), cirq.Z(q1), cirq.measure(q0, key='a') + ) + serialized = v2.program_pb2.Program( + language=v2.program_pb2.Language(gate_set='xmon'), + schedule=v2.program_pb2.Schedule( + scheduled_operations=[ + v2.program_pb2.ScheduledOperation( + operation=cg.XMON.serialize_op(cirq.CZ(q0, q1)), start_time_picos=0 + ), + v2.program_pb2.ScheduledOperation( + operation=cg.XMON.serialize_op(cirq.X(q0)), start_time_picos=200000 + ), + v2.program_pb2.ScheduledOperation( + operation=cg.XMON.serialize_op(cirq.Z(q1)), start_time_picos=200000 + ), + v2.program_pb2.ScheduledOperation( + operation=cg.XMON.serialize_op(cirq.measure(q0, key='a')), + start_time_picos=400000, + ), + ] + ), + ) + assert cg.XMON.deserialize(serialized) == circuit + + def test_serialize_deserialize_syc(): proto = op_proto({'gate': {'id': 'syc'}, 'args': {}, 'qubits': [{'id': '1_2'}, {'id': '1_3'}]}) diff --git a/cirq-google/cirq_google/serialization/serializable_gate_set.py b/cirq-google/cirq_google/serialization/serializable_gate_set.py index 6a9497e2cb1..6c5b632d208 100644 --- a/cirq-google/cirq_google/serialization/serializable_gate_set.py +++ b/cirq-google/cirq_google/serialization/serializable_gate_set.py @@ -273,6 +273,12 @@ def serialize_circuit_op( return proto_msg raise ValueError(f'Cannot serialize CircuitOperation {op!r}') + @cirq._compat.deprecated_parameter( + deadline='v0.15', + fix='The returned circuit will no longer include a device object.', + parameter_desc='device', + match=lambda args, kwargs: 'device' in kwargs or len(args) > 2, + ) def deserialize( self, proto: v2.program_pb2.Program, device: Optional[cirq.Device] = None ) -> cirq.Circuit: @@ -322,10 +328,12 @@ def deserialize( constants=proto.constants, deserialized_constants=deserialized_constants, ) - return circuit if device is None else circuit.with_device(device) + if device is not None: + circuit._device = device + return circuit if which == 'schedule': - if device is None: - raise ValueError('Deserializing schedule requires a device but None was given.') + # if device is None: + # raise ValueError('Deserializing schedule requires a device but None was given.') return self._deserialize_schedule( proto.schedule, device, arg_function_language=proto.language.arg_function_language ) @@ -510,4 +518,8 @@ def _deserialize_schedule( scheduled_op_proto.operation, arg_function_language=arg_function_language ) ) - return cirq.Circuit(result, device=device) + ret = cirq.Circuit(result) + if device is None: + device = cirq.UNCONSTRAINED_DEVICE + ret._device = device + return ret diff --git a/cirq-google/cirq_google/serialization/serializable_gate_set_test.py b/cirq-google/cirq_google/serialization/serializable_gate_set_test.py index 8d7d9689897..a55a50bbca7 100644 --- a/cirq-google/cirq_google/serialization/serializable_gate_set_test.py +++ b/cirq-google/cirq_google/serialization/serializable_gate_set_test.py @@ -387,29 +387,6 @@ def test_serialize_unrecognized(): MY_GATE_SET.serialize("not quite right") -def test_serialize_deserialize_schedule_no_device(): - q0 = cirq.GridQubit(1, 1) - q1 = cirq.GridQubit(1, 2) - proto = v2.program_pb2.Program( - language=v2.program_pb2.Language(arg_function_language='', gate_set='my_gate_set'), - schedule=v2.program_pb2.Schedule( - scheduled_operations=[ - v2.program_pb2.ScheduledOperation( - operation=X_SERIALIZER.to_proto(cirq.X(q0)), start_time_picos=0 - ), - v2.program_pb2.ScheduledOperation( - operation=X_SERIALIZER.to_proto(cirq.X(q1)), start_time_picos=200000 - ), - v2.program_pb2.ScheduledOperation( - operation=X_SERIALIZER.to_proto(cirq.X(q0)), start_time_picos=400000 - ), - ] - ), - ) - with pytest.raises(ValueError): - MY_GATE_SET.deserialize(proto) - - def test_serialize_deserialize_op(): q0 = cirq.GridQubit(1, 1) proto = op_proto( @@ -769,15 +746,6 @@ def test_deserialize_invalid_gate_set(): MY_GATE_SET.deserialize(proto) -def test_deserialize_schedule_missing_device(): - proto = v2.program_pb2.Program( - language=v2.program_pb2.Language(gate_set='my_gate_set'), - schedule=v2.program_pb2.Schedule(scheduled_operations=[]), - ) - with pytest.raises(ValueError, match='device'): - MY_GATE_SET.deserialize(proto) - - def test_deserialize_no_operation(): proto = v2.program_pb2.Program( language=v2.program_pb2.Language(gate_set='my_gate_set'), diff --git a/cirq-pasqal/cirq_pasqal/pasqal_device_test.py b/cirq-pasqal/cirq_pasqal/pasqal_device_test.py index c13b8b3eb86..8872162b997 100644 --- a/cirq-pasqal/cirq_pasqal/pasqal_device_test.py +++ b/cirq-pasqal/cirq_pasqal/pasqal_device_test.py @@ -18,6 +18,9 @@ import cirq import cirq_pasqal + +from unittest import mock + from cirq_pasqal import PasqalDevice, PasqalVirtualDevice from cirq_pasqal import TwoDQubit, ThreeDQubit @@ -164,7 +167,7 @@ def with_qubits(self, *new_qubits): def test_validate_operation_errors(): d = generic_device(3) - circuit = cirq.Circuit(device=d) + circuit = cirq.Circuit() with pytest.raises(ValueError, match="Unsupported operation"): d.validate_operation(cirq.NamedQubit('q0')) @@ -178,16 +181,22 @@ def test_validate_operation_errors(): with pytest.raises(ValueError, match="is not part of the device."): d.validate_operation(cirq.X.on(cirq.NamedQubit('q6'))) - with pytest.raises( - NotImplementedError, match="Measurements on Pasqal devices don't support invert_mask." - ): - circuit.append(cirq.measure(*d.qubits, invert_mask=(True, False, False))) d = square_virtual_device(control_r=1.0, num_qubits=3) with pytest.raises(ValueError, match="are too far away"): d.validate_operation(cirq.CZ.on(TwoDQubit(0, 0), TwoDQubit(2, 2))) +def test_validate_operation_errors_deprecated(): + d = generic_device(3) + circuit = cirq.Circuit() + circuit._device = d + with pytest.raises( + NotImplementedError, match="Measurements on Pasqal devices don't support invert_mask." + ): + circuit.append(cirq.measure(*d.qubits, invert_mask=(True, False, False))) + + def test_validate_moment(): d = square_virtual_device(control_r=1.0, num_qubits=2) m1 = cirq.Moment([cirq.Z.on(TwoDQubit(0, 0)), (cirq.X).on(TwoDQubit(1, 1))]) @@ -202,7 +211,7 @@ def test_validate_moment(): def test_validate_circuit(): d = generic_device(2) - circuit1 = cirq.Circuit(device=d) + circuit1 = cirq.Circuit() circuit1.append(cirq.X(cirq.NamedQubit('q1'))) circuit1.append(cirq.measure(cirq.NamedQubit('q1'))) d.validate_circuit(circuit1) diff --git a/cirq-pasqal/cirq_pasqal/pasqal_noise_model_test.py b/cirq-pasqal/cirq_pasqal/pasqal_noise_model_test.py index d6668ab134c..f98b0c7423d 100644 --- a/cirq-pasqal/cirq_pasqal/pasqal_noise_model_test.py +++ b/cirq-pasqal/cirq_pasqal/pasqal_noise_model_test.py @@ -42,7 +42,7 @@ def test_noisy_moments(): circuit = cirq.Circuit() circuit.append(cirq.ops.CZ(p_qubits[0], p_qubits[1])) circuit.append(cirq.ops.Z(p_qubits[1])) - p_circuit = cirq.Circuit(circuit, device=p_device) + p_circuit = cirq.Circuit(circuit) n_mts = [] for moment in p_circuit._moments: @@ -65,7 +65,7 @@ def test_default_noise(): circuit = cirq.Circuit() Gate_l = cirq.ops.CZPowGate(exponent=2) circuit.append(Gate_l.on(p_qubits[0], p_qubits[1])) - p_circuit = cirq.Circuit(circuit, device=p_device) + p_circuit = cirq.Circuit(circuit) n_mts = [] for moment in p_circuit._moments: n_mts.append(noise_model.noisy_moment(moment, p_qubits)) diff --git a/cirq-pasqal/cirq_pasqal/pasqal_sampler.py b/cirq-pasqal/cirq_pasqal/pasqal_sampler.py index 6cca5cd82d4..e26415ee420 100644 --- a/cirq-pasqal/cirq_pasqal/pasqal_sampler.py +++ b/cirq-pasqal/cirq_pasqal/pasqal_sampler.py @@ -21,7 +21,10 @@ class PasqalSampler(cirq.work.Sampler): - def __init__(self, remote_host: str, access_token: str = '') -> None: + def __init__(self, + remote_host: str, + access_token: str = '', + device: cirq_pasqal.PasqalDevice = None) -> None: """Inits PasqalSampler. Args: @@ -30,6 +33,7 @@ def __init__(self, remote_host: str, access_token: str = '') -> None: """ self.remote_host = remote_host self._authorization_header = {"Authorization": access_token} + self._device = device def _serialize_circuit( self, @@ -114,8 +118,11 @@ def run_sweep( Result list for this run; one for each possible parameter resolver. """ - assert isinstance(program.device, cirq_pasqal.PasqalDevice) - program.device.validate_circuit(program) + if self._device is None: + assert isinstance(program._device, cirq_pasqal.PasqalDevice) + program._device.validate_circuit(program) + else: + self._device.validate_circuit(program) trial_results = [] for param_resolver in cirq.study.to_resolvers(params): diff --git a/cirq-pasqal/cirq_pasqal/pasqal_sampler_test.py b/cirq-pasqal/cirq_pasqal/pasqal_sampler_test.py index 90c7fa21a1d..51611ba8049 100644 --- a/cirq-pasqal/cirq_pasqal/pasqal_sampler_test.py +++ b/cirq-pasqal/cirq_pasqal/pasqal_sampler_test.py @@ -36,9 +36,11 @@ def text(self): return self.json -def _make_sampler() -> cirq_pasqal.PasqalSampler: +def _make_sampler(device) -> cirq_pasqal.PasqalSampler: - sampler = cirq_pasqal.PasqalSampler(remote_host='http://00.00.00/', access_token='N/A') + sampler = cirq_pasqal.PasqalSampler( + remote_host='http://00.00.00/', access_token='N/A', + device=device) return sampler @@ -47,7 +49,7 @@ def test_pasqal_circuit_init(): ex_circuit = cirq.Circuit() ex_circuit.append([[cirq.CZ(qs[i], qs[i + 1]), cirq.X(qs[i + 1])] for i in range(len(qs) - 1)]) device = cirq_pasqal.PasqalDevice(qubits=qs) - test_circuit = cirq.Circuit(device=device) + test_circuit = cirq.Circuit() test_circuit.append( [[cirq.CZ(qs[i], qs[i + 1]), cirq.X(qs[i + 1])] for i in range(len(qs) - 1)] ) @@ -74,22 +76,22 @@ def test_run_sweep(mock_post, mock_get): binary = bin(num)[2:].zfill(9) device = cirq_pasqal.PasqalVirtualDevice(control_radius=1, qubits=qs) - ex_circuit = cirq.Circuit(device=device) + ex_circuit = cirq.Circuit() for i, b in enumerate(binary[:-1]): if b == '1': ex_circuit.append(cirq.X(qs[-i - 1]), strategy=cirq.InsertStrategy.NEW) ex_circuit_odd = copy.deepcopy(ex_circuit) - ex_circuit_odd.append(cirq.X(qs[0])) - ex_circuit_odd.append(cirq.measure(*qs)) + ex_circuit_odd.append(cirq.X(qs[0]), strategy=cirq.InsertStrategy.NEW) + ex_circuit_odd.append(cirq.measure(*qs), strategy=cirq.InsertStrategy.NEW) xpow = cirq.XPowGate(exponent=par) - ex_circuit.append([xpow(qs[0])]) - ex_circuit.append(cirq.measure(*qs)) + ex_circuit.append([xpow(qs[0])], strategy=cirq.InsertStrategy.NEW) + ex_circuit.append(cirq.measure(*qs), strategy=cirq.InsertStrategy.NEW) mock_get.return_value = MockGet(cirq.to_json(ex_circuit_odd)) - sampler = _make_sampler() + sampler = _make_sampler(device) with pytest.raises(ValueError, match="Non-empty moment after measurement"): wrong_circuit = copy.deepcopy(ex_circuit) From ddc6bb7bacfc19cbbf17c4ebb169d75bef646d6e Mon Sep 17 00:00:00 2001 From: Michael Broughton Date: Fri, 14 Jan 2022 14:50:14 -0800 Subject: [PATCH 2/5] small cleanups. --- cirq-core/cirq/circuits/circuit.py | 6 +++--- cirq-core/cirq/circuits/circuit_dag.py | 2 +- cirq-core/cirq/circuits/circuit_dag_test.py | 6 +++--- cirq-core/cirq/circuits/circuit_test.py | 4 ++-- cirq-core/cirq/circuits/frozen_circuit.py | 12 ++++++------ cirq-core/cirq/circuits/frozen_circuit_test.py | 6 +++--- cirq-google/cirq_google/api/v1/programs_test.py | 2 -- .../optimizers/optimize_for_xmon_test.py | 1 - .../cirq_google/serialization/gate_sets_test.py | 2 +- .../serialization/serializable_gate_set.py | 8 -------- cirq-pasqal/cirq_pasqal/pasqal_device_test.py | 13 ------------- cirq-pasqal/cirq_pasqal/pasqal_sampler.py | 1 - 12 files changed, 19 insertions(+), 44 deletions(-) diff --git a/cirq-core/cirq/circuits/circuit.py b/cirq-core/cirq/circuits/circuit.py index 267194025a6..29194f28a9d 100644 --- a/cirq-core/cirq/circuits/circuit.py +++ b/cirq-core/cirq/circuits/circuit.py @@ -53,7 +53,7 @@ import numpy as np import cirq._version -from cirq import _compat, devices, ops, protocols, value, qis +from cirq import _compat, devices, ops, protocols, qis from cirq.circuits._bucket_priority_queue import BucketPriorityQueue from cirq.circuits.circuit_operation import CircuitOperation from cirq.circuits.insert_strategy import InsertStrategy @@ -1727,7 +1727,7 @@ def __init__( self._device = device self.append(contents, strategy=strategy) - @property + @property # type: ignore @_compat.deprecated( deadline='v0.15', fix=_DEVICE_DEP_MESSAGE, @@ -1735,7 +1735,7 @@ def __init__( def device(self) -> devices.Device: return self._device - @device.setter + @device.setter # type: ignore @_compat.deprecated( deadline='v0.15', fix=_DEVICE_DEP_MESSAGE, diff --git a/cirq-core/cirq/circuits/circuit_dag.py b/cirq-core/cirq/circuits/circuit_dag.py index 6c5bc2f1b3a..5d59e0ee2f2 100644 --- a/cirq-core/cirq/circuits/circuit_dag.py +++ b/cirq-core/cirq/circuits/circuit_dag.py @@ -100,7 +100,7 @@ def __init__( self.can_reorder = can_reorder self._device = device - @property + @property # type: ignore @_compat.deprecated( deadline='v0.15', fix=circuit._DEVICE_DEP_MESSAGE, diff --git a/cirq-core/cirq/circuits/circuit_dag_test.py b/cirq-core/cirq/circuits/circuit_dag_test.py index 99d34f5dc39..66f5e7da187 100644 --- a/cirq-core/cirq/circuits/circuit_dag_test.py +++ b/cirq-core/cirq/circuits/circuit_dag_test.py @@ -70,7 +70,7 @@ def test_init_device_deprecated(): with cirq.testing.assert_deprecated( cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' ): - dag = cirq.CircuitDag(device=cirq.UNCONSTRAINED_DEVICE) + _ = cirq.CircuitDag(device=cirq.UNCONSTRAINED_DEVICE) def test_device_deprecated(): @@ -78,7 +78,7 @@ def test_device_deprecated(): with cirq.testing.assert_deprecated( cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' ): - dev = dag.device + _ = dag.device def test_append(): @@ -119,7 +119,7 @@ def test_from_ops_device_deprecated(): cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' ): q0 = cirq.LineQubit(0) - dag = cirq.CircuitDag.from_ops(cirq.X(q0), cirq.Y(q0), device=cirq.UNCONSTRAINED_DEVICE) + _ = cirq.CircuitDag.from_ops(cirq.X(q0), cirq.Y(q0), device=cirq.UNCONSTRAINED_DEVICE) def test_from_circuit(): diff --git a/cirq-core/cirq/circuits/circuit_test.py b/cirq-core/cirq/circuits/circuit_test.py index f88bb2d81f3..ed69d5a17e2 100644 --- a/cirq-core/cirq/circuits/circuit_test.py +++ b/cirq-core/cirq/circuits/circuit_test.py @@ -16,6 +16,7 @@ from collections import defaultdict from random import randint, random, sample, randrange from typing import Iterator, Optional, Tuple, TYPE_CHECKING +from unittest import mock import numpy as np import pytest @@ -23,7 +24,6 @@ import cirq import cirq.testing -from unittest import mock from cirq import circuits from cirq import ops from cirq.testing.devices import ValidatingTestDevice @@ -4397,7 +4397,7 @@ def test_init_deprecated(circuit_cls): with cirq.testing.assert_deprecated( cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' ): - c = circuit_cls( + _ = circuit_cls( cirq.Moment([cirq.X(a)]), cirq.Moment([cirq.X(b)]), device=FOXY, diff --git a/cirq-core/cirq/circuits/frozen_circuit.py b/cirq-core/cirq/circuits/frozen_circuit.py index 4bb0b74176e..0b9d9dbc99d 100644 --- a/cirq-core/cirq/circuits/frozen_circuit.py +++ b/cirq-core/cirq/circuits/frozen_circuit.py @@ -25,16 +25,16 @@ Union, ) +from cirq.circuits import AbstractCircuit, Alignment, Circuit +from cirq.circuits.insert_strategy import InsertStrategy +from cirq.type_workarounds import NotImplementedType + import numpy as np -from cirq import _import, _compat, devices, ops, protocols, value +from cirq import _import, _compat, devices, ops, protocols circuit = _import.LazyLoader("circuit", globals(), "cirq.circuits.circuit") -from cirq.circuits import AbstractCircuit, Alignment, Circuit -from cirq.circuits.insert_strategy import InsertStrategy -from cirq.type_workarounds import NotImplementedType - if TYPE_CHECKING: import cirq @@ -97,7 +97,7 @@ def __init__( def moments(self) -> Sequence['cirq.Moment']: return self._moments - @property + @property # type: ignore @_compat.deprecated( deadline='v0.15', fix=circuit._DEVICE_DEP_MESSAGE, diff --git a/cirq-core/cirq/circuits/frozen_circuit_test.py b/cirq-core/cirq/circuits/frozen_circuit_test.py index 1065a121cf6..745094713ed 100644 --- a/cirq-core/cirq/circuits/frozen_circuit_test.py +++ b/cirq-core/cirq/circuits/frozen_circuit_test.py @@ -52,7 +52,7 @@ def test_init_device_deprecated(): with cirq.testing.assert_deprecated( cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' ): - a = cirq.FrozenCircuit(cirq.X(q), device=cirq.UNCONSTRAINED_DEVICE) + _ = cirq.FrozenCircuit(cirq.X(q), device=cirq.UNCONSTRAINED_DEVICE) def test_device_deprecated(): @@ -61,7 +61,7 @@ def test_device_deprecated(): with cirq.testing.assert_deprecated( cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' ): - b = a.device + _ = a.device def test_with_device_deprecated(): @@ -71,7 +71,7 @@ def test_with_device_deprecated(): cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' ): # one for frozencircuit.with_device and one for circuit.with_device. - b = a.with_device(cirq.UNCONSTRAINED_DEVICE) + _ = a.with_device(cirq.UNCONSTRAINED_DEVICE) def test_immutable(): diff --git a/cirq-google/cirq_google/api/v1/programs_test.py b/cirq-google/cirq_google/api/v1/programs_test.py index f5f9d786d17..4a1078c525e 100644 --- a/cirq-google/cirq_google/api/v1/programs_test.py +++ b/cirq-google/cirq_google/api/v1/programs_test.py @@ -15,8 +15,6 @@ import pytest import sympy -from unittest import mock - import cirq import cirq_google as cg import cirq_google.api.v1.programs as programs diff --git a/cirq-google/cirq_google/optimizers/optimize_for_xmon_test.py b/cirq-google/cirq_google/optimizers/optimize_for_xmon_test.py index 526f3636564..eed11197768 100644 --- a/cirq-google/cirq_google/optimizers/optimize_for_xmon_test.py +++ b/cirq-google/cirq_google/optimizers/optimize_for_xmon_test.py @@ -20,7 +20,6 @@ assert_circuits_with_terminal_measurements_are_equivalent, ) -from unittest import mock @pytest.mark.parametrize( 'n,d', diff --git a/cirq-google/cirq_google/serialization/gate_sets_test.py b/cirq-google/cirq_google/serialization/gate_sets_test.py index 132098bc126..91e80f525c0 100644 --- a/cirq-google/cirq_google/serialization/gate_sets_test.py +++ b/cirq-google/cirq_google/serialization/gate_sets_test.py @@ -23,7 +23,7 @@ import cirq import cirq_google as cg from cirq_google.api import v2 -from unittest import mock + def op_proto(json_dict: Dict) -> v2.program_pb2.Operation: op = v2.program_pb2.Operation() diff --git a/cirq-google/cirq_google/serialization/serializable_gate_set.py b/cirq-google/cirq_google/serialization/serializable_gate_set.py index edd21f56c52..985098b4eaa 100644 --- a/cirq-google/cirq_google/serialization/serializable_gate_set.py +++ b/cirq-google/cirq_google/serialization/serializable_gate_set.py @@ -329,17 +329,9 @@ def deserialize( deserialized_constants=deserialized_constants, ) if device is not None: -<<<<<<< HEAD - circuit._device = device - return circuit - if which == 'schedule': - # if device is None: - # raise ValueError('Deserializing schedule requires a device but None was given.') -======= circuit._device = device # coverage: ignore return circuit if which == 'schedule': ->>>>>>> master return self._deserialize_schedule( proto.schedule, device, arg_function_language=proto.language.arg_function_language ) diff --git a/cirq-pasqal/cirq_pasqal/pasqal_device_test.py b/cirq-pasqal/cirq_pasqal/pasqal_device_test.py index e1175e620ca..1e59407e458 100644 --- a/cirq-pasqal/cirq_pasqal/pasqal_device_test.py +++ b/cirq-pasqal/cirq_pasqal/pasqal_device_test.py @@ -18,9 +18,6 @@ import cirq import cirq_pasqal - -from unittest import mock - from cirq_pasqal import PasqalDevice, PasqalVirtualDevice from cirq_pasqal import TwoDQubit, ThreeDQubit @@ -195,16 +192,6 @@ def test_validate_operation_errors_deprecated(): circuit.append(cirq.measure(*d.qubits, invert_mask=(True, False, False))) -def test_validate_operation_errors_deprecated(): - d = generic_device(3) - circuit = cirq.Circuit() - circuit._device = d - with pytest.raises( - NotImplementedError, match="Measurements on Pasqal devices don't support invert_mask." - ): - circuit.append(cirq.measure(*d.qubits, invert_mask=(True, False, False))) - - def test_validate_moment(): d = square_virtual_device(control_r=1.0, num_qubits=2) m1 = cirq.Moment([cirq.Z.on(TwoDQubit(0, 0)), (cirq.X).on(TwoDQubit(1, 1))]) diff --git a/cirq-pasqal/cirq_pasqal/pasqal_sampler.py b/cirq-pasqal/cirq_pasqal/pasqal_sampler.py index cbcf0f50daa..2027a043057 100644 --- a/cirq-pasqal/cirq_pasqal/pasqal_sampler.py +++ b/cirq-pasqal/cirq_pasqal/pasqal_sampler.py @@ -21,7 +21,6 @@ class PasqalSampler(cirq.work.Sampler): - def __init__( self, remote_host: str, access_token: str = '', device: cirq_pasqal.PasqalDevice = None ) -> None: From c1d6519f058675151c4b694de0d7dd6ad46f502d Mon Sep 17 00:00:00 2001 From: Michael Broughton Date: Sat, 15 Jan 2022 14:14:17 -0800 Subject: [PATCH 3/5] small cleanup. --- cirq-core/cirq/circuits/circuit.py | 3 +- cirq-core/cirq/circuits/circuit_dag.py | 3 +- cirq-core/cirq/circuits/circuit_dag_test.py | 29 ++++++++++++++++++- cirq-core/cirq/circuits/circuit_test.py | 18 +++++++----- cirq-core/cirq/testing/devices_test.py | 2 +- .../cirq/testing/sample_circuits_test.py | 5 +++- .../serialization/gate_sets_test.py | 1 - 7 files changed, 48 insertions(+), 13 deletions(-) diff --git a/cirq-core/cirq/circuits/circuit.py b/cirq-core/cirq/circuits/circuit.py index 29194f28a9d..42cbb987009 100644 --- a/cirq-core/cirq/circuits/circuit.py +++ b/cirq-core/cirq/circuits/circuit.py @@ -2372,7 +2372,8 @@ def _resolve_parameters_( resolved_moments.append(new_moment) if self._device == devices.UNCONSTRAINED_DEVICE: return Circuit(resolved_moments) - return Circuit(resolved_moments, device=self._device) + with _block_overlapping_dep(): + return Circuit(resolved_moments, device=self._device) @property def moments(self): diff --git a/cirq-core/cirq/circuits/circuit_dag.py b/cirq-core/cirq/circuits/circuit_dag.py index 5d59e0ee2f2..1000e831b4d 100644 --- a/cirq-core/cirq/circuits/circuit_dag.py +++ b/cirq-core/cirq/circuits/circuit_dag.py @@ -138,7 +138,8 @@ def from_ops( if device == devices.UNCONSTRAINED_DEVICE: dag = CircuitDag(can_reorder=can_reorder) else: - dag = CircuitDag(can_reorder=can_reorder, device=device) + with circuit._block_overlapping_dep(): + dag = CircuitDag(can_reorder=can_reorder, device=device) for op in ops.flatten_op_tree(operations): dag.append(cast(ops.Operation, op)) diff --git a/cirq-core/cirq/circuits/circuit_dag_test.py b/cirq-core/cirq/circuits/circuit_dag_test.py index 66f5e7da187..38776e7953c 100644 --- a/cirq-core/cirq/circuits/circuit_dag_test.py +++ b/cirq-core/cirq/circuits/circuit_dag_test.py @@ -21,6 +21,11 @@ import cirq +class TestDevice(cirq.Device): + def __init__(self): + pass + + def test_wrapper_eq(): q0, q1 = cirq.LineQubit.range(2) eq = cirq.testing.EqualsTester() @@ -119,7 +124,7 @@ def test_from_ops_device_deprecated(): cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' ): q0 = cirq.LineQubit(0) - _ = cirq.CircuitDag.from_ops(cirq.X(q0), cirq.Y(q0), device=cirq.UNCONSTRAINED_DEVICE) + _ = cirq.CircuitDag.from_ops(cirq.X(q0), cirq.Y(q0), device=TestDevice()) def test_from_circuit(): @@ -132,6 +137,16 @@ def test_from_circuit(): assert sorted(circuit.all_qubits()) == sorted(dag.all_qubits()) +def test_from_circuit_deprecated(): + q0 = cirq.LineQubit(0) + circuit = cirq.Circuit(cirq.X(q0), cirq.Y(q0)) + circuit._device = TestDevice() + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + _ = cirq.CircuitDag.from_circuit(circuit) + + def test_to_empty_circuit(): circuit = cirq.Circuit() dag = cirq.CircuitDag.from_circuit(circuit) @@ -153,6 +168,18 @@ def test_to_circuit(): ) +def test_to_circuit_device_deprecated(): + q0 = cirq.LineQubit(0) + circuit = cirq.Circuit(cirq.X(q0), cirq.Y(q0)) + dag = cirq.CircuitDag.from_circuit(circuit) + dag._device = TestDevice() + + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + _ = dag.to_circuit() + + def test_equality(): q0, q1 = cirq.LineQubit.range(2) circuit1 = cirq.Circuit( diff --git a/cirq-core/cirq/circuits/circuit_test.py b/cirq-core/cirq/circuits/circuit_test.py index ed69d5a17e2..d08dc773ed6 100644 --- a/cirq-core/cirq/circuits/circuit_test.py +++ b/cirq-core/cirq/circuits/circuit_test.py @@ -92,8 +92,7 @@ def test_alignment(): assert repr(cirq.Alignment.RIGHT) == 'cirq.Alignment.RIGHT' -@mock.patch.dict(os.environ, clear='CIRQ_TESTING') -def test_insert_moment_types(): +def test_insert_moment_types_deprecated(): x = cirq.NamedQubit('x') with pytest.raises(ValueError): @@ -102,7 +101,10 @@ def test_insert_moment_types(): with pytest.raises(ValueError): moment_and_op_type_validating_device.validate_moment(cirq.X(x)) - circuit = cirq.Circuit(device=moment_and_op_type_validating_device) + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + circuit = cirq.Circuit(device=moment_and_op_type_validating_device) moment_or_operation_tree = [cirq.X(x), cirq.Moment([cirq.Y(x)])] circuit.insert(0, moment_or_operation_tree) @@ -202,7 +204,6 @@ def test_approx_eq(circuit_cls): ) -@mock.patch.dict(os.environ, clear='CIRQ_TESTING') @pytest.mark.parametrize('circuit_cls', [cirq.Circuit, cirq.FrozenCircuit]) def test_approx_eq_device_deprecated(circuit_cls): class TestDevice(cirq.Device): @@ -210,9 +211,13 @@ def validate_operation(self, operation: cirq.Operation) -> None: pass a = cirq.NamedQubit('a') + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + other_device = circuit_cls([cirq.Moment([cirq.X(a)])], device=TestDevice()) assert not cirq.approx_eq( circuit_cls([cirq.Moment([cirq.X(a)])]), - circuit_cls([cirq.Moment([cirq.X(a)])], device=TestDevice()), + other_device, ) @@ -3717,7 +3722,7 @@ def test_insert_operations_errors(): @mock.patch.dict(os.environ, clear='CIRQ_TESTING') -def test_validates_while_editing(): +def test_validates_while_editing_deprecated(): c = cirq.Circuit(device=FOXY) with pytest.raises(ValueError, match='Unsupported qubit type'): @@ -4282,7 +4287,6 @@ def test_moments_property(circuit_cls): assert c.moments[1] == cirq.Moment([cirq.Y(q)]) -@mock.patch.dict(os.environ, clear='CIRQ_TESTING') @pytest.mark.parametrize('circuit_cls', [cirq.Circuit, cirq.FrozenCircuit]) def test_json_dict(circuit_cls): q0, q1 = cirq.LineQubit.range(2) diff --git a/cirq-core/cirq/testing/devices_test.py b/cirq-core/cirq/testing/devices_test.py index 6d28232ea4c..57f276f929d 100644 --- a/cirq-core/cirq/testing/devices_test.py +++ b/cirq-core/cirq/testing/devices_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import os -import pytest from unittest import mock +import pytest import cirq from cirq.testing.devices import ValidatingTestDevice diff --git a/cirq-core/cirq/testing/sample_circuits_test.py b/cirq-core/cirq/testing/sample_circuits_test.py index 71459c81950..052b4bbaaa7 100644 --- a/cirq-core/cirq/testing/sample_circuits_test.py +++ b/cirq-core/cirq/testing/sample_circuits_test.py @@ -23,11 +23,14 @@ def test_nonoptimal_toffoli_circuit(): atol=1e-7, ) + def test_nonoptimal_toffoli_circuit_device_deprecated(): q0, q1, q2 = cirq.LineQubit.range(3) with cirq.testing.assert_deprecated('no longer include a device', deadline='v0.15'): cirq.testing.assert_allclose_up_to_global_phase( - cirq.testing.nonoptimal_toffoli_circuit(q0, q1, q2, cirq.UNCONSTRAINED_DEVICE).unitary(), + cirq.testing.nonoptimal_toffoli_circuit( + q0, q1, q2, cirq.UNCONSTRAINED_DEVICE + ).unitary(), cirq.unitary(cirq.TOFFOLI(q0, q1, q2)), atol=1e-7, ) diff --git a/cirq-google/cirq_google/serialization/gate_sets_test.py b/cirq-google/cirq_google/serialization/gate_sets_test.py index 91e80f525c0..8899f599b61 100644 --- a/cirq-google/cirq_google/serialization/gate_sets_test.py +++ b/cirq-google/cirq_google/serialization/gate_sets_test.py @@ -383,7 +383,6 @@ def test_deserialize_schedule_device_deprecated(): ] ), ) - print('WTF', cg.XMON.deserialize(serialized, cg.Bristlecone)) assert cg.XMON.deserialize(serialized, cg.Bristlecone) == circuit From 605fc81693602d994a0d575d3bcbae186c4813a3 Mon Sep 17 00:00:00 2001 From: Michael Broughton Date: Tue, 18 Jan 2022 12:26:54 -0800 Subject: [PATCH 4/5] Doug feedback. --- cirq-core/cirq/circuits/circuit.py | 8 +++--- cirq-core/cirq/circuits/circuit_dag.py | 10 ++++---- cirq-core/cirq/circuits/frozen_circuit.py | 31 +++++++++++++++++------ 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/cirq-core/cirq/circuits/circuit.py b/cirq-core/cirq/circuits/circuit.py index 42cbb987009..c2a5f56c068 100644 --- a/cirq-core/cirq/circuits/circuit.py +++ b/cirq-core/cirq/circuits/circuit.py @@ -74,7 +74,7 @@ @contextlib.contextmanager -def _block_overlapping_dep(): +def _block_overlapping_deprecation(): with warnings.catch_warnings(): warnings.filterwarnings( action='ignore', @@ -1885,7 +1885,7 @@ def with_device( Returns: The translated circuit. """ - with _block_overlapping_dep(): + with _block_overlapping_deprecation(): return Circuit( [ ops.Moment( @@ -1953,7 +1953,7 @@ def transform_qubits( if new_device is None and self._device == devices.UNCONSTRAINED_DEVICE: return Circuit(op_list) - with _block_overlapping_dep(): + with _block_overlapping_deprecation(): return Circuit(op_list, device=self._device if new_device is None else new_device) def _prev_moment_available(self, op: 'cirq.Operation', end_moment_index: int) -> Optional[int]: @@ -2372,7 +2372,7 @@ def _resolve_parameters_( resolved_moments.append(new_moment) if self._device == devices.UNCONSTRAINED_DEVICE: return Circuit(resolved_moments) - with _block_overlapping_dep(): + with _block_overlapping_deprecation(): return Circuit(resolved_moments, device=self._device) @property diff --git a/cirq-core/cirq/circuits/circuit_dag.py b/cirq-core/cirq/circuits/circuit_dag.py index 1000e831b4d..e5c10904e09 100644 --- a/cirq-core/cirq/circuits/circuit_dag.py +++ b/cirq-core/cirq/circuits/circuit_dag.py @@ -114,13 +114,13 @@ def make_node(op: 'cirq.Operation') -> Unique: @staticmethod def from_circuit( - qcircuit: circuit.Circuit, + circuit: circuit.Circuit, can_reorder: Callable[['cirq.Operation', 'cirq.Operation'], bool] = _disjoint_qubits, ) -> 'CircuitDag': - if qcircuit._device == devices.UNCONSTRAINED_DEVICE: - return CircuitDag.from_ops(qcircuit.all_operations(), can_reorder=can_reorder) + if circuit._device == devices.UNCONSTRAINED_DEVICE: + return CircuitDag.from_ops(circuit.all_operations(), can_reorder=can_reorder) return CircuitDag.from_ops( - qcircuit.all_operations(), can_reorder=can_reorder, device=qcircuit._device + circuit.all_operations(), can_reorder=can_reorder, device=circuit._device ) @staticmethod @@ -138,7 +138,7 @@ def from_ops( if device == devices.UNCONSTRAINED_DEVICE: dag = CircuitDag(can_reorder=can_reorder) else: - with circuit._block_overlapping_dep(): + with circuit._block_overlapping_deprecation(): dag = CircuitDag(can_reorder=can_reorder, device=device) for op in ops.flatten_op_tree(operations): diff --git a/cirq-core/cirq/circuits/frozen_circuit.py b/cirq-core/cirq/circuits/frozen_circuit.py index 0b9d9dbc99d..be1d6da52d3 100644 --- a/cirq-core/cirq/circuits/frozen_circuit.py +++ b/cirq-core/cirq/circuits/frozen_circuit.py @@ -24,6 +24,9 @@ Tuple, Union, ) +import contextlib +import warnings +import re from cirq.circuits import AbstractCircuit, Alignment, Circuit from cirq.circuits.insert_strategy import InsertStrategy @@ -31,15 +34,27 @@ import numpy as np -from cirq import _import, _compat, devices, ops, protocols - -circuit = _import.LazyLoader("circuit", globals(), "cirq.circuits.circuit") +from cirq import _compat, devices, ops, protocols if TYPE_CHECKING: import cirq +_DEVICE_DEP_MESSAGE = 'Attaching devices to circuits will no longer be supported.' + + +@contextlib.contextmanager +def _block_overlapping_deprecation(): + with warnings.catch_warnings(): + warnings.filterwarnings( + action='ignore', + category=DeprecationWarning, + message=f'(.|\n)*{re.escape(_DEVICE_DEP_MESSAGE)}(.|\n)*', + ) + yield + + class FrozenCircuit(AbstractCircuit, protocols.SerializableByKey): """An immutable version of the Circuit data structure. @@ -50,7 +65,7 @@ class FrozenCircuit(AbstractCircuit, protocols.SerializableByKey): @_compat.deprecated_parameter( deadline='v0.15', - fix=circuit._DEVICE_DEP_MESSAGE, + fix=_DEVICE_DEP_MESSAGE, parameter_desc='device', match=lambda args, kwargs: 'device' in kwargs, ) @@ -76,7 +91,7 @@ def __init__( if device == devices.UNCONSTRAINED_DEVICE: base = Circuit(contents, strategy=strategy) else: - with circuit._block_overlapping_dep(): + with _block_overlapping_deprecation(): base = Circuit(contents, strategy=strategy, device=device) self._moments = tuple(base.moments) @@ -100,7 +115,7 @@ def moments(self) -> Sequence['cirq.Moment']: @property # type: ignore @_compat.deprecated( deadline='v0.15', - fix=circuit._DEVICE_DEP_MESSAGE, + fix=_DEVICE_DEP_MESSAGE, ) def device(self) -> devices.Device: return self._device @@ -203,14 +218,14 @@ def _with_sliced_moments(self, moments: Iterable['cirq.Moment']) -> 'FrozenCircu @_compat.deprecated( deadline='v0.15', - fix=circuit._DEVICE_DEP_MESSAGE, + fix=_DEVICE_DEP_MESSAGE, ) def with_device( self, new_device: 'cirq.Device', qubit_mapping: Callable[['cirq.Qid'], 'cirq.Qid'] = lambda e: e, ) -> 'FrozenCircuit': - with circuit._block_overlapping_dep(): + with _block_overlapping_deprecation(): return self.unfreeze().with_device(new_device, qubit_mapping).freeze() def _resolve_parameters_( From 0a20ec4e7b45e4a7ae8db67802ed8156f2555dab Mon Sep 17 00:00:00 2001 From: Michael Broughton Date: Tue, 18 Jan 2022 14:52:54 -0800 Subject: [PATCH 5/5] Orion feedback. --- cirq-core/cirq/circuits/circuit.py | 11 +- cirq-core/cirq/circuits/circuit_test.py | 9 + .../protocols/json_test_data/Circuit.json | 15 +- .../json_test_data/Circuit.json_inward | 205 -- .../json_test_data/Circuit.repr_inward | 23 - .../json_test_data/CircuitOperation.json | 15 +- .../json_test_data/FrozenCircuit.json | 15 +- .../json_test_data/FrozenCircuit.json_inward | 231 -- .../json_test_data/FrozenCircuit.repr_inward | 23 - .../json_test_data/CalibrationLayer.json | 5 +- .../cirq.google.QuantumExecutable.json | 5 +- .../cirq.google.QuantumExecutable.json_inward | 873 ------ .../cirq.google.QuantumExecutable.repr_inward | 72 - .../cirq.google.QuantumExecutableGroup.json | 15 +- ....google.QuantumExecutableGroup.json_inward | 2654 ----------------- ....google.QuantumExecutableGroup.repr_inward | 221 -- 16 files changed, 73 insertions(+), 4319 deletions(-) delete mode 100644 cirq-core/cirq/protocols/json_test_data/Circuit.json_inward delete mode 100644 cirq-core/cirq/protocols/json_test_data/Circuit.repr_inward delete mode 100644 cirq-core/cirq/protocols/json_test_data/FrozenCircuit.json_inward delete mode 100644 cirq-core/cirq/protocols/json_test_data/FrozenCircuit.repr_inward delete mode 100644 cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.json_inward delete mode 100644 cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.repr_inward delete mode 100644 cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.json_inward delete mode 100644 cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.repr_inward diff --git a/cirq-core/cirq/circuits/circuit.py b/cirq-core/cirq/circuits/circuit.py index c2a5f56c068..bb298b823f8 100644 --- a/cirq-core/cirq/circuits/circuit.py +++ b/cirq-core/cirq/circuits/circuit.py @@ -1343,11 +1343,16 @@ def save_qasm( self._to_qasm_output(header, precision, qubit_order).save(file_path) def _json_dict_(self): - return protocols.obj_to_dict_helper(self, ['moments']) + ret = protocols.obj_to_dict_helper(self, ['moments', '_device']) + ret['device'] = ret['_device'] + del ret['_device'] + return ret @classmethod - def _from_json_dict_(cls, moments, **kwargs): - return cls(moments, strategy=InsertStrategy.EARLIEST) + def _from_json_dict_(cls, moments, device, **kwargs): + if device == cirq.UNCONSTRAINED_DEVICE: + return cls(moments, strategy=InsertStrategy.EARLIEST) + return cls(moments, device=device, strategy=InsertStrategy.EARLIEST) def zip( *circuits: 'cirq.AbstractCircuit', align: Union['cirq.Alignment', str] = Alignment.LEFT diff --git a/cirq-core/cirq/circuits/circuit_test.py b/cirq-core/cirq/circuits/circuit_test.py index d08dc773ed6..6739cc05836 100644 --- a/cirq-core/cirq/circuits/circuit_test.py +++ b/cirq-core/cirq/circuits/circuit_test.py @@ -4296,9 +4296,18 @@ def test_json_dict(circuit_cls): moments = tuple(moments) assert c._json_dict_() == { 'moments': moments, + 'device': cirq.UNCONSTRAINED_DEVICE, } +def test_from_json_device_deprecated(): + q0, q1 = cirq.GridQubit.rect(1, 2) + with cirq.testing.assert_deprecated( + cirq.circuits.circuit._DEVICE_DEP_MESSAGE, deadline='v0.15' + ): + _ = cirq.Circuit._from_json_dict_([cirq.CZ(q0, q1)], FOXY) + + def test_with_noise(): class Noise(cirq.NoiseModel): def noisy_operation(self, operation): diff --git a/cirq-core/cirq/protocols/json_test_data/Circuit.json b/cirq-core/cirq/protocols/json_test_data/Circuit.json index b6d3e24041a..ac467a20390 100644 --- a/cirq-core/cirq/protocols/json_test_data/Circuit.json +++ b/cirq-core/cirq/protocols/json_test_data/Circuit.json @@ -113,7 +113,10 @@ } ] } - ] + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } }, { "cirq_type": "Circuit", @@ -164,7 +167,10 @@ } ] } - ] + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } }, { "cirq_type": "Circuit", @@ -191,6 +197,9 @@ } ] } - ] + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } } ] \ No newline at end of file diff --git a/cirq-core/cirq/protocols/json_test_data/Circuit.json_inward b/cirq-core/cirq/protocols/json_test_data/Circuit.json_inward deleted file mode 100644 index ac467a20390..00000000000 --- a/cirq-core/cirq/protocols/json_test_data/Circuit.json_inward +++ /dev/null @@ -1,205 +0,0 @@ -[ - { - "cirq_type": "Circuit", - "moments": [ - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "MeasurementGate", - "num_qubits": 5, - "key": "0,1,2,3,4", - "invert_mask": [] - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - }, - { - "cirq_type": "LineQubit", - "x": 1 - }, - { - "cirq_type": "LineQubit", - "x": 2 - }, - { - "cirq_type": "LineQubit", - "x": 3 - }, - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - } - ] - } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } - }, - { - "cirq_type": "Circuit", - "moments": [ - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CCXPowGate", - "exponent": 1, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - }, - { - "cirq_type": "LineQubit", - "x": 1 - }, - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "XPowGate", - "exponent": 0.123, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - } - ] - } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } - }, - { - "cirq_type": "Circuit", - "moments": [ - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "XPowGate", - "exponent": { - "cirq_type": "sympy.Symbol", - "name": "theta" - }, - "global_shift": 0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - } - ] - } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } - } -] \ No newline at end of file diff --git a/cirq-core/cirq/protocols/json_test_data/Circuit.repr_inward b/cirq-core/cirq/protocols/json_test_data/Circuit.repr_inward deleted file mode 100644 index b4bad10bee8..00000000000 --- a/cirq-core/cirq/protocols/json_test_data/Circuit.repr_inward +++ /dev/null @@ -1,23 +0,0 @@ -[cirq.Circuit([ - cirq.Moment( - cirq.H(cirq.LineQubit(0)), - cirq.H(cirq.LineQubit(1)), - cirq.H(cirq.LineQubit(2)), - cirq.H(cirq.LineQubit(3)), - cirq.H(cirq.LineQubit(4)), - ), - cirq.Moment( - cirq.MeasurementGate(5, '0,1,2,3,4', ()).on(cirq.LineQubit(0), cirq.LineQubit(1), cirq.LineQubit(2), cirq.LineQubit(3), cirq.LineQubit(4)), - ), -]), cirq.Circuit([ - cirq.Moment( - cirq.TOFFOLI(cirq.LineQubit(0), cirq.LineQubit(1), cirq.LineQubit(2)), - ), - cirq.Moment( - (cirq.X**0.123).on(cirq.LineQubit(0)), - ), -]), cirq.Circuit([ - cirq.Moment( - (cirq.X**sympy.Symbol('theta')).on(cirq.LineQubit(0)), - ), -])] \ No newline at end of file diff --git a/cirq-core/cirq/protocols/json_test_data/CircuitOperation.json b/cirq-core/cirq/protocols/json_test_data/CircuitOperation.json index e0632b172c8..73b77c264db 100644 --- a/cirq-core/cirq/protocols/json_test_data/CircuitOperation.json +++ b/cirq-core/cirq/protocols/json_test_data/CircuitOperation.json @@ -118,7 +118,10 @@ } ] } - ] + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } } }, { @@ -146,7 +149,10 @@ } ] } - ] + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } } }, { @@ -177,7 +183,10 @@ } ] } - ] + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } } }, [ diff --git a/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.json b/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.json index 9e2f6722311..02e4cf78a6b 100644 --- a/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.json +++ b/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.json @@ -115,7 +115,10 @@ } ] } - ] + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } } }, { @@ -170,7 +173,10 @@ } ] } - ] + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } } }, { @@ -201,7 +207,10 @@ } ] } - ] + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } } }, [ diff --git a/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.json_inward b/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.json_inward deleted file mode 100644 index 02e4cf78a6b..00000000000 --- a/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.json_inward +++ /dev/null @@ -1,231 +0,0 @@ -{ - "cirq_type": "_ContextualSerialization", - "object_dag": [ - { - "cirq_type": "_SerializedContext", - "key": 1, - "obj": { - "cirq_type": "FrozenCircuit", - "moments": [ { "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "MeasurementGate", - "num_qubits": 5, - "key": "0,1,2,3,4", - "invert_mask": [] - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - }, - { - "cirq_type": "LineQubit", - "x": 1 - }, - { - "cirq_type": "LineQubit", - "x": 2 - }, - { - "cirq_type": "LineQubit", - "x": 3 - }, - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - } - ] - } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } - } - }, - { - "cirq_type": "_SerializedContext", - "key": 2, - "obj": { - "cirq_type": "FrozenCircuit", - "moments": [ - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CCXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - }, - { - "cirq_type": "LineQubit", - "x": 1 - }, - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "XPowGate", - "exponent": 0.123, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - } - ] - } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } - } - }, - { - "cirq_type": "_SerializedContext", - "key": 3, - "obj": { - "cirq_type": "FrozenCircuit", - "moments": [ - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "XPowGate", - "exponent": { - "cirq_type": "sympy.Symbol", - "name": "theta" - }, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - } - ] - } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } - } - }, - [ - { - "cirq_type": "_SerializedKey", - "key": 1 - }, - { - "cirq_type": "_SerializedKey", - "key": 2 - }, - { - "cirq_type": "_SerializedKey", - "key": 3 - } - ] - ] -} \ No newline at end of file diff --git a/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.repr_inward b/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.repr_inward deleted file mode 100644 index 0bc98a8f705..00000000000 --- a/cirq-core/cirq/protocols/json_test_data/FrozenCircuit.repr_inward +++ /dev/null @@ -1,23 +0,0 @@ -[cirq.FrozenCircuit([ - cirq.Moment( - cirq.H(cirq.LineQubit(0)), - cirq.H(cirq.LineQubit(1)), - cirq.H(cirq.LineQubit(2)), - cirq.H(cirq.LineQubit(3)), - cirq.H(cirq.LineQubit(4)), - ), - cirq.Moment( - cirq.MeasurementGate(5, '0,1,2,3,4', ()).on(cirq.LineQubit(0), cirq.LineQubit(1), cirq.LineQubit(2), cirq.LineQubit(3), cirq.LineQubit(4)), - ), -]), cirq.FrozenCircuit([ - cirq.Moment( - cirq.TOFFOLI(cirq.LineQubit(0), cirq.LineQubit(1), cirq.LineQubit(2)), - ), - cirq.Moment( - (cirq.X**0.123).on(cirq.LineQubit(0)), - ), -]), cirq.FrozenCircuit([ - cirq.Moment( - (cirq.X**sympy.Symbol('theta')).on(cirq.LineQubit(0)), - ), -])] \ No newline at end of file diff --git a/cirq-google/cirq_google/json_test_data/CalibrationLayer.json b/cirq-google/cirq_google/json_test_data/CalibrationLayer.json index e884d09d166..44934e78477 100644 --- a/cirq-google/cirq_google/json_test_data/CalibrationLayer.json +++ b/cirq-google/cirq_google/json_test_data/CalibrationLayer.json @@ -22,7 +22,10 @@ } ] } - ] + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } }, "args": { "type": "full", diff --git a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.json b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.json index 6ee36ec4696..5710d73d654 100644 --- a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.json +++ b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.json @@ -839,7 +839,10 @@ } ] } - ] + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } } }, { diff --git a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.json_inward b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.json_inward deleted file mode 100644 index 5710d73d654..00000000000 --- a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.json_inward +++ /dev/null @@ -1,873 +0,0 @@ -{ - "cirq_type": "_ContextualSerialization", - "object_dag": [ - { - "cirq_type": "_SerializedContext", - "key": 1, - "obj": { - "cirq_type": "FrozenCircuit", - "moments": [ - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 8 - }, - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 7 - }, - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 6 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - }, - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 6 - }, - { - "cirq_type": "LineQubit", - "x": 5 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - }, - { - "cirq_type": "LineQubit", - "x": 8 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 7 - } - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CZPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 6 - }, - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliX", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 1 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - }, - { - "cirq_type": "LineQubit", - "x": 5 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - }, - { - "cirq_type": "LineQubit", - "x": 8 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 7 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 5 - }, - { - "cirq_type": "LineQubit", - "x": 6 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 9 - }, - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 7 - }, - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 6 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - }, - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 8 - } - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 6 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 5 - }, - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 8 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - }, - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 1 - } - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - }, - { - "cirq_type": "LineQubit", - "x": 5 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 6 - }, - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - }, - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 8 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - }, - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 5 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - }, - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 7 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 6 - }, - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - }, - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 8 - }, - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 7 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - }, - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 9 - }, - { - "cirq_type": "LineQubit", - "x": 6 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliX", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 9 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliX", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 7 - } - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 0 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 6 - }, - { - "cirq_type": "LineQubit", - "x": 8 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - }, - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - } - ] - } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } - } - }, - { - "cirq_type": "cirq.google.QuantumExecutable", - "circuit": { - "cirq_type": "_SerializedKey", - "key": 1 - }, - "measurement": { - "cirq_type": "cirq.google.BitstringsMeasurement", - "n_repetitions": 10 - }, - "params": [], - "spec": { - "cirq_type": "cirq.google.KeyValueExecutableSpec", - "executable_family": "cirq_google.algo_benchmarks.example", - "key_value_pairs": [ - [ - "name", - "example-program" - ] - ] - }, - "problem_topology": null, - "initial_state": null - } - ] -} \ No newline at end of file diff --git a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.repr_inward b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.repr_inward deleted file mode 100644 index 74bb8e19f5b..00000000000 --- a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutable.repr_inward +++ /dev/null @@ -1,72 +0,0 @@ -cirq_google.QuantumExecutable(circuit=cirq.FrozenCircuit([ - cirq.Moment( - cirq.SWAP(cirq.LineQubit(8), cirq.LineQubit(1)), - cirq.ISWAP(cirq.LineQubit(7), cirq.LineQubit(3)), - cirq.S(cirq.LineQubit(6)), - ), - cirq.Moment( - cirq.CNOT(cirq.LineQubit(3), cirq.LineQubit(0)), - cirq.CNOT(cirq.LineQubit(6), cirq.LineQubit(5)), - cirq.CNOT(cirq.LineQubit(1), cirq.LineQubit(8)), - cirq.Z(cirq.LineQubit(7)), - ), - cirq.Moment( - cirq.T(cirq.LineQubit(2)), - cirq.CZ(cirq.LineQubit(6), cirq.LineQubit(9)), - cirq.X(cirq.LineQubit(1)), - cirq.H(cirq.LineQubit(4)), - cirq.CNOT(cirq.LineQubit(0), cirq.LineQubit(5)), - ), - cirq.Moment( - cirq.SWAP(cirq.LineQubit(3), cirq.LineQubit(8)), - cirq.Z(cirq.LineQubit(7)), - cirq.T(cirq.LineQubit(4)), - cirq.CNOT(cirq.LineQubit(5), cirq.LineQubit(6)), - cirq.T(cirq.LineQubit(1)), - cirq.CNOT(cirq.LineQubit(9), cirq.LineQubit(0)), - ), - cirq.Moment( - cirq.CNOT(cirq.LineQubit(7), cirq.LineQubit(3)), - cirq.T(cirq.LineQubit(6)), - cirq.CNOT(cirq.LineQubit(4), cirq.LineQubit(1)), - cirq.Z(cirq.LineQubit(8)), - ), - cirq.Moment( - cirq.Y(cirq.LineQubit(6)), - cirq.SWAP(cirq.LineQubit(5), cirq.LineQubit(0)), - cirq.H(cirq.LineQubit(9)), - cirq.S(cirq.LineQubit(4)), - cirq.S(cirq.LineQubit(8)), - cirq.SWAP(cirq.LineQubit(3), cirq.LineQubit(2)), - cirq.Y(cirq.LineQubit(1)), - ), - cirq.Moment( - cirq.ISWAP(cirq.LineQubit(3), cirq.LineQubit(5)), - cirq.ISWAP(cirq.LineQubit(6), cirq.LineQubit(2)), - cirq.SWAP(cirq.LineQubit(4), cirq.LineQubit(0)), - cirq.T(cirq.LineQubit(8)), - cirq.CNOT(cirq.LineQubit(1), cirq.LineQubit(9)), - ), - cirq.Moment( - cirq.H(cirq.LineQubit(5)), - cirq.SWAP(cirq.LineQubit(0), cirq.LineQubit(3)), - cirq.Z(cirq.LineQubit(7)), - cirq.ISWAP(cirq.LineQubit(6), cirq.LineQubit(9)), - cirq.CNOT(cirq.LineQubit(1), cirq.LineQubit(2)), - ), - cirq.Moment( - cirq.SWAP(cirq.LineQubit(8), cirq.LineQubit(2)), - cirq.Y(cirq.LineQubit(7)), - cirq.CNOT(cirq.LineQubit(3), cirq.LineQubit(0)), - cirq.CNOT(cirq.LineQubit(9), cirq.LineQubit(6)), - ), - cirq.Moment( - cirq.X(cirq.LineQubit(9)), - cirq.T(cirq.LineQubit(1)), - cirq.X(cirq.LineQubit(7)), - cirq.Z(cirq.LineQubit(0)), - cirq.ISWAP(cirq.LineQubit(6), cirq.LineQubit(8)), - cirq.ISWAP(cirq.LineQubit(3), cirq.LineQubit(4)), - cirq.T(cirq.LineQubit(2)), - ), -]), measurement=cirq_google.BitstringsMeasurement(n_repetitions=10), params=(), spec=cirq_google.KeyValueExecutableSpec(executable_family='cirq_google.algo_benchmarks.example', key_value_pairs=(('name', 'example-program'),)), problem_topology=None, initial_state=None) diff --git a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.json b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.json index 577b2507e5d..7a01a7f9a47 100644 --- a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.json +++ b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.json @@ -881,7 +881,10 @@ } ] } - ] + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } } }, { @@ -1766,7 +1769,10 @@ } ] } - ] + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } } }, { @@ -2561,7 +2567,10 @@ } ] } - ] + ], + "device": { + "cirq_type": "_UnconstrainedDevice" + } } }, { diff --git a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.json_inward b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.json_inward deleted file mode 100644 index 7a01a7f9a47..00000000000 --- a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.json_inward +++ /dev/null @@ -1,2654 +0,0 @@ -{ - "cirq_type": "_ContextualSerialization", - "object_dag": [ - { - "cirq_type": "_SerializedContext", - "key": 1, - "obj": { - "cirq_type": "FrozenCircuit", - "moments": [ - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - }, - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 7 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 6 - }, - { - "cirq_type": "LineQubit", - "x": 8 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 5 - }, - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - }, - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliX", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 5 - } - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 3 - } - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 9 - } - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 1 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CZPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - }, - { - "cirq_type": "LineQubit", - "x": 7 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 8 - }, - { - "cirq_type": "LineQubit", - "x": 6 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 6 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 9 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 5 - }, - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 7 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - }, - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 4 - } - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 7 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 9 - }, - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 5 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 2 - }, - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliX", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 3 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 6 - }, - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliX", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 0 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 7 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 8 - }, - { - "cirq_type": "LineQubit", - "x": 5 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - }, - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 8 - }, - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 6 - }, - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 5 - }, - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - }, - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 6 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 2 - }, - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliX", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 8 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 7 - }, - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 9 - }, - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 7 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CZPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 8 - }, - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CZPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 6 - }, - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 6 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - }, - { - "cirq_type": "LineQubit", - "x": 8 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 5 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 7 - }, - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - } - ] - } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } - } - }, - { - "cirq_type": "_SerializedContext", - "key": 2, - "obj": { - "cirq_type": "FrozenCircuit", - "moments": [ - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 2 - }, - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 0 - } - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliX", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 4 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 7 - }, - { - "cirq_type": "LineQubit", - "x": 8 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 5 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 0 - } - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 6 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - }, - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 7 - }, - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliX", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 7 - } - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 3 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 6 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - }, - { - "cirq_type": "LineQubit", - "x": 5 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 8 - }, - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliX", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 9 - } - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 2 - } - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliX", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 3 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CZPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 5 - }, - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliX", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 6 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 7 - }, - { - "cirq_type": "LineQubit", - "x": 8 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 7 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - }, - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 6 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 5 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - }, - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 8 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CZPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 5 - }, - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 7 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 8 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 5 - }, - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - }, - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 7 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - }, - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 5 - }, - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 6 - } - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 5 - } - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliX", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 7 - } - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 1 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 9 - }, - { - "cirq_type": "LineQubit", - "x": 8 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - }, - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - }, - { - "cirq_type": "LineQubit", - "x": 5 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CZPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 8 - }, - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - } - ] - } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } - } - }, - { - "cirq_type": "_SerializedContext", - "key": 3, - "obj": { - "cirq_type": "FrozenCircuit", - "moments": [ - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 4 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - }, - { - "cirq_type": "LineQubit", - "x": 7 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliX", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 5 - } - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 9 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 8 - } - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 6 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 2 - }, - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - }, - { - "cirq_type": "LineQubit", - "x": 5 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 2 - }, - { - "cirq_type": "LineQubit", - "x": 8 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - }, - { - "cirq_type": "LineQubit", - "x": 6 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 8 - }, - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CZPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - }, - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliX", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 1 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 6 - }, - { - "cirq_type": "LineQubit", - "x": 7 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CZPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - }, - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - }, - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 9 - }, - { - "cirq_type": "LineQubit", - "x": 8 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 7 - }, - { - "cirq_type": "LineQubit", - "x": 6 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CZPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - }, - { - "cirq_type": "LineQubit", - "x": 5 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 9 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.5, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 5 - }, - { - "cirq_type": "LineQubit", - "x": 6 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 6 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 5 - }, - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 8 - }, - { - "cirq_type": "LineQubit", - "x": 1 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 7 - }, - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ZPowGate", - "exponent": 0.25, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 7 - }, - { - "cirq_type": "LineQubit", - "x": 5 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CZPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 3 - }, - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 9 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 1 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 7 - }, - { - "cirq_type": "LineQubit", - "x": 6 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - }, - { - "cirq_type": "LineQubit", - "x": 2 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliY", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 5 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "SwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 0 - }, - { - "cirq_type": "LineQubit", - "x": 8 - } - ] - } - ] - }, - { - "cirq_type": "Moment", - "operations": [ - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CXPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 9 - }, - { - "cirq_type": "LineQubit", - "x": 5 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 1 - }, - { - "cirq_type": "LineQubit", - "x": 6 - } - ] - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "CZPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 4 - }, - { - "cirq_type": "LineQubit", - "x": 7 - } - ] - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 2 - } - }, - { - "cirq_type": "SingleQubitPauliStringGateOperation", - "pauli": { - "cirq_type": "_PauliZ", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubit": { - "cirq_type": "LineQubit", - "x": 0 - } - }, - { - "cirq_type": "GateOperation", - "gate": { - "cirq_type": "HPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "qubits": [ - { - "cirq_type": "LineQubit", - "x": 8 - } - ] - } - ] - } - ], - "device": { - "cirq_type": "_UnconstrainedDevice" - } - } - }, - { - "cirq_type": "cirq.google.QuantumExecutableGroup", - "executables": [ - { - "cirq_type": "cirq.google.QuantumExecutable", - "circuit": { - "cirq_type": "_SerializedKey", - "key": 1 - }, - "measurement": { - "cirq_type": "cirq.google.BitstringsMeasurement", - "n_repetitions": 10 - }, - "params": [], - "spec": { - "cirq_type": "cirq.google.KeyValueExecutableSpec", - "executable_family": "cirq_google.algo_benchmarks.example", - "key_value_pairs": [ - [ - "name", - "example-program-0" - ] - ] - }, - "problem_topology": null, - "initial_state": null - }, - { - "cirq_type": "cirq.google.QuantumExecutable", - "circuit": { - "cirq_type": "_SerializedKey", - "key": 2 - }, - "measurement": { - "cirq_type": "cirq.google.BitstringsMeasurement", - "n_repetitions": 10 - }, - "params": [], - "spec": { - "cirq_type": "cirq.google.KeyValueExecutableSpec", - "executable_family": "cirq_google.algo_benchmarks.example", - "key_value_pairs": [ - [ - "name", - "example-program-1" - ] - ] - }, - "problem_topology": null, - "initial_state": null - }, - { - "cirq_type": "cirq.google.QuantumExecutable", - "circuit": { - "cirq_type": "_SerializedKey", - "key": 3 - }, - "measurement": { - "cirq_type": "cirq.google.BitstringsMeasurement", - "n_repetitions": 10 - }, - "params": [], - "spec": { - "cirq_type": "cirq.google.KeyValueExecutableSpec", - "executable_family": "cirq_google.algo_benchmarks.example", - "key_value_pairs": [ - [ - "name", - "example-program-2" - ] - ] - }, - "problem_topology": null, - "initial_state": null - } - ] - } - ] -} \ No newline at end of file diff --git a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.repr_inward b/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.repr_inward deleted file mode 100644 index 6038a348d18..00000000000 --- a/cirq-google/cirq_google/json_test_data/cirq.google.QuantumExecutableGroup.repr_inward +++ /dev/null @@ -1,221 +0,0 @@ -cirq_google.QuantumExecutableGroup(executables=(cirq_google.QuantumExecutable(circuit=cirq.FrozenCircuit([ - cirq.Moment( - cirq.SWAP(cirq.LineQubit(4), cirq.LineQubit(9)), - cirq.Y(cirq.LineQubit(7)), - cirq.CNOT(cirq.LineQubit(6), cirq.LineQubit(8)), - cirq.ISWAP(cirq.LineQubit(5), cirq.LineQubit(1)), - cirq.CNOT(cirq.LineQubit(0), cirq.LineQubit(3)), - ), - cirq.Moment( - cirq.X(cirq.LineQubit(5)), - cirq.Y(cirq.LineQubit(3)), - cirq.Z(cirq.LineQubit(9)), - cirq.Z(cirq.LineQubit(1)), - cirq.S(cirq.LineQubit(2)), - cirq.S(cirq.LineQubit(0)), - cirq.CZ(cirq.LineQubit(4), cirq.LineQubit(7)), - cirq.SWAP(cirq.LineQubit(8), cirq.LineQubit(6)), - ), - cirq.Moment( - cirq.H(cirq.LineQubit(6)), - cirq.Z(cirq.LineQubit(9)), - cirq.ISWAP(cirq.LineQubit(5), cirq.LineQubit(1)), - cirq.Z(cirq.LineQubit(7)), - cirq.H(cirq.LineQubit(2)), - cirq.ISWAP(cirq.LineQubit(0), cirq.LineQubit(3)), - cirq.Y(cirq.LineQubit(4)), - ), - cirq.Moment( - cirq.H(cirq.LineQubit(1)), - cirq.S(cirq.LineQubit(7)), - cirq.CNOT(cirq.LineQubit(9), cirq.LineQubit(3)), - cirq.T(cirq.LineQubit(0)), - cirq.T(cirq.LineQubit(5)), - ), - cirq.Moment( - cirq.T(cirq.LineQubit(1)), - cirq.SWAP(cirq.LineQubit(2), cirq.LineQubit(4)), - cirq.X(cirq.LineQubit(3)), - cirq.H(cirq.LineQubit(9)), - ), - cirq.Moment( - cirq.SWAP(cirq.LineQubit(6), cirq.LineQubit(1)), - cirq.X(cirq.LineQubit(0)), - cirq.H(cirq.LineQubit(7)), - cirq.SWAP(cirq.LineQubit(8), cirq.LineQubit(5)), - cirq.SWAP(cirq.LineQubit(4), cirq.LineQubit(9)), - ), - cirq.Moment( - cirq.T(cirq.LineQubit(0)), - cirq.SWAP(cirq.LineQubit(8), cirq.LineQubit(9)), - cirq.ISWAP(cirq.LineQubit(6), cirq.LineQubit(4)), - cirq.CNOT(cirq.LineQubit(5), cirq.LineQubit(3)), - ), - cirq.Moment( - cirq.CNOT(cirq.LineQubit(1), cirq.LineQubit(3)), - cirq.S(cirq.LineQubit(6)), - cirq.ISWAP(cirq.LineQubit(2), cirq.LineQubit(9)), - cirq.X(cirq.LineQubit(8)), - cirq.CNOT(cirq.LineQubit(7), cirq.LineQubit(0)), - ), - cirq.Moment( - cirq.ISWAP(cirq.LineQubit(9), cirq.LineQubit(2)), - cirq.Z(cirq.LineQubit(7)), - cirq.H(cirq.LineQubit(3)), - cirq.T(cirq.LineQubit(0)), - cirq.CZ(cirq.LineQubit(8), cirq.LineQubit(1)), - cirq.CZ(cirq.LineQubit(6), cirq.LineQubit(4)), - ), - cirq.Moment( - cirq.Y(cirq.LineQubit(6)), - cirq.S(cirq.LineQubit(1)), - cirq.ISWAP(cirq.LineQubit(0), cirq.LineQubit(8)), - cirq.Y(cirq.LineQubit(5)), - cirq.CNOT(cirq.LineQubit(7), cirq.LineQubit(4)), - ), -]), measurement=cirq_google.BitstringsMeasurement(n_repetitions=10), params=(), spec=cirq_google.KeyValueExecutableSpec(executable_family='cirq_google.algo_benchmarks.example', key_value_pairs=(('name', 'example-program-0'),)), problem_topology=None, initial_state=None), cirq_google.QuantumExecutable(circuit=cirq.FrozenCircuit([ - cirq.Moment( - cirq.SWAP(cirq.LineQubit(2), cirq.LineQubit(3)), - cirq.H(cirq.LineQubit(1)), - cirq.H(cirq.LineQubit(9)), - cirq.Y(cirq.LineQubit(0)), - cirq.X(cirq.LineQubit(4)), - cirq.ISWAP(cirq.LineQubit(7), cirq.LineQubit(8)), - ), - cirq.Moment( - cirq.S(cirq.LineQubit(5)), - cirq.Z(cirq.LineQubit(0)), - cirq.Y(cirq.LineQubit(6)), - cirq.CNOT(cirq.LineQubit(4), cirq.LineQubit(3)), - cirq.SWAP(cirq.LineQubit(7), cirq.LineQubit(1)), - cirq.S(cirq.LineQubit(9)), - ), - cirq.Moment( - cirq.X(cirq.LineQubit(7)), - cirq.Y(cirq.LineQubit(3)), - cirq.H(cirq.LineQubit(4)), - cirq.T(cirq.LineQubit(6)), - cirq.SWAP(cirq.LineQubit(0), cirq.LineQubit(5)), - cirq.CNOT(cirq.LineQubit(8), cirq.LineQubit(1)), - cirq.X(cirq.LineQubit(9)), - ), - cirq.Moment( - cirq.Z(cirq.LineQubit(2)), - cirq.X(cirq.LineQubit(3)), - cirq.CZ(cirq.LineQubit(5), cirq.LineQubit(1)), - cirq.S(cirq.LineQubit(4)), - cirq.X(cirq.LineQubit(6)), - cirq.ISWAP(cirq.LineQubit(7), cirq.LineQubit(8)), - ), - cirq.Moment( - cirq.H(cirq.LineQubit(7)), - cirq.ISWAP(cirq.LineQubit(4), cirq.LineQubit(0)), - cirq.S(cirq.LineQubit(3)), - cirq.Y(cirq.LineQubit(6)), - cirq.S(cirq.LineQubit(1)), - cirq.T(cirq.LineQubit(2)), - cirq.T(cirq.LineQubit(5)), - ), - cirq.Moment( - cirq.CNOT(cirq.LineQubit(4), cirq.LineQubit(9)), - cirq.S(cirq.LineQubit(1)), - cirq.T(cirq.LineQubit(3)), - cirq.Y(cirq.LineQubit(8)), - cirq.CZ(cirq.LineQubit(5), cirq.LineQubit(2)), - ), - cirq.Moment( - cirq.Z(cirq.LineQubit(7)), - cirq.H(cirq.LineQubit(8)), - cirq.ISWAP(cirq.LineQubit(5), cirq.LineQubit(9)), - cirq.H(cirq.LineQubit(0)), - cirq.CNOT(cirq.LineQubit(1), cirq.LineQubit(4)), - ), - cirq.Moment( - cirq.H(cirq.LineQubit(7)), - cirq.CNOT(cirq.LineQubit(1), cirq.LineQubit(0)), - cirq.CNOT(cirq.LineQubit(5), cirq.LineQubit(4)), - ), - cirq.Moment( - cirq.H(cirq.LineQubit(3)), - cirq.Y(cirq.LineQubit(6)), - cirq.Z(cirq.LineQubit(5)), - cirq.X(cirq.LineQubit(7)), - cirq.Z(cirq.LineQubit(1)), - cirq.S(cirq.LineQubit(2)), - cirq.CNOT(cirq.LineQubit(9), cirq.LineQubit(8)), - cirq.H(cirq.LineQubit(4)), - ), - cirq.Moment( - cirq.ISWAP(cirq.LineQubit(1), cirq.LineQubit(0)), - cirq.SWAP(cirq.LineQubit(4), cirq.LineQubit(5)), - cirq.CZ(cirq.LineQubit(8), cirq.LineQubit(9)), - ), -]), measurement=cirq_google.BitstringsMeasurement(n_repetitions=10), params=(), spec=cirq_google.KeyValueExecutableSpec(executable_family='cirq_google.algo_benchmarks.example', key_value_pairs=(('name', 'example-program-1'),)), problem_topology=None, initial_state=None), cirq_google.QuantumExecutable(circuit=cirq.FrozenCircuit([ - cirq.Moment( - cirq.Y(cirq.LineQubit(4)), - cirq.SWAP(cirq.LineQubit(1), cirq.LineQubit(7)), - cirq.X(cirq.LineQubit(5)), - cirq.Y(cirq.LineQubit(9)), - cirq.H(cirq.LineQubit(0)), - cirq.Y(cirq.LineQubit(8)), - cirq.Y(cirq.LineQubit(6)), - cirq.SWAP(cirq.LineQubit(2), cirq.LineQubit(3)), - ), - cirq.Moment( - cirq.ISWAP(cirq.LineQubit(1), cirq.LineQubit(5)), - cirq.S(cirq.LineQubit(4)), - cirq.SWAP(cirq.LineQubit(2), cirq.LineQubit(8)), - ), - cirq.Moment( - cirq.SWAP(cirq.LineQubit(0), cirq.LineQubit(6)), - cirq.CNOT(cirq.LineQubit(8), cirq.LineQubit(4)), - cirq.CZ(cirq.LineQubit(3), cirq.LineQubit(1)), - ), - cirq.Moment( - cirq.X(cirq.LineQubit(1)), - cirq.ISWAP(cirq.LineQubit(6), cirq.LineQubit(7)), - cirq.CZ(cirq.LineQubit(0), cirq.LineQubit(9)), - ), - cirq.Moment( - cirq.ISWAP(cirq.LineQubit(3), cirq.LineQubit(1)), - cirq.CNOT(cirq.LineQubit(9), cirq.LineQubit(8)), - cirq.SWAP(cirq.LineQubit(7), cirq.LineQubit(6)), - cirq.CZ(cirq.LineQubit(0), cirq.LineQubit(5)), - cirq.S(cirq.LineQubit(4)), - ), - cirq.Moment( - cirq.T(cirq.LineQubit(2)), - cirq.Y(cirq.LineQubit(9)), - cirq.S(cirq.LineQubit(3)), - cirq.SWAP(cirq.LineQubit(5), cirq.LineQubit(6)), - ), - cirq.Moment( - cirq.H(cirq.LineQubit(6)), - cirq.H(cirq.LineQubit(0)), - cirq.CNOT(cirq.LineQubit(5), cirq.LineQubit(9)), - cirq.H(cirq.LineQubit(3)), - cirq.ISWAP(cirq.LineQubit(8), cirq.LineQubit(1)), - cirq.ISWAP(cirq.LineQubit(7), cirq.LineQubit(2)), - ), - cirq.Moment( - cirq.T(cirq.LineQubit(0)), - cirq.ISWAP(cirq.LineQubit(7), cirq.LineQubit(5)), - cirq.CZ(cirq.LineQubit(3), cirq.LineQubit(9)), - ), - cirq.Moment( - cirq.H(cirq.LineQubit(9)), - cirq.Y(cirq.LineQubit(1)), - cirq.ISWAP(cirq.LineQubit(7), cirq.LineQubit(6)), - cirq.ISWAP(cirq.LineQubit(4), cirq.LineQubit(2)), - cirq.Y(cirq.LineQubit(5)), - cirq.SWAP(cirq.LineQubit(0), cirq.LineQubit(8)), - ), - cirq.Moment( - cirq.CNOT(cirq.LineQubit(9), cirq.LineQubit(5)), - cirq.ISWAP(cirq.LineQubit(1), cirq.LineQubit(6)), - cirq.CZ(cirq.LineQubit(4), cirq.LineQubit(7)), - cirq.Z(cirq.LineQubit(2)), - cirq.Z(cirq.LineQubit(0)), - cirq.H(cirq.LineQubit(8)), - ), -]), measurement=cirq_google.BitstringsMeasurement(n_repetitions=10), params=(), spec=cirq_google.KeyValueExecutableSpec(executable_family='cirq_google.algo_benchmarks.example', key_value_pairs=(('name', 'example-program-2'),)), problem_topology=None, initial_state=None)))