{'fraction_non_alphanumeric': 0.031237948322406478, 'fraction_numerical': 0.01334361743154647, 'mean_word_length': 4.809708737864078, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
HarmoFL: Harmonizing Local and Global Drifts in Federated Learning on Heterogeneous Medical Images

Multiple medical institutions collaboratively training a model using federated learning (FL) has become a promising solution for maximizing the potential of data-driven models, yet the non-independent and identically distributed (non-iid) data in medical images is still an outstanding challenge in real-world practice. The feature heterogeneity caused by diverse scanners or protocols introduces a drift in the learning process, in both local (client) and global (server) optimizations, which harms the convergence as well as model performance. Many previous works have attempted to address the non-iid issue by tackling the drift locally or globally, but how to jointly solve the two essentially coupled drifts is still unclear. In this work, we concentrate on handling both local and global drifts and introduce a new harmonizing framework called HarmoFL. First, we propose to mitigate the local update drift by normalizing amplitudes of images transformed into the frequency domain to mimic a unified imaging setting, in order to generate a harmonized feature space across local clients. Second, based on harmonized features, we design a client weight perturbation guiding each local model to reach a flat optimum, where a neighborhood area of the local optimal solution has a uniformly low loss. Without any extra communication cost, the perturbation assists the global model to optimize towards a converged optimal solution by aggregating several local flat optima. We have theoretically analyzed the proposed method and empirically conducted extensive experiments on three medical image classification and segmentation tasks, showing that HarmoFL outperforms a set of recent state-of-the-art methods with promising convergence behavior. Code is available at https://github.com/med-air/HarmoFL.


Introduction
Multi-site collaborative training of deep networks is increasingly important for maximizing the potential of datadriven models in medical image analysis (Shilo, Rossman, and Segal 2020;Peiffer-Smadja et al. 2020;Dhruva et al. 2020), however, the data sharing is still restricted by some legal and ethical issues for protecting patient data. Federated learning recently allows a promising decentralized privacy-preserving solution, in which different institutions can jointly train a model without actual data sharing, i.e., training client models locally and aggregating them globally (McMahan et al. 2017;Kaissis et al. 2020).
Despite the recent promising progress achieved by FL in medical image analysis Rieke et al. 2020;Sheller et al. 2020;Roth et al. 2020;Ju et al. 2020), the non-independent and identically distributed (non-iid) data is still an outstanding challenge in real-world practice (Kairouz et al. 2019;Hsieh et al. 2020;Xu et al. 2021). Non-iid issue typically happens, and the device vendors or data acquisition protocols are responsible for heterogeneity in the feature distributions (Aubreville et al. 2020;Liu et al. 2020). For example, the appearance of histology images varies due to different staining situations, and MRI data of different hospitals suffer from feature distribution shifts associated with various scanners or imaging protocols.
Previous literature has demonstrated, both empirically and theoretically, that such data heterogeneity across clients introduces drift in both local (client) and global (server) optimizations, making the convergence slow and unstable (Zhao et al. 2018;Li et al. 2019;Karimireddy et al. 2020). Specif-ically, in the local update, each client model will be optimized towards its own local optima (i.e., fitting its individual feature distribution) instead of solving the global objective, which raises a drift across client updates. Meanwhile, in the global update that aggregates these diverged local models, the server model is further distracted by the set of mismatching local optima, which subsequently leads to a global drift at the server model. Fig. 1 intuitively illustrates such local and global drifts via loss landscape visualization , in an example of two non-iid clients. The vertical axis shows the loss at each client (denoting the solution for global objective as F * and for each local objective as F * i ), and the horizontal plane represents a parameter space centered at the specific parameters of global model . With the same objective function and parameter initialization for each client, we can see the local solution of two clients in the first column are significantly different, which indicates the drift across local client updates. Globally, a current good solution F * may achieve a relatively low loss for both clients. However, since each client has its own shaped loss landscape, optimizing the current solution towards global optima is difficult and the aggregation of the two diverged local solutions further distracts the current good solution.
To address such non-iid problem in FL, existing works can be mainly divided into two groups, which correspond to tackling the drift locally or globally. The local side emphasizes how to better normalize those diverse data. For example, (Sheller et al. 2018) conducted a pioneer study and proposed using data pre-processing to reduce data heterogeneity. Recently, FedBN ) kept batch normalization layers locally to normalize local data distribution. As for the global server side, adjusting aggregation weight is a typical strategy, for instance, (Yeganeh et al. 2020) used inverse distance to adaptively reweight aggregation. Recently, the framework FedAdam (Reddi et al. 2021) is proposed for introducing adaptive optimization to stabilize server update in heterogeneous data. However, these methods tackle heterogeneity partially via either client or server update. The local and global drifts are essentially coupled, yet how to jointly solve them as a whole still remains unclear.
In this paper, we consider both client and server updates and propose a new harmonizing strategy to effectively solve the data heterogeneity problem for federated medical image analysis. First, to mitigate local drift at the local update, we propose a more effective normalization strategy via amplitude normalization, which unifies amplitude components from images decomposed in the frequency domain. Then for the global drift, although weighted parameter aggregation is widely adopted, the coordination can fail over heterogeneous clients with large parameter differences. Thus, we aim to promote client models that are easy to aggregate rather than design a new re-weighting strategy. Based on the harmonized feature space, we design a weight-perturbation strategy to reduce the server update drift. The perturbation is generated locally from gradients and applied on the client model to constrain a neighborhood area of the local converged model to have a uniformly low loss. With the perturbation, each client finds a shared flat optimal solution that can be directly aggregated with others, assisting the global model to optimize towards a converged optimal solution. As can be observed from the last two columns of Fig. 1, the proposed amplitude normalization for local harmonization well mitigates the distance between global and local solutions, and with the weight perturbation for global harmonization, our approach achieves flat client solutions that can be directly aggregated to obtain an optimal global model.
Our main contributions are highlighted as follows: • We propose to effectively mitigate the local update drift by normalizing the frequency-space amplitude component of different images into a unified space, which harmonizes non-iid features across clients. • Based on the harmonized features, we further design a novel weight-perturbation based strategy to rectify global server update shift without extra communication cost. • To the best of our knowledge, we are the first to simultaneously address both local and global update drifts for federated learning on heterogeneous medical images. We have also theoretically analyzed the proposed HarmoFL framework from the aspect of gradients similarity, showing that drift caused by data heterogeneity is bounded. • We conduct extensive experiments on three medical image tasks, including breast cancer histology image classification, histology nuclei segmentation, and prostate MRI segmentation. Our HarmoFL significantly outperforms a set of latest state-of-the-art FL methods.

