Package: qsurface
QsurfaceQsurface is a simulation package for the surface code, and is designed to modularize 3 aspects of a surface code simulation.The surface codeThe error modelThe used decoderNew types of surface codes, error modules and decoders can be added to Qsurface by using the included templates for each of the three core module categories.The current included decoders are:TheMininum-Weight Perfect Matching(mwpm) decoder.Delfosse's and Nickerson'sUnion-Find(unionfind) decoder, which hasalmost-linearworst-case time complexity.Our modification to the Union-Find decoder; theUnion-Find Node-Suspension(ufns) decoder, which improves the threshold of the Union-Find decoder to near MWPM performance, while retaining quasi-linear worst-case time complexity.The compatibility of these decoders with the included surface codes are listed below.Decoderstoriccodeplanarcodemwpm✅✅unionfind✅✅ufns✅✅InstallationAll required packages can be installed through:pipinstallqsurfaceRequirementsPython 3.7+TkinterorPyQt5for interactive plotting.Matplotlib 3.4+ for plotting on a 3D lattice (Refers to a future release of matplotlib, seepull request)MWPM decoderThe MWPM decoder utilizesnetworkxfor finding the minimal weights in a fully connected graph. This implementation is however rather slow compared to Kolmogorov'sBlossom Valgorithm. Blossom V has its own license and is thus not included with Qsurface. We do provided a single function to download and compile Blossom V, and to setup the integration with Qsurface automatically.>>>fromqsurface.decodersimportmwpm>>>mwpm.get_blossomv()UsageTo simulate the toric code and simulate with bitflip error for 10 iterations and decode with the MWPM decoder:>>>fromqsurface.mainimportinitialize,run>>>code,decoder=initialize((6,6),"toric","mwpm",enabled_errors=["pauli"])>>>run(code,decoder,iterations=10,error_rates={"p_bitflip":0.1}){'no_error':8}Benchmarking of decoders can be enabled by attaching abenchmarkerobject to the decoder. See the docs for the syntax and information to setup benchmarking.>>>fromqsurface.mainimportinitialize,run>>>benchmarker=BenchmarkDecoder({"decode":"duration"})>>>run(code,decoder,iterations=10,error_rates={"p_bitflip":0.1},benchmark=benchmarker){'no_error':8,'benchmark':{'success_rate':[10,10],'seed':12447.413636559,'durations':{'decode':{'mean':0.00244155000000319,'std':0.002170364089572033}}}}PlottingThe 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). Presshwhen the figure is open for more information.>>>fromqsurface.mainimportinitialize,run>>>code,decoder=initialize((6,6),"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)Plotting will be performed on a 3D axis if faulty measurements are enabled.>>>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,"p_bitflip_plaq":0.05},decode_initial=False)In IPython, inline images are created for each iteration of the plot, which can be tested in theexample notebook.Command line interfaceSimulations can also be initiated from the command line$python-mqsurface-epauli-Dmwpm-Ctoricsimulation--p_bitflip0.1-n10{'no_error':8}For more information on command line interface:$python-mqsurface-h
usage:qsurface
...This project is proudly funded by theUnitary Fund.