††thanks: Shuai Li and Ming Gong are co-first authors

# Supplementary Materials for “Dissipationless Layertronics in Axion Insulator
$\bf{MnBi_{2}Te_{4}}$”

Shuai Li  School of Physical Science and Technology, Soochow University,
Suzhou 215006, China.  Institute for Advanced Study, Soochow University,
Suzhou 215006, China.  Ming Gong  Corresponding author<EMAIL_ADDRESS>International Center for Quantum Materials, School of Physics, Peking
University, Beijing 100871, China  Shuguang Cheng  Department of Physics,
Northwest University, Xi’an 710069, China.  Hua Jiang  Corresponding author:
<EMAIL_ADDRESS>School of Physical Science and Technology, Soochow
University, Suzhou 215006, China.  Institute for Advanced Study, Soochow
University, Suzhou 215006, China.  X. C. Xie  International Center for Quantum
Materials, School of Physics, Peking University, Beijing 100871, China  CAS
Center for Excellence in Topological Quantum Computation, University of
Chinese Academy of Sciences, Beijing 100190, China

###### Contents

  1. SI Physical origin of the chiral domain wall modes in antiferromagnetic axion insulator $\mathbf{MnBi_{2}Te_{4}}$
  2. SII Simulation of the layertronic devices with the realistic material parameters of $\bf{MnBi_{2}Te_{4}}$
  3. SIII Influence of the domain wall structures
    1. SIII.1 The finite-size effect of the DW
    2. SIII.2 The influence of the non-uniformity and different spin-flop states inside the DW
    3. SIII.3 The influence of the curved DW
  4. SIV Local current distributions in the layer valve
  5. SV Reversal of the layer polarization of the transmission currents in the layer valve
  6. SVI Layer valve with higher on-off ratio
  7. SVII Realizing layer filter and layer valve devices in a gate-controlled way
  8. SVIII Some details in the numerical calculations

##  SI Physical origin of the chiral domain wall modes in antiferromagnetic
axion insulator $\mathbf{MnBi_{2}Te_{4}}$

In this section, we show the physical origin of the chiral domain wall (DW)
modes in antiferromagnetic (AFM) topological axion insulator (AI)
$\mathrm{MnBi_{2}Te_{4}}$ in the view of Hall conductance. The two AFM ground
states (I and II) of $\mathrm{MnBi_{2}Te_{4}}$ are sketched in Fig. S1(a),
where a magnetic DW is formed at the interface between them. We calculate the
layer-dependent Hall conductance for AFM states I and II as functions of layer
indices $z$ [see Fig. S1(b)]. The Hall conductances on the inner layers
($z=2,\cdots,19$) are quantitatively small and oscillate around zero. While on
the surface layers $z=1$ and $z=20$, the Hall conductances nearly approach
$0.5(e^{2}/h)$ but with a sign reverse as labeled in Fig. S1(a), indicating
that AFM $\mathrm{MnBi_{2}Te_{4}}$ owns a half-quantized layer Hall effect
where electrons on the top and bottom surface layers deflect in opposite
directions [1]. We also evaluate the cumulative summation of the Hall
conductance from each layer, i.e.,
$\sum^{n=z}_{n=1}\sigma^{\rm{I/II}}_{xy}(n)$, as given in Fig. S1(c). The
cumulative conductances maintain almost half-quantized from $z=1$ to $z=19$
and vanish at $z=20$, since the top and bottom surface layers cancel out each
other. Therefore, the AFM AI $\mathrm{MnBi_{2}Te_{4}}$ is characterized by a
zero Hall conductance plateau [2].

Figure S1: (color online) (a) Sketch of the magnetic DW between the two AFM
ground states I and II of $\mathrm{MnBi_{2}Te_{4}}$. Blue and red arrows
illustrate the magnetization in each single septuple layers. The vertices at
the interface represent the propagation direction of the chiral DW modes. The
half-quantized surface Hall conductances are labeled correspondingly. (b)
Layer-dependent Hall conductances $\sigma^{\rm{I/II}}_{xy}(z)$ of AFM states I
and II, versus the layer index $z$. (c) The cumulative summation of the layer-
dependent Hall conductances $\sigma^{\rm{I/II}}_{xy}(z)$ from the $1$st to the
$z$th layer versus $z$. (d) Hall conductance difference between the two AFM
states I and II as a function of $z$. Model parameters are: $M_{z}=0.05$,
$N_{z}=20$ and Fermi energy of the AFM $\mathrm{MnBi_{2}Te_{4}}$ $E_{F}=0$.

We give the difference of the layer Hall conductances between the two AFM
states, $\sigma^{\rm{I}}_{xy}(z)-\sigma^{\rm{II}}_{xy}(z)$, as a function of
layer indices $z$ in Fig. S1(d). On the surfaces ($z=1,20$), the conductance
differences are quantized ($\pm e^{2}/h$), giving rise to the generation of
chiral modes at the DW between the two AFM domains. Inside the bulk
($z=2,\cdots,19$), the Hall conductance differences are nearly zero. It
indicates that the chiral DW modes are spatially separated on the two
surfaces. And the chirality of the DW modes is determined by the sign ($\pm$)
of the Hall conductance differences on the surfaces and thus locked to the
layer degree of freedom. Therefore, the DW modes have 1D features as
illustrated in Fig. S1(a). Our numerical results give another view of the
physical origin of the topological DW modes counter-propagating on different
surfaces along the DW between the AFM $\mathrm{MnBi_{2}Te_{4}}$ domains I and
II.

##  SII Simulation of the layertronic devices with the realistic material
parameters of $\bf{MnBi_{2}Te_{4}}$

The numerical calculations in the main text for the “layertronics” devices are
based on a theoretical model with scaled parameters $A_{1}$, $A_{2}$, $B_{1}$,
$B_{2}$, $M_{0}$ and perpendicular magnetization $M_{z}$ (in unit of
$\frac{\hbar V_{F}}{a}$ where $V_{F}$ is the Fermi velocity of the Dirac
surface states and $a=1.35$ nm which measures the distance between two
adjacent septuple layers of $\rm{MnBi_{2}Te_{4}}$). To identify that our
proposals are experimentally feasible in AFM AI $\rm{MnBi_{2}Te_{4}}$, we give
in this section the complementary calculations and discussions that utilize
the realistic material parameters of $\rm{MnBi_{2}Te_{4}}$.

Figure S2: (color online) (a) Top-view of the two-terminal layer filter device
constructed with AFM $\rm{MnBi_{2}Te_{4}}$. The vertices illustrate the
directions (in and out) of the surface magnetization $M_{z}$. Horizontal blue
arrow denotes the chiral DW mode on the top surface. (b) Corresponding energy
spectrum of the leads and the filter. The blue/red linear dispersion
highlights the DW mode on the top/bottom surface. $\mu$ is the chemical
potential of the filter which measures the difference between Fermi energy
$E_{F}$ and the Dirac point. (c) Transmission current $J^{RL}$ ($J^{LR}$)
through the filter and its layer-polarization $P^{RL}$ ($P^{LR}$) versus
$\mu/M_{z}$. The left/right (right/left) lead is the source/drain terminal.
(d) Local current distributions of the top-layer (top panel) and bottom-layer
(bottom panel) polarized currents through the layer filter, with
$\mu/M_{z}=0.25$. Other model parameters are: $M_{0}$=-0.1165 eV,
$A_{1}$=2.7023 eV$\cdot{\rm{\AA}}$, $A_{2}$=3.1964 eV$\cdot{\rm{\AA}}$,
$B_{1}$=-11.9048 eV$\cdot{\rm{\AA}^{2}}$, $B_{2}$=-9.4048
eV$\cdot{\rm{\AA}^{2}}$, $M_{z}$=0.04 eV, $N_{z}$=10, $N_{y}$=40, $N_{x}$=40,
lead chemical potential 2$M_{z}$=0.08 eV, and lattice constant $a$=1.35 nm
($a$ measures the distance between two adjacent septuple layers of
$\rm{MnBi_{2}Te_{4}}$).

An effective model for AFM $\rm{MnBi_{2}Te_{4}}$ [3] is employed whose
parameters are determined by fitting the energy spectrum of the effective
Hamiltonian with that of the $ab$ initio calculation. The effective material
parameters are given as $M_{0}$=-0.1165 eV, $A_{1}$=2.7023
eV$\cdot{\rm{\AA}}$, $A_{2}$=3.1964 eV$\cdot{\rm{\AA}}$, $B_{1}$=-11.9048
eV$\cdot{\rm{\AA}^{2}}$, $B_{2}$=-9.4048 eV$\cdot{\rm{\AA}^{2}}$ [3, 4, 5].
Note that this effective model provides a reasonable perpendicular
magnetization about $M_{z}$=0.04 eV along $z$ direction in
$\rm{MnBi_{2}Te_{4}}$ septuple layers. Therefore, the surface band gaps of
$\rm{MnBi_{2}Te_{4}}$ induced by intrinsic magnetism can be large of about
$2M_{z}$=0.08 eV, as consistent with the $ab$ initio calculation [4]. The
effective model is regularized on a cubic lattice with the lattice constant
$a=1.35$ nm standing for the distance between two adjacent septuple layers of
$\mathrm{MnBi_{2}Te_{4}}$.

