|
| 1 | +# Copyright 2024 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 | +"""A class that can be used to denote FSim gate implementation using polynomial model.""" |
| 15 | +from typing import Any, Dict |
| 16 | + |
| 17 | +import cirq |
| 18 | + |
| 19 | + |
| 20 | +class FSimViaModelTag: |
| 21 | + """A tag class to denote FSim gate implementation using polynomial model. |
| 22 | +
|
| 23 | + Without the tag, the translation of FSim gate implementation is possible only for a certain |
| 24 | + angles. For example, when theta=pi/2, phi=0, it translates into the same implementation |
| 25 | + as the SWAP gate. If FSimGate is tagged with this class, the translation will become |
| 26 | + a coupler gate that with proper coupler strength and coupler length via some polynomial |
| 27 | + modelling. Note not all combination of theta and phi in FSim gate are feasible and |
| 28 | + you need the calibration for these angle in advance before using them. |
| 29 | + """ |
| 30 | + |
| 31 | + def __str__(self) -> str: |
| 32 | + return 'FSimViaModelTag()' |
| 33 | + |
| 34 | + def __repr__(self) -> str: |
| 35 | + return 'cirq_google.FSimViaModelTag()' |
| 36 | + |
| 37 | + def _json_dict_(self) -> Dict[str, Any]: |
| 38 | + return cirq.obj_to_dict_helper(self, []) |
| 39 | + |
| 40 | + def __eq__(self, other) -> bool: |
| 41 | + return isinstance(other, FSimViaModelTag) |
| 42 | + |
| 43 | + def __hash__(self) -> int: |
| 44 | + return hash("FSimViaModelTag") |
0 commit comments