Related Work
There have been many methods proposed trying to improve federated learning on heterogeneous data and can be mainly divided into two groups, including improvements on local client training and on global server aggregation.
Local client training: Literature towards improving the client training to tackle local drift includes, using data pre-processing to reduce data heterogeneity (Sheller et al. 2018), introducing a domain loss for heterogeneous electroencephalography classification (Gao et al. 2019), using simulated CT volumes to mitigate scanner differences in cardiac segmentation (Li et al. 2020a), adding a proximal term to penalize client update towards smaller weight differences between client and server model (Li et al. 2020b), and learning affine transformation against shift under the assumption that data follows an affine distribution (Reisizadeh et al. 2020). Recently, both SiloBN (Andreux et al. 2020) and FedBN  propose keeping batch normalization locally to help clients obtain similar feature distributions, and MOON (Li, He, and Song 2021) uses contrastive learning on latent feature representations at the client-side to enhance the agreements between local and global models.
Global server aggregation: Besides designs on the clientside, many methods are proposed towards reducing global drift with a focus on the server-side. (Zhao et al. 2018) create a small subset of data that is globally shared across clients, and many other methods improve the aggregation strategy, e.g. (Yeganeh et al. 2020) calculate the inverse distance to re-weight aggregation and FedNova (Wang et al. 2020) proposes to use normalized stochastic gradients to perform global model aggregation rather than the cumulative raw local gradient changes. Very recently, FedAdam (Reddi et al. 2021) introduces adaptive optimization into federated learning to stabilize convergence in heterogeneous data. However, the above-mentioned methods partially address the drift either from the local client or global server perspective. Instead, our approach aims jointly mitigating the two coupled drifts both locally and globally.

