1# Google devices 2 3This section describes the devices in Cirq for Google hardware devices and their usage. 4Since quantum hardware is an active area of research, hardware specifications and best 5practices are constantly evolving in an attempt to continuously improve performance. 6While this information should be a solid base for beginning your quantum application, 7please work with your Google sponsor to obtain the latest information on devices that 8you plan to use. 9 10## General limitations 11 12Qubits on Google devices are laid out in a grid structure. Connectivity is limited to 13adjacent qubits, either horizontally or vertically. 14 15Measurement takes much longer than other gates. Currently, the only supported 16configuration is to have terminal measurement in the final moment of a circuit. 17 18Most devices have a limited set of gates that can be applied. Gates not in that set 19must be decomposed into an equivalent circuit using gates within the set. 20See below for those restrictions. 21 22There are some limitations to the total circuit length due to hardware limitations. 23Several factors can influence this limit, but this can be estimated at about 40 microseconds 24of total circuit run-time. Circuits that exceed this limit will return a 25"Program too long" error code. 26 27 28### Moment structure 29 30The hardware will attempt to run your circuit as it exists in cirq to the 31extent possible. The device will respect the moment structure of your circuit 32and will execute successive moments in a serial fashion. 33 34The only exception is that identity gates (such as `cirq.Z ** 0`) and virtual 35Z gates (see below) will not actually perform any hardware actions. 36If a moment contains only these "virtual" gates, it will disappear. 37 38For example, this circuit will execute the two gates in parallel: 39 40``` 41cirq.Circuit( 42 cirq.Moment(cirq.X(cirq.GridQubit(4,4)), cirq.X(cirq.GridQubit(4,5))) 43) 44``` 45 46This circuit will execute the two gates in serial: 47 48 49``` 50cirq.Circuit( 51 cirq.Moment(cirq.X(cirq.GridQubit(4,4))), 52 cirq.Moment(cirq.X(cirq.GridQubit(4,5))) 53) 54``` 55 56Lastly, this circuit will only execute one gate, since the first gate 57is virtual and its moment will disappear: 58 59``` 60cirq.Circuit( 61 cirq.Moment(cirq.Z(cirq.GridQubit(4,4))), 62 cirq.Moment(cirq.X(cirq.GridQubit(4,5))) 63) 64``` 65 66The duration of a moment is the time of its longest gate. For example, 67if a moment has gates of duration 12ns, 25ns, and 32ns, the entire moment 68will take 32ns. Qubits executing the shorter gtes will idle during the rest 69of the time. To minimize the duration of the circuit, it is best to align 70gates of the same duration together when possible. See the 71[best practices](./best_practices.md) for more details. 72 73## Gates supported 74 75The following lists the gates supported by Google devices. 76Please note that gate durations are subject to change as hardware is 77updated and modified, so please refer to the 78[device specification](./specification.md) 79to get up-to-date information on supported gates and durations for 80specific processors. 81 82In addition, please note that all gates will have variations and 83errors that vary from device to device and from qubit to qubit. 84This can include both incoherent as well as coherent error. 85 86Note: Gate durations are subject to change based on device or 87configuration. To get gates durations for a specific device, see the 88[Device specification](./specification.md#gate-durations) page. Also 89note that some gates (such as Z gates or Fsim gates) have multiple 90variations that can have different durations. 91 92### One qubit gates 93 94Google devices support arbitrary one-qubit gates of any rotation. 95The full complement of these rotations can be accessed by using the 96`cirq.PhasedXZGate`. More restrictive one-qubit gates, such as 97the Pauli gates `cirq.X`, `cirq.Y`, `cirq.Z`, as well as the 98gate `cirq.PhasedXPowGate` can also be natively executed. 99One qubit rotations have a duration of 25 ns on most Google devices. 100 101#### Virtual Z gates 102 103Rotation around the Z axis is not a hardware operation on its own. 104Instead, the compilation keeps track of the Z phase rotations, 105commuting them forward through the circuit until a non-commuting 106gate is reached. This compilation is handled automatically for you. 107Adding a Z gate will generally not add any duration to the circuit, though 108it may modify how the other gates are applied. 109 110What this means is that `cirq.Z` and `cirq.ZPowGate` gates will 111have zero duration on the device. Any moments containing only 112these gates will silently disappear from the circuit. Even when 113this gate is absorbed by non-commuting gates, such as the square 114root of iSWAP, already have physical Z gates, so this absorption 115still does not add duration to the circuit. 116 117#### Physical Z gates 118 119While most applications prefer shorter circuit durations and 120virtual Z gates, Google hardware does offer the possibility of 121applying a physical Z gate that performs a hardware operation 122to affect the frequency of the qubit. 123 124This can be done by applying a PhysicalZTag to the Z gate, 125such as in the following example: 126 127``` 128cirq.Z(cirq.GridQubit(5, 5)).with_tags(cirq.google.PhysicalZTag()) 129``` 130 131Physical Z gates have a duration of 20 ns on most Google devices. 132 133### Two Qubit Gates 134 135Google devices provide several options for two-qubit gates. 136The availability of these gates is controlled by the gateset 137parameter that is used. 138 139Note that current hardware gates are noisy and not homogenous 140across the device. Unitaries provided below are for the ideal case. 141Real unitaries applied to the qubit may vary from qubit to qubit 142and may drift over time. 143 144#### Sycamore Gate 145 146The hardware provides a gate known as the Sycamore gate that can 147be accessed using `cirq.google.SYC`. This gate is equivalent to 148an FSimGate(π/2, π/6). That is, it does both a partial swap and 149controlled phase rotation of the |11⟩ state. 150 151The unitary of this gate, which can also be found via the `cirq.unitary` 152function, is: 153 154$$ 155\left[ 156\begin{matrix} 1571 & 0 & 0 & 0 \\ 1580 & 0 & -i & 0 \\ 1590 & -i & 0 & 0 \\ 1600 & 0 & 0 & e^{-i \frac{\pi}{6}} 161\end{matrix} 162\right] 163$$ 164 165This gate has a duration of 12ns and can be used in `cirq.google.SYC_GATESET` 166or in the `cirq.google.FSIM_GATESET`. 167 168#### Square root of iSWAP 169 170The hardware provides the square root of the iSWAP gate 171using `cirq.ISWAP ** 0.5`. This gate is equivalent to an FSimGate(-π/4, 0). 172The inverse (`cirq.ISWAP ** -0.5`) is also available. 173 174The unitary of this gate, which can also be found via the `cirq.unitary` 175function, is: 176 177$$ 178\left[ 179\begin{matrix} 1801 & 0 & 0 & 0 \\ 1810 & \frac{1}{\sqrt{2}} & \frac{i}{\sqrt{2}} & 0 \\ 1820 & \frac{i}{\sqrt{2}}& \frac{1}{\sqrt{2}} & 0 \\ 1830 & 0 & 0 & 1 184\end{matrix} 185\right] 186$$ 187 188This gate has a duration of 32ns and can be used in 189`cirq.google.SQRT_ISWAP_GATESET` or in the `cirq.google.FSIM_GATESET`. 190 191This gate is implemented by using an entangling gate surrounding by 192Z gates. The preceding Z gates are physical Z gates and will absorb 193any phases that have accumulated through the use of Virtual Z gates. 194Following the entangler are virtual Z gates to match phases back. All 195of this is computed and handled for the user automatically. 196 197Users should note that this gate is approximate and calibrated for 198average performance across the entire processor. In particular, 199average variations of the 'phi' angle of about π/24 have been observed 200on some devices. 201 202#### CZ gate 203 204The controlled-Z gate `cirq.CZ` is experimentally available on some 205devices. Be sure to check with your sponsor or in the device specification 206to see if it is available on the processor you are using. 207 208This gate is equivalent to FSimGate(0, π). It has an approximate duration 209of 26ns. 210 211#### FSim gateset 212 213The `cirq.FSIM_GATESET` provides all three of the above gates in one set. 214In addition, by using this combined gate set, the FSimGate can be parameterized, 215which allows for efficient sweeps across varying two-qubit gates. 216Note that providing a theta/phi combination that 217is not one of the above gates will cause an error when run on hardware. 218 219 220### Wait gate 221 222For decay experiments and other applications, a WaitGate is provided 223that causes the device to idle for a specified amount of time. 224This can be accomplished by specifying a `cirq.WaitGate`. 225 226## Specific Device Layouts 227 228The following devices are provided as part of cirq and can help you get your 229circuit ready for running on hardware by verifying that you are using 230appropriate qubits. 231 232Note that real hardware does not always have all qubits enabled, and it 233is important to check the device specification for the processor that you 234will attempt to run on to make sure that the qubits your circuit uses 235are actually active. Regular calibration and maintenance can disable 236and enable misbehaving qubits, so the grid configuration can change on a 237daily basis. 238 239### Sycamore 240 241The Sycamore device is a 54 qubit device introduced in 2019 with a 242[publication in Nature](https://www.nature.com/articles/s41586-019-1666-5). 243Note that the supremacy result in the paper utilized a device that had 53 qubits since 244one qubit had malfunctioned. 245 246It can be accessed using `cirq.GridQubit(row, col)` using grid coordinates specified below. 247 248``` 249 0123456789 2500 -----AB--- 2511 ----ABCD-- 2522 ---ABCDEF- 2533 --ABCDEFGH 2544 -ABCDEFGHI 2555 ABCDEFGHI- 2566 -CDEFGHI-- 2577 --EFGHI--- 2588 ---GHI---- 2599 ----I----- 260``` 261 262It can be accessing by using `cirq.google.Sycamore`. This device has two possible 263two-qubits gates that can be used. 264 265* Square root of ISWAP. The gate `cirq.ISWAP ** 0.5` or `cirq.ISWAP ** -0.5` can be 266used on `cirq.google.optimized_for_sycamore` with optimizer type `sqrt_iswap` 267* Sycamore gate. This gate, equivalent to FSimGate(π/2, π/6) can be used as `cirq.google.SYC` 268or by using `cirq.FsimGate(numpy.pi/2,numpy.pi/6)`. Circuits can be compiled to use this gate 269by using `cirq.google.optimized_for_sycamore` with optimizer type `sycamore` 270 271 272### Sycamore23 273 274The Sycamore23 chip is a 23-qubit subset of the Sycamore chip that is easier to work 275with and presents less hardware-related complications than using the full Sycamore device. 276 277 278``` 279 0123456789 2800 ---------- 2811 ---------- 2822 ---------- 2833 --A------- 2844 -ABC------ 2855 ABCDE----- 2866 -CDEFG---- 2877 --EFGHI--- 2888 ---GHI---- 2899 ----I----- 290``` 291 292This grid can be accessed using `cirq.google.Sycamore23` and uses the same gate sets and 293compilation as the Sycamore device. 294 295 296### Bristlecone 297 298The Bristlecone processor is a 72 qubit device 299[announced by Google in 2018](https://ai.googleblog.com/2018/03/a-preview-of-bristlecone-googles-new.html). 300 301The device is arrayed on a grid in a diamond pattern like this. 302 303``` 304 11 305 012345678901 3060 -----AB----- 3071 ----ABCD---- 3082 ---ABCDEF--- 3093 --ABCDEFGH-- 3104 -ABCDEFGHIJ- 3115 ABCDEFGHIJKL 3126 -CDEFGHIJKL- 3137 --EFGHIJKL-- 3148 ---GHIJKL--- 3159 ----IJKL---- 31610-----KL----- 317``` 318 319It can be accessing by using `cirq.google.Bristlecone`. Circuits can be compiled to it by using 320`cirq.google.optimized_for_xmon` or by using `cirq.google.optimized_for_sycamore` with 321optimizer_type `xmon`. 322 323### Foxtail 324 325The Foxtail device is a 2 by 11 XMON device arranged in a bilinear array, 326addressable by using grid qubits `({0,1}, {0-11})`. It was one of the first 327super-conducting quantum devices announced by Google. Due to the small number of qubits 328and limited connectivity, it is still interesting for exploring the space of constrained 329algorithms on NISQ devices. 330 331It can be accessing by using `cirq.google.Foxtail`. Circuits can be compiled to it by using 332`cirq.google.optimized_for_xmon` or by using `cirq.google.optimized_for_sycamore` with 333optimizer_type `xmon`. 334