algo[Algorithm][List of Algorithms]

# Addressing Heterogeneity in Federated
Load Forecasting with Personalization Layers

Shourya Bose, Yu Zhang
Department of Electrical and Computer Engineering
University of California, Santa Cruz, Santa Cruz, CA

Kibaek Kim
Mathematics and Computer Science Division
Argonne National Laboratory, Lemont, IL

###### Abstract

The advent of smart meters has enabled pervasive collection of energy
consumption data for training short-term load forecasting models. In response
to privacy concerns, federated learning (FL) has been proposed as a privacy-
preserving approach for training, but the quality of trained models degrades
as client data becomes heterogeneous. In this paper we propose the use of
personalization layers for load forecasting in a general framework called PL-
FL. We show that PL-FL outperforms FL and purely local training, while
requiring lower communication bandwidth than FL. This is done through
extensive simulations on three different datasets from the NREL ComStock
repository.

## Keywords

Model personalization, federated learning, machine learning, load forecasting,
smart grid

##  I Introduction

Smart grid operations rely on effectively forecasting electrical load demands
of different participants in the grid. While commercial smart meters are
capable of collecting load data at intervals on the scale of a few minutes,
this capability so far has not translated into widespread adoption of
residence-level short-term load forecasting models. A principal reason for
this is the privacy-sensitive nature of smart meter data [1], which has led to
many legislation against downloading such data to third-party servers. On the
other hand, utility operators require high-quality forecasts in order to
balance loads in grids with high renewable penetration. This quandary can be
resolved with federated learning (FL), wherein a shared forecasting model is
trained cooperatively by all smart meters (henceforth called _clients_) and a
server, all while ensuring data localization. The latter is achieved by
sharing model parameters instead of raw data during training. There exists a
vast literature on the implementation of FL in load forecasting from the
perspective of system design [2], communications [3], choice of forecasting
model [4], data leakage from trained models [5] and methods to prevent the
same [5, 6]. Two aspects of load forecasting with FL make it distinct from
other FL applications. First, it has been observed that FL performance
degrades under data heterogeneity [7], i.e. a single shared model may not
sufficiently capture the diversity of load shapes and scales for each client.
Secondly, any model and training algorithm used must run on limited
computational resources and low communication bandwidth, as is typical for the
clients [8].

The aforementioned issues in the context of FL can be solved with
_personalization_ , wherein each client generates a model which is biased to
its own data, while retaining characteristics of the shared model.
Personalization has attracted significant research interest in the context of
load forecasting, see for e.g. [9]. These works can be classified into two
categories, i.e. those using _proximal methods_ (e.g. [2]), and those using
_fine tuning_ (e.g. [10]). In the former, a penalty term is added to the loss
during client training which discourages large deviations from the server’s
model, whereas in the latter a shared model trained using conventional FL is
further trained with each client’s data to generate personalized models.

Different from such strategies, we propose a novel approach through utilizing
_personalization layers_ (PLs) to achieve model personalization with a train
algorithm called PL-FL. PL-FL involves marking certain model parameters (or
layers) as personalized, and other as shared. PLs are updated using only local
data, while shared layer parameters participate in the FL update process (see
[11] for an implementation in computer vision domain). There are two major
benefits to using PL-FL over proximal or fine-tuning methods.

  1. 1.

Since only shared layer parameters are communicated during updates as opposed
to every parameter, the required communication bandwidth is significantly
reduced.

  2. 2.

As will be shown empirically, PL-FL achieves better performance than
conventional FL and purely local training on load forecasting tasks.

In our numerical study, we compare a wide variety of server and client
optimization algorithms reported in literature [12, 13, 14, 15] for the
purpose of training. For testing different algorithms, we use the long-short
term memory (LSTM) based load forecasting model introduced in [16]. While
there exist more sophisticated models comprising attention-based recurrent
neural networks [17], their evaluation time-complexity grows as $O(T^{2})$
where $T$ is the length of the past sequence used to generate forecasts. This
makes them unsuitable for smart meter applications, as compared to LSTM.

##  II Classical Federated Learning

Consider clients $c=1,\dots,N$ which want to collectively learn a model
$\mathbf{y}=f_{\boldsymbol{\theta}}(\mathbf{x})$, where
$\boldsymbol{\theta}\in\mathbb{R}^{p}$ is the learnable parameter. Each
possesses a dataset $D_{c}=\\{\mathbf{x}_{i},\mathbf{y}_{i}\\}_{i=1}^{n_{c}}$
and can share model updates to a central server indexed by $c=0$. The basic
framework of FL is sketched in Algorithm 1. Herein, the server executes
$T_{s}$ global epochs, each of which involves two communications and a client
update. The first communication broadcasts the server’s parameters
$\boldsymbol{\theta}^{c}_{t-1}$ to each client. This is followed by each
client $c$ updating their local models with ClientOpt for $T_{c}$ local epochs
using their data $D_{c}$, thereby generating a gradient $\mathbf{g}_{t}^{c}$
representing the local model’s update. These gradients are transferred back to
the server, which aggregates them in ServerOpt to update the server state
$\mathbf{S}_{t}$, which contains the server parameters
$\boldsymbol{\theta}^{0}_{t}$ alongside other elements.

In this paper, we consider an extensive list of federated optimization
algorithms as benchmarks for both ServerOpt and ClientOpt. The role of the
client optimizers is to minimize a loss function of the local parameters
defined at each client’s data, with some examples being stochastic gradient
descent (SGD), AdaGrad, Adam, etc. We consider four candidates for ClientOpt
_viz._ Adam, AdamAMS, Prox, and ProxAdam (see Appendix for details). All but
Prox are based on Adam, which is known to produce good training performance
due to its adaptivity. Prox and ProxAdam are the proximal variants of SGD and
Adam, respectively, to achieve model personalization in FL, as in Section IV.
We now move to ServerOpt, which aims to aggregate the gradient of client
updates in order to update the server’s parameters
$\boldsymbol{\theta}^{0}_{t}$. We consider FedAvg [13], FedAvgAdaptive [15],
FedAdagrad [14], FedAdam [14], and FedYogi [14] as candidates. All these
algorithms maintain a single set of parameters except FedAvgAdaptive, which
maintains distinct parameters for each client, thereby providing a degree of
personalization from the outset. As mentioned earlier, both server and client
states contain additional elements which aids the optimization and
aggregation. For example, adaptive algorithms maintain states $\mathbf{m}$ and
$\mathbf{v}$ apart from model parameters, which are used to track the
exponential moving average of the gradients and their second moments. This is
the case for all server and client algorithms we consider except FedAvg and
Prox.

1:Initialize server state $\mathbf{S}_{0}$

2:Locally initialize client states $\mathbf{C}^{c}_{0}$ for $c=1$ to $N$

3:for $t=1$ to $T_{s}$ do

4: for $c=1$ to $N$ do

5: Extract $\boldsymbol{\theta}_{t-1}^{0}$ from $\mathbf{S}_{t-1}$

6: $\textsc{Communicate}(\boldsymbol{\theta}_{t-1}^{0},0\rightarrow c)$

7:
$\mathbf{C}^{c}_{t},\mathbf{g}_{t}^{c}\leftarrow\textsc{ClientOpt}(\boldsymbol{\theta}_{t-1}^{0},\mathbf{C}^{c}_{t-1},D_{c},T_{c})$

8: $\textsc{Communicate}(\mathbf{g}_{t}^{c},c\rightarrow 0)$

9: end for

10:
$\mathbf{S}_{t}\leftarrow\textsc{ServerOpt}(\mathbf{S}_{t-1},\mathbf{g}_{t}^{1},\cdots,\mathbf{g}_{t}^{N})$

11:end for

12:from $\mathbf{S}_{T_{s}}$, extract $\boldsymbol{\theta}^{0}_{Ts}$ and
return $\boldsymbol{\theta}^{0}_{T_{s}}$

Algorithm Classical FL Algorithm Personalization Layers for FL (PL-FL)

1:Initialize shared server state $\mathbf{S}_{0}^{sh}$

2:Locally initialize client states $\mathbf{C}^{c}_{0}$ for $c=1$ to $N$

3:for $t=1$ to $T_{s}$ do

4: for $c=1$ to $N$ do

5: Extract $\boldsymbol{\theta}_{t-1}^{0,sh}$ from $\mathbf{S}_{t-1}^{sh}$

6: $\textsc{Communicate}(\boldsymbol{\theta}_{t-1}^{0,sh},0\rightarrow c)$

7: Extract $\boldsymbol{\theta}_{t-1}^{0,pe}$ from $\mathbf{C}^{c}_{t-1}$

8:
$\boldsymbol{\theta}^{0}_{t-1}\leftarrow[\boldsymbol{\theta}_{t-1}^{0,sh},\boldsymbol{\theta}_{t-1}^{0,pe}]$

9:
$\mathbf{C}^{c}_{t},\mathbf{g}_{t}^{c}\leftarrow\textsc{ClientOpt}(\boldsymbol{\theta}_{t-1}^{0},\mathbf{C}^{c}_{t-1},D_{c},T_{c})$

10: Extract $\mathbf{g}^{c,sh}_{t}$ from $\mathbf{g}^{c}_{t}$

11: $\textsc{Communicate}(\mathbf{g}_{t}^{c,sh},c\rightarrow 0)$

12: end for

13:
$\mathbf{S}_{t}^{sh}\leftarrow\textsc{ServerOpt}(\mathbf{S}_{t-1}^{sh},\mathbf{g}_{t}^{1,sh},\cdots,\mathbf{g}_{t}^{N,sh})$

14:end for

15:from $\mathbf{S}_{T_{s}}$, extract $\boldsymbol{\theta}^{0}_{Ts}$ and
return $\boldsymbol{\theta}^{0}_{T_{s}}$

##  III Personalization Layers for FL (PL-FL)

Two major factors motivate the need for PL-FL. Firstly, we want to tackle the
non-i.i.d (independent and identically distributed) nature of data at each
client, for which personalization can be a possible solution. Secondly, we see
in Algorithm 1 that on every global epoch, the communication of vectors
$\boldsymbol{\theta}_{t}^{0}$ and $\mathbf{g}^{c}_{t}$ between each client and
the server is required. While it is possible to employ compression schemes to
reduce the size of communications, personalization allows for the transfer of
smaller vectors pertaining only to shared layers, thereby providing a
principled yet effective means of communication reduction. Note that for
proximal methods as implemented in [2], the second problem remains: full
parameter and gradient vectors are communicated on every epoch.

We introduce PL-FL for the purpose of resolving this issue, wherein each
parameter (or possibly layer) is marked either _shared_ (denoted with
superscript _sh_) and _personalized_ (denoted with superscript _pe_). In other
words, we split the model parameters as
$\boldsymbol{\theta}^{c}_{t}=[\boldsymbol{\theta}^{c,sh}_{t},\boldsymbol{\theta}^{c,pe}_{t}]$
(similarly for any associated states such as $\mathbf{m}$ and $\mathbf{v}$).
Different from classical FL, PL-FL only communicates shared parameters with
the server, while letting personalized ones remain local to each client. Since
most server algorithms (including the ones we consider in this paper) carry
out parameter-wise aggregation, it is possible to personalize any arbitrary
subset of parameters. The algorithmic steps of PL-FL are described in
Algorithm 2. We summarize three potential benefit of PL-FL.

  * •