Methodology
To address the non-iid issues from both local and global aspects, we propose an effective new federated learning framework of HarmoFL. We start with the formulation of federated heterogeneous medical images analysis, then describe amplitude normalization and weight perturbation towards reducing local drift and global drift respectively. At last, we give a theoretical analysis of HarmoFL.

Preliminaries
Denote (X , Y) as the joint image and label space over N clients. A data sample is an image-label pair (x, y) with x ∈ X , y ∈ Y, and the data sampled from a specific i-th client follows data distribution D i . In this work, we focus on the non-iid feature shift. Given the joint probability P (x, y) of feature x of image x and label y, we have P i (x) varies even if P (y| x) is the same or P i (x |y) varies across clients while P (y) is unchanged.
Our proposed HarmoFL aims to improve federated learning for both local client training and global aggregation. The federated optimization objective is formulated as follows: where F i = (x,y)∼Di i (Ψ(x), y; θ + δ) is the local objective function and i is the loss function defined by the learned model θ and sampled pair (x, y). For the i-th client, p i is the corresponding weight such that p i ≥ 0 and N i=1 p i = 1. The δ is a weight perturbation term and D i is the harmonized feature distribution obtained by our amplitude normalization. Specifically, we propose a new amplitude normalization operator Ψ(·) harmonizing various client features distribution to mitigate client update drift. The normalizer manipulates amplitudes of data in the frequency space without violating the local original data preserving. Based on the harmonized features, we can generate a weight perturbation for each client without any extra communication cost. The perturbation forces each client reaching a uniformly low error in a neighborhood area of local optima, thus reducing the drift in the server.

Amplitude normalization for local training
Structure semantic is an important factor to support medical imaging analysis while low-level statistics (e.g. color, contrast) usually help to differentiate the structure. By decomposing the two parts, we are able to harmonize low-level features across hospitals while preserving critical structures. Using the fast Fourier transform (Nussbaumer 1981), we can transform images into the frequency space signals and decompose out the amplitude spectrum which captures lowlevel features. Considering the patient level privacy sensitivity and forbiddance of sharing original images, we propose only using averaged amplitude term during communication to conduct the normalization.
More specifically, for input image x from the i-th client, we transform each channel of image x ∈ R H×W ×C into the frequency space signals . Then we can split the real part R i (x) and the imaginary part I i (x) from the frequency signals F i (x). The amplitude and phase component can be expressed as: (2) Next, we normalize the amplitude component of each image batch-wise with a moving average term. For the k-th batch of M sampled images, first we decompose the amplitude A i,xm and phase P i,xm for each single image x m in the batch. We calculate the in-batch average amplitude and update the average amplitude with a decay factor v: where A i,k−1 is the average amplitude calculated from the previous batch and this term is set to zero for the first batch. The A i,k harmonizes low-level distributions inside a client and keeps tracking amplitudes of the whole client images. With the updated average term, each original image of the k-th batch is normalized using the average amplitude A i,k and its original phase component P i,xm in below: where F −1 is the inverse Fourier transform. After client training, the amplitude normalization layer which only contains the average amplitude information will be sent to the central server and generate a global amplitude. This global amplitude compromises various low-level visual features across clients and can help reduce client update drift at the next federated round. In practice, we find that only communication at the first round and fix the global amplitude can well harmonize non-iid features as well as saving the communication cost.

