# Functionality of I and x^sweep gates in the code from the surface code implementation by Google

In the code availability by Google and implemented using Stim, they use I and x^sweep gates which I can't understand their use.

I suppose they are, somehow, used in the more sophisticated simulation named Pauli+ on Cirq, but why these gates, and how to link them with Pauli+ on Cirq? Probably the identity gate will be mapped to some idling noise, but how? And for the x^sweep gate, I can't even find a reference for it at https://github.com/quantumlib/Stim/blob/main/doc/gates.md.

In stim, the gate CX sweep[2] 3 is either X 3 or I 3 depending on the value of sweep[2]. If sweep[2] is ON then the gate is X. If sweep[2] is OFF then the gate is I. The value of sweep[2] can vary from shot to shot. In diagrams, this state of affairs is drawn like X^sweep[2]. The purpose of sweep bits is to allow one circuit file to specify a whole family of circuits where each member differs only by specified Paulis.

As an example of where you might use this, the command line command stim m2d has an optional --sweep argument that takes a filepath to a file containing the sweep data that was used for each shot. This is needed in order to compute the expected parities of detectors, to determine whether a measurement was supposed to be off or on depending on which intentional flips were inserted.

The underlying reason this feature was added was a worry about the distinction between the initial state and the steady state in the 3v5 surface code experiment. We were worried that the hardware might perform better when the stabilizers of the surface code were in the +1 state, due to T1 decay during measurements. That would mean, if we started the system in a state where most of the stabilizers were in the +1 eigenstate, it would look artificially good and then appear to get worse as it thermalized the stabilizers to the steady state where half were +1 and half were -1. To avoid this, we wanted to insert varying patterns of bit flips at the start, randomizing or balancing the stabilizers. But we didn't want to generate a separate circuit file for every one of these configurations, especially given how Paulis have basically no impact on the core structure of the circuit (they don't change what commutes and anticommutes). So... sweep bits.

I suppose they are, somehow, used in the more sophisticated simulation named Pauli+

Nope. Nothing to do with more advanced simulations.

for the x^sweep gate, I can't even find a reference for it at https://github.com/quantumlib/Stim/blob/main/doc/gates.md

It's documented in the "target types" section of the stim circuit file reference. I opened an issue to also note it on the CX/CY/etc gates.

• Thanks, @Craig Gidney. What about the identity gates on syndrome qubits? Were they generated from a sweep command or put on purpose for later association with idling noise? If the latter, how? Commented Feb 23, 2023 at 9:05
• @Unknown I don't think the I gates have any special significance; probably just an unintended side effect of the noise-adding code. Commented Feb 23, 2023 at 9:41