While simulating any Stabilizer code on STIM do we need an explicit encoding circuit before performing circuit-level noise simulation and error-correction ?
2 Answers
Yes, Stim needs you to explain your code as a circuit, so you end up needing things like encoders. However, nothing stops you from making the encoding circuit just a series of MPP
instructions measuring each stabilizer and observable.
Stim can also automatically generate a bad encoding circuit from the stabilizers. It won't be fault tolerant, but it will produce the correct state:
import stim
stabilizers_and_obs = [
# stabilizers of perfect code
stim.PauliString("XZZX_"),
stim.PauliString("_XZZX"),
stim.PauliString("X_XZZ"),
stim.PauliString("ZX_XZ"),
# observable to prepare
stim.PauliString("ZZZZZ"),
]
tableau = stim.Tableau.from_stabilizers(stabilizers_and_obs)
print(tableau.to_circuit("elimination").diagram())
# q0: -X-@-X-H-@-@---X-------------------------------------------S-S-------
# | | | | | |
# q1: -|-|-|---|-|---|-X-@-X-H-S-@-@---X---------------------------S-S-----
# | | | | | | | | | | | |
# q2: -@-X-@---|-|-H-@-|-|-|---S-X-|---|-X-@-X-H-@-@-----------------S-S---
# | | | | | | | | | | | |
# q3: ---------X-|-----@-X-@-------|-H-@-|-|-|-H-X-|-X-@-X-H-S-@-----------
# | | | | | | | | | |
# q4: -----------X-------------H---X-----@-X-@-H---X-@-X-@-----X-H-----S-S-
There's a more compact state-prep circuit method coming in v1.13 called "graph_state"
:
# Needs v1.13.dev or later
print(tableau.to_circuit("graph_state").diagram())
# /-----------\ /-\
# q0: -RX-@-@-@---------Z---
# | | |
# q1: -RX-|-|-|-@-@---------
# | | | | |
# q2: -RX-@-|-|-@-|-@-@-X-H-
# | | | | |
# q3: -RX---@-|---|-@-|-----
# | | |
# q4: -RX-----@---@---@-Z---
# \-----------/ \-/
There will also be "mpp_state"
and "mpp_state_unsigned"
which just measure the stabilizers using MPP
, which is what I always do. If it's not fault tolerant anyways, no point in worrying about the details.
-
$\begingroup$ just to confirm if I got it right: You are suggesting to start the data qubits in all |0> state and project this state into simultaneous +1-eigenspace of all the stabilizers using MPP instruction. The final resultant state will be our code space. $\endgroup$ Commented Jan 30 at 0:56
-
$\begingroup$ @OmprakashChandra that's right. Assuming you don't need the initialization itself to be fault tolerant, that is sufficient. $\endgroup$ Commented Jan 30 at 2:13
-
$\begingroup$ how can we force the state into +1 eigenspace of the stabilizers? Is there a specific instruction in STIM accomplishing this? How do you do it? $\endgroup$ Commented Jan 31 at 3:30
-
$\begingroup$ You can use feedback operations and the destabilizers of the code to force them. But what I always do is just include the initial measurement in the detector/observable declarations which makes it work regardless of the initial measurement result. $\endgroup$ Commented Jan 31 at 5:31
-
$\begingroup$ Thank you very much for your help. I have rewritten the circuit in my own way and it's working now. $\endgroup$ Commented Feb 6 at 11:37
To supplement @Craig Gidney's answer, the TQEC project is under development for the purpose of assisting researchers who build error-correcting circuits. This project takes Stim as a dependency in circuit construction on the backend.
-
1$\begingroup$ thanks for this. I will have a look at the project. $\endgroup$ Commented Jan 30 at 0:57