Weight perturbation for global aggregation
The above-proposed amplitude normalization allows each client to optimize within a harmonized feature space, mitigating the local drift. Based on the harmonized feature space, we further aim to promote client models that are easy to aggregate, thus rectifying the global drift. As the global aggregation is typically the weighted averaging, a client with flat optima can well coordinate with other clients than sharp local minima (Keskar et al. 2016), which shows large error increases even with minor parameter change. Motivated from adversarial training, we propose a local optimization objective of each client as below: where x is the adversarial image within a L p -norm bounded δ-ball centered at original image x, the adversarial image is generated with the same label of x but different feature shift. However, the generating process has an extra communication burden since we have to transfer feature distribution information across clients. Based on the harmonized features, we carefully design a weight perturbation to effectively solve the Eq. (5). With a little abuse of notation, instead of generating adversarial images bonded by the term δ, we propose a new δ as a perturbation that is directly applied to model parameters. The perturbation is self-generated using gradients from the harmonized feature and has no extra communication cost. Formally, for the k-th batch, we first calculate the gradients of client model θ i,k−1 on the amplitude normalized feature Ψ(x), which is calculated from Eq. (4). Then we use the Euclidean norm · 2 to normalize the gradients and obtain the perturbation term for the current iteration of gradient descent: where α is a hyper-parameter to control the degree of perturbation. The flat area around the local client optimum can be expanded with the larger α, and the choice of α is studied in the experiment section. After obtaining the perturbation term δ k , we minimize the loss on the parameter-perturbated model as below: where θ i,k−1 is the model from the previous batch and η l is the local client learning rate. After iteratively update, each local client model is gradually driven towards an optimal solution that holds a uniformly low loss around its neighborhood area (i.e. flat optimum), thus promoting the aggregation and getting rid of trapped into the local sharp minima.

Theoretical analysis for HarmoFL
With the help of amplitude normalization and weight perturbation, we constrain the client update with less dissimilarity and achieve a model having a relatively low error with a range of parameter changes. To theoretically analyze HarmoFL, we transform our approach into a simplified setting where we interpret both the amplitude normalization 1: Initialize server model θ (1) 2: for t = 1, 2, · · · , T do 3: for i = 1, 2, · · · , N in parallel do 4: for k = 1, 2, · · · , K do client training 6: sample a batch of data pairs (x, y) of D i 7: (4) 10: Eq. (6) 11: (7) 13: and weight perturbation from the gradients perspective. For amplitude normalization, it reduces gradients dissimilarity between clients by harmonizing the non-iid features. In the meanwhile, the weight perturbation forces clients to achieve flat optima, in which the loss variation is constrained, making the gradients change mildly. So both amplitude normalization and weight perturbation bound gradient differences across clients, and this assumption has also been widely explored in different forms (Yin et al. 2018;Li et al. 2020b;Vaswani, Bach, and Schmidt 2019;Karimireddy et al. 2019). Based on the standard federated optimization objective, we formulate a new form in below: where j ∈ {1, · · · , N }\{i} and is a non-negative constant and (x i , y i ) is the image-label pair from the i-th client's distribution. To quantify the overall drift between client and server models at the t-th communication round, we define the overall drift term as below: where K is the mini-batch steps. We theoretically show that with the bounded gradient difference, our HarmoFL strategy is guaranteed to have an upper bound on the overall drift caused by non-iid data. Theorem 3.1 With the shift term Γ defined in Eq. (9), assume the gradient dissimilarity and variance are bounded and the functions F i are β-smooth, denote the effective stepsizeη = Kη g η l , we have the upper bound for the overall drift of our HarmoFL below: and for non-convex situation, we have C := ∇F (θ) . This theorem gives the upper bound with both the convex and non-convex assumptions for F i . Please find the notation table in Appendix A. All assumptions and proofs are formally given in Appendix B. The proof sketch is applying our extra gradient differences constraint in the subproblem of one round optimization and using the bounded dissimilarity. The shift bound is finally unrolled from a recursion format of one round progress.