Figure S3: (color online) (a) Top-view of the two-terminal layer valve device
fabricated with AFM $\rm{MnBi_{2}Te_{4}}$. The vertices represent the
directions (in and out) of the surface magnetization $M_{z}$. Horizontal blue
arrows denote the chiral DW modes on the top surfaces of the TLF and BLF. $D$
is the separation of the two DW modes in $y$ direction. (b) Corresponding
energy spectrum of the leads and the valve. $\mu_{L}$ ($\mu_{R}$) is chemical
potential of the TLF (BLF) that measures the difference between Fermi energy
$E_{F}$ and the Dirac point of the DW modes in the TLF (BLF). The layer-
resolved transmission currents $J_{t}$, $J_{b}$ and $J=J_{t}+J_{b}$ through
the valve versus (c) $\mu_{L}/M_{z}$ with $\mu_{R}/M_{z}=0.25$ and versus (d)
$\mu_{R}/M_{z}$ with $\mu_{L}/M_{z}=0.25$. (e) Transmission current $J$
through the valve versus $\mu_{L}/M_{z}$ with ($W=0.2$ eV and 0.5 eV) and
without ($W$=0 eV) disorders. $\mu_{R}/M_{z}=0.25$. (f) Current $J$ through
the valve versus $\mu_{L}/M_{z}$ for $D=11a$, $21a$ and $41a$, under disorders
($W=0.5$ eV). $\mu_{R}/M_{z}=0.25$. The left/right lead is the source/drain
terminal. Other model parameters are: $M_{0}$=-0.1165 eV, $A_{1}$=2.7023
eV$\cdot{\rm{\AA}}$, $A_{2}$=3.1964 eV$\cdot{\rm{\AA}}$, $B_{1}$=-11.9048
eV$\cdot{\rm{\AA}^{2}}$, $B_{2}$=-9.4048 eV$\cdot{\rm{\AA}^{2}}$, $M_{z}$=0.04
eV, $N_{z}$=10, $N_{y}$=50, $N_{L}$=50, $N_{R}$=50, lead chemical potential
2$M_{z}$=0.08 eV, and lattice constant $a$=1.35 nm.

The calculation results for the layer filter using realistic parameters are
given in Figs. S2. The energy spectrum of the device exhibits a sizable
surface gap of $\Delta\approx 2M_{z}$ =0.08 eV [see Fig. S2 (b)]. Inside the
surface gap of the layer filter, two linear and layer-locked DW modes emerge.
When the Fermi level $E_{F}$ crosses over the surface states of the two leads
and the DW states [see dashed line in Fig. S2(b)], a layer-polarized and
quantized transmission current can be induced. Figure S2(c) plots the
transmission current $J$ and its layer polarization $P$ versus the chemical
potential $\mu$ of the filter. When $E_{F}$ locates inside the surface gap or
at the DW states ($-1<\mu/M_{z}<1$), a quantized current $J^{RL}=e^{2}V/h$ is
flowing through with top-layer polarization $P^{RL}=+1$ [see the solid lines
with empty and filled squares in Fig. S2(c)]. The filtered current can be
directly visualized by the local current distribution, as shown in the top
panel of Fig. S2(d). On the contrary, a bottom-layer polarized ($P^{LR}=-1$)
current $J^{LR}=e^{2}V/h$ is transmitted through the filter by simply
reversing the source and drain leads [see the solid lines with empty and
filled circles in Fig. S2(c) and bottom panel of Fig. S2(d)]. The above
calculations demonstrate that the layer filter constructed by
$\rm{MnBi_{2}Te_{4}}$ is capable of filtering electronic currents with
specific layer-polarization. Therefore, we have theoretically proved the
feasibility of fabricating the layer filter device with $\rm{MnBi_{2}Te_{4}}$.

The layer valve device is designed with the AFM $\rm{MnBi_{2}Te_{4}}$ by
connecting the top-layer filter (TLF) and (BLF) from the left to the right, as
sketched in Fig. S3(a). A sizable surface band gap $\Delta$ of about
$2M_{z}$=0.08 eV is induced in the device by the intrinsic magnetism, as shown
in the energy spectrum [see Fig. S3(b)]. Inside the gaps, a pair of linear
dispersion appears both in the TLF and BLF. However, the chirality of the DW
modes in the TLF and BLF on the same surface is opposite, as illustrated by
the blue arrows in Fig. S3(a). The layer valve device can switch the layer-
polarized currents on and off. As shown in Figs. S3(c) and (d), the top-layer
current $J_{t}$, bottom-layer current $J_{b}$ and $J=J_{t}+J_{b}$ all vanish
when Fermi energy $E_{F}$ is located at the DW states of both the TLF and BLF
($-1<\mu_{L}/M_{z}<1$ and $-1<\mu_{R}/M_{z}<1$). The layer valve is tuned off.
By independently shifting $E_{F}$ out of the gap to the surface states of the
TLF or BLF, a layer polarized current is generated with the layer valve
switched on. Specifically, as shown in Fig. S3(c), by tuning $E_{F}$ to the
surface states of the TLF ($\mu_{L}/M_{z}<-1$ or $\mu_{L}/M_{z}>1$), $J_{t}$
keeps zero and $J_{b}$ rises to $e^{2}V/h$, implying that a quantized and
bottom-layer polarized current is switched on. Contrarily, the current with
top-layer polarization can be induced by shifting $E_{F}$ to the surface
states of the BLF ($\mu_{R}/M_{z}<-1$ or $\mu_{R}/M_{z}>1$), as shown in Fig.
S3(d). From above, we demonstrate that the designed layer valve with AFM
$\rm{MnBi_{2}Te_{4}}$ can realize a switch on/off of the layer-polarized
current with specific layer-polarization that is manipulated by independently
tuning $\mu_{L}$ of the TLF or $\mu_{R}$ or the BLF.

The performance of layer valve is also robust against weak disorders. As shown
by the green dashed line in Fig. S3(e), the transmission current $J$ slightly
deviates from zero when $E_{F}$ sits both inside the surface gaps of the TLF
and BLF (-1$<\mu_{L}/M_{z}<$1 and -1$<\mu_{R}/M_{z}<$1) under weak disorders
$W$=0.2 eV, compared to that in the clean system ($W$=0 eV) shown by the blue
solid line. However, the on-off ratio remains large since the scattering
between the two DW modes of TLF and BLF is not much strengthened. Thus, the
layer valve constructed with AFM $\rm{MnBi_{2}Te_{4}}$ maintains functional
and robust against weak disorders. In the presence of very strong disorders
with $W$=0.5 eV (the surface gap approximates 0.08 eV), as shown by the pink
dotted line in Fig. S3(e), $J$ in -1$<\mu_{L}/M_{z}<$1 climbs up to a moderate
value, implying a leakage of the transmission current. Out of the surface gap,
$J$ cannot reach the quantized value $e^{2}V/h$ for that the tunneling
electrons by the surface states of the TLF are scattered by disorders. Both
aspects lower the on-off ratio of the layer valve. Whereas, we can enhance the
performance of the layer valve by suppressing the scattering between the DW
modes, which is realized by increasing their spatial separation $D$ as shown
in Fig. S3(a). When $D$ rises from $11a$ to $21a$ and $41a$, the leaked
current $J$ lowers down to almost zero [see Fig. S3(f)]. Meanwhile, $J$ in
$\mu_{L}/M_{z}<-1$ or $\mu_{L}/M_{z}>-1$ is not much affected. The on-off
ratio of the layer valve is then enhanced. We conclude that it is
experimentally feasible to construct high performance layer valve device with
the AFM $\rm{MnBi_{2}Te_{4}}$.

##  SIII Influence of the domain wall structures

In the main text, we have assumed that the magnetic DW between the two AFM AIs
in the layer filter is atomically sharp. However, in experimentally grown AFM
$\mathrm{MnBi_{2}Te_{4}}$, the DW can be inherently wide [6] which may bring
non-negligible finite-size effect. In addition, there is intrinsic spin
structure within the DW, across which the magnetization smoothly varies to
flip the spin order in the two domains of AFM $\mathrm{MnBi_{2}Te_{4}}$ [6,
7]. Moreover, the shapes of the DWs can also be naturally curved as observed
on the surfaces of $\mathrm{MnBi_{2}Te_{4}}$ [6, 7]. We discuss, in this
section, the effects of the finite-size, the spin-flop states, and shapes of
the DWs on the transport properties of the layer filter device. Because of the
topological origin of the DW modes, the layer-polarized and quantized
transport is supposed to be robust and insensitive to the finite-size, the
shapes and the spin structures of the DWs. Thus, it is achievable to realize
the layer filter device in experiment with realistic materials, such as
$\mathrm{MnBi_{2}Te_{4}}$.

