T and T_DAG instructions.
The following circuit demonstrates this by preparing and measuring the state
To sample from this circuit, we first compile it into a sampler:
Output
1.
Output
Detectors and Observables
Next, we consider a more complex example: an encoding circuit for the [[7,1,3]] Steane code. This circuit prepares the logical statestim’s “timeline-svg” visualization function:
Tsim also supports visualization as a ZX diagram, where measurement vertices are annotated with
rec[i], and detector and observable vertices are annotated with det[i] and obs[i], respectively.
To sample detection events and logical observables, we can compile a detector sampler, similar to
stim.
Output
Output
Adding Noise
A core capability of tsim is its support for Pauli noise channels. Let’s look at a simple example. We’ll insert a depolarizing channelDEPOLARIZE1(0.01) before the final stabilizer measurements.
In the ZX diagram, the noise is represented by parametrized vertices with binary parameters
e0, e1, etc. Since a depolarizing channel either applies X, Y, Z gates, each channel requires two bits, i.e. an X and a Z vertex.
Now we compile the sampler for the noisy circuit.
Output
Output
Error detection
One simple error correction strategy is post-selection: we discard any shots where a detector fired (indicating an error occurred). This effectively projects us back to the code space, but reduces the success rate (yield).Output
Error correction
To actively correct errors, we need a decoder. A decoder takes the detector syndrome and predicts whether the observable should be flipped. In this example, we will use the tesseract decoder. After correction, we see that the the probability of getting a logical is close to the ideal value.Output
Output