Two-layer measurement pattern for CNOT and x-axis rotations (source code)

= Two-layer measurement pattern for CNOT and x-axis rotations
{title2=$\text{measurement depth}\le2$}

An $R(\alpha)=J(\alpha)J(0)$ gadget with input <Pauli frame> $X^pZ^q$, angle-zero outcome $s$, and arbitrary-angle outcome $t$ uses angle $(-1)^{s\oplus q}\alpha$ and produces frame $X^{p\oplus t}Z^{q\oplus s}$. The <CNOT gate> gadget also updates its $Z$ frames without any dependence on incoming $X$ frames. Therefore all adaptive angle signs depend solely on angle-zero outcomes. Measure all those vertices first, compute every sign, and measure all remaining vertices in a second layer. The result is the desired logical circuit in a known <Pauli frame>. Computational output measurements can share the second layer.