###  SIII.1 The finite-size effect of the DW

The schematic diagram of the layer filter is displayed in Fig. S4(a), where
the boundaries of the AFM AIs form a smooth DW with finite width $W_{D}$. On
the top/bottom surface, the perpendicular magnetization across such a DW is
described by a smooth cosine function, i.e., $\pm
M_{z}\cos[\frac{\pi}{W_{D}+2a}(y+\frac{W_{D}}{2}+a)]$, and the magnetization
is homogeneous away from the DW, as shown in Figs. S4(a) and (b). In general,
the finite $W_{D}$ of the DW inevitably induces the trivial sub-band states on
its surfaces whose gap $E_{g}$ is related to $W_{D}$ and can be approximated
by $E_{g}=\frac{2\pi A_{2}}{W_{D}}$ if the DW has no spin structure inside
($M_{z}=0$ across the DW) [8]. Here, $A_{2}$ is the Fermi velocity of the
Dirac surface states in the DW. As $W_{D}$ is increased large enough, the
confinement induced sub-band gap $E_{g}$ could decrease even lower than the
intrinsic-magnetism raised surface gaps in AFM AIs (about $2M_{z}$), thus
influencing the layertronic transport in the layer filter. That is to say, the
dissipationless transport is possibly affected by the sub-band gap $E_{g}$.
When taking the smooth spin structure of the DW into consideration, the sub-
band gap $E^{\prime}_{g}$ should also exist.

Figure S4: (color online) (a) Top-view of the layer filter with smooth DW,
whose width $W_{D}$ is variable. The width $W_{AI}$ of the AFM AI is fixed to
19$a$. $a$=1.35 nm measures the distance between two adjacent layers. (b) The
top-surface perpendicular magnetization $M_{z}$ of the layer filters with
$W_{D}$=0, 29$a$ and 59$a$. (c)-(e) Energy spectrum for the layer filters with
$W_{D}$=0, 29$a$ and 59$a$, respectively. (f)-(g) The bottom- and top-surface
LDOS of the DW states for layer filters with $W_{D}$=0, 29$a$ and 59$a$. The
energy is $E$=0.01. (h) The transmission current $J$ and its layer
polarization $P$ versus chemical potential $\mu$ of the layer filters with
$W_{D}$=0, 29$a$ and 59$a$. $\mu$ is defined as the difference between Fermi
energy $E_{F}$ and the Dirac point of the DW modes [see (c)]. Model parameters
are: $M_{z}$=0.12, $N_{z}$=10, $N_{x}$=100, $W_{AI}$=19a and chemical
potentials of the two leads 0.2.

In order to illuminate the finite-size effect of $W_{D}$ with reduced
computational resources, we first increase the magnetization $M_{z}$ from 0.05
to 0.12 to create a larger magnetic surface gap. Then, we fix the width
$W_{AI}$ of the AFM AI, but only vary the DW width $W_{D}$, as show in Fig.
S4(a). When $W_{D}$ increases from 0 to 29$a$ and 59$a$, the sub-band gap of
the DW states reduces [see Figs. S4(c)-(e)]. Especially as shown in Fig.
S4(e), the sub-band gap ($E^{\prime}_{g}\approx 1.125M_{z}$=0.135) is much
smaller than the magnetic surface gap ($\approx 2M_{z}$=0.24), identifying the
existence of the trivial 1D sub-band states in the DW. However, the
topologically protected chiral DW modes persist in the sub-band gaps,
independent of $W_{D}$ [see green linear lines in Figs. S4(c)-(e)]. The effect
of increasing $W_{D}$ is barely broadening the DW states, as shown by the
local density of states on the top and bottom surfaces in Figs. S4(f) and (g).
The electronic transport currents by the DW modes preserve to be quantized
($J=e^{2}V/h$) and layer-polarized ($P$=+1)[see Fig. S4(h)], which clarifies
the robustness of the layer filter against smooth domain walls. Nevertheless,
the chemical potential $\mu$-window where the layer filter works shrinks from
the magnetic gap ($\approx 2M_{z}$) to the sub-band gap $E^{{}^{\prime}}_{g}$
due to the finite-size effect of the DW, as shown in Fig. S4(h). We see above
that the layertronic and quantized transport occurs in the sub-band gap
$E^{\prime}_{g}$ of the DWs and thus determined by $W_{D}$. The larger $W_{D}$
is, the narrower $\mu$-window the layer filter works.

We further give an estimation of the critical $W_{D}$ where the electronic
transport by the DW modes can be distinguished in realistic material
$\mathrm{MnBi_{2}Te_{4}}$. Recall that the confinement-induced sub-band gap of
the DW without spin structure is approximated by $E_{g}=\frac{2\pi
A_{2}}{W_{D}}$. Taking the parameters of the effective model in Fig. S4(e), we
have $E_{g}\approx 0.488M_{z}$=0.0586. From that $E_{g}<E^{\prime}_{g}$, it is
reasonably believed that the smooth domain wall spin structure renormalizes
the realistic DW width by a factor $\alpha$, i.e., $E^{\prime}_{g}=\frac{2\pi
A_{2}}{\alpha W_{D}}$. Then we obtain
$\alpha=\frac{E_{g}}{E^{\prime}_{g}}\approx$ 0.43. The $\alpha$ is expected to
be insensitive to the parameters if the spin structure insider the DW is
smooth. Therefore it can be used as a constant to estimate the DW width with
realistic material parameters. From the transport experiment of HgTe/CdTe[9,
10], it is proved that the topological transport can be detected as long as
the bulk gap remains larger than about $\Delta$=10 meV. Therefore for
realistic $\rm{MnBi_{2}Te_{4}}$, the DW width $W_{D}$ is required to be
smaller than $\frac{2\pi A_{2}}{\alpha\Delta}\approx$ 468 nm ($A_{2}\approx$
3.2 eV$\cdot$Å is proportional to the Fermi velocity of the Dirac surface
states for $\rm{MnBi_{2}Te_{4}}$). We ensure that in such a condition, the
layer filter keeps working and the layertronic transport can be detected. Note
that the observed DW width in experiment is about a few hundred nanometers on
the surfaces of $\rm{MnBi_{2}Te_{4}}$ [6, 7], which quantitatively meets the
requirement and makes $\rm{MnBi_{2}Te_{4}}$ an ideal platform to construct
layertronic devices.

The above estimation is based on the case that $\mathrm{MnBi_{2}Te_{4}}$ is in
clean condition. The disorder should exist in experimental samples. Meanwhile,
the number of the trivial sub-bands around the DWs is small since they are
spaced by $E^{\prime}_{g}/2$ in energy regime. The 1D nature of the trivial
states further makes them easier to be localized by disorders, expanding the
$\mu$-window where DW-mode transport occurs and the layer filter works.
Therefore, quantized and layer-polarized transport can be observed in
$\rm{MnBi_{2}Te_{4}}$ with even wider DWs than the estimated 468 nm.

###  SIII.2 The influence of the non-uniformity and different spin-flop states
inside the DW

The studies on the surface spin-flop transitions of the AFM
$\rm{MnBi_{2}Te_{4}}$ have demonstrated that the magnetic order within the DW
is a canted AFM order [6, 7]. Besides the perpendicular component $M_{z}$,
other two magnetization components ($M_{x}$ and $M_{y}$) that are parallel to
the terminated surface are possibly finite inside the DWs.

Figure S5: (color online) (a)-(d) Schematic diagrams of the Néel, Bloch,
nonuniform (NU) Néel and NU Bloch magnetic DWs (shadow regions). Green arrows
with spheres illustrate the spin-flop on each layers. For Néel (Bloch) wall,
the spin flops along $y$ ($x$) direction. For NU Néel and NU Bloch walls, the
magnetic DW on each layers is displaced randomly, as shown by the shadow
regions. (e)-(h) Corresponding energy spectrum of the layer filters with the
four kinds of DW structures. (i)-(l) The corresponding current $J$ and layer
polarization $P$ versus chemical potentials $\mu/M$, with ($W$=0.5, 1) or
without ($W$=0) disorders. Model parameters are: $M$=0.05, $N_{z}$=10,
$N_{y}$=60, $N_{x}$=80, $W_{D}$=19$a$ and $\mu$ of the two leads is $4M=0.2$.
For the NU Néel and NU Bloch walls, the displacement of the magnetic DW on
each layer is randomly chosen to be (5$a$ 7$a$ -6$a$ 7$a$ 2$a$ -7$a$ -4$a$
1$a$ 8$a$ 8$a$).