Experiments
In this section, we extensively evaluate our method to demonstrate that harmonizing local and global drifts are beneficial for clients with heterogeneous features. Our harmonizing strategy, HarmoFL, achieves higher performance as well as more stable convergence compared with other methods on feature non-iid datasets. This is shown on the breast cancer histology image classification, histology nuclei segmentation, and prostate MRI segmentation. All results reported are the average of three repeating runs with a standard deviation of different random seeds. More results please refer to Appendix C.

Dataset and experimental settings
Breast cancer histology image classification. We use the public tumor dataset Camelyon17, which contains 450,000 histology images with different stains from 5 different hospitals (Bandi et al. 2018). As shown in Fig. 3, we take each hospital as a single client, and images from different clients have heterogeneous appearances but share the same label distribution (i.e. normal and tumor tissues). We use a deep network of DenseNet121 (Huang et al. 2017) and train the model for 100 epochs at the client-side with different communication frequencies. We use cross-entropy loss and SGD optimizer with a learning rate of 1e −3 .
Histology nuclei segmentation. For the cell nuclei segmentation, we gather three public datasets, including MoNuSAC2020 (Verma et al. 2021), MoNuSAC2018 (Kumar et al. 2019) and TNBC (Naylor et al. 2018). For data from MoNuSAC2020, we divide them into 4 clients according to different hospitals they come from and form 6 clients in total. We use U-Net (Ronneberger, Fischer, and Brox 2015) and train the model for 500 communication rounds with 1 local update epoch for each communication round. We use segmentation Dice loss and Adam optimizer with learning rate of 1e −4 , momentum of 0.9 and 0.99.
Prostate MRI segmentation. For the prostate segmentation, we use a multi-site prostate segmentation dataset  which contains 6 different data sources from 3 public datasets (Nicholas et al. 2015;Lemaître et al. 2015;Litjens et al. 2014). We regard each data source as a client and train the U-Net using Adam optimizer with a learning rate of 1e −4 , momentum of 0.9 and 0.99.
We report the performance of global models, i.e., the final results of our overall framework. The model was selected using the separate validation set and evaluated on the testing set. To avoid distracting focus on the feature non-iid problem due to data imbalance, we truncate the sample size of each client to their respective smaller number in histology image classification and prostate MRI segmentation task, but we keep the client data imbalance in the nuclei segmentation task to demonstrate the performance with data quantity difference. If not specified, our default setting for the local update epoch is 1. We use the momentum of 0.9 and weight decay of 1e −4 for all optimizers in three tasks. We empirically set the decay factor v to 0.1 and set the degree of perturbation term to 5e −2 by grid search. For more dataset and implementation details, please refer to Appendix C.

Comparison with the state-of-the-arts
We compare our approach with recent state-of-the-art   may come from that images in client E appear differently as shown in Fig. 3, making the representations of client E failed to be constrained towards other clients. With the harmonized strategy reducing both local and global drifts, our method consistently outperforms others, reaching an accuracy of 95.48% on average, which is 8% higher than the previous SOTA (FedBN) for the feature non-iid problem. Besides, our method can help all heterogeneous clients benefit from the federated learning, where clients show a testing accuracy with a small standard deviation on average, while other methods show larger variance across clients. For segmentation tasks, the experimental results of Dice are shown in Table 1 in the form of single client and average performance. On histology nuclei segmentation, HarmoFL significantly outperforms the SOTA method of FedBN and improves at least 4% on mean accuracy compared with all other methods. On the prostate segmentation task, as MRI images show fewer non-iid feature shifts than histology images, the performance gap of each client is not as large as nuclei segmentation. However, our method still consistently achieves the highest Dice of 94.28% and has a smaller standard deviation over different clients. Besides, we visualize the segmentation results to demonstrate a qualitative comparison, as shown in Fig. 4. Comparing with the first groundtruth column, due to the heterogeneous features, other federated learning methods either cover more or fewer areas in both prostate MRI and histology images. As can be observed from the second and fourth row, the heterogeneity in features also makes other methods fail to obtain an accurate boundary. But with the proposed harmonizing strategy, our approach shows more accurate and smooth boundaries.

