|
| 1 | +# Copyright 2025 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 | +"""An instance of FSimGate that works naturally on Google's Sycamore chip""" |
| 15 | + |
| 16 | +import numpy as np |
| 17 | + |
| 18 | +import cirq |
| 19 | +from cirq._doc import document |
| 20 | + |
| 21 | + |
| 22 | +class WillowGate(cirq.FSimGate): |
| 23 | + """The Willow gate is a two-qubit gate equivalent to FSimGate(π/2, π/9). |
| 24 | +
|
| 25 | + The unitary of this gate is simulated as: |
| 26 | +
|
| 27 | + [[1, 0, 0, 0], |
| 28 | + [0, 0, -1j, 0], |
| 29 | + [0, -1j, 0, 0], |
| 30 | + [0, 0, 0, exp(- 1j * π/9)]] |
| 31 | +
|
| 32 | + This gate can be performed on the Google's Willow chip. Note that |
| 33 | + this gate will be transformed to a "ISWAP-like" gate on hardware |
| 34 | + and that the C-phase angle (phi) may change from processor to |
| 35 | + processor. The specified value is provided only for simulation |
| 36 | + purposes. |
| 37 | + """ |
| 38 | + |
| 39 | + def __init__(self): |
| 40 | + super().__init__(theta=np.pi / 2, phi=np.pi / 9) |
| 41 | + |
| 42 | + def __repr__(self) -> str: |
| 43 | + return 'cirq_google.WILLOW' |
| 44 | + |
| 45 | + def __str__(self) -> str: |
| 46 | + return 'WILLOW' |
| 47 | + |
| 48 | + def _circuit_diagram_info_(self, args: cirq.CircuitDiagramInfoArgs): |
| 49 | + return 'WILLOW', 'WILLOW' |
| 50 | + |
| 51 | + def _json_dict_(self): |
| 52 | + return cirq.obj_to_dict_helper(self, []) |
| 53 | + |
| 54 | + |
| 55 | +WILLOW = WillowGate() |
| 56 | +document( |
| 57 | + WILLOW, |
| 58 | + """The Willow gate is a two-qubit gate equivalent to FSimGate(π/2, π/9). |
| 59 | +
|
| 60 | + The unitary of this gate is simulated as: |
| 61 | +
|
| 62 | + [[1, 0, 0, 0], |
| 63 | + [0, 0, -1j, 0], |
| 64 | + [0, -1j, 0, 0], |
| 65 | + [0, 0, 0, exp(- 1j * π/9)]] |
| 66 | +
|
| 67 | + This gate can be performed on the Google's Willow chip. Note that |
| 68 | + this gate will be transformed to a "ISWAP-like" gate on hardware |
| 69 | + and that the C-phase value (phi) may change from processor to |
| 70 | + processor. The specified value is provided only for simulation |
| 71 | + purposes.""", |
| 72 | +) |
0 commit comments