Communication Efficiency: The amount of communication needed reduces since we
transfer $(\boldsymbol{\theta}^{sh}_{t-1},\mathbf{g}^{c,sh}_{t-1})$ as opposed
to the larger $(\boldsymbol{\theta}_{t-1},\mathbf{g}^{c}_{t-1})$.

  * •

Combatting Heterogeneity: The effect of data heterogeneity (non-i.i.d data) on
FL is mitigated by letting parameters $\boldsymbol{\theta}^{c,pe}_{t}$ remain
local to each client. This allows better fitting of local data, while a common
shared representation is learned via shared parameters
$\boldsymbol{\theta}^{c,sh}_{t}$.

  * •

Model Privacy: Since the server never possesses a full set of parameters,
inference remains local to each client, thereby enhancing privacy. Third
parties may request forecasts from local models as needed, which are computed
locally.

As compared to PL-FL, proximal methods do not offer the first benefit since
the server has to communicate the full weights $\boldsymbol{\theta}^{0}_{t}$
on every global epoch. Furthermore, we show in Section IV that PL-FL offers
much better performance than using purely proximal methods. On the other hand,
proximal methods themselves can be made amenable to PL-FL by only considering
proximal penalties corresponding to shared parameters which we test.
Furthermore, we forgo testing more complex server algorithms such as FedDANE
[18] and SCAFFOLD [19] due to multiple back-and-forth communications needed
per server epoch, which increases computation and communication overheads.

##  IV Case Study

In this section, we compare different algorithms using the LSTM load
forecasting model and NREL ComStock dataset [20]. The trained model accuracy
on each client’s model, as well as the amount of communication are compared.

###  IV-A Load Forecasting Model

Algorithm LSTMCell
_$\sigma\left(\,\cdot\,\right)$ denotes the sigmoid function while $\odot$
represents elementwise product_

1:Input: $\mathbf{h}_{t-1},\mathbf{c}_{t-1},\mathbf{x}_{t}$

2:Parameters:
$\mathbf{W}_{ii},\mathbf{W}_{hi},\mathbf{b}_{i},\mathbf{W}_{if},\mathbf{W}_{hf},\mathbf{b}_{f},$

3:$\mathbf{W}_{ig},\mathbf{W}_{hg},\mathbf{b}_{g},\mathbf{W}_{io},\mathbf{W}_{ho},\mathbf{b}_{o}$

4:$\mathbf{i}_{t}\leftarrow\sigma\left(\mathbf{W}_{ii}\mathbf{x}_{t}+\mathbf{W}_{hi}\mathbf{h}_{t-1}+\mathbf{b}_{i}\right)$

5:$\mathbf{f}_{t}\leftarrow\sigma\left(\mathbf{W}_{if}\mathbf{x}_{t}+\mathbf{W}_{hf}\mathbf{h}_{t-1}+\mathbf{b}_{f}\right)$

6:$\mathbf{g}_{t}\leftarrow\text{tanh}\left(\mathbf{w}_{ig}\mathbf{x}_{t}+\mathbf{W}_{hg}\mathbf{h}_{t-1}+\mathbf{b}_{g}\right)$

7:$\mathbf{o}_{t}=\sigma\left(\mathbf{W}_{io}\mathbf{x}_{t}+\mathbf{W}_{ho}\mathbf{h}_{t-1}+\mathbf{b}_{o}\right)$

8:$\mathbf{c}_{t}=\mathbf{f}_{t}\odot\mathbf{c}_{t-1}+\mathbf{i}_{t}\odot\mathbf{g}_{t}$

9:$\mathbf{h}_{t}=\mathbf{o}_{t}\odot\text{tanh}\left(\mathbf{c}_{t}\right)$

10:return $\mathbf{h}_{t},\mathbf{c}_{t}$

The LSTM model is capable of learning load forecasting problems of the form
$\hat{y}_{T+L}=f_{\boldsymbol{\theta}}(y_{1},\cdots,y_{T},\mathbf{z}_{1},\cdots,\mathbf{z}_{T})$.
Here $y_{t}\in\mathbb{R}$ represents the load, while
$\mathbf{z}_{t}\in\mathbb{R}^{d}$ represents additional features such as
datetime indices, weather forecasts, building characteristics, etc. The
quantities $T$ and $L$ are called look-back and look-ahead, and denote the
number of past data points ($T$) required to estimate the demand $L$ steps in
the future. Therefore, the inputs $\mathbf{x}_{i}$ and labels $\mathbf{y}_{i}$
of any dataset over which LSTM trains are given as

$\displaystyle\mathbf{x}_{i}=\left\\{\begin{bmatrix}y_{1}\\\
\mathbf{z}_{1}\end{bmatrix},\cdots,\begin{bmatrix}y_{T}\\\
\mathbf{z}_{T}\end{bmatrix}\right\\},\quad\mathbf{y}_{i}=y_{T+L},$

wherein each input-label pair $i$ may be drawn from any random point in the
historical data stored at each client. LSTM at its core consists of a
recursive rollout of a LSTMCell kernel (Algorithm 6), which ingests previous
hidden and cell states $\mathbf{h}_{t-1},\mathbf{c}_{t-1}$ as well as the
current input $\mathbf{x}_{t}$ to generate updated states
$\mathbf{h}_{t},\mathbf{c}_{t}$. The final forecast $\hat{y}_{T+L}$ is
generated by passing the hidden states $\mathbf{h}_{1},\cdots,\mathbf{h}_{T}$
through a multilayer perceptron (MLP) to generate the forecast
$\hat{y}_{T+L}$. Overall, LSTM inference can be described as

$\displaystyle\mathbf{h}_{t},\mathbf{c}_{t}=\text{LSTMCell}(\mathbf{h}_{t-1},\mathbf{c}_{t-1},\mathbf{x}_{t}),\forall
t\in\\{1,\cdots,T\\}$
$\displaystyle\mathbf{h}_{0}=\mathbf{c}_{0}=\mathbf{0},\quad\hat{y}_{T+L}=\text{MLP}(\mathbf{h}_{1},\cdots,\mathbf{h}_{T}).$

Note that the total parameter $\boldsymbol{\theta}$ of the LSTM model includes
parameters from the LSTMCell as well as those of the MLP. For the purpose of
PL-FL, we consider three configurations:

  * •

P1: All parameters shared (i.e. FL)

  * •

P2: LSTMCell parameters shared, MLP parameters personalized

  * •

P3: All parameters personalized (i.e. purely local training)

Comparisons between these three schemes enable us to evaluate the benefits of
PL-FL. In order to keep the model size small and amenable to running on
clients, we choose $\mathbf{h}_{t},\mathbf{c}_{t}\in\mathbb{R}^{25}$ and use a
MLP with layer input sizes $(300,150,75)$ and PReLU activations.

###  IV-B Dataset

[width=]img/var.pdf

Figure 1: Mean and standard deviation of loads of 12 clients each from the
tree datasets.

[width=]img/comm.pdf

Figure 2: Total data transferred per global epoch per client. This consists of
a bidirectional communication between the server and client.

We use the NREL ComStock dataset, which is a semi-synthetic dataset consisting
of load shapes and other features for different commercial buildings across
all 50 US states. We choose 12 randomly selected buildings (corresponding to
clients) from the states of California, Illinois and New York, which are
treated as three separate experiments. Apart from loads, we select $d=7$
features for $\mathbf{z}_{t}$, which include date and time indices,
temperature, windspeed, and static building features such as floor space, wall
area, and window area. The heterogeneity in clients’ load data is reflected in
Figure 1. Herein, it can be seen that the temporal mean and standard deviation
of each client’s loads differ significantly in scale, which reflects the
reality of different buildings having diverse load consumption patterns.

The dataset contains one year’s data at a granularity of 15 minutes. We split
the data along the time axis in a ratio of $0.8:0.1:0.1$ as training,
validation, and test sets respectively. We choose a look-back of $T=12$ (3
hours) to generate a forecast $L=4$ steps (1 hour) into the future. In the
interest of reducing computational burden, we choose a small batch size of 16.

###  IV-C Setup and Simulation Results

[width=0.83]img/results.pdf

Figure 3: Average MASE metric on the test set for different client and server
algorithms via PL-FL. These are calculated for local training, MLP
personalization, and all layers shared (FL). Three datasets _viz._ New York,
Illinois, and California are used.

All code is written in PyTorch with the aid of the APPFL package [21], and
implemented using PyTorch and OpenMPI. We use MASE errors,

$\displaystyle\text{MASE}=\frac{\sum_{t}|\hat{x}_{t}-x_{t}|}{\sum_{t}|x_{t-L}-x_{t}|},$

wherein it is assumed that both sequences are aligned and the number of terms
in the numerator and denominator are equal. MASE values of less than 1 can be
interpreted as the forecasts being of a better quality than the persistent
method, i.e. forecasting the last known data point. The results can be seen in
Figure 3. Immediately, it is obvious that adaptive methods such as Adam and
AdamAMS perform better than proximal methods across all tests. Furthermore,
for all three datasets, the best performance is achieved when the MLP is
personalized and Adam is used, thereby showing the advantages of local
adaptive optimization. Combined with the per-epoch data transfer shown in
Figure 2, it is obvious that PL-FL with adaptive algorithms performs better
than even purely local training, while taking a fraction of the bandwidth of
FL. However, it is important to note that none of the tests achieved a MASE of
$<1$ on the California dataset, which might indicate the need for more
sophisticated forecast models or better feature selection for that dataset.

##  V Conclusion

In this paper, we introduced PL-FL, which is a framework to train personalized
load forecasting models for smart meter clients. We tested a variety of client
and server algorithms over multiple datasets, which showed that PLs are
effective in improving FL across all settings. Future work involves the design
of distributed model inference schemes, which enables practical implementation
of PL-FL on commercial smart meter hardware.