To explore the effects of the DWs with realistic spin structures, some
complementary calculations are performed and given in the Fig. S5. Two
energetically favorable DW spin structures, the Néel wall and Bloch wall [11,
12], are considered. These two DW configurations can be described by a
magnetization vector
$\mathbf{M}(y)=(M_{x},M_{y},M_{z})=M(\sin\theta\cos\phi,\sin\theta\sin\phi,\cos\theta)$,
where $M$ is a constant magnetization magnitude originating from magnetic
doping [13, 14]. The azimuthal angle $\phi$ defines the type of DW. $\phi=0$
and $\phi=\frac{\pi}{2}$ represent the Néel wall and Bloch wall respectively,
as shown by the schematic diagrams in Figs. S5(a)-(b). And the azimuthal angle
$\theta$ is a function of $y$ with $\cos\theta(y)=-\tanh\frac{y}{W_{D}}$. The
AFM magnetization is homogeneous away from the DW. We calculate the energy
spectrum of the layer filters with the Néel and Bloch DWs [see Figs.
S5(e)-(f)]. The DW modes emerge in the surface band gaps as expected, which
originate from the topology difference across the DWs. The transmission
currents through the filter carried by the DW states are quantized
($J=e^{2}V/h$) and layer-polarized ($P=+1$) [see red and blue solid lines in
Figs. S5(i)-(j)], which evidently confirms that layer filters with the two DW
structures are desirably functional. When disorders are involved in, the
transport properties ($J=e^{2}V/h$ and $P=+1$) persist owning to the topology
and robustness of the DW states against disorders [see the red, blue dashed
and dot-dashed lines in Figs. S5(i)-(j)].

Furthermore, we have also studied the non-uniformity of the DWs across the
sample from the top to bottom layers. The magnetic DW on each layer is
displaced randomly, as shown in Figs. S5(c)-(d). We plot the energy spectrum
of the layer filters with nonuniform Néel and Bloch walls in Figs. S5(g)-(h).
The non-uniformity brings little impacts and the DW modes in the surface gaps
still exist. The characteristics of the electronic transport by the DW states
with and without disorders are similar as that of the filters with uniform
Néel and Bloch DWs [see Figs. S5(i)-(l)]. Thus, we conclude that the layer
filter device can perform as well as designed, regardless of the spin
structures, or the spin-flop states, inside the DWs between the AFM AIs.

###  SIII.3 The influence of the curved DW

The curved shape of the magnetic DWs is intrinsic in experimentally fabricated
$\rm{MnBi_{2}Te_{4}}$ [6]. We here simulate the curved domain wall by a cosine
function $y=\frac{(N_{y}-1)a}{8}\cos(\frac{2\pi x}{L})$, as shown in the
central part of Fig. S6(a). The topological DW modes are expected to emerge at
the interface regardless of the shapes of the DWs. Their existence is
manifested by the energy spectrum where two linear dispersion crosses over the
surface band gaps, as shown Fig. S6(b). We numerically plot the LDOS on the
top and bottom surfaces of the chiral states inside the surface gap, as given
in Figs. S6(d)-(e). The LDOS peaks nearby the curved interface, which further
verifies that the chiral states are well-confined DW modes. The layer filter
with curved DW shares similar electronic transport properties as the layer
filter with straight DW by comparing their transmission current $J$ and layer-
polarization $P$, as shown in Fig, S6(c). Therefore, the layer filter with
curved DWs can indeed filter quantized ($J=e^{2}V/h$) and fully layer-
polarized ($P=+1$) currents. In conclusion, the layer filters maintain robust
against curved DW structures.

Figure S6: (color online) (a) Top-view of the layer filter with curved DW
described by $y=\frac{(N_{y}-1)a}{8}\cos(\frac{2\pi x}{L})$, where $L$ is the
period. The vertices represent the surface magnetization directions (in and
out) of each part. (b) Folded energy spectrum of the layer filter. (c) The
transmission current $J$ and its layer polarization $P$ of the layer filters
with curved DW (solid lines) and straight DW (dashed lines), versus chemical
potential $\mu/M_{z}$. The left/right lead is the source/drain terminal. (d)
Energy-resolved ($E=0.01$) top and (e) bottom surface LDOS of the DW states
inside the surface band gap. Model parameters are: $M_{z}=0.05$, $N_{z}=10$,
$N_{y}=40$, $N_{x}=36$, $L=12a$ and $\mu$ of the leads is $4M_{z}=0.2$.

##  SIV Local current distributions in the layer valve

We have seen in the main text that the layer-polarized current can be switched
on or off in the layer valve device,

Figure S7: (color online) (a) Top: Schematic energy spectrum for the TLF and
BLF in the layer valve, with Fermi energy $E_{F}$ marked by the dashed line.
Chemical potential $\mu_{L}$ ($\mu_{R}$) is the difference between $E_{F}$ and
the Dirac point of the DW modes in the TLF (BLF). Bottom: local current
distribution of the bottom-layer polarized current in the layer valve, with
$\mu_{R}/M_{z}=0.4$ and $\mu_{L}/M_{z}=4.1$. (b) Top: Schematic energy
spectrum for the TLF and BLF. Bottom: local current distribution of the top-
layer polarized current, with $\mu_{L}/M_{z}=0.4$ and $\mu_{R}/M_{z}=4.1$.
Other model parameters are $M_{z}=0.05$, $N_{z}=10$,
$N_{y}=N^{L}_{x}=N^{R}_{x}=50$, $D=11a$ and $\mu$ of the terminals is
$5M_{z}=0.25$.

and its layer polarization is manipulated by independently controlling the
Fermi level to the surface states of the TLF or of the BLF. We here display
the local current distributions of the layer-polarized transmission currents
when the valve is tuned on. For the first kind of “on” status, as shown in the
bottom panel of Fig. S7(a), the current flows into the right terminal totally
from the bottom surface with $P=-$1\. The majority of electrons flowing to the
interface ($x/a=50$) between the TLF and BLF are reflected, because the number
of surface state transverse modes in the TLF is significantly larger than that
of the DW mode in the BLF [see top panel of Fig. S7(a)]. The local current
distribution is determined by the interference of the $N$ injected and $N-1$
reflected current modes. The situation differs in the second case. As shown in
the bottom panel of Fig. S7(b), the current flows to the right terminal
entirely from the top surface ($P=+1$). The electrons carried by the upper DW
mode of the TLF transmit to the top surface of the BLF without reflection,
since only one injected mode in the TLF carries electrons to transport to the
large $N$ surface state transmitted modes in the BLF [see the top panel of
Fig. S7(b)]. The local current distribution is determined by the perfect
transmission mode.

The surface transport for the two “on” status of the layer valve is apparently
different, as shown in Fig. S7. In spit of the mismatch between the number of
transverse modes in the TLF and BLF discussed above, another aspect is the
applied bias. Since a voltage drop is imposed between the leads to drive
electrons to flow from left to right in both cases, there should be no
symmetry connecting the surface transport in Figs. S7(a) and (b).

##  SV Reversal of the layer polarization of the transmission currents in the
layer valve

In this section, we show that by exchanging the positions of the TLF and BLF
in the layer valve or by inverting the source and drain terminals in the main
text, we are able to reverse and thus control the layer polarization of the
transmission current when layer valve is tuned on. The newly structured layer
valve is presented in Fig. S8(a). The chirality of all DW modes reverses on
each part, compared to that in the main text [see Fig. 3(a)]. When either
chemical potential $\mu_{L}$ of the left part (BLF) or $\mu_{R}$ of the right
part (TLF) is located at the surface states to switch on the valve, the layer
polarization of the transmission current is reversed as well, contrary to that
in the main text [see Figs. 3(b)-(c)]. Specifically, as shown in Fig. S8(b),
when $\mu_{L}$ is shifted from the DW states in the gap (-1$<\mu_{L}/M_{z}<$1)
to the surface states ($\mu_{L}/M_{z}<$-1 or $\mu_{L}/M_{z}>$1), the top layer
transmission current $J_{t}$ increases significantly from zero to about
$e^{2}V/h$ while bottom transmission current $J_{b}$ keeps vanishing. A top-
layer polarized current is generated [bottom-layer polarized current in the
main text as shown in Fig. 3(b)]. On the other hand, when tuning $\mu_{R}$,
$J_{b}$ arises from 0 to $e^{2}V/h$ with vanishing $J_{t}$, as seen in Fig.
S8(c). A bottom-layer polarized current is switched on [top-layer polarized
current in the main text as shown in Fig. 3(c)]. The layer valve proposed here
can generate layer polarized current whose layer polarization is opposite to
that in the main text when shifting either $\mu_{L}$ of the left part or
$\mu_{R}$ of the right part to the surface states. Note that the exchange of
the TLF and BLF might be achieved using electromagnetic field to reverse the
AMF order in each AI domain through the $\mathbf{E}\cdot\mathbf{B}$ term [1].

Figure S8: (color online) (a) Sketch of the layer valve consisting of BLF and
TLF that are connected in sequence from left to right. (b) Layer-resolved
transmission currents $J_{t}$ and $J_{b}$ versus chemical potential
$\mu_{L}/M_{z}$ of the left part (BLF) of the valve, with fixed chemical
potential $\mu_{R}/M_{z}=0.4$ of the right part (TLF). (c) $J_{t}$ and $J_{b}$
versus $\mu_{R}/M_{z}$, with fixed $\mu_{L}/M_{z}=0.4$. Model parameters are
$M_{z}=0.05$, $N_{y}=N^{L}_{x}=N^{R}_{x}=50$, $D=11a$ and $\mu$ of the leads
is $5M_{z}=0.25$.

