<jupyter_start><jupyter_text>QsurfaceQsurface is a simulation package for the surface code, and is designed to modularize 3 aspects of a surface code simulation.1. The surface code2. The error model3. The used decoder Examples from the readme.The included examples in this section uses `qsurface.main.initialize` to setup the surface code and decoder, and `qsurface.main.run` to perform simulations. We'll expand these examples with more in-depth descriptions and  how to perform a threshold simulation with `qsurface.main.threshold`. To simulate the toric code and simulate with bit-flip error for 10 iterations and decode with the MWPM decoder:<jupyter_code>from qsurface.main import initialize, run, BenchmarkDecoder
code, decoder = initialize((6,6), "toric", "mwpm", enabled_errors=["pauli"])
run(code, decoder, iterations=10, error_rates = {"p_bitflip": 0.1})<jupyter_output><empty_output><jupyter_text>Benchmarking of decoders can be enabled by attaching a *benchmarker* object to the decoder. See the docs for the syntax and information to setup benchmarking.<jupyter_code>benchmarker = BenchmarkDecoder({"decode":"duration"})
code, decoder = initialize((6,6), "toric", "mwpm", enabled_errors=["pauli"])
run(code, decoder, iterations=10, error_rates = {"p_bitflip": 0.1}, benchmark=benchmarker)<jupyter_output><empty_output><jupyter_text>The figures in Qsurface allows for step-by-step visualization of the surface code simulation (and if supported the decoding process). Each figure logs its history such that the user can move backwards in time to view past states of the surface (and decoder). Press `h` when the figure is open for more information.The GUI of the figure is made possible by the PyQt5 or Tkinter backend. However, for Jupyter notebooks such as this one, the GUI is not available. Qsurface automatically detects this and plots each iteration inline instead. If you're running the notebook locally, or have proper X11 forwarding setup, you can still force the PyQt5 or Tkinter with the magic `%matplotlib qt` or `%matplotlib tk` prior to importing qsurface.<jupyter_code># When display is available interactive plotting can be enabled by either 
# %matplotlib qt
# or 
# %matplotlib tk
from qsurface.main import initialize, run, BenchmarkDecoder
code, decoder = initialize(
    (3,3),
    "toric",
    "mwpm",
    enabled_errors=["pauli"],
    plotting=True,
    initial_states=(0,0),
)
run(code, decoder, error_rates = {"p_bitflip": 0.1, "p_phaseflip": 0.1}, decode_initial=False, iterations=1)
from qsurface.main import initialize, run, BenchmarkDecoder
code, decoder = initialize((3,3), "toric", "mwpm", enabled_errors=["pauli"], faulty_measurements=True, plotting=True, initial_states=(0,0))
run(code, decoder, error_rates = {"p_bitflip": 0.05, "pm_bitflip": 0.05}, decode_initial=False)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup