|
| 1 | +# Copyright 2022 The Cirq Developers |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +import random |
| 16 | +import numpy as np |
| 17 | +import sympy |
| 18 | +import cirq |
| 19 | + |
| 20 | + |
| 21 | +class RabiCalibration: |
| 22 | + params = ([50, 100, 150, 200], [20, 40, 60, 80, 100]) |
| 23 | + param_names = ["num_qubits", "num_scan_points"] |
| 24 | + |
| 25 | + def setup(self, num_qubits: int, _): |
| 26 | + qubits = cirq.GridQubit.rect(1, num_qubits) |
| 27 | + self.symbols = {q: sympy.Symbol(f'a_{q}') for q in qubits} |
| 28 | + self.circuit = cirq.Circuit( |
| 29 | + [cirq.X(q) ** self.symbols[q] for q in qubits], cirq.measure_each(*qubits) |
| 30 | + ) |
| 31 | + self.qubit_amps = {q: random.uniform(0.48, 0.52) for q in qubits} |
| 32 | + |
| 33 | + def time_parameter_resolution(self, _, num_scan_points: int): |
| 34 | + for diff in np.linspace(-0.3, 0.3, num=num_scan_points): |
| 35 | + resolver = {self.symbols[q]: amp + diff for q, amp in self.qubit_amps.items()} |
| 36 | + _ = cirq.resolve_parameters(self.circuit, resolver) |
0 commit comments