## References

  * [1] M. R. Asghar, G. Dán, D. Miorandi, and I. Chlamtac, “Smart meter data privacy: A survey,” _IEEE Communications Surveys & Tutorials_, vol. 19, no. 4, pp. 2820–2835, 2017.
  * [2] A. Taïk and S. Cherkaoui, “Electrical load forecasting using edge computing and federated learning,” in _ICC 2020–2020 IEEE International Conference on Communications (ICC)_ , 2020, pp. 1–6.
  * [3] Z. Mao, H. Li, Z. Huang, C. Yang, Y. Li, and Z. Zhou, “Communication-efficient federated learning for power load forecasting in electric iots,” _IEEE Access_ , vol. 11, pp. 47 930–47 939, 2023.
  * [4] Y. Shi and X. Xu, “Deep federated adaptation: An adaptative residential load forecasting approach with federated learning,” _Sensors_ , vol. 22, no. 9, 2022. [Online]. Available: https://www.mdpi.com/1424-8220/22/9/3264
  * [5] M. A. Husnoo, A. Anwar, N. Hosseinzadeh, S. N. Islam, A. N. Mahmood, and R. Doss, “A secure federated learning framework for residential short term load forecasting,” _IEEE Transactions on Smart Grid_ , pp. 1–1, 2023.
  * [6] D. Qin, C. Wang, Q. Wen, W. Chen, L. Sun, and Y. Wang, “Personalized federated DARTS for electricity load forecasting of Individual buildings,” _IEEE Transactions on Smart Grid_ , pp. 1–1, 2023.
  * [7] A. Azeem, I. Ismail, S. M. Jameel, F. Romlie, K. U. Danyaro, and S. Shukla, “Deterioration of electrical load forecasting models in a smart grid environment,” _Sensors_ , vol. 22, no. 12, 2022. [Online]. Available: https://www.mdpi.com/1424-8220/22/12/4363
  * [8] M. technology. [Online]. Available: https://www.microchip.com/en-us/products/smart-energy-metering
  * [9] F. Widmer, S. Nowak, B. Bowler, P. Huber, and A. Papaemmanouil, “Data-driven comparison of federated learning and model personalization for electric load forecasting,” _Energy and AI_ , vol. 14, p. 100253, 2023. [Online]. Available: https://www.sciencedirect.com/science/article/pii/S2666546823000253
  * [10] C. Briggs, Z. Fan, and P. Andras, “Federated learning for short-term residential load forecasting,” _arXiv preprint arXiv:2105.13325_ , 2021.
  * [11] M. G. Arivazhagan, V. Aggarwal, A. K. Singh, and S. Choudhary, “Federated learning with personalization layers,” _arXiv preprint arXiv:1912.00818_ , 2019.
  * [12] S. J. Reddi, S. Kale, and S. Kumar, “On the convergence of adam and beyond,” _arXiv preprint arXiv:1904.09237_ , 2019.
  * [13] B. McMahan, E. Moore, D. Ramage, S. Hampson, and B. A. y Arcas, “Communication-efficient learning of deep networks from decentralized data,” in _Artificial intelligence and statistics_. PMLR, 2017, pp. 1273–1282.
  * [14] S. J. Reddi, Z. Charles, M. Zaheer, Z. Garrett, K. Rush, J. Konečný, S. Kumar, and H. B. McMahan, “Adaptive federated optimization,” in _International Conference on Learning Representations_ , 2021. [Online]. Available: https://openreview.net/forum?id=LkFG3lB13U5
  * [15] X. Wu, F. Huang, Z. Hu, and H. Huang, “Faster adaptive federated learning,” in _Proceedings of the AAAI Conference on Artificial Intelligence_ , vol. 37, no. 9, 2023, pp. 10 379–10 387.
  * [16] W. Kong, Z. Y. Dong, Y. Jia, D. J. Hill, Y. Xu, and Y. Zhang, “Short-term residential load forecasting based on lstm recurrent neural network,” _IEEE transactions on smart grid_ , vol. 10, no. 1, pp. 841–851, 2017.
  * [17] Y. Qin, D. Song, H. Chen, W. Cheng, G. Jiang, and G. W. Cottrell, “A dual-stage attention-based recurrent neural network for time series prediction,” in _Proceedings of the Twenty-Sixth International Joint Conference on Artificial Intelligence, IJCAI-17_ , 2017, pp. 2627–2633. [Online]. Available: https://doi.org/10.24963/ijcai.2017/366
  * [18] T. Li, A. K. Sahu, M. Zaheer, M. Sanjabi, A. Talwalkar, and V. Smithy, “Feddane: A federated newton-type method,” in _2019 53rd Asilomar Conference on Signals, Systems, and Computers_. IEEE, 2019, pp. 1227–1231.
  * [19] S. P. Karimireddy, S. Kale, M. Mohri, S. Reddi, S. Stich, and A. T. Suresh, “Scaffold: Stochastic controlled averaging for federated learning,” in _International conference on machine learning_. PMLR, 2020, pp. 5132–5143.
  * [20] A. Parker, H. Horsey, M. Dahlhausen, M. Praprost, C. CaraDonna, A. LeBar, and L. Klun, “Comstock reference documentation: Version 1,” National Renewable Energy Lab.(NREL), Golden, CO (United States), Tech. Rep., 2023.
  * [21] M. Ryu, Y. Kim, K. Kim, and R. K. Madduri, “APPFL: Open-source software framework for privacy-preserving federated learning,” in _2022 IEEE International Parallel and Distributed Processing Symposium Workshops (IPDPSW)_ , 2022, pp. 1074–1083.

##  Appendix A Appendix