##  SVI Layer valve with higher on-off ratio

We propose that by inserting antiferromagnetic AI domain between the TLF and
BLF of the layer valve in the main text [see Fig. 3(a)], the on-off ratio of
the valve can be further enhanced in the presence of disorders, due to a
larger separation and reduction of the scattering between the DW states in the
TLF and BLF. This newly constructed layer valve is shown in Fig. S9(a). A
central part of antiferromagnetic AI domain is inserted to separate the DW
states further in $x$ direction. As a consequence, the scattering between DW
states in TLF and BLF assisted by disorders, is lowered and a higher on-off
ratio is achieved compared to that in the main text. We plot together the
transmission current $J$ versus $\mu_{L}/M_{z}$ of this new valve and of the
layer valve in the main text in the presence of disorders [see blue dashed and
black dot-dashed lines in Fig. S9(b)]. When $\mu_{L}$ sits in the gap of the
surface states (-1$<\mu_{L}/M_{z}<$1), $J$ of this new valve is smaller than
that of the valve in the main text, indicating that this new layer valve
possesses a higher on-off ratio in the presence of disorders.

Figure S9: (color online) (a) Schematic diagram of the layer valve consisting
of TLF, AFM AI and BLF that are connected in sequence from left to right. (b)
Transmission current $J$ of this new valve (blue dashed line $N^{C}_{x}=30$)
and of the valve in the main text (black dot-dashed line $N^{C}_{x}=0$) in the
presence of disorders ($W=1$), versus $\mu_{L}/M_{z}$ of the TLF and AFM AI,
with fixed $\mu_{R}/M_{z}=0.4$ of the BLF. Green solid line is the $J$ of this
new valve in absence of disorders, plotted for comparison. $\mu$ of the
central AFM AI is set the same as that of the TLF. Model parameters are:
$M_{z}=0.05$, $N_{z}=10$, $N_{y}=N^{L}_{x}=N^{C}_{x}=N^{R}_{x}=30$ and $\mu$
of the leads is $5M_{z}=0.25$.

##  SVII Realizing layer filter and layer valve devices in a gate-controlled
way

In real experimental conditions, it may be difficult to realize the
layertronic devices from naturally formed domain structures, especially the
layer valve device. Fortunately, $\rm{MnBi_{2}Te_{4}}$ is Van der Waals
stacked material, of which the fabrication technique is based on mechanical
exfoliation. Its fabrication technique is very similar to the bilayer
graphene. Therefore, motivated by the technical route of realizing the
valleytronic devices in bilayer graphene [15, 16, 17, 18, 19], we propose that
the layer filter and layer valve devices can similarly be realized in a gate-
controlled way. The key ingredient is that in the presence of a perpendicular
magnetic field $\mathbf{B}$, the AFM order of $\rm{MnBi_{2}Te_{4}}$ can be
reversed by applying perpendicular electric field $\mathbf{E}$ due to the
uique magnetoelectric coupling (i.e., the $\theta\mathbf{E}\cdot\mathbf{B}$)
of the axion insulator. Such a process has already been realized
experimentally [1]. Similar to what has been realized in bilayer graphene, the
layer filter can be achieved by a pair of split gates on which opposite gate
voltages are applied in the presence of a perpendicular magnetic field as
shown in Fig. S10 (a). Due to the magnetoelectric coupling
$\theta\mathbf{E}\cdot\mathbf{B}$, the domain of the perpendicular
$\mathbf{E}$ gives rise to the domain of AFM order. Further, the layer valve
device can be achieved by fabricating two pairs of split gates [see Fig. S10
(b)]. Moreover, the bulk gap of the valley valve devices is about 86 meV [17],
while the surface gap of $\rm{MnBi_{2}Te_{4}}$ is about 50-100 meV. They are
of the similar order. Therefore, the topologically nontrivial transports
should emerge at similar length scale of the devices.

There are some advantages in realizing layertronic deivces in
$\rm{MnBi_{2}Te_{4}}$ than realizing valleytronic devices in bilayer graphene.
Firstly, the magnetization reversal can be achieved by applying an impulse
voltage. Therefore, one convenience in $\rm{MnBi_{2}Te_{4}}$ is that the gate
voltage need not to be applied continuously. Specifically, the gate voltages
applied on bilayer graphene should be fine-tuned such that the bulk gap of
oppositely-gated domains are always aligned to ensure the global insulating
bulk. But in $\rm{MnBi_{2}Te_{4}}$, such a difficulty is naturally
circumvented because we only need the impulse voltage to prepare the initial
domain configuration. Secondly, during the repeatable switching process as
shown in [1], the maximum (around +0.5 $k\Omega$) and the minimum values
(around -0.9 $k\Omega$) of $R_{yx}$ do not show any decay feature, which
indicates that the reversal of the AFM order is of high-efficiency and causes
little magnetization loss. Therefore, making high quality layertronic devices
in $\rm{MnBi_{2}Te_{4}}$ is achievable. Thirdly, the topological kink states
in valleytronics are not robust to disorders. This is because the chiral
domain wall modes from $K$ and $K^{\prime}$ valleys are not spatially
separated and can be backscattered by short range disorders. Therefore,
quantized transport is hard to observe. In contrast, the chiral domain wall
modes in $\rm{MnBi_{2}Te_{4}}$ are spatially separated (located on the top and
bottom surfaces). Backscattering between these domain wall modes requires
stronger disorder. Therefore, the quantized transport properties make the
dissipationless layertronics easier to be characterized.

Figure S10: (color online) Schematic of gate-controlled layer filter and layer
valve devices in AFM $\rm{MnBi_{2}Te_{4}}$. (a) The formation of a single
domain wall to realize the layer filter can be achieved through a pair of
split gates. Due to the magnetoelectric coupling of AIs, opposite gate
voltages ($V$ or $-V$) on the gates induce opposite perpendicular electric
field E, giving rise to a heterostructure of the two types of AFM orders under
a perpendicular magnetic field B. (b) The layer valve device can be similarly
constructed by two pairs of split gates. Gate voltages are applied
alternatively.

##  SVIII Some details in the numerical calculations

This section is devoted to clarify some of the details in our numerical
calculations in the main text. 1) The NEGF method is applied for the
calculation of local current distribution. The current flowing from site $i$
to its neighboring site $j$ can be calculated by [20]

$J_{i\rightarrow j}=\frac{2e^{2}}{h}{\rm
Im}\\{\sum_{\alpha,\beta}H_{i\alpha,j\beta}\left[G^{r}\Gamma^{L}G^{a}\right]_{j\beta,i\alpha}\\}(V_{L}-V_{R}),$
(S1)

where $H_{i\alpha,j\beta}$ is the hopping of electrons from orbit $\alpha$ at
$i$ to orbit $\beta$ at $j$, $G^{r}$ ($G^{a}$) denotes the retarded (advanced)
Green’s functions of the central region, $\Gamma^{L}$ represents the linewidth
function of the left terminal, and $V=V_{L}-V_{R}$ gives the external bias.
The layer-resolved transmission currents $J_{t}$, $J_{b}$, $J=J_{t}+J_{b}$ and
layer polarization $P$ are evaluated by summing $J_{i\rightarrow j}$ on a
specific layer perpendicular to $x$ direction that is close to the drain
terminals, in order to explore the effects of layertronic devices on the
unpolarized current injected from source terminals. 2) Due to the restriction
of the theoretical 3D topological insulator model, the Dirac fermions on the
side surface are inevitably involved into the electronic transport.
Experimentally, the contribution of the side surface states to the transport
should not count, for that the size of the experimentally fabricated
$\mathrm{MnBi_{2}Te_{4}}$ is super large [e.g., see Fig. 1 in the main text.
$N_{x}$ and $N_{y}$ are of the order $\mu m$, while $N_{z}$ is of the order
$nm$]. Thus in our calculations, we incorporate a $y$-direction magnetization
term $M_{2}(y)s_{2}\otimes\sigma_{0}$ in $H_{\rm mag}$ to gap out the side
surface states. $M_{2}(y)=\pm M_{y}=\pm 0.3$ is the perpendicular
magnetization on the side surfaces. 3) We have shown the local current
distributions for the layer filters and layer reversers in the main text.
However, these configurations are plotted in a simplified way that the local
currents whose magnitudes are smaller than a critical value, like 0.01
$e^{2}V/h$, are omitted for the sake of clarity. 4) Disorder effect is also
considered in the main text. The calculations for $J$ and $P$ are all averaged
over 200 configurations of disorders. 5) For the experimental scheme to verify
the layer polarization reverse in the layer reverser device, we propose to
attach two metallic contacts (terminals 3 and 4) at the DWs on the top
surface. The density of states of the two metallic terminals are approximated
by wide band approximation, and we choose the self-energy contributed by the
two contacts as $\Sigma^{r}=-1.5i$ in our numerical calculations.