Ablation study
We further conduct ablation study based on the breast cancer histology image classification to investigate key properties of our HarmoFL, including the convergence analysis, influence of different local update epochs, and the effects of weight perturbation degree.
Convergence analysis. To demonstrate the effectiveness of our method on reducing local update and server update drifts, we plot the testing accuracy curve on the average of five clients for 100 communication rounds with 1 local update epoch. As shown in Fig. 5(a), the curve of HarmoFL increases smoothly with communication rounds increasing, while the state-of-the-art method of FedBN , shows unstable convergence as well as lower accuracy. From the curve of FedBN , we can see the there are almost no improvements at the first 10 communication rounds, the potential reason is that the batch normalization layers in each local client model are not fully trained to normalize feature distributions.
Influence of local update epochs. Aggregating with different frequencies may affect the learning behavior, since less frequent communication will further enhance the drift due to the non-iid feature, and finally obtaining a worse global model. We study the effectiveness of Har-moFL with different local update epochs and the results are shown in Fig. 5(b). When the local epoch is 1, each client communicates with others frequently, all methods have a relatively high testing accuracy. With more local epochs added, the local client update drift is increased and the differences between local and global models become larger. Both FedAvg and FedBN suffer from large drifts and show severe performance drops. However, because our method enables each client to train the model using weight perturbation with harmonized features, HarmoFL significantly outperforms other approaches and shows robustness to larger drift brought by more local update epochs.
Effects of weight perturbation degree. We further analyze how the weight perturbation degree control hyper-parameter α affects the performance of our method. Intuitively, the value of α indicates the radius of the flat optima area. A small radius may hinder clients to find a shared flat area during aggregation, while a large radius creates difficulties in the optimization of reaching such a flat optimum. As shown in Fig 5(c), we plot the average testing accuracy with standard error across clients by searching α ∈ {1, 5e −1 , 5e −2 , 5e −3 , 5e −4 }. Our method reaches the highest accuracy when α = 5e −2 and the performance decreases with α reducing. Besides, we can see our method can achieve more than 90% accuracy even without degree control (i.e. α = 1).

Conclusion
This work proposes a novel harmonizing strategy, HarmoFL, which uses amplitude normalization and weight perturbation to tackle the drifts that exist in both local client and global server. Our solution gives inspiration on simultaneously solving the essentially coupled local and global drifts in FL, instead of regarding each drift as a separate issue. We conduct extensive experiments on heterogeneous medical images, including one classification task and two segmentation tasks, and demonstrates the effectiveness of our approach consistently. We further provide theoretical analysis to support the empirical results by showing the overall non-iid drift caused by data heterogeneity is bounded in our proposed HarmoFL. Overall, our work is beneficial to promote wider impact of FL in real world medical applications.

Roadmap of Appendix:
The Appendix is organized as follows. We list the notations table in Section A. We provide formal assumptions, theoretical analysis, and proof of bounded non-iid drift in Section B. The details of the experimental setting and additional results are in Section C. Table   Notations Description F global objective function.    A i,k average amplitude calculated from the current batch. δ perturbation applied to model parameters.

A Notation
α hyper-parameter to control the degree of perturbation. η l client model learning rate. η g global model learning rate. η effective step-size.
θ t global server model at the t-th communication round. θ t i,k the i-th client model after k mini-batch steps. g δ gradients of weight with perturbation. a non-negative constant to bound gradients difference. Γ overall non-iid drift term.

B Theoretical analysis of bounded drift
We give the theoretical analysis and proofs of HarmoFL in this section. First, we state the convexity, smoothness, and bounder gradient assumptions about the local function F i and global function F , which are typically used in optimization literature (Li et al. 2020b;Reddi et al. 2021;Karimireddy et al. 2020;Tong, Liang, and Bi 2020).