Optimizer | Local State $\mathbf{C}^{c}_{t}$ | ClientOpt
---|---|---
Adam AdamAMS Prox ProxAdam |  $\\{\boldsymbol{\theta}^{c}_{t},\mathbf{m}^{c}_{t},\mathbf{v}^{c}_{t}\\}$ $\\{\boldsymbol{\theta}^{c}_{t},\mathbf{m}^{c}_{t},\mathbf{v}^{c}_{t}\\}$ $\\{\boldsymbol{\theta}^{c}_{t}\\}$ $\\{\boldsymbol{\theta}^{c}_{t},\mathbf{m}^{c}_{t},\mathbf{v}^{c}_{t}\\}$ |  1:Inputs: $\boldsymbol{\theta}^{0}_{t-1},\mathbf{C}^{c}_{t-1},D_{c},T_{c}$ 2:Hyperparameters: Client learning rate $\eta$, Adaptivity parameters $\beta_{1},\beta_{2},\epsilon$ (for Adam,AdamAMS,ProxAdam)  3:Extract $\boldsymbol{\theta}^{c}_{t-1}$ from $\mathbf{C}^{c}_{t-1}$ and set $\boldsymbol{\theta}^{c}_{t,0}\leftarrow\boldsymbol{\theta}^{c}_{t-1}$ {AdamAMS,ProxAdam}  4:Initialize $\mathbf{m}^{c}_{t,0}$, $\mathbf{v}^{c}_{t,0},\mathbf{v}^{c,\max}_{t,0}$ depending on optimizer  5:for $t^{\prime}=1$ to $T_{c}$ do 6: Sample minibatch $D_{c,t^{\prime}}$ from $D_{c}$ of size $B$ 7: $\mathbf{g}_{t,t^{\prime}-1}^{c}\leftarrow\frac{1}{B}\sum\limits_{((\mathbf{x},\mathbf{y})\in D_{c,t^{\prime}}}\hskip-14.22636pt\nabla_{\boldsymbol{\theta}}(f_{\boldsymbol{\theta}}(\mathbf{x})-\mathbf{y})^{2}$ {Adam,AdamAMS}  6: $\mathbf{g}_{t,t^{\prime}-1}^{c}\leftarrow\frac{1}{B}\sum\limits_{((\mathbf{x},\mathbf{y})\in D_{c,t^{\prime}}}\hskip-14.22636pt\nabla_{\boldsymbol{\theta}}\left((f_{\boldsymbol{\theta}}(\mathbf{x})-\mathbf{y})^{2}+\alpha\lVert\boldsymbol{\theta}-\boldsymbol{\theta}^{0}_{t-1}\rVert_{2}^{2}\right)\big{|}_{\boldsymbol{\theta}\leftarrow\boldsymbol{\theta}^{c}_{t,t^{\prime}-1}}$ {Prox, ProxAdam}  7: $\mathbf{m}^{c}_{t}\leftarrow\beta_{1}\mathbf{m}^{c}_{t-1}+(1-\beta_{1})\mathbf{g}_{t,t^{\prime}-1}^{c}$ {Adam,AdamAMS,ProxAdam}  8: $\mathbf{v}^{c}_{t,t^{\prime}}\leftarrow\beta_{2}\mathbf{v}^{c}_{t-1}+(1-\beta_{2})(\mathbf{g}_{t,t^{\prime}-1}^{c})^{2}$ {Adam,AdamAMS,ProxAdam}  9: $\hat{\mathbf{m}}^{c}_{t,t^{\prime}},\hat{\mathbf{v}}^{c}_{t,t}\leftarrow\frac{\mathbf{m}^{c}_{t,t^{\prime}}}{1-\beta_{1}^{t}},\frac{\mathbf{v}^{c}_{t,t^{\prime}}}{1-\beta_{2}^{t}}$ {Adam,AdamAMS,ProxAdam}  10: $\mathbf{v}^{c,\max}_{t,t^{\prime}}\leftarrow\max\left(\mathbf{v}^{c,\max}_{t,t^{\prime}-1},\hat{\mathbf{v}}^{c}_{t,t^{\prime}}\right)$ {AdamAMS}  11: $\boldsymbol{\theta}^{c}_{t,t^{\prime}}\leftarrow\boldsymbol{\theta}^{c}_{t,t^{\prime}-1}-\eta\mathbf{g}^{c}_{t,t^{\prime}-1}$ {Prox}  11: $\boldsymbol{\theta}^{c}_{t,t^{\prime}}\leftarrow\boldsymbol{\theta}^{c}_{t,t^{\prime}-1}-\eta\frac{\hat{\mathbf{m}}^{c}_{t,T_{c}}}{\sqrt{\hat{\mathbf{v}}^{c}_{t,t^{\prime}}}+\epsilon}$ {Adam,ProxAdam}  11: $\boldsymbol{\theta}^{c}_{t,t^{\prime}}\leftarrow\boldsymbol{\theta}^{c}_{t,t^{\prime}-1}-\eta\frac{\hat{\mathbf{m}}^{c}_{t,t^{\prime}}}{\sqrt{\hat{\mathbf{v}}^{c,\max}_{t,T_{c}}}+\epsilon}$ {AdamAMS}  12:end for 13:$\mathbf{g}^{c}_{t}\leftarrow\boldsymbol{\theta}^{c}_{t,0}-\boldsymbol{\theta}^{c}_{t,T_{c}}$ 14:$\mathbf{C}^{c}_{t}\leftarrow\\{\theta^{c}_{t}=\theta^{c}_{t,T_{c}}\\}${Prox}  14:$\mathbf{C}^{c}_{t}\leftarrow\\{\theta^{c}_{t}=\theta^{c}_{t,T_{c}},\mathbf{m}^{c}_{t}=\mathbf{m}^{c}_{t,T_{c}},\mathbf{v}^{c}_{t}=\mathbf{v}^{c}_{t,T_{c}}\\}${Adam,AdamAMS,ProxAdam}  15:return $\mathbf{C}^{c}_{t}$, $\mathbf{g}^{c}_{t}$

Figure 4: A schematic of ClientOpt for different client algorithms. Note that in line 4, client states $\mathbf{m}$ or $\mathbf{v}$ are reinitialized rather than inheriting stale values to ensure better performance. All vector operations here are elementwise. Optimizer | Server State $\mathbf{S}_{t}$ | ServerOpt
---|---|---
FedAvg FedAdagrad FedYogi FedAdam FedAvgAdaptive |  $\\{\boldsymbol{\theta}_{t}^{0}\\}$ $\\{\boldsymbol{\theta}_{t}^{0},\mathbf{m}^{0}_{t},\mathbf{v}^{0}_{t}\\}$ $\\{\boldsymbol{\theta}_{t}^{0},\mathbf{m}^{0}_{t},\mathbf{v}^{0}_{t}\\}$ $\\{\boldsymbol{\theta}_{t}^{0},\mathbf{m}^{0}_{t},\mathbf{v}^{0}_{t}\\}$ $\\{\\{\boldsymbol{\theta}_{t}^{0,(c)},$
$\mathbf{v}^{0,(c)}_{t}\\}_{c=1}^{N}\\}$ |  1:Inputs: $\boldsymbol{\theta}^{0}_{t-1},\mathbf{C}^{c}_{t-1},D_{c},T_{c}$ 2:Hyperparameters: Server learning rate $\eta_{s}$, Server adaptivity parameters $\beta_{1s},\beta_{2s},\epsilon_{s}$ (for FedAdagrad, FedYogi, FedAdam, FedAvgAdaptive)  3:$\bar{\mathbf{g}}_{t}\leftarrow\sum_{c=1}^{N}\mathbf{\mathbf{g}}^{c}_{t}$ 4:$\mathbf{m}^{0}_{t}\leftarrow\beta_{1s}\mathbf{m}^{0}_{t-1}+(1-\beta_{1s})\bar{\mathbf{g}}_{t}$ {FedAdagrad,FedYogi,FedAdam}  5:$\mathbf{v}^{0}_{t}\leftarrow\left(\bar{\mathbf{g}}_{t}\right)^{2}$ {FedAdagrad}  3:$\mathbf{v}^{0}_{t}\leftarrow\beta_{2s}\mathbf{v}^{0}_{t-1}-(1-\beta_{2s})\left(\bar{g}_{t}\right)^{2}\text{sign}\left(\mathbf{v}^{0}_{t-1}-\left(\bar{g}_{t}\right)^{2}\right)$ {FedYogi}  3:$\mathbf{v}^{0}_{t}\leftarrow\beta_{2s}\mathbf{v}^{0}_{t-1}-(1-\beta_{2s})\left(\bar{g}_{t}\right)^{2}$ {FedAdam}  4:$\boldsymbol{\theta}^{0}_{t}\leftarrow\boldsymbol{\theta}^{0}_{t-1}+\eta_{s}\bar{\mathbf{g}}_{t}$ {FedAvg}  5:$\boldsymbol{\theta}^{0}_{t}\leftarrow\boldsymbol{\theta}^{0}_{t-1}+\eta_{s}\frac{\mathbf{m}^{0}_{t}}{\sqrt{\mathbf{v}^{0}_{t}}+\epsilon_{s}}$ {FedAdagrad,FedYogi,FedAdam}  6:for $c=1$ to $N$ do 7: $\mathbf{v}^{0,(c)}_{t}\leftarrow\beta_{1s}\mathbf{v}^{0,(c)}_{t-1}+(1-\beta_{1s})\left(\mathbf{g}^{c}_{t}\right)^{2}$ {FedAvgAdaptive}  8: $\boldsymbol{\theta}^{0,(c)}_{t}\leftarrow\sum_{c=1}^{C}\left(\boldsymbol{\theta}^{0,(c)}_{t-1}-\eta_{s}\frac{\mathbf{g}^{c}_{t}}{\sqrt{\mathbf{v}^{0,(c)}}+\epsilon_{s}}\right)$ {FedAvgAdaptive}  9:end for 10:Populate state $\mathbf{S}_{t}$ and return
Figure 5: A schematic of ServerOpt for different server algorithms. All
algorithms use a single state except FedAvgAdaptive, which uses $N$ distinct
states for each of the clients. All vector operations here are elementwise.


# Kondo Screening Cloud Scaling: Impurity Entanglement and Magnetization

Erik S. Sørensen  0000-0002-5956-1190 Department of Physics & Astronomy,
McMaster University, Hamilton ON L8S 4M1, Canada<EMAIL_ADDRESS>
###### Abstract

The screening of an impurity spin in the Kondo model occurs over a
characteristic length scale $\xi_{K}$, that defines the size of the Kondo
screening cloud or “mist”. The presence of such a length scale in experimental
and numerical results is rather subtle. A consistent way to show the presence
of the screening cloud is to demonstrate scaling in the spatial correlations
depending on $r$, in terms of the single variable $r/\xi_{K}$ rather than
depending on $r$ and $\xi_{K}$ separately. Here we study the paradigmatic one
channel Kondo model using a spin chain representation, with an impurity spin
at one end of the chain coupled with a strength $J_{K}^{\prime}$. Using Fermi
liquid theory combined with numerical results, we obtain new high precision
estimates of the non-universal terms in the entanglement entropy which leads
to a verification of the expected non-integer ground-state degeneracy, $g$.
This then allows us to study the impurity contribution to the entanglement in
detail. If the impurity coupling $J_{K}^{\prime}$ is varied, a precise
determination of $\xi_{K}$ can then be obtained. The length scale, $\xi_{K}$,
is then shown to characterize the scaling of both the uniform and alternating
part of a measure of the magnetization of part of an odd length chain with.

##  1 Introduction

The Kondo effect [1, 2, 3] continues to yield surprising insights. In its
simplest form, the Kondo effect describes the coupling of a single $S=1/2$
impurity spin to a bath of non-interacting conduction electrons. In the
absence of any coupling, the electrons are undisturbed by the impurity, while
at very strong coupling, a single electron is trapped by the impurity, forming
a singlet at the impurity site. Intuitively, one might then expect that at
intermediate coupling the low energy physics is again described by the
formation of a singlet state between the conduction electrons and the impurity
spin, often described as a screening cloud [4]. Only a single electron is
needed to form this singlet, but in this case the screening singlet could be
macroscopic in size. The natural length scale associated with this phenomenon
is $\xi_{K}=\hbar v/k_{B}T_{K}$ with $v$ the velocity of the low energy
excitations and $T_{K}$ the Kondo temperature, and for $T_{K}\simeq 1K$, could
extend into the $\mu m$ regime for typical values of $v_{F}$. It is important
to realize that this screening cloud [4] which forms the singlet with the
impurity only involves a single electron even though it is of course a many-
body state, and it is perhaps better described as a “mist”. The presence of
the screening cloud is therefore a particular subtle feature of the Kondo
effect, since it involves spatial correlations around the impurity out to
large distances involving a single electron. It is natural to ask what it
actually means to have a screening cloud. The best definition is that physical
quantities should obey a scaling form [5] in $r/\xi_{K}$ instead of depending
on $r$ and $\xi_{K}$ independently, this then implies variations over at least
a distance of $\xi_{K}$. In fact, it is by demonstrating such scaling in
experimental data that the presence of the Kondo screening cloud has recently
been detected in experiments on quantum dots coupled to a quasi-one-
dimensional channel [6].

A focus of particular current interest has been the entanglement between the
impurity and the electrons [7]. In the strong coupling limit where a single
electron is trapped at the impurity site into a singlet state, other electrons
are not allowed onto the site since it would destroy the singlet, and we do
not expect the impurity to significantly alter the entanglement. However, for
intermediate couplings, the impurity contribution to the entanglement can be
shown to again follow a scaling form [7, 8]. At finite temperatures, the
negativity is a convenient measure of the impurity entanglement [9] and the
thermal decay of the negativity has been shown to obey a characteristic power-
law form [10, 11]. More generally, the entanglement across conformal and
topological defects has been investigated [12, 13, 14] and the Kondo effect in
spin liquids has been studied [15, 16, 17, 18, 19], but the corresponding
entanglement has so far only received limited attention. A difficulty is here
that non-universal terms appear in the entanglement entropy that are often not
known with sufficient precision. Furthermore, the impurity contribution to the
entanglement is defined by subtracting the bulk contribution, which is often a
challenging procedure. Here we revisit the one channel Kondo model and study
the impurity entanglement in detail. With open boundary conditions a
contribution arising from the non-integer ground-state degeneracy, $g$[20],
can only be precisely determined if the impurity entanglement from open
boundaries are taken into account. We then turn to the magnetization,
demonstrating similar scaling with $r/\xi_{K}$.

We shall here take the coupling between the impurity spin and the conduction
electrons to be a delta-function. The spherical symmetry of the coupling
implies that the problem can be reduced to a one-dimensional model after an
expansion in harmonics since only the s-wave harmonic interacts with the
impurity. If one linearizes the dispersion relation around the Fermi momentum,
$k_{F}$, one can then write a one-dimensional effective Hamiltonian in terms
of left and right moving Fermi fields that are functions of $(v_{F}t+x)$ and
$(v_{F}t-x)$, respectively, obeying the anti-commutation relation
$\\{\psi_{L/R}(x),\psi^{\dagger}_{L/R}(y)\\}=2\pi\delta(x-y)$:

$H=\frac{v_{F}}{2\pi}\int_{0}^{\infty}dx\left[i\psi_{L}^{\dagger}\frac{d}{dx}\psi_{L}-i\psi_{R}^{\dagger}\frac{d}{dx}\psi_{R}\right]+v_{F}\lambda_{K}\vec{S}_{\mathrm{el}}(0)\cdot\vec{S}_{\mathrm{imp}}.$
(1.1)

Here, $x$ is the radial coordinate and the impurity is now situated at $x=0$
with the electrons confined to a semi-infinite line and

$\vec{S}_{\mathrm{el}}(0)=\psi^{\dagger}_{L}(0)\frac{\vec{\sigma}}{2}\psi_{L}(0)$
(1.2)

is the electron spin density at $x=0$ and the boundary condition
$\psi_{L}(x=0)=-\psi_{R}(x=0)$ is imposed at the origin. Here, $\lambda_{K}$
is the coupling between the impurity spin and the electron spin density. (See,
for example, [21] for more details.) Since this model explicitly refer to
electronic degrees of freedom, we refer to this model as the free electron
Kondo model (FEKM).

A model closely to the one-dimensional FEKM consists of an open gap-less
spin-$\frac{1}{2}$ Heisenberg chain, defined on a semi-infinite line, with one
coupling at the end of the chain weaker than the others, described by the
following Hamiltonian.

$H_{\mathrm{1CK}}=J_{K}^{\prime}\left(\vec{S}_{1}\cdot\vec{S}_{2}+J_{2}\vec{S}_{1}\cdot\vec{S}_{3}\right)+\sum_{r=2}^{{L}-1}\vec{S}_{r}\cdot\vec{S}_{r+1}+J_{2}\sum_{r=2}^{{L}-2}\vec{S}_{r}\cdot\vec{S}_{r+2}.$
(1.3)

It turns out that a low energy field theory description of this spin chain
model is essentially the same as Eq. (1.1), and one may therefore think of Eq.
(1.3) as a spin chain Kondo model (SCKM) [7, 8, 22] equivalent to the one-
channel Kondo model. In fact, it turns out that in the limit
$J_{K}^{\prime}\to 0$, a very simple linear relation exists between
$\lambda_{K}$ in Eq. (1.1) and $J_{K}^{\prime}$ in Eq. (1.3),
$J_{K}^{\prime}=1.381\lambda_{K}$ [22]. For $J^{\prime}_{K}$=1 this model is
the well-known $J_{1}$-$J_{2}$ spin model that with $J_{2}$=0 is simply the
antiferromagnetic Heisenberg chain. However, we shall only be interested in a
very specific value of $J_{2}$, corresponding to a critical point [23]:

$J^{c}_{2}=0.24116$ (1.4)

At this value of $J_{2}$ a bulk marginally irrelevant coupling becomes exactly
zero [24], leading to the disappearances of logarithmic corrections, a
significant advantage for numerical work. For $J_{2}>J_{2}^{c}$ the SCKM
develops a gap and orders in a dimer state, and the correspondence to the FEKM
no longer holds. Another advantage of the SCKM is the significant reduction in
the on-site degrees of freedom, which means that higher precision results can
be obtained with fewer resources.

As a measure of the entanglement, we mainly focus on the von Neumann
entanglement entropy. For a subsystem of linear length $x$ the entanglement
entropy is defined in terms of the corresponding reduced density matrix,
$\rho_{x}$,

$S(x)=-\Tr\rho_{x}\log\rho_{x},$ (1.5)

where $\rho_{x}$ is obtained from the ground-state wave-function. To study the
entanglement entropy and the magnetization in the SCKM, we use density matrix
renormalization group techniques [25, 26, 27, 28, 29, 30, 31] (DMRG) on finite
chains of length up to $L=400$, typically with $\epsilon=10^{-12}$.

We begin with an analysis of quantum impurity entanglement in the SCKM,
building on previous studies [5, 7, 8, 22, 32]. Here we significantly extend
and refine many of the results. All the results in this section are obtained
using the SCKM, Eq. (1.3) at $J_{2}$=$J_{2c}$=$0.241167$. As mentioned above,
at this value of $J_{2}$ corrections arising from the bulk marginal operator
are absent, significantly improving the precision of the results. In the
subsequent sections, we then turn to a discussion of our results for the
magnetization.

##  2 Entanglement in the Periodic Chain, $s_{1}$

Figure 1: The entanglement entropy, $S(x)$, as a function of $x$ for a L=400
site periodic chain with $J_{2}=J_{2}^{c}=0.241167$. The black circles
indicate the numerical DMRG results while the solid red circles are a fit to
the analytical form, Eq. (2.1), with $s_{1}=0.743744(3)$.

First, we focus on the purely periodic chain with $J_{2}=J_{2}^{c}=0.241167$
since this will allow us to determine non-universal constants that are crucial
for our subsequent analysis. From analytical results [33, 34] it is known that
for a finite periodic system of $L$ sites, the entanglement entropy of a sub-
system of size $x$ is:

$S^{\mathrm{pbc}}(x)=\frac{c}{3}\ln\left[\frac{L}{\pi}\sin\left(\frac{\pi
x}{L}\right)\right]+s_{1},$ (2.1)

where $c$ is the central charge and $s_{1}$ is a non-universal constant. For
the models we consider, we have $c=1$. Our DMRG results with
$\epsilon=10^{-12}$ for $S(x)$ are shown in Fig. 1 for a periodic chain with
$J_{2}=J_{2}^{c}=0.241167$. With periodic boundary conditions (PBC) there is
no boundary and $S(x)$ is smoothly varying as the size of the sub-system $x$
changes. The DMRG results can be fitted extremely well to the expected form,
Eq. (2.1), from which we obtain at $J_{2}^{c}$:

$s_{1}=0.743744(3)\ \ (J_{2}=J_{2}^{c}=0.241167).$ (2.2)

Note that, $s_{1}$ is non-universal and for instance depends on $J_{2}$.
Hence, at the isotropic Heisenberg point with $J_{2}=0$, we find a slightly
smaller value of $s_{1}\sim 0.73771(1)$. One may also note that $s_{1}$ the
for the non-interacting $XX$ chain has been determined to be $s_{1}=0.726\
067$ [35]. The variation in $s_{1}$ between the different models is
surprisingly small.

##  3 Fermi Liquid Theory

Consider now the uniform $S$=1/2 SCKM chain with open boundary conditions
(OBC) of interest here. The chain has length $L$ and we consider a region at
one end of the open chain of length $x$. As shown in [35], one effect of the
open boundary conditions is to induce an alternating term $S_{A}$, in the von
Neumann entanglement entropy, $S(x)$. The latter is therefore best view as
composed of a uniform and alternating term

$S^{\mathrm{obc}}=S^{\mathrm{obc}}_{U}(x)+(-1)^{x}S^{\mathrm{obc}}_{A}(x)$
(3.1)

with both $S_{U}$ and $S_{A}$ smoothly varying functions. If the bulk of the
system is uniform, the alternating term $S_{A}^{\mathrm{obc}}(x)$ decays to
zero with $x$. However, recent work has shown that if the sub-system starts at
the boundary and ends at an impurity, then the alternating term does not
necessarily decay to zero [36]. The bulk contribution to the uniform part of
the von Neumann entanglement entropy, $S_{U}^{\mathrm{obc}}$, is given by [33,
34, 37, 38]:

$S_{U}^{\mathrm{bulk}}(x)=\frac{c}{6}\ln\left[\frac{2L}{\pi}\sin\left(\frac{\pi
x}{L}\right)\right]+\frac{s_{1}}{2}+\ln g.$ (3.2)

In contrast to $s_{1}$ the constant $\ln g$ is a universal term arising from a
non-integer ground-state degeneracy, $g$ [20]. However, this is not the only
contribution to $S^{\mathrm{obc}}_{U}$ since the open ends of the chain gives
rise to a boundary term, $\delta S_{U}$ [7, 8], so that

$S_{U}^{\mathrm{obc}}(x)=S_{U}^{\mathrm{bulk}}(x)+\delta S_{U}(x).$ (3.3)

It is possible to describe the leading contributions to $\delta S_{U}$ using
conformal field theory (CFT) methods based on Nozières local Fermi liquid
theory (FLT) [39, 21, 40, 41]. The leading contributions, due to the two open
ends, are caused by the leading irrelevant operator $\eta[T(0)+T(L)]$ where
$T(x)$ is the energy density, $\propto(\partial_{x}\phi)^{2}$ in Abelian
bosonization, and $\eta$ is a coupling constant of order a lattice spacing.
The first order correction due to $T(0)$, the boundary interaction at the left
end of the system, was calculated in Ref. [7]:

$\delta S^{\rm left}_{\mathrm{FLT}}={\eta\over 12L}\left[1+\pi{L-x\over
L}\cot(\pi x/L)\right].$ (3.4)

This result is valid in the FLT regime:

$\xi_{K}\ll x\ll L$ (3.5)

There is another correction due to $T(L)$, the boundary operator at the right
end of the system. This can be obtained by substituting $x\to L-x$, thereby
obtaining:

$\delta S^{\rm right}_{\mathrm{FLT}}={\eta\over 12L}\left[1-\pi{x\over
L}\cot(\pi x/L)\right],$ (3.6)

where we have used the standard relation $\cot(\pi-x)=-\cot(x)$. Since the
analysis in Refs. [7, 8] involved a subtractive procedure, approximately
eliminating $\delta S^{\rm right}_{\mathrm{FLT}}$, this term was not included.
Following the convention adopted in [7, 22] we identify $\eta$ with
$\pi\xi_{K}$, where $\xi_{K}$ can be identified with the size of the Kondo
screening cloud. With this normalization, the zero-temperature impurity
susceptibility is $\chi_{imp}=1/(4T_{K})$. The total correction arising from
both ends of the open chain is then:

$\delta S_{\mathrm{FLT}}=\delta S^{\rm left}_{\mathrm{FLT}}+\delta S^{\rm
right}_{\mathrm{FLT}}={\pi\xi_{K}\over 12L}\left[2+\pi{L-2x\over L}\cot(\pi
x/L)\right].$ (3.7)

This is symmetric under $x\to L-x$ and is functionally similar to
$1/[L\sin(\pi x/L)]$ up to an overall multiplicative constant and in Ref. [35]
the leading correction term to Eq. (3.2) arising from the open boundary was
therefore assumed to be of the form $1/(L\sin(\pi x/L))$ instead of the
correct form, Eq. (3.7).

If we consider a slightly modified coupling, $J_{K}^{\prime}$, of the spin at
the left end of the chain, the boundary operator $T(0)$ will still appear but
with a different coupling constant which we can write as
$\pi\xi_{K}^{\mathrm{left}}$. If we denote the coupling on the right side as
$\pi\xi_{K}^{\mathrm{right}}$, we obtain:

$\displaystyle S^{\mathrm{obc}}_{U}=S_{U}^{\mathrm{bulk}}+\delta S^{\rm
left}_{\mathrm{FLT}}+\delta S^{\rm right}_{\mathrm{FLT}}$ $\displaystyle\delta
S^{\rm left}_{\mathrm{FLT}}={\pi\xi_{K}^{\rm left}\over
12L}\left[1+\pi{L-x\over L}\cot(\pi x/L)\right]$ $\displaystyle\delta S^{\rm
right}_{\mathrm{FLT}}={\pi\xi_{K}^{\rm right}\over 12L}\left[1-\pi{x\over
L}\cot(\pi x/L)\right],$ (3.8)

with $S_{U}^{\mathrm{bulk}}$ from Eq. (3.2). Note that in the limit
$L\to\infty$ we have [7]:

$\delta S^{\rm left}_{\mathrm{FLT}}\sim\pi\xi_{K}^{\rm left}/(12x),$ (3.9)

with a similar expression for $\delta S^{\rm right}_{\mathrm{FLT}}$. Hence,
both $\delta S^{\rm left}_{\mathrm{FLT}}$ and $\delta S^{\rm
right}_{\mathrm{FLT}}$ remain finite in the thermodynamic limit at fixed $x$.
On the other hand, they can be neglected if $x/L$ is kept fixed as
$L\to\infty$.

##  4 Impurity Entanglement in the Open Chain, $\ln g$

We begin by considering the uniform open chain, with $J_{K}^{\prime}$=1,
performing DMRG calculations on a system with $L=400$. We first extract the
uniform part of the entanglement entropy, $S_{U}^{\mathrm{obc}}$. This is done
using a 9-point stencil as described in A. We then fit the results for
$S_{U}^{\mathrm{obc}}$ directly to Eq. (3.8). With only $\ln g+s_{1}/2$ and
$\xi_{K}$ as the two free parameters, we obtain an excellent fit, see solid
red line in Fig. (2). We explicitly determine:

$\ln g+\frac{s_{1}}{2}=0.198585(1)$ (4.1)

Figure 2: $\delta S_{U}=S_{U}^{\mathrm{obc}}-S_{U}^{\mathrm{bulk}}$ from DMRG
calculations with $\epsilon=10^{-12}$ on an open uniform chain with
$J^{\prime}_{K}=1$ at $J_{2}^{c}=0.241167$ with $L=400$ (black circles). The
blue and dark green dashed lines correspond to fits to $\delta S^{\rm
left}_{\mathrm{FLT}}$, Eq. (3.4) and $\delta S^{\rm right}_{\mathrm{FLT}}$,
Eq. (3.6), respectively. The solid red line is a fit to the combined FLT
expression, $\delta S_{\mathrm{FLT}}$, Eq. (3.7). The dotted magenta line is
the thermodynamic limit FLT result, Eq. (3.9). In all cases $\xi_{K}^{\rm
left}=\xi_{K}^{\rm right}=\xi_{K}(J^{\prime}_{K}=1)=0.49866(5)$ was used.

With the previously determined value for $s_{1}=0.743744(3)$ we can now
determine $\ln g$ finding:

$\ln g=0.198585(1)-0.743744(3)/2=-0.173287(4),$ (4.2)

in excellent agreement with the theoretical result, $\ln g=\ln
2^{-\frac{1}{4}}=-0.17328679$ [42, 38]. It is important to note that the
precision of the numerical result crucially relies on the detailed
understanding of the correction term Eq. (3.7). A similar analysis at a
$J_{2}<J_{2}^{c}$ is complicated by additional corrections arising from the
bulk marginal operator, rendering a high precision determination of $\ln g$
very challenging.

Figure 3: $\delta S_{U}=S_{U}^{\mathrm{obc}}-S_{U}^{\mathrm{bulk}}$ from DMRG
calculations with $\epsilon=10^{-12}$ on an open chain at $J_{2}^{c}=0.241167$
with $L=400$ and leftmost coupling $J^{\prime}_{K}=1,0.95,0.9,0.85,0.8$. The
solid lines are fits to $\delta S_{\mathrm{FLT}}=\delta S^{\rm
left}_{\mathrm{FLT}}+\delta S^{\rm right}_{\mathrm{FLT}}$, Eq. (3.8) with
$\xi^{L}_{K}(J^{\prime}_{K})=0.49866(5)$, $0.7011(2)$, $0.9594(3)$,
$1.2841(5)$ and $1.7090(5)$, respectively. In all cases with
$\xi^{R}_{K}(J^{\prime}_{K}=1)=0.49866(5)$.

In order to focus solely on the contribution arising from the two ends of the
open chain we define:

$\delta S_{U}=S_{U}^{\mathrm{obc}}-S_{U}^{\mathrm{bulk}},$ (4.3)

with $S_{U}^{\mathrm{bulk}}$ given in Eq. (3.2). Our results for $\delta
S_{U}$ for the uniform open chain with $J^{\prime}_{K}=1$ are shown in Fig. 2.
An excellent agreement between the numerical results (black circles) and the
fit to Eq. (3.7) (solid red line) is evident. Since the analytical expression
is not valid for $x\ll\xi_{K}$ we fit only data for $x>10\xi_{K}$. With the
above validation of the $\ln g$ term and the value of $s_{1}$ from the results
with PBC, Eq. (2.2), we fix these parameters and perform a one parameter fit
in $\xi_{K}$ determining:

$\xi_{K}(J^{\prime}_{K}=1)=0.49866(5).\ \ (J_{2}=J_{2}^{c})$ (4.4)

We note, that a similar analysis at $J_{2}=0$ yields a significantly larger
estimate of $\xi_{K}$. For completeness, the separate contributions from
$\delta S^{\rm left}_{\mathrm{FLT}}$, Eq. (3.4) and $\delta S^{\rm
right}_{\mathrm{FLT}}$, Eq. (3.6) are shown as the dashed blue and green
lines, respectively, in Fig. 2. For comparison, we also show the thermodynamic
limit FLT result, Eq. (3.9) (dotted magenta line) which agrees very
convincingly with the numerical results at small $x$ although the finite $L$
corrections, accounted for in Eq. (3.7), are visible for $x>50$.

It is now possible to obtain very precise estimates for
$\xi_{K}(J^{\prime}_{K})$ as a function of $J^{\prime}_{K}$ by performing
numerical calculations with a range of $J^{\prime}_{K}$ at the left end of the
chain, (see Eq. (1.3), thereby varying $\xi_{K}^{L}$. With the known values of
$\xi_{K}^{R}=0.49866(5)$ as well as $\ln g+\frac{s_{1}}{2}$, Eq. (4.1), we
then perform a one parameter fit of $\delta S_{U}$ to the analytical FLT form
$\delta S_{\mathrm{FLT}}=\delta S^{\rm left}_{\mathrm{FLT}}+\delta S^{\rm
right}_{\mathrm{FLT}}$, Eq. (3.8). Our results are shown in Fig. 3 for
$J^{\prime}_{K}=1,0.95,0.9,0.85,0.8$ with the solid lines representing the
fitted form. An excellent agreement between the numerical data and analytical
expression can be seen. Again, we restrict the fits to $10\xi_{K}<x$ to be
sure we are in the FLT regime, Eq. (3.5). We typically use $L=400$ and since
we also must require that $10\xi_{K}\ll L/2$ we stop the calculations at
$J_{K}^{\prime}=0.5$ where $\xi_{K}^{L}$ reaches the value of 11.824(4). It
would of course be relatively straight forward to repeat the calculations with
$L>400$, however, since $\xi_{K}\sim\exp(a/J_{K}^{\prime})$ it quickly becomes
unfeasible to extract $\xi_{K}(J_{K}^{\prime})$ for smaller $J_{K}^{\prime}$
by fitting numerical results to Eq. (3.8).

$J^{\prime}_{K}$ | $\xi_{K}$ | $J^{\prime}_{K}$ | $\xi_{K}$ | $J^{\prime}_{K}$ | $\xi_{K}$ | $J^{\prime}_{K}$ | $\xi_{K}$ | $J^{\prime}_{K}$ | $\xi_{K}$
---|---|---|---|---|---|---|---|---|---
1.00 | 0.49866(5) | 0.90 | 0.9594(3) | 0.80 | 1.7293(5) | 0.70 | 3.066(2) | 0.60 | 5.708(2)
0.99 | 0.5361(1) | 0.89 | 1.0308(3) | 0.79 | 1.8296(7) | 0.69 | 3.253(2) | 0.59 | 6.112(2)
0.98 | 0.5749(1) | 0.88 | 1.0936(4) | 0.78 | 1.9396(8) | 0.68 | 3.456(2) | 0.58 | 6.540(2)
0.97 | 0.6152(1) | 0.87 | 1.1595(4) | 0.77 | 2.0524(8) | 0.67 | 3.676(3) | 0.57 | 7.006(2)
0.96 | 0.6572(2) | 0.86 | 1.2289(5) | 0.76 | 2.1720(9) | 0.66 | 3.906(1) | 0.56 | 7.524(2)
0.95 | 0.7011(2) | 0.85 | 1.3018(5) | 0.75 | 2.2989(9) | 0.65 | 4.152(2) | 0.55 | 8.082(2)
0.94 | 0.7513(2) | 0.84 | 1.3785(5) | 0.74 | 2.4337(9) | 0.64 | 4.418(2) | 0.54 | 8.693(2)
0.93 | 0.7999(2) | 0.83 | 1.4593(6) | 0.73 | 2.5770(9) | 0.63 | 4.704(2) | 0.53 | 9.365(3)
0.92 | 0.8507(3) | 0.82 | 1.5445(6) | 0.72 | 2.730(1) | 0.62 | 5.013(2) | 0.52 | 10.104(4)
0.91 | 0.9038(3) | 0.81 | 1.6344(7) | 0.71 | 2.892(1) | 0.61 | 5.346(2) | 0.51 | 10.920(5)
Table 1: $\xi_{K}(J_{K}^{\prime})$ for the 1CK from DMRG calculations with
$\epsilon=10^{-12}$ on an open chain at $J_{2}^{c}=0.241167$ with $L=400$
determined by fitting the numerical results for $\delta S_{U}=S_{U}-S_{A}$ to
$\delta S_{\mathrm{FLT}}=\delta S^{\rm left}_{\mathrm{FLT}}+\delta S^{\rm
right}_{\mathrm{FLT}}$, Eq. (3.8). The error bar listed is the statistical
error from the fit, which does not include systematic errors arising from
corrections terms to Eq. (3.8) and other sources such as the range of $x$ used
in the fit.

It is often very useful to have high precision numerical data for
$\xi_{K}(J^{\prime}_{K})$ available, and we have collected some of our results
for $\xi_{K}$ in Table 1. Again, we stress that these results are obtained at
$J_{2}=J_{2}^{c}$ and similar calculations at $J_{2}<J_{2}^{c}$ and in
particular at $J_{2}=0$ yield larger values for $\xi_{K}$.

##  5 $\xi_{K}$ as a function of $1/J^{\prime}_{K}$

Figure 4: Numerical data (open circles) for $\xi_{K}(J_{K}^{\prime})$ as
obtained from $\delta S_{\mathrm{FLT}}$ (see Table 1) fitted to the Eq. (5.2)
(solid red line) with the resulting fit given in Eq. (5.3). The solid blue
line indicates the $\xi_{K}(J_{K}^{\prime})-\xi_{K}(J_{K}^{\prime}=1)$ needed
to scale $M^{z}$ and $N^{z}$.

Through perturbative calculations as detailed in [22], $\xi_{K}$ can be
related to the coupling $\lambda_{K}$ in Eq. (1.1) as follows:
$\xi_{K}=(\hbox{constant}/\sqrt{\lambda_{K}})\exp\left(1/\lambda_{K}\right)\left[1+O(\lambda_{K})\right].$
Furthermore, through a careful determination of the spin velocity
$v_{s}=1.174(1)$ and by studying end to end correlation functions, it was
shown [22] that in the limit $J_{K}^{\prime}\to 0$, at $J_{2}^{c}$, the
following relation between $J_{K}^{\prime}$ and $\lambda_{K}$ holds

$J_{K}^{\prime}=1.381~{}\lambda_{K}.$ (5.1)

In terms of $J_{K}^{\prime}$ we therefore have

$\xi_{K}=\frac{\hbox{constant}}{\sqrt{J_{K}^{\prime}}}\exp\left(1.381/J_{K}^{\prime}\right)\left[1+O(J_{K}^{\prime})\right].$
(5.2)

Here, the $O(J_{K}^{\prime})$ term represents a power series in
$J_{K}^{\prime}$. Note that, for $J_{2}=0$, the behavior is slightly different
and instead one has $\xi_{K}\sim\exp(c/\sqrt{J_{K}^{\prime}})$ [22]. It is
straightforward to verify that our results obey this relation very precisely.
As shown in Fig. 4 we can fit the numerical data from Table 1 to Eq. (5.2)
obtaining

$\xi_{K}=\frac{1.002(1)}{\sqrt{J_{K}^{\prime}}}\exp\left(1.381/J_{K}^{\prime}\right)\left(1-0.963(1)J_{K}^{\prime}+0.089(1)\left(J_{K}^{\prime}\right)^{3}\right).$
(5.3)

In this fit the previously estimated constant $1.381$ is held fixed and as is
clearly evident in Fig. 4 at large $1/J_{K}^{\prime}$ the exponential
divergence is clearly in agreement with this independently determined
constant. The addition of the correction terms allows the form Eq. (5.2) to
fit the data even for relatively large $J_{K}^{\prime}$ even exceeding 1. This
indicates that a critical value $J_{K}^{\prime c}$ exists at which the
correction $\delta S_{\mathrm{FLT}}$ vanishes. This coupling can be estimated
to be:

$J_{K}^{\prime c}=1.188(2).`$ (5.4)

##  6 Scaling of $\langle S^{z}(x)\rangle$ for Odd Length Chains

Figure 5: $\langle S^{z}_{i}\rangle$ for a uniform ($J_{K}^{\prime}=1$) spin
chain at $J_{2}^{c}$ of length $L=199$ (squares) and $399$ (circles). The
solid points are fits to the form Eq. (6.2) including a constant, $1/(2L+3)$,
representing the uniform part.

We now turn to an analysis of scaling of the magnetization $\langle
S^{z}_{i}\rangle$ occurring in odd length systems and we focus exclusively on
the ground-state with $S^{z}_{\mathrm{Tot}}\equiv\sum_{x}S^{z}(x)$=1/2. Since
the system is antiferromagnetic and the length is odd, $\langle
S^{z}(x)\rangle$ will have both a uniform and alternating part. We write:

$\langle S^{z}(x)\rangle=M^{z}(x)+(-1)^{x+1}N^{z}(x),$ (6.1)

Our goal here is to develop a scaling form for the uniform and alternating
part of the magnetization as the coupling to the impurity spin,
$J^{\prime}_{K}$, is varied. In the case of the uniform chain with
($J_{K}^{\prime}=1$) at $J_{2}^{c}$, it was shown [43] that for the
alternating part, $N^{z}$, of $\langle S^{z}(x)\rangle$ in the
$S^{z}_{\mathrm{Tot}}=1/2$ subspace:

$N^{z}(x)\simeq C\sqrt{\frac{\pi}{2L+3}\sin\frac{\pi x}{L+1}}.$ (6.2)

At small $x$ the alternating part $N^{z}(x)$ then increases in a
characteristic $\sqrt{x}$ manner. There is also a uniform part, $M^{z}$, which
in the middle of the chain is well approximated by the constant $1/(2L+3)$. We
note that for the calculations we consider here in the
$S^{z}_{\mathrm{Tot}}=1/2$ subspace we must have
$S^{z}_{Tot}=\sum_{x}S^{z}(x)=\sum_{x}(M^{z}(x)+(-1)^{x+1}N^{z}(x))=1/2$. Our
fits to this form are shown in Fig. 5 yielding excellent agreement with Eq.
(6.2) allowing us to determine $C=0.46788(1)$. Here, the calculations are
performed at $J_{2}^{c}$. At smaller values of $J_{2}$ corrections to the form
Eq. (6.2) occur [44].

Figure 6: The $4M^{z}_{\mathrm{half}}-1$ for a range of $J_{K}^{\prime}$
between $0$ and $1$, and $L=29,\ldots,399$. Results are shown to scale when
plotted versus
$L/(\xi_{K}^{\mathrm{FLT}}-\xi_{K}^{\mathrm{FLT}}(J_{K}^{\prime}=1))$. All
calculations are at $J_{2}=J_{2}^{c}$ in the subspace with
$S^{z}_{\mathrm{Tot}}=1/2$.

At the isotropic point, $J_{K}^{\prime}=1$, the on-site magnetization $\langle
S^{z}(x)\rangle$ is also symmetric around the site $x=(L+1)/2$ which means
that we can define the half-magnetization:

$M^{z}_{\mathrm{half}}=\sum_{x=1}^{(L-1)/2}S^{z}(x)+\frac{1}{2}S^{z}(x=(L+1)/2).$
(6.3)

Since $S^{z}_{Tot}=1/2$ and since $M^{z}_{\mathrm{half}}$ encompasses half of
this magnetization when $J^{\prime}_{K}=1$ it follows that
$4M^{z}_{\mathrm{half}}-1=0$ at $J_{K}^{\prime}=1$. Note that the impurity
spin resides on site $x=1$. In the other limit of $J_{K}^{\prime}\to 0$ we
instead find $4M^{z}_{\mathrm{half}}-1\to 1$ since the effectively decoupled
impurity spin at $x=1$ will carry all the magnetization so that
$4M^{z}_{\mathrm{half}}=2$. However, for intermediate, $J_{K}^{\prime}$ we
expect $4M^{z}_{\mathrm{half}}-1$ to only depend on the single variable
$L/\xi_{K}$ and follow the scaling form:

$4M^{z}_{\mathrm{half}}-1\equiv h(L/\xi_{K}),$ (6.4)

as $J_{K}^{\prime}$ is varied between $0$ and $1$. We want to demonstrate this
scaling using the previously determined $\xi_{K}^{\mathrm{FLT}}$, however, for
the quantity $4M^{z}_{\mathrm{half}}-1$ the strong coupling fixed point where
$\xi_{K}=0$ corresponds $J_{K}^{\prime}=1$ whereas for $\delta
S_{\mathrm{FLT}}$ $\xi_{K}=0$ occurs for $J_{K}^{\prime c}=1.188(2)$. In order
to correct for this difference, we therefore need to scale the data for
$4M^{z}_{\mathrm{half}}-1$ using
$\xi_{K}^{\mathrm{FLT}}-\xi_{K}^{\mathrm{FLT}}(J_{K}^{\prime}=1)$ instead of
just $\xi_{K}^{\mathrm{FLT}}$. In Fig. 6 we show numerical results for
$4M^{z}_{\mathrm{half}}-1$ displaying excellent scaling with
$L/(\xi_{K}^{\mathrm{FLT}}-\xi_{K}^{\mathrm{FLT}}(J_{K}^{\prime}=1))$ with
$\xi_{K}^{\mathrm{FLT}}$ obtained from $\delta S_{\mathrm{FLT}}$. (See Table
1.)

Figure 7: Leftmost data set: The scaled uniform part of $\langle
S^{z}(x=(L+1)/2)\rangle$ in the middle of the chain $(2L+3)M^{z}$, for a range
of $J_{K}^{\prime}$ between $0$ and $1$ and $L=29,\ldots,399$. Rightmost data
set: The scaled alternating part of $\langle S^{z}(x=(L+1)/2)\rangle$ in the
middle of the chain, $\sqrt{(2L+3)/\pi}N^{z}$, for the same range of
$J_{K}^{\prime}$ and $L$. The results clearly scale when plotted versus
$L/(\xi_{K}^{\mathrm{FLT}}-\xi_{K}^{\mathrm{FLT}}(J_{K}^{\prime}=1))$. All
calculations are at $J_{2}=J_{2}^{c}$ in the subspace with
$S^{z}_{\mathrm{Tot}}=1/2$.

Building on the relations, Eq. (6.1) and (6.2), we can also construct scaling
forms for $M^{z}(x)$ and $N^{z}(x)$. Again we focus on the middle of the chain
$x=(L+1)/2$ and extract the uniform and alternating part of $\langle
S^{z}(x=(L+1)/2)\rangle$. We then expect to find:

$(2L+3)M^{z}\equiv u(L/\xi_{K})$ (6.5)

as well as

$\sqrt{\frac{2L+3}{\pi}}N^{z}\equiv n(L/\xi_{K}),$ (6.6)

with $u$ and $n$ scaling functions. We note that for the impurity spin itself
and for the site coupled to it, weak scaling violations should be observed
[22] due to the presence of an anomalous dimension for the corresponding
operator [45]. For both the prefactors of $2L+3$ for $M^{z}$ and
$\sqrt{(2L+3)/\pi}$ for $N^{z}$, it is only the overall $L$ dependence that is
known, with the precise additive constant determined numerically. As was the
case for $M^{z}_{\mathrm{half}}$, the strong coupling fixed point where
$\xi_{K}=0$ again corresponds to $J_{K}^{\prime}=1$ and we therefore again use
$\xi_{K}^{\mathrm{FLT}}-\xi_{K}^{\mathrm{FLT}}(J_{K}^{\prime}=1)$ instead of
just $\xi_{K}^{\mathrm{FLT}}$. Our results are shown in Fig. 7 where data for
both the scaled $M^{z}$ and $N^{z}$ are shown together. An excellent scaling
of the data when plotted versus
$L/(\xi_{K}^{\mathrm{FLT}}-\xi_{K}^{\mathrm{FLT}}(J_{K}^{\prime}=1))$ is
evident. However, in the limit $L\ll\xi_{K}$ deviations are clearly visible as
one would expect. Similar deviations from scaling for $L\ll\xi_{K}$ are
visible in Fig. (6) but are obscured by the fact that
$4M^{z}_{\mathrm{half}}-1$ approaches 1 in the $J_{K}^{\prime}\to 0$ limit.

##  7 Discussion

Using a spin chain representation of the one-channel Kondo model we have shown
that scaling with the Kondo length scale $\xi_{K}$ is obeyed to a high degree
of precision and that reliable estimates of $\xi_{K}$ can be obtained. For the
open chain it is clear that apart from the usual term proportional to the
central charge, the entanglement entropy contains two other terms, an
alternating term $S_{A}$ but also an impurity term arising from the boundary.
We have also demonstrated that the same length scale, $\xi_{K}$, from our
analysis of the entanglement entropy can be used to scale the magnetization
present in a sub-system of the chain if a proper normalization is taken into
account. The analysis of the magnetization is in some sense simpler since it
directly yields the impurity contribution without involving a subtractive
procedure.

The author acknowledges many valuable discussions with Ian Affleck, and
acknowledges the support of the Natural Sciences and Engineering Research
Council of Canada (NSERC) through Discovery Grant No. RGPIN-2017-05759. This
research was enabled in part by support provided by SHARCNET (sharcnet.ca) and
the Digital Research Alliance of Canada (alliancecan.ca). Part of the
numerical calculations were performed using the ITensor library [31].

##  Appendix A Extracting the Uniform and Alternating Parts

For the analysis of the data, it is necessary to extract the uniform and
alternating part of a function defined on discrete points $i$. Focusing on a
point $i=0$, we make the following assumption [8]:

$f(i)=u(i)+(-1)^{i}s(i).$ (1.1)

In the vicinity of the point $i=0$ we can then develop a 7-point stencil by
assuming that $u$ and $s$ are well approximated by slowly varying polynomials:
$u(i)\simeq ai^{3}+bi^{2}+ci+d$ and $s(i)=ei^{2}+fi+g$, for $i=0,\pm 1,\pm
2,\pm 3$, arriving at the equations:

$\displaystyle f(i-3)$ $\displaystyle\simeq$
$\displaystyle-27a+9b-3c+d-(9e-3f+g)$ $\displaystyle f(i-2)$
$\displaystyle\simeq$ $\displaystyle-8a+4b-2c+d+(4e-2f+g)$ $\displaystyle
f(i-1)$ $\displaystyle\simeq$ $\displaystyle-a+b-c+d-(e-f+g)$ $\displaystyle
f(i)$ $\displaystyle\simeq$ $\displaystyle d+g$ $\displaystyle f(i+1)$
$\displaystyle\simeq$ $\displaystyle a+b+c+d-(e+f+g)$ $\displaystyle f(i+2)$
$\displaystyle\simeq$ $\displaystyle 8a+4b+2c+d+(4e+2f+g)$ $\displaystyle
f(i+3)$ $\displaystyle\simeq$ $\displaystyle 27a+9b+3c+d-(9e+3f+g)$

As can easily be verified, the solutions for $u,s$ are then:

$\displaystyle u(i)$ $\displaystyle=$
$\displaystyle-\frac{1}{32}f(i-3)+\frac{9}{32}f(i-1)+\frac{1}{2}f(i)$ (1.3)
$\displaystyle-\frac{1}{32}f(i+3)+\frac{9}{32}f(i+1).$ $\displaystyle s(i)$
$\displaystyle=$ $\displaystyle f(i)-u(i)$ (1.4)

In Ref. [8] a slight variation on these solutions were used. The above
equations have the advantage that they are explicitly invariant under
$i-3\leftrightarrow i+3$, $i-2\leftrightarrow i+2$ and $i-1\leftrightarrow
i+1$ as one would expect. Note that, as we move along the chain, the sign of
$g$ will vary. An equivalent 9-point stencil can be derived, yielding:

$\displaystyle u(i)$ $\displaystyle=$
$\displaystyle\frac{3}{256}f(i-4)-\frac{1}{32}f(i-3)-\frac{3}{64}f(i-2)+\frac{9}{32}f(i-1)+\frac{73}{128}f(i)$
(1.5) $\displaystyle+$
$\displaystyle\frac{3}{256}f(i+4)-\frac{1}{32}f(i+3)-\frac{3}{64}f(i+2)+\frac{9}{32}f(i+1).$
$\displaystyle s(i)$ $\displaystyle=$ $\displaystyle f(i)-u(i)$ (1.6)

## References

  * [1] Jun Kondo.  Resistance minimum in dilute magnetic alloys.  Progress of Theoretical Physics, 32:37–49, 1964.
  * [2] A. C. Hewson.  The Kondo Problem to Heavy Fermions.  Cambridge University Press, 2000.
  * [3] N. Andrei, K. Furuya, and J. H. Lowenstein.  Solution of the kondo problem.  Rev. Mod. Phys., 55(2):331–402, Apr 1983.
  * [4] Ian Affleck.  The kondo screening cloud: what it is and how to observe it.  In Amnon Aharony and Ora Entin-wohlman, editors, Perspectives Of Mesoscopic Physics: Dedicated To Yoseph Imry’s 70th Birthday, chapter 1, pages 1–45. World Scientific, 2010.
  * [5] Erik S. Sørensen and Ian Affleck.  Scaling theory of the kondo screening cloud.  Phys. Rev. B, 53:9153–9167, Apr 1996.
  * [6] Ivan V. Borzenets, Jeongmin Shim, Jason C. H. Chen, Arne Ludwig, Andreas D. Wieck, Seigo Tarucha, H.-S. Sim, and Michihisa Yamamoto.  Observation of the kondo screening cloud.  Nature, 579:210–213, 2020.
  * [7] Erik S. Sørensen, Ming-Shyang Chang, Nicolas Laflorencie, and Ian Affleck.  Impurity entanglement entropy and the kondo screening cloud.  Journal of Statistical Mechanics: Theory and Experiment, 2007(01):L01001, 2007.
  * [8] Erik S. Sørensen, Ming-Shyang Chang, Nicolas Laflorencie, and Ian Affleck.  Quantum impurity entanglement.  Journal of Statistical Mechanics: Theory and Experiment, 2007(08):P08003, 2007.
  * [9] Abolfazl Bayat, Pasquale Sodano, and Sougato Bose.  Negativity as the entanglement measure to probe the kondo regime in the spin-chain kondo model.  Phys. Rev. B, 81:064429, Feb 2010.
  * [10] S.-S. B. Lee, Jinhong Park, and H.-S. Sim.  Macroscopic quantum entanglement of a kondo cloud at finite temperature.  Phys. Rev. Lett., 114:057203, Feb 2015.
  * [11] Donghoon Kim, Jeongmin Shim, and H.-S. Sim.  Universal thermal entanglement of multichannel kondo effects.  Phys. Rev. Lett., 127:226801, Nov 2021.
  * [12] Ananda Roy and Hubert Saleur.  Entanglement entropy in the ising model with topological defects.  Phys. Rev. Lett., 128:090603, Mar 2022.
  * [13] David Rogerson, Frank Pollmann, and Ananda Roy.  Entanglement entropy and negativity in the ising model with defects.  Journal of High Energy Physics, 2022:165, 2022.
  * [14] Luca Capizzi and Viktor Eisler.  Zero-mode entanglement across a conformal defect.  Journal of Statistical Mechanics: Theory and Experiment, 2023(5):053109, may 2023.
  * [15] Alexei Kolezhuk, Subir Sachdev, Rudro R. Biswas, and Peiqiu Chen.  Theory of quantum impurities in spin liquids.  Phys. Rev. B, 74:165114, Oct 2006.
  * [16] Kusum Dhochak, R. Shankar, and V. Tripathi.  Magnetic impurities in the honeycomb kitaev model.  Phys. Rev. Lett., 105:117201, Sep 2010.
  * [17] S. D. Das, K. Dhochak, and V. Tripathi.  Kondo route to spin inhomogeneities in the honeycomb kitaev model.  Phys. Rev. B, 94:024411, Jul 2016.
  * [18] Wen-Yu He and Patrick A. Lee.  Magnetic impurity as a local probe of the $u$(1) quantum spin liquid with spinon fermi surface.  Phys. Rev. B, 105:195156, May 2022.
  * [19] Shuangyuan Lu and Yuan-Ming Lu.  Detecting symmetry fractionalization in gapped quantum spin liquids by magnetic impurities, arXiv:2209.09853, 2022.
  * [20] Ian Affleck and Andreas W. W. Ludwig.  Universal noninteger “ground-state degeneracy” in critical quantum systems.  Phys. Rev. Lett., 67:161–164, Jul 1991.
  * [21] I. Affleck.  A current algebra approach to the kondo effect.  Nucl. Phys. B, 336:517, 1990.
  * [22] Nicolas Laflorencie, Erik S. Sørensen, and Ian Affleck.  The kondo effect in spin chains.  Journal of Statistical Mechanics: Theory and Experiment, 2008(02):P02007, 2008.
  * [23] Sebastian Eggert.  Numerical evidence for multiplicative logarithmic corrections from marginal operators.  Phys. Rev. B, 54:R9612–R9615, Oct 1996.
  * [24] Sebastian Eggert and Ian Affleck.  Magnetic impurities in half-integer-spin Heisenberg antiferromagnetic chains.  Phys. Rev. B, 46:10866–10883, Nov 1992.
  * [25] S. R. White and R. M. Noack.  Real-space quantum renormalization groups.  Phys. Rev. Lett., 68:3487–3490, Jun 1992.
  * [26] Steven R. White.  Density matrix formulation for quantum renormalization groups.  Phys. Rev. Lett., 69:2863–2866, Nov 1992.
  * [27] Steven R. White.  Density-matrix algorithms for quantum renormalization groups.  Phys. Rev. B, 48:10345–10356, Oct 1993.
  * [28] U. Schollwöck.  The density-matrix renormalization group.  Rev. Mod. Phys., 77:259–315, Apr 2005.
  * [29] Karen A. Hallberg.  New trends in density matrix renormalization.  Advances in Physics, 55(5-6):477–526, 2006.
  * [30] Ulrich Schollwöck.  The density-matrix renormalization group in the age of matrix product states.  Annals of Physics, 326(1):96 – 192, 2011.  January 2011 Special Issue.
  * [31] Matthew Fishman, Steven R. White, and E. Miles Stoudenmire.  The ITensor Software Library for Tensor Network Calculations.  SciPost Phys. Codebases, page 4, 2022.
  * [32] Ian Affleck, Nicolas Laflorencie, and Erik S. Sørensen.  Entanglement entropy in quantum impurity systems and systems with boundaries.  Journal of Physics A: Mathematical and Theoretical, 42(50):504009, 2009.
  * [33] C. Holzhey, F. Larsen, and F. Wilczek.  Geometric and renormalized entropy in conformal field theory.  Nucl. Phys. B, 424:443, 1994.
  * [34] P. Calabrese and J. Cardy.  Entanglement entropy and quantum field theory.  J. Stat. Mech., page P06002, 2004.
  * [35] Nicolas Laflorencie, Erik S. Sørensen, Ming-Shyang Chang, and Ian Affleck.  Boundary effects in the critical scaling of entanglement entropy in 1d systems.  Phys. Rev. Lett., 96:100603, Mar 2006.
  * [36] Henning Schlömer, Chunyu Tan, Stephan Haas, and Hubert Saleur.  Parity effects and universal terms of $\mathcal{O}(1)$ in the entanglement near a boundary.  SciPost Phys., 13:110, 2022.
  * [37] Pasquale Calabrese and John Cardy.  Entanglement entropy and quantum field theory: A non-technical introduction.  International Journal of Quantum Information, 04(03):429–438, 2006\.
  * [38] Huan-Qiang Zhou, Thomas Barthel, John Ove Fjærestad, and Ulrich Schollwöck.  Entanglement and boundary critical phenomena.  Phys. Rev. A, 74:050305, Nov 2006.
  * [39] P. Nozières.  A ”fermi-liquid” description of the kondo problem at low temperatures.  J. Low Temp. Phys., 17:31, 1974.
  * [40] I. Affleck and A. W. W. Ludwig.  The kondo effect, conformal field theory and fusion rules.  Nucl. Phys. B, 352:849, 1991.
  * [41] I. Affleck and A. W. W. Ludwig.  Critical theory of overscreened kondo fixed points.  Nucl. Phys. B, 360:641, 1991.
  * [42] Ian Affleck.  Edge magnetic field in the $xxz$ spin chain.  Journal of Physics A: Mathematical and General, 31(12):2761–2766, mar 1998.
  * [43] Sebastian Eggert, Ian Affleck, and Matthew D. P. Horton.  Néel order in doped quasi-one-dimensional antiferromagnets.  Phys. Rev. Lett., 89:047202, Jul 2002.
  * [44] Sambuddha Sanyal, Argha Banerjee, and Kedar Damle.  Vacancy-induced spin texture in a one-dimensional $s=\frac{1}{2}$ Heisenberg antiferromagnet.  Phys. Rev. B, 84:235129, Dec 2011.
  * [45] Victor Barzykin and Ian Affleck.  Screening cloud in the $k$-channel kondo model: Perturbative and large-$k$ results.  Phys. Rev. B, 57:432–448, Jan 1998.