## References

  * Gao  _et al._ [2021] A. Gao, Y.-F. Liu, C. Hu, J.-X. Qiu, C. Tzschaschel, B. Ghosh, S.-C. Ho, D. Bérubé, R. Chen, H. Sun, Z. Zhang, X.-Y. Zhang, Y.-X. Wang, N. Wang, Z. Huang, C. Felser, A. Agarwal, T. Ding, H.-J. Tien, A. Akey, J. Gardener, B. Singh, K. Watanabe, T. Taniguchi, K. S. Burch, D. C. Bell, B. B. Zhou, W. Gao, H.-Z. Lu, A. Bansil, H. Lin, T.-R. Chang, L. Fu, Q. Ma, N. Ni, and S.-Y. Xu, Layer Hall effect in a 2D topological axion antiferromagnet, Nature 595, 521 (2021).
  * Liu  _et al._ [2020] C. Liu, Y. Wang, H. Li, Y. Wu, Y. Li, J. Li, K. He, Y. Xu, J. Zhang, and Y. Wang, Robust axion insulator and Chern insulator phases in a two-dimensional antiferromagnetic topological insulator, Nat. Mater. 19, 522 (2020).
  * Chen  _et al._ [2021] R. Chen, S. Li, H.-P. Sun, Q. Liu, Y. Zhao, H.-Z. Lu, and X. C. Xie, Using nonlocal surface transport to identify the axion insulator, Phys. Rev. B 103, L241409 (2021).
  * Zhang  _et al._ [2019] D. Zhang, M. Shi, T. Zhu, D. Xing, H. Zhang, and J. Wang, Topological axion states in the magnetic insulator $\mathrm{MnBi_{2}Te_{4}}$ with the quantized magnetoelectric effect, Phys. Rev. Lett. 122, 206401 (2019).
  * Zhang  _et al._ [2020] R.-X. Zhang, F. Wu, and S. Das Sarma, Möbius insulator and higher-order topology in $\rm{{MnBi_{2n}}{Te_{3n+1}}}$, Phys. Rev. Lett. 124, 136407 (2020).
  * Sass  _et al._ [2020a] P. M. Sass, W. Ge, J. Yan, D. Obeysekera, J. J. Yang, and W. Wu, Magnetic imaging of domain walls in the antiferromagnetic topological insulator $\mathrm{MnBi_{2}Te_{4}}$, Nano Lett. 20, 2609 (2020a).
  * Sass  _et al._ [2020b] P. M. Sass, J. Kim, D. Vanderbilt, J. Yan, and W. Wu, Robust ${A}$-type order and spin-flop transition on the surface of the antiferromagnetic topological insulator $\mathrm{MnBi_{2}Te_{4}}$, Phys. Rev. Lett. 125, 037201 (2020b).
  * Yang  _et al._ [2020] Y. Yang, Z. Jia, Y. Wu, R.-C. Xiao, Z. H. Hang, H. Jiang, and X. Xie, Gapped topological kink states and topological corner states in honeycomb lattice, Sci. Bull. 65, 531 (2020).
  * Bernevig  _et al._ [2006] B. A. Bernevig, T. L. Hughes, and S.-C. Zhang, Quantum spin hall effect and topological phase transition in HgTe quantum wells, Science 314, 1757 (2006).
  * König  _et al._ [2007] M. König, S. Wiedmann, C. Brüne, A. Roth, H. Buhmann, L. W. Molenkamp, X.-L. Qi, and S.-C. Zhang, Quantum spin Hall insulator state in HgTe quantum wells, Science 318, 766 (2007).
  * Chen  _et al._ [2013a] G. Chen, J. Zhu, A. Quesada, J. Li, A. T. N’Diaye, Y. Huo, T. P. Ma, Y. Chen, H. Y. Kwon, C. Won, Z. Q. Qiu, A. K. Schmid, and Y. Z. Wu, Novel chiral magnetic domain wall structure in $\mathrm{Fe}/\mathrm{Ni}/\mathrm{Cu}(001)$ films, Phys. Rev. Lett. 110, 177204 (2013a).
  * Chen  _et al._ [2013b] G. Chen, T. Ma, A. T. N’Diaye, H. Kwon, C. Won, Y. Wu, and A. K. Schmid, Tailoring the chirality of magnetic domain walls by interface engineering, Nat. Commun. 4, 2671 (2013b).
  * Yasuda  _et al._ [2017] K. Yasuda, M. Mogi, R. Yoshimi, A. Tsukazaki, K. S. Takahashi, M. Kawasaki, F. Kagawa, and Y. Tokura, Quantized chiral edge conduction on domain walls of a magnetic topological insulator, Science 358, 1311 (2017).
  * Zhou  _et al._ [2018] Y.-F. Zhou, Z. Hou, and Q.-F. Sun, Configuration-sensitive transport at the domain walls of a magnetic topological insulator, Phys. Rev. B 98, 165433 (2018).
  * Ju  _et al._ [2015] L. Ju, Z. Shi, N. Nair, Y. Lv, C. Jin, J. Velasco, C. Ojeda-Aristizabal, H. A. Bechtel, M. C. Martin, A. Zettl, J. Analytis, and F. Wang, Topological valley transport at bilayer graphene domain walls, Nature 520, 650 (2015).
  * Li  _et al._ [2016] J. Li, K. Wang, K. J. McFaul, Z. Zern, Y. Ren, K. Watanabe, T. Taniguchi, Z. Qiao, and J. Zhu, Gate-controlled topological conducting channels in bilayer graphene, Nat. Nanotechnol. 11, 1060 (2016).
  * Li  _et al._ [2018] J. Li, R.-X. Zhang, Z. Yin, J. Zhang, K. Watanabe, T. Taniguchi, C. Liu, and J. Zhu, A valley valve and electron beam splitter, Science 362, 1149 (2018).
  * Chen  _et al._ [2020] H. Chen, P. Zhou, J. Liu, J. Qiao, B. Oezyilmaz, and J. Martin, Gate controlled valley polarizer in bilayer graphene, Nat. Commun. 11, 1202 (2020).
  * Martin  _et al._ [2008] I. Martin, Y. M. Blanter, and A. F. Morpurgo, Topological confinement in bilayer graphene, Phys. Rev. Lett. 100, 036804 (2008).
  * Jiang  _et al._ [2009] H. Jiang, L. Wang, Q.-f. Sun, and X. C. Xie, Numerical study of the topological anderson insulator in HgTe/CdTe quantum wells, Phys. Rev. B 80, 165316 (2009).


# Sequence-to-Sequence Model with Transformer-based Attention Mechanism and
Temporal Pooling for Non-Intrusive Load Monitoring

Mohammad Irani Azad  Faculty of ECE
Qom University of Technology
Qom, Iran
<EMAIL_ADDRESS>Roozbeh Rajabi  Faculty of ECE
Qom University of Technology
Qom, Iran
<EMAIL_ADDRESS>Abouzar Estebsari  School of the Built Environment and
Architecture
London South Bank University
London, United Kingdom
<EMAIL_ADDRESS>
###### Abstract

This paper presents a novel Sequence-to-Sequence (Seq2Seq) model based on a
transformer-based attention mechanism and temporal pooling for Non-Intrusive
Load Monitoring (NILM) of smart buildings. The paper aims to improve the
accuracy of NILM by using a deep learning-based method. The proposed method
uses a Seq2Seq model with a transformer-based attention mechanism to capture
the long-term dependencies of NILM data. Additionally, temporal pooling is
used to improve the model’s accuracy by capturing both the steady-state and
transient behavior of appliances. The paper evaluates the proposed method on a
publicly available dataset and compares the results with other state-of-the-
art NILM techniques. The results demonstrate that the proposed method
outperforms the existing methods in terms of both accuracy and computational
efficiency.

###### Index Terms:

NILM, Smart Building, Deep Learning, Transformer, Attention Mechanism.

##  I Introduction

Non-intrusive load monitoring (NILM) is a technique used to separate
electricity consumption at the household appliance level. Smart meters only
provide total energy consumption at the building level, which may not be
sufficient to influence consumer behavior. The NILM process includes data
collection, feature extraction, event detection, load identification, and
energy separation, and machine learning techniques are used to identify
appliances and extract features during steady-state and transient conditions.
The NILM system can also evaluate appliance performance over a long period,
helping manufacturers improve energy efficiency. Suggestions can be sent to
consumers to reduce or postpone the use of portable appliances to non-peak
times to save energy [1].

Monitoring the energy consumption of buildings can prevent wastage and help
consumers take necessary measures. Smart meters monitor overall energy
consumption, providing regular feedback to consumers, which has been shown to
reduce energy use by 3%. Additionally, instantaneous energy consumption
feedback at the building level can save up to 9% [2]. Consumer behavior plays
a significant role in efficient energy use, and consumers are likely to change
their consumption patterns based on feedback. The NILM system is an effective
solution to monitor energy consumption and identify appliances that consume
the most energy, providing insights to consumers and manufacturers to improve
energy efficiency [3].