B.1 Assumptions
Assumption B.1 (β-smooth) {F i } are β-smooth and satisfy ∇F i (θ) − ∇F i (θ i ) ≤ β θ − θ i , for any i, θ, θ i Assumption B.2 (bounded gradient dissimilarity) there exist constants G ≥ 0 and B ≥ 1 such that Lemma B.4 (relaxed triangle inequality) Let a 1 , · · · , a n be n vectors in R d . Then the following are true: Proof: The proof of the first statement for any γ > 0 follows from the identity: For the second inequality, we use the convexity of x → x 2 and Jensen's inequality Lemma B.5 (separating mean and variance) Let {Ξ 1 , . . . , Ξ τ } be n random variables in R d which are not necessarily independent. First suppose that their mean is Then, the following holds Proof. For any random variable X, expand the above equation using Lemma B.4, we can have

B.2 Theorem of bounded drift and proof
We first restate the Theorem 3.1 with some additional details and then give the proof. Recall that Γ = . Theorem B.6 Suppose that the functions {F i } satisfies assumptions B.1, B.2 and B.3. Denote the effective step-sizẽ η = Kη g η l , then the updates of HarmoFL have a bounded drift: • Convex: • Non-convex: Proof: First, we consider K = 1, then this theorem trivially holds, since θ i,0 = θ for all i ∈ [N ]. Then we assume K ≥ 2, and have For the first inequality, we separate the mean and variance, the second inequality is obtained by using the relaxed triangle inequality with γ = 1 K−1 . For the next equality, it is obtained with the definition ofη and the rest inequalities follow the assumptions on gradients. Up to now, we get the recursion format and then we unroll this and get below: averaging over i and k, if {F i } are non-convex, we can have

C Complete experiment details and results
In this section, we demonstrate details of the experimental setting and more results. For all experiments, we implement the framework with PyTorch library of Python version 3.6.10, and train and test our models on TITAN RTX GPU. The randomness of all experiments is controlled by setting three random seeds, i.e., 0, 1, and 2.

C.1 Experimental details
Breast cancer histology image classification. For the breast cancer histology image classification experiment, we use the all data from the public dataset Camelyon17 (Bandi et al. 2018) dataset. This dataset comprises 450,000 patches of breast cancer metastasis in lymph node sections from 5 hospitals. The task is to predict whether a given region of tissue contains any tumor tissue or not. All the data are preprocessed into the shape of 96 × 96 × 3, for all clients, we use 20% of client data for test, for the reaming data, we use 80% for train and 20% for validation. For training details, we use the DenseNet121 (Huang et al. 2017) and train it with a learning rate of 0.001 for 100 epochs, the batch size is 128. We use cross-entropy loss and SGD optimizer with the momentum of 0.9 and weight decay of 1e −4 . Histology nuclei segmentation. For the histology nuclei segmentation, we use three public datasets, including MoNuSAC2020 (Verma et al. 2021), MoNuSAC2018 (Kumar et al. 2019) and TNBC (Naylor et al. 2018), and we further divide the MoNuSAC2020 into 4 clients. The criterion is according to the official multi-organ split, where each organ group contains several specific hospitals and has no overlap with other groups. All images are reshaped to 256 × 256 × 3. For all clients, we follow the original traintest split and split out 20% of training data for validation. For the training process, we use U-Net (Ronneberger, Fischer, and Brox 2015) and train the model for 500 epochs using segmentation Dice loss. We use the SGD optimizer with the momentum of 0.9 and weight decay of 1e −4 . The batch size is 8 and the learning rate is 1e −4 . Prostate MRI segmentation. For the prostate MRI segmentation, we use a multi-site prostate segmentation dataset  containing 6 different data sources (Nicholas et al. 2015;Lemaître et al. 2015;Litjens et al. 2014). For all clients, we use 20% of client data for test, for the reaming data, we use 80% for train and 20% for validation. We use cross-entropy and dice loss together to train the U-Net and use Adam optimizer with a beta of (0.9, 0.99) and weight decay of 1e −4 . The communication rounds are the same as the nuclei segmentation task. Following , we randomly rotate the image with the angle of {0, 90, 180, 270} and horizontally or vertically flip images.

