  Decoding algorithms based on approximate tensor network contraction have
proven tremendously successful in decoding 2D local quantum codes such as
surface/toric codes and color codes, effectively achieving optimal decoding
accuracy. In this work, we introduce several techniques to generalize tensor
network decoding to higher dimensions so that it can be applied to 3D codes as
well as 2D codes with noisy syndrome measurements (phenomenological noise or
circuit-level noise). The three-dimensional case is significantly more
challenging than 2D, as the involved approximate tensor contraction is
dramatically less well-behaved than its 2D counterpart. Nonetheless, we
numerically demonstrate that the decoding accuracy of our approach outperforms
state-of-the-art decoders on the 3D surface code, both in the point and loop
sectors, as well as for depolarizing noise. Our techniques could prove useful
in near-term experimental demonstrations of quantum error correction, when
decoding is to be performed offline and accuracy is of utmost importance. To
this end, we show how tensor network decoding can be applied to circuit-level
noise and demonstrate that it outperforms the matching decoder on the rotated
surface code. Our code is available at https://github.com/ChriPiv/tndecoder3d
