  In this work we develop a general tensor network decoder for 2D codes.
Specifically, we propose a decoder that approximates maximally likelihood
decoding for 2D stabiliser and subsystem codes subject to Pauli noise. For a
code consisting of $n$ qubits our decoder has a runtime of $O(n\log
n+n\chi^3)$, where $\chi$ is an approximation parameter. We numerically
demonstrate the power of this decoder by studying four classes of codes under
three noise models, namely regular surface codes, irregular surface codes,
subsystem surface codes and colour codes, under bit-flip, phase-flip and
depolarising noise. We show that the thresholds yielded by our decoder are
state-of-the-art, and numerically consistent with optimal thresholds where
available, suggesting that the tensor network decoder well approximates optimal
decoding in all these cases. Novel to our decoder is an efficient and effective
approximate contraction scheme for arbitrary 2D tensor networks, which may be
of independent interest. We have also released an implementation of this
algorithm as a stand-alone Julia package: SweepContractor.jl.