There are two main types of approaches in Non-Invasive Load Monitoring (NILM)
- supervised and unsupervised. The supervised approach involves training
models using the power consumption data of appliances. On the other hand,
unsupervised methods include Factorial hidden Markov models (FHMM), hidden
Markov models (HMM) [4], and methods based on event identification and
clustering. A comprehensive review of unsupervised NILM methods can be found
in [5, 6].

In recent years, various neural network-based methods under the supervision of
NILM have been presented, thanks to the development of deep neural networks.
Significant progress has been made through the use of Convolutional Neural
Networks (CNN) [7, 8]. One method, called WaveNILM [9], is based on a gated
version of the dilated causal convolutional layer (DC-CNN) and examines the
benefits of additional input signals while maintaining causality. Another
method, proposed in [10] that used a variational autoencoder, consists of two
main parts: Net-IBN and VAE. Net-IBN is used to extract relevant features from
raw power consumption measurements, and these features are then used in the
VAE model to estimate the power consumption of each electrical device.

In a different study [11], a neural network-based structure called Concurrent
Loads Disaggregator (COLD) was developed to solve the NILM problem. The COLD
network is based on a feedforward ReLu network with a self-attention mechanism
that estimates any continuous function. The input of the spectrogram matrix
network is obtained from the Short Time Fourier Transform (STFT) and is
related to cumulative consumption information, and the output of the network
is binary vectors that indicate the activity or inactivity of electrical
devices at each time step.

Another method based on transformers, called ELECTRIcity [12], extracts
features from the cumulative signal of electricity consumption. During the
pre-processing stage, the model consists of a transformer-based generator and
a discriminator to improve performance. The generator generates artificial
signals for electrical devices using cumulative signals, and the discriminator
distinguishes the artificial data produced by the generator from real data.
During the training phase, the pre-trained transformer is fine-tuned in a
supervised manner to predict the amount of power consumed by the electrical
appliances.

In a general sense, the goal of another study is to separate the consumption
of electrical appliances based on the amount of consumption by the entire
household. The architecture considered in this study is a combination of
ResNet and Dialed Convolution network architecture. ResNet solves the gradient
fading problem that occurs when the number of layers in a network increases,
and Dialed Convolution is used instead of pooling layers to extract local
information with less information loss [13].

Overall, these methods show promising results in the field of NILM, and
further research could lead to even more efficient and accurate methods for
energy consumption estimation. In the paper a method for improving non-
intrusive load monitoring (NILM) using various techniques such as attention
mechanism, temporal pooling, residual connections, and transformers is
proposed. Attention mechanism helps the model focus on relevant parts of input
sequence, temporal pooling combines representations of multiple time steps
into a single representation, residual connections bypass one or more layers
to make gradient flow smoother during training, and transformers have been
shown to achieve advanced results in NLP and time series prediction tasks.
These techniques can help improve the accuracy and robustness of energy
decomposition at the device level while reducing computational cost.

This paper is structured as follows. In Section II, we present the proposed
method, which includes the use of Transformers and Residual Connections,
Temporal Pooling, and Attention Mechanism. In Section III, we describe the
experimental setup and present the results obtained from applying the proposed
method to several publicly available datasets. In Section IV, we provide a
discussion of the results and draw conclusions regarding the effectiveness of
the proposed method. We also discuss possible directions for future work in
this area.

##  II Proposed Method

The proposed method is composed of four main parts: Attention Mechanism,
Temporal Pooling, Residual Connections, and Transformers. This section
provides a detailed explanation of the structure of the model used.

Firstly, the Attention Mechanism is a technique that allows the model to
selectively focus on the most relevant parts of the input sequence at a given
time step. This mechanism calculates the output element as a weighted sum of
input elements, where the weights are determined dynamically by the model
based on the input sequence and the current state of the model. This approach
significantly enhances the performance of sequence-to-sequence models.

Secondly, Temporal Pooling is a technique that extracts useful information
from sequential data, such as video or speech signals. It combines
representations of multiple frames or time steps into a single representation
that captures the crucial features of the entire sequence. This technique
addresses the challenge of processing sequences of variable length and allows
the model to work with fixed-size inputs by summarizing the sequence’s
information in a compact representation.

Thirdly, Residual Connections or coupling, is a technique that connects the
output of one layer to the input of the next layer, bypassing one or more
layers in between. This method makes the gradient flow more smoothly during
training, avoiding the vanishing gradient problem in deep networks. It also
allows the network to learn a residual mapping, which is easier to learn than
the full mapping from input to output, especially when the network is very
deep.

Finally, Transformers have been applied recently in non-intrusive load
monitoring to separate household power consumption into individual appliances,
achieving advanced results on a wide range of NLP and time-series prediction
tasks. Overall, the proposed method presents a robust and accurate technique
for device-level energy decomposition in NILM, reducing the computational cost
and improving the accuracy of energy decomposition. Figure 1 shows the
proposed model architecture.

Figure 1: Proposed sequence to sequence model using transformer-based
attention mechanism and temporal pooling.

##  III Dataset and Results

###  III-A Dataset

The UK-DALE dataset is a widely used dataset in the field of non-intrusive
load monitoring (NILM) and is used extensively in this article. It consists of
energy consumption data collected from five different households in England.
The dataset was collected using smart meters that were installed in each
household, and the data was sampled at a frequency of 1 Hz. Along with the
energy consumption data, device data samples were also collected every 6
seconds, providing a detailed picture of the energy usage patterns of each
household [14].

The dataset is divided into two parts: training and testing. The training
dataset consists of energy consumption and device data samples from four
households, while the remaining household is reserved for testing purposes.
The dataset contains a total of 112 days of data for the training set and 28
days of data for the testing set. Each household in the dataset has a unique
set of appliances, which provides a diverse range of energy usage patterns to
train and test the NILM algorithms.

###  III-B Experiments and Results

To assess the model’s generalization ability and its capacity to recognize the
typical characteristics of home appliances, the network was trained and tested
using seen and unseen scenarios. In the seen scenario, houses used for
training also included in the test set, and in the unseen scenario, houses
used for training of the proposed method are not included in the test set. The
model employed a multi-class classification approach for predicting the energy
consumption of appliances, assuming that their consumption remains constant
during operation. The network’s parameters were optimized through gradient
descent method using the Adam optimization algorithm with a learning rate of
$10^{-4}$ and batch size of 32. The training lasted for 300 epochs. The plot
of the loss per epoch during the training of the network is presented in
Figures 2 and 3 for the seen and unseen scenarios respectively. As it can be
seen, in both cases the algorithm is converged and reached a satisfactory
result.

The results of the proposed model are summarized in Tables I and II for seen
and unseen cases respectively. It is observed that the model achieved better
performance in terms of evaluation criteria such as SAE and F1 score than the
existing state-of-the-art methods. These outcomes demonstrate the
effectiveness of the designed model in non-intrusive load monitoring.

Figure 2: Training, validation, and test losses of the proposed method for the
seen case.

Figure 3: Training, validation, and test losses of the proposed method for the unseen case. TABLE I: Results of the proposed method for different appliances based on standard metrics in seen case. Metrics/Appliances | F1 | Precision | Recall | Acc | MCC | MAE | SAE
---|---|---|---|---|---|---|---
Fridge | 0.885 | 0.889 | 0.876 | 0.896 | 0.791 | 13.89 | -0.019
Dish Washer | 0.923 | 0.928 | 0.930 | 0.996 | 0.922 | 20.68 | -0.016
Washing Machine | 0.981 | 0.976 | 0.984 | 0.997 | 0.979 | 41.87 | -0.072
TABLE II: Results of the proposed method for different appliances based on standard metrics in unseen case. Metrics/Appliances | F1 | Precision | Recall | Acc | MCC | MAE | SAE
---|---|---|---|---|---|---|---
Fridge | 0.877 | 0.894 | 0.861 | 0.909 | 0.805 | 16.76 | -0.037
Dish Washer | 0.818 | 0.801 | 0.900 | 0.991 | 0.797 | 32.38 | 0.078
Washing Machine | 0.861 | 0.846 | 0.867 | 0.996 | 0.845 | 8.44 | 0.033

###  III-C Comparison Study

Based on the comparison of various evaluation criteria including SAE and F1
score, the results presented in Table III suggest that the proposed model
outperforms the previous methods. This indicates the potential of the proposed
model in effectively addressing the problem of non-invasive load monitoring.

