From 55c592beeb16ea1c23a81514a2de0e52b728f6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Doreau?= <32459935+ayshiff@users.noreply.github.com> Date: Sun, 19 Jan 2025 15:49:07 +0200 Subject: [PATCH] [cleanup] Remove unused `GridParallelXEBMetadata` class (#6909) The `GridParallelXEBMetadata` class is not being used anywhere in the codebase. Fixes #6601 --- .../grid_parallel_two_qubit_xeb.py | 62 --------- .../grid_parallel_two_qubit_xeb_test.py | 28 ----- cirq-core/cirq/json_resolver_cache.py | 2 - .../GridParallelXEBMetadata.json | 119 ------------------ .../GridParallelXEBMetadata.repr | 1 - 5 files changed, 212 deletions(-) delete mode 100644 cirq-core/cirq/experiments/grid_parallel_two_qubit_xeb.py delete mode 100644 cirq-core/cirq/experiments/grid_parallel_two_qubit_xeb_test.py delete mode 100644 cirq-core/cirq/protocols/json_test_data/GridParallelXEBMetadata.json delete mode 100644 cirq-core/cirq/protocols/json_test_data/GridParallelXEBMetadata.repr diff --git a/cirq-core/cirq/experiments/grid_parallel_two_qubit_xeb.py b/cirq-core/cirq/experiments/grid_parallel_two_qubit_xeb.py deleted file mode 100644 index 4d00b5ec277..00000000000 --- a/cirq-core/cirq/experiments/grid_parallel_two_qubit_xeb.py +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright 2020 The Cirq Developers -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -"""Remnants of Parallel two-qubit cross-entropy benchmarking on a grid. - -This module keeps GridParallelXEBMetadata around for JSON backwards compatibility. -""" -import dataclasses -from typing import Optional, Sequence, TYPE_CHECKING -from cirq.experiments.random_quantum_circuit_generation import GridInteractionLayer -from cirq import protocols - -if TYPE_CHECKING: - import cirq - - -LAYER_A = GridInteractionLayer(col_offset=0, vertical=True, stagger=True) -LAYER_B = GridInteractionLayer(col_offset=1, vertical=True, stagger=True) -LAYER_C = GridInteractionLayer(col_offset=1, vertical=False, stagger=True) -LAYER_D = GridInteractionLayer(col_offset=0, vertical=False, stagger=True) - - -@dataclasses.dataclass -class GridParallelXEBMetadata: - """Metadata for a grid parallel XEB experiment. - Attributes: - data_collection_id: The data collection ID of the experiment. - """ - - qubits: Sequence['cirq.Qid'] - two_qubit_gate: 'cirq.Gate' - num_circuits: int - repetitions: int - cycles: Sequence[int] - layers: Sequence[GridInteractionLayer] - seed: Optional[int] - - def _json_dict_(self): - return protocols.dataclass_json_dict(self) - - def __repr__(self) -> str: - return ( - 'cirq.experiments.grid_parallel_two_qubit_xeb.' - 'GridParallelXEBMetadata(' - f'qubits={self.qubits!r}, ' - f'two_qubit_gate={self.two_qubit_gate!r}, ' - f'num_circuits={self.num_circuits!r}, ' - f'repetitions={self.repetitions!r}, ' - f'cycles={self.cycles!r}, ' - f'layers={self.layers!r}, ' - f'seed={self.seed!r})' - ) diff --git a/cirq-core/cirq/experiments/grid_parallel_two_qubit_xeb_test.py b/cirq-core/cirq/experiments/grid_parallel_two_qubit_xeb_test.py deleted file mode 100644 index 69d16ad3001..00000000000 --- a/cirq-core/cirq/experiments/grid_parallel_two_qubit_xeb_test.py +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2022 The Cirq Developers -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -from cirq.experiments.grid_parallel_two_qubit_xeb import GridParallelXEBMetadata, LAYER_A, LAYER_B -import cirq - - -def test_grid_parallel_xeb_metadata_repr(): - metadata = GridParallelXEBMetadata( - qubits=cirq.GridQubit.square(2), - two_qubit_gate=cirq.ISWAP, - num_circuits=10, - repetitions=10_000, - cycles=[2, 4, 6, 8, 10], - layers=[LAYER_A, LAYER_B], - seed=1234, - ) - cirq.testing.assert_equivalent_repr(metadata) diff --git a/cirq-core/cirq/json_resolver_cache.py b/cirq-core/cirq/json_resolver_cache.py index 4def25ee5ee..56db643c752 100644 --- a/cirq-core/cirq/json_resolver_cache.py +++ b/cirq-core/cirq/json_resolver_cache.py @@ -49,7 +49,6 @@ def _class_resolver_dictionary() -> Dict[str, ObjectFactory]: from cirq.devices.noise_model import _NoNoiseModel from cirq.devices import InsertionNoiseModel from cirq.experiments import GridInteractionLayer - from cirq.experiments.grid_parallel_two_qubit_xeb import GridParallelXEBMetadata def _boolean_hamiltonian_gate_op(qubit_map, boolean_strs, theta): return cirq.BooleanHamiltonianGate( @@ -142,7 +141,6 @@ def _symmetricalqidpair(qids): 'GlobalPhaseGate': cirq.GlobalPhaseGate, 'GridDeviceMetadata': cirq.GridDeviceMetadata, 'GridInteractionLayer': GridInteractionLayer, - 'GridParallelXEBMetadata': GridParallelXEBMetadata, 'GridQid': cirq.GridQid, 'GridQubit': cirq.GridQubit, 'HPowGate': cirq.HPowGate, diff --git a/cirq-core/cirq/protocols/json_test_data/GridParallelXEBMetadata.json b/cirq-core/cirq/protocols/json_test_data/GridParallelXEBMetadata.json deleted file mode 100644 index 6a3f0796b93..00000000000 --- a/cirq-core/cirq/protocols/json_test_data/GridParallelXEBMetadata.json +++ /dev/null @@ -1,119 +0,0 @@ -[ - { - "cirq_type": "GridParallelXEBMetadata", - "qubits": [ - { - "cirq_type": "GridQubit", - "row": 0, - "col": 0 - }, - { - "cirq_type": "GridQubit", - "row": 0, - "col": 1 - }, - { - "cirq_type": "GridQubit", - "row": 1, - "col": 0 - }, - { - "cirq_type": "GridQubit", - "row": 1, - "col": 1 - } - ], - "two_qubit_gate": { - "cirq_type": "ISwapPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "num_circuits": 10, - "repetitions": 10000, - "cycles": [ - 2, - 4, - 6, - 8, - 10 - ], - "layers": [ - { - "cirq_type": "GridInteractionLayer", - "col_offset": 0, - "vertical": true, - "stagger": true - }, - { - "cirq_type": "GridInteractionLayer", - "col_offset": 1, - "vertical": true, - "stagger": true - } - ], - "seed": 1234 - }, - { - "cirq_type": "GridParallelXEBMetadata", - "qubits": [ - { - "cirq_type": "GridQubit", - "row": 0, - "col": 0 - }, - { - "cirq_type": "GridQubit", - "row": 0, - "col": 1 - }, - { - "cirq_type": "GridQubit", - "row": 0, - "col": 2 - }, - { - "cirq_type": "GridQubit", - "row": 1, - "col": 0 - }, - { - "cirq_type": "GridQubit", - "row": 1, - "col": 1 - }, - { - "cirq_type": "GridQubit", - "row": 1, - "col": 2 - } - ], - "two_qubit_gate": { - "cirq_type": "CZPowGate", - "exponent": 1.0, - "global_shift": 0.0 - }, - "num_circuits": 50, - "repetitions": 1000, - "cycles": [ - 3, - 6, - 9, - 12 - ], - "layers": [ - { - "cirq_type": "GridInteractionLayer", - "col_offset": 1, - "vertical": false, - "stagger": true - }, - { - "cirq_type": "GridInteractionLayer", - "col_offset": 0, - "vertical": false, - "stagger": true - } - ], - "seed": null - } -] \ No newline at end of file diff --git a/cirq-core/cirq/protocols/json_test_data/GridParallelXEBMetadata.repr b/cirq-core/cirq/protocols/json_test_data/GridParallelXEBMetadata.repr deleted file mode 100644 index ff23a842ce5..00000000000 --- a/cirq-core/cirq/protocols/json_test_data/GridParallelXEBMetadata.repr +++ /dev/null @@ -1 +0,0 @@ -[cirq.experiments.grid_parallel_two_qubit_xeb.GridParallelXEBMetadata(qubits=[cirq.GridQubit(0, 0), cirq.GridQubit(0, 1), cirq.GridQubit(1, 0), cirq.GridQubit(1, 1)], two_qubit_gate=cirq.ISWAP, num_circuits=10, repetitions=10000, cycles=[2, 4, 6, 8, 10], layers=[cirq.experiments.GridInteractionLayer(col_offset=0, vertical=True, stagger=True), cirq.experiments.GridInteractionLayer(col_offset=1, vertical=True, stagger=True)], seed=1234), cirq.experiments.grid_parallel_two_qubit_xeb.GridParallelXEBMetadata(qubits=[cirq.GridQubit(0, 0), cirq.GridQubit(0, 1), cirq.GridQubit(0, 2), cirq.GridQubit(1, 0), cirq.GridQubit(1, 1), cirq.GridQubit(1, 2)], two_qubit_gate=cirq.CZ, num_circuits=50, repetitions=1000, cycles=[3, 6, 9, 12], layers=[cirq.experiments.GridInteractionLayer(col_offset=1, vertical=False, stagger=True), cirq.experiments.GridInteractionLayer(col_offset=0, vertical=False, stagger=True)], seed=None)] \ No newline at end of file