C.2 Ablation studies
In this section we present the ablation experiments regarding our proposed two parts on all three datasets (see results in Tables 4, 5, 6). We start with the baseline method FedAvg and then add the amplitude normalization (Amp-Norm), on top of this, we further utilize the weight perturbation (WeightPert) and thus completing our proposed whole framework HarmoFL. From all three tables can be observed that the amplitude normalization (the second row) exceeds the baseline with consistent performance gain on all clients for all three datasets, demonstrating the benefits of harmonizing local drifts. On top of this, adding the weight perturbation (the third row) to mitigate the global drifts can further boost the performance with a clear margin.

C.3 Additional results
Loss landscape visualization on breast cancer histology image classification. We use the loss landscape visualization  to empirically show the non-iid drift in terms of the Γ i := 1 for each client i. As shown in Fig. 6, we draw the loss of FedAvg and our HarmoFL, each column represents a client. The 2-d coordination denotes a parameter space centered at the final obtained global model, loss value varies with the parameter change. From the first row can be observed that the model trained with FedAvg is more sensitive to a parameter change, and the minimal solution for each client does not match the global model (i.e., the center of the figure). The observation is consistent with the Introduction part, with the same objective function and parameter initialization for each client, the five local optimal solutions (local minima) have significantly different parameters, which is caused by the drift across client updates. Besides, the loss landscape shape of each client differs from others, making the global optimization fail to find a converged solution matching various local optimal solutions. However, from the second row of our proposed HarmoFL, we can observe the loss variation is smaller than FedAvg and robust to the parameter changes, showing flat solutions both locally and globally. We further draw loss values with a higher scale as shown in the third row, which means we change the parameter with a large range. From the third row can be observed that HarmoFL holds flat optima around the central area, even with 8 times wider parameter change range. Besides, the global solution well matches every client's local optimal solution, demonstrating the effectiveness of reducing drifts locally and globally. Gradient inversion attacks with the shared amplitudes across clients. To further explore the potential privacy issue regarding the inverting gradient attack by using our shared average amplitudes across client, we implement the inverting gradient method (Geiping et al. 2020) and show results in below Fig. 7. We first extract the amplitude from the original images and then conduct the inverting gradient attack on the amplitudes which will be shared during the federated communication. The reconstruction results of the attack are shown at the last column. It implies that it is difficult (if possible) to perfectly reconstruct the original data solely using frequency information. Visualization of amplitude normalization results. In this section we demonstrate the visual effects of our amplitude normalization. The qualitative results for the two segmentation datasets (Fig. 2 is the classification dataset) are shown in Fig. 8. Given that amplitudes mainly relate to low-level features, the AmpNorm operation would not affect the high-  level semantic structures. In addition, though the normalization might introduce tiny changes in some ambiguous boundaries, the network with a large receptive field would have the ability to combat such local changes by using contextual information.
Visualization of segmentation results. More qualitative segmentation results comparison on both prostate MRI segmentation and histology nuclei segmentation tasks are shown in Fig. 9 and Fig. 10. From Fig. 9, as can be observed from the first row, alternative methods show several small separate parts for the segmentation on big cells while HarmoFL gives more complete segmentation results. As for small cells, HarmoFL has the capability to split each small region out while others may connect small nuclei together or only cover a very small explicit region. Specifically for the fourth row, others fail to segment some nuclei which have fewer differences with background, but our method demonstrates more accurate results. For the prostate MRI segmentation results shown in Fig. 10, the images from different hospitals show a shift in feature distributions, which brings difficulties for other methods to obtain a more accurate boundary. Especially for the third row, the compared methods fail to figure out the structure, while ours delineates the accurate boundary.