TABLE III: Comparison of the proposed method with other NILM methods. Model | Metric | DW | FR | KE | MW | WM | Overall
---|---|---|---|---|---|---|---
WaveNILM | acc | - | - | - | - | - | 94.7
MAE | - | - | - | - | - | -
SAE | - | - | - | - | - | -
F1(%) | - | - | - | - | - | -
VAE-NILM | acc | - | - | - | - | - | -
MAE | 23.4 | 21.6 | 22.1 | 10.8 | 6.7 | 16.9
SAE | - | - | - | - | - | -
F1(%) | 32.1 | 80.6 | 73.5 | 64.6 | 87.1 | 67.6
COLD | acc | - | - | - | - | - | -
MAE | - | - | - | - | - | -
SAE | - | - | - | - | - | -
F1(%) | - | - | - | - | - | 94.55
ELECTRIcity | acc | 98.4 | 84.3 | 99.9 | 99.6 | 99.4 | 96.32
MAE | 18.96 | 22.61 | 9.26 | 6.28 | 3.65 | 12.152
SAE | - | - | - | - | - | -
F1(%) | 81.8 | 81.0 | 93.9 | 27.7 | 79.7 | 72.82
D-ResNet | acc | 98.8 | 99.6 | 99.8 | 100 | 99.6 | 99.56
MAE | 7.8 | 2.627 | 2.518 | 1.505 | 2.966 | 3.48
SAE | 0.010 | 0.020 | 0.024 | 0.162 | 0.072 | 0.0576
F1(%) | 79.6 | 99.4 | 85.9 | 97.8 | 82.6 | 89.06
LDwA | acc | - | - | - | - | - | -
MAE | 6.57 | 13.24 | 5.69 | 3.79 | 7.26 | 7.31
SAE | 3.91 | 6.02 | 3.74 | 2.98 | 4.87 | 4.30
F1(%) | 68.99 | 87.01 | 99.81 | 67.55 | 71.94 | 79.06
Proposed method | acc | 99.6 | 89.6 | - | - | 99.7 | 96.33
MAE | 20.68 | 13.89 | - | - | 41.87 | 25.48
SAE | -0.016 | -0.019 | - | - | -0.072 | -0.035
F1(%) | 92.3 | 88.5 | - | - | 98.1 | 92.96

##  IV Conclusion and Future Works

In conclusion, the proposed model in this paper shows improved performance in
non-invasive load monitoring compared to previous methods. The incorporation
of attention mechanism, time composition, residual connections, and
transformers in the model allows for a better depiction of the complex
temporal patterns and dependencies of energy consumption data. The model was
able to accurately identify the consumption patterns of each household
appliance, even in situations where there was a significant overlap between
their energy consumption patterns.

The implications of accurately identifying the energy consumption patterns of
personal appliances in a household are significant for energy-saving
challenges, as it can help families better understand their energy consumption
and identify areas where they can reduce their energy consumption. However,
there is still room for future research to improve the proposed model’s
performance, optimize it for accuracy and computational efficiency, evaluate
it on larger and more diverse data sets, and compare it with other advanced
models and methods.

Furthermore, incorporating additional features such as time, day, weather
conditions, etc., and extending the model to multi-task learning settings or
combining it with other techniques such as transfer learning and group
learning can contribute to the development of more accurate and efficient
energy management systems. Overall, these future research directions can
contribute to the advancement of the field of non-invasive load monitoring and
have important implications for energy-saving and sustainability.

## References

  * [1] D. Weißhaar, P. Held, D. Benyoucef, D. Ould Abdeslam, P. Wira, and J. Mercklé, _Smart Meters Improved by NILM_. Cham: Springer International Publishing, 2023, pp. 29–54.
  * [2] A. L. Davis, T. Krishnamurti, B. Fischhoff, and W. Bruine de Bruin, “Setting a standard for electricity pilot studies,” _Energy Policy_ , vol. 62, pp. 401–409, 2013. [Online]. Available: https://www.sciencedirect.com/science/article/pii/S0301421513007362
  * [3] R. Gopinath, M. Kumar, C. Prakash Chandra Joshua, and K. Srinivas, “Energy management using non-intrusive load monitoring techniques – state-of-the-art and future research directions,” _Sustainable Cities and Society_ , vol. 62, p. 102411, 2020. [Online]. Available: https://www.sciencedirect.com/science/article/pii/S2210670720306326
  * [4] J. Z. Kolter and T. Jaakkola, “Approximate inference in additive factorial hmms with application to energy disaggregation,” in _Proceedings of the Fifteenth International Conference on Artificial Intelligence and Statistics_ , ser. Proceedings of Machine Learning Research, N. D. Lawrence and M. Girolami, Eds., vol. 22. La Palma, Canary Islands: PMLR, 21–23 Apr 2012, pp. 1472–1482.
  * [5] R. Bonfigli, S. Squartini, M. Fagiani, and F. Piazza, “Unsupervised algorithms for non-intrusive load monitoring: An up-to-date overview,” in _2015 IEEE 15th International Conference on Environment and Electrical Engineering (EEEIC)_ , 2015, pp. 1175–1180.
  * [6] M. Zhuang, M. Shahidehpour, and Z. Li, “An overview of non-intrusive load monitoring: Approaches, business applications, and challenges,” in _2018 International Conference on Power System Technology (POWERCON)_ , 2018, pp. 4291–4299.
  * [7] C. Zhang, M. Zhong, Z. Wang, N. Goddard, and C. Sutton, “Sequence-to-point learning with neural networks for non-intrusive load monitoring,” in _Proceedings of the AAAI Conference on Artificial Intelligence_ , vol. 32, no. 1, 2018, pp. 1332–1339.
  * [8] C. Shin, S. Joo, J. Yim, H. Lee, T. Moon, and W. Rhee, “Subtask gated networks for non-intrusive load monitoring,” ser. AAAI’19/IAAI’19/EAAI’19. AAAI Press, 2019.
  * [9] A. Harell, S. Makonin, and I. V. Bajić, “Wavenilm: A causal neural network for power disaggregation from the complex power signal,” in _ICASSP 2019 - 2019 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)_ , 2019, pp. 8335–8339.
  * [10] A. Langevin, M.-A. Carbonneau, M. Cheriet, and G. Gagnon, “Energy disaggregation using variational autoencoders,” _Energy and Buildings_ , vol. 254, p. 111623, 2022.
  * [11] I. Kamyshev, D. Kriukov, and E. Gryazina, “Cold: Concurrent loads disaggregator for non-intrusive load monitoring,” 2021.
  * [12] S. Sykiotis, M. Kaselimi, A. Doulamis, and N. Doulamis, “Electricity: An efficient transformer for non-intrusive load monitoring,” _Sensors_ , vol. 22, no. 8, 2022.
  * [13] M. Xia, W. Liu, K. Wang, X. Zhang, and Y. Xu, “Non-intrusive load disaggregation based on deep dilated residual network,” _Electric Power Systems Research_ , vol. 170, pp. 277–285, 2019.
  * [14] J. Kelly and W. Knottenbelt, “The UK-DALE dataset, domestic appliance-level electricity demand and whole-house demand from five UK homes,” vol. 2, no. 150007, 2015.


* [64] Jacob T. Schwartz.  On programming, an interim report on the setl project.  Technical report, Courant Institute of Mathematical Sciences, New York University, NY, USA, 1973.
  * [65] Dana Stewart Scott and Christopher Strachey.  Toward a mathematical semantics for computer languages.  In Proceedings Symposium on Computers and Automata, volume 21 of Microwave Institute Symposia Series. Polytechnic Institute of Brooklyn, 1971.
  * [66] Yuri Serdyuk.  Delta-language implementation, http://www.botik.ru/~logic/bst/delta_implementation.html, 1996.  Supported by RBRF (project 96-01-01717) and INTAS (project 93-0972).
  * [67] Simon St.Laurent and Michael Fitzgerald.  XML pocket reference.  O’Reilly Media, third edition, 2005.
  * [68] Christopher Strachey.  Fundamental concepts in programming languages.  Lecture Notes, International Summer School in Computer Programming, Copenhagen, August 1967.  Reprinted in Higher-Order and Symbolic Computation, 13(1–2), pp. 1–49, 2000.
  * [69] Dan Suciu.  Typechecking for semistructured data.  In Database Programming Languages, 8th International Workshop, DBPL 2001 Frascati, Italy, September 8 10, 2001 Revised Papers, volume 2397, pages 1–20, London, UK, 2002. Springer-Verlag.
  * [70] Robert Walker Taylor and Randall L. Frank.  Codasyl data-base management systems.  ACM Computing Survey, 8(1):67–103, 1976.
  * [71] Stan J. Thomas and Patrick C. Fischer.  Nested relational structures.  Advances in Computing Research, 3:269–307, 1986.
  * [72] Dennis Tsichritzis and Frederick Horst Lochovsky.  Hierarchical data-base management: A survey.  ACM Computing. Survey, 8(1):105–123, 1976.
  * [73] Jeffrey David Ullman.  Principles of Database and Knowledge-Base Systems, volume 1 of Principles of Computer Science Series, 14.  Computer Science Press, Rockville, MD, USA, 1988.
  * [74] Moshe Y. Vardi.  The complexity of relational query languages.  In Proceedings of the Fourteenth Annual ACM Symposium on Theory of Computing, pages 137–146, San Francisco, CA, USA, 1982. ACM.
  * [75] Des Watson.  High-Level Languages and their Compilers.  Addison-Wesley Publishing Company, 1989.
  * [76] Reinhard Wilhelm and Dieter Maurer.  Compiler Design.  Addison-Wesley Publishing Company, 1995.