{'fraction_non_alphanumeric': 0.0388634431310167, 'fraction_numerical': 0.016318806395875046, 'mean_word_length': 4.765654648956357, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Exploiting Personalized Invariance for Better Out-of-distribution Generalization in Federated Learning

Recently, data heterogeneity among the training datasets on the local clients (a.k.a., Non-IID data) has attracted intense interest in Federated Learning (FL), and many personalized federated learning methods have been proposed to handle it. However, the distribution shift between the training dataset and testing dataset on each client is never considered in FL, despite it being general in real-world scenarios. We notice that the distribution shift (a.k.a., out-of-distribution generalization) problem under Non-IID federated setting becomes rather challenging due to the entanglement between personalized and spurious information. To tackle the above problem, we elaborate a general dual-regularized learning framework to explore the personalized invariance, compared with the exsiting personalized federated learning methods which are regularized by a single baseline (usually the global model). Utilizing the personalized invariant features, the developed personalized models can efficiently exploit the most relevant information and meanwhile eliminate spurious information so as to enhance the out-of-distribution generalization performance for each client. Both the theoretical analysis on convergence and OOD generalization performance and the results of extensive experiments demonstrate the superiority of our method over the existing federated learning and invariant learning methods, in diverse out-of-distribution and Non-IID data cases.


Introduction
As data privacy is attached more and more importance to in the field of machine learning, federated learning [McMahan et al., 2017] (FL) gains increasing attention and dramatic development in recent years. Federated learning allows the participation of a massive number of data holders (usually called clients) to train the learning models in a collaborative manner. Most importantly, the participating clients can preserve their data locally during the collaborative training process, and hence prevent the leakage of private data. Traditional federated learning approaches develop a shared gloal model by model aggregation to fit all the local datasets, which can work well when the local data instances on clients subjects to independent and identically distribution (IID). Conversely, the Non-IID setting where the local datasets don't satisfy the IID assumption can degrade the performance (both model accuracy and convergence rate) of the global model dramatically [Hsieh et al., 2020]. To settle the challenge of Non-IID data, personalized federated learning (PFL) is proposed to train a personalized model for each client. Contrary to the individually trained local model which is often trapped in overfitting due to the insufficient local data, the personalized model obtains some generalization knowledge from the sever or the cooperation with other clients.
Despite the exsiting personalized federated learning methods achieve great success recently, we notice that all of them focus on ,the model performance on in-distribution testing dataset. In this way, the produced models can hardly adapt to the scenarios where the testing dataset is out-of-distribution in terms of the training dataset. Here, we refer to out-of-distribution (OOD) scenario as the case where there exists distribution shift between the training and testing dataset. In fact, the out-ofdistribution scenario is more genreal and practical in machine learning applications, and has drawn lots of efforts in the literature on OOD generalization [Arjovsky et al., 2019, Sagawa et al., 2019, Ye et al., 2021, Shen et al., 2021, Krueger et al., 2021, Zhang et al., 2021c. However, the out-of-distribution generalization problem is mostly studied in centralized setting where all data can be accessed, but has seldom been considered in the federated learning. Although some of the methods designed for centralized setting can be naively applied into the federated learning to generate a shared global model, they cannot cast off the Non-IID data quagmire because the gained model drops the useful information about personalization. In summary, the existing federated learning works can hardly handle the out-of-distribution scenarios, and meanwhile the centralized methods for OOD generalization will be troubled by the Non-IID data even if they can be implemented in federated learning setting.
What's worse, we find that the simple combination of the existing PFL and OOD methods, instead of solving the OOD generalization problem under Non-IID federated setting, will produce much worse performance than the better one of themselves (the finding will be shown and discussed in the experiment part). To handle the challenging OOD problem under Non-IID federated setting, we disscting the data heterogeneity (Non-IID) from two orthogonal perspectives and then introduce a novel concept: personalized invariance. The proposed personalized invariance can preserve the personal information, and in the meantime eliminate the spurious information to equip the obtained personalized models with out-of-distribution generalization. In contrast with the naive combination of PFL and OOD methods which can easily 'pick up' the spurious correlation during the process of personalization because of the entanglement of personalized and spurious information, we propose a general learning framework that is regularized by two baselines: global invariance and local invariance. The global invariance can prevent the personalized models from being stuck in overfitting due to the insufficiency of local data. However, global invariance will discard both personalized and spurious information. Therefore, the constraint of local invariance is utilized to exclude the spurious correlation. With the guidance of the designed dual-constraint, the personalized models can effectively exploit personalized invariance to solve the challenging OOD problem for every client in federated setting. The main contributions of this paper are summarized as follows: • To the best of our knowledge, we are the first to consider and handle the challenging personalized out-of-distribution problem under Non-IID federated learning setting. We propose the novel concept of personalized invariance and theoretically analyze the advantage of personalized invariance over the naive global invariance. • We elaborate a dual-regularized learing framework to explore the personalized invariant features which can include important personalization information and meanwhile exclude the spurious correlation. Formally, the OOD problem under Non-IID setting is formulated as a bi-level optimization where the client-level objective is constrained by a dual-baseline regularization. Besides, we provide theoretical analysis on convergence rate and OOD generalization performance which proves the effectiveness of our method. • We conduct extensive experiments on diverse datasets to compare the performance of our method with the existing federated learning (including personalized federated learning) and invariant learning methods. The results show that our method outperforms the state-of-theart ones in varied out-of-distribution and Non-IID settings.
2 Related work

Personalized Federated Learning
One of the most challenging problems in federated learning [McMahan et al., 2017] is the data heterogeneity (a.k.a, Non-IID) across the local clients [Hsieh et al., 2020]. To handle the Non-IID data quagmire, personalized federated learning (PFL) methods have been widely explored in many realworld applications. Jeong et al. [Jeong et al., 2018, Duan et al., 2020 focus on data augmentation methods by generating additional data to augment its local data towards yielding an IID dataset. However, these methods usually require the FL server to know some statistical information about the local data distributions (e.g., class sizes, mean and standard deviation), which may potentially violate privacy policy [Tan et al., 2021]. Another line of work designs special client selection mechanisms to simulate homogeneous data distribution [Wang et al., 2020, Yang et al., 2020, Lyu et al., 2020.
On the other hand, many model-based PFL methods focus on producing customized model structures or parameters for different clients, which can also be divided into two types: single-model, multiple-model based approaches. Single-model based methods extended from the conventional FL algorithms like FedAvg [McMahan et al., 2017] combine the optimization of the local models and global model, including: local fine-tuning [Wang et al., 2019, Schneider and Vlachos, 2019, Arivazhagan et al., 2019, regularization [T Dinh et al., 2020, Hanzely and Richtárik, 2020, Hanzely et al., 2020, model mixture [Mansour et al., 2020, Deng et al., 2020, meta learning [Fallah et al., 2020, Jiang et al., 2019 and parameter decomposition [Bui et al., 2019, Collins et al., 2021, Arivazhagan et al., 2019. Considering the diversity and inherent relationship of local data, multi-model-based approaches where multiple global models are trained for heterogeneous clients are more reasonable. Some researchers [Ghosh et al., 2020, Mansour et al., 2020, Tang et al., 2022 propose to train multiple global models at the server, where similar clients are clustered into a group to share the in-distribution generalization knowledge. Another strategy is to collaboratively train a personalized model without explicit global models, e.g., FedAMP [Huang et al., 2021], FedFomo [Zhang et al., 2021b, MOCHA [Smith et al., 2017], and KT-pFL [Zhang et al., 2021a]. However, all of these works focus on the discrepancy between training data distributions rather than that between training and testing distributions.

Out-of-distribution Generalization
Out-of-Distribution (OOD) generalization problem refers to a challenging setting where the testing distribution is unknown and different from the training. In order to deal with the OOD generalization problem, tremendous efforts have been made and vary greatly ranging from causality to representation learning and from structure-based to optimization-based. The existing methods can be categorized into three parts: unsupervised representation learning (e.g., to analyse causal relationships between data) , Shen et al., 2020a, Yang et al., 2021, Träuble et al., 2021, Locatello et al., 2019, supervised model learning (e.g., design various model architectures and learning strategies to achieve OOD generalization, including domain generalization [Wang et al., 2021, Zhao et al., 2020, Garg et al., 2021, Du et al., 2020, causal & invariant learning [Gamella and Heinze-Deml, 2020, Oberst et al., 2021, Krueger et al., 2021, Kamath et al., 2021, Arjovsky et al., 2019 and stable learning [Shen et al., 2018, 2020b, Zhang et al., 2021c) and optimization approaches (focus on distributed robust optimization across different distributions [Liu et al., 2021c, Sagawa et al., 2019 or capturing invariant features [Liu et al., 2021a, Chang et al., 2020, Koyama and Yamaguchi, 2020). All of the above OOD generalization methods are studied in centralized scenarios, where all training data can be accessed. In some real-world applications, the data are usually generated locally and the data owners are not willing to share data with others due to the concern about privacy. Therefore, we are motivated to investigate the OOD generalization problem under the federated setting.

Problem formulation
In this section, we first introduce the preliminary knowledge of invariant learning and then deconstruct the data heterogeneity into two orthogonal levels to investigate what information is necessary and what is spurious for solving the OOD problem under the Non-IID federated learning. For the purpose of fully exploiting the useful invariant information, we propose the personalized invariance which retains the important personalized information and concurrently excludes the spurious information to equip the obtained models with both personalization and out-of-distribution generalization.
Notations. Let X denotes the input space, Y denotes the target space, and correspondingly (X, y) ∈ (X , Y) is the data instance. The sets of training and testing environments are represented by E train and E test respectively. We use E all as the set of all possible environments in the task concerned, i.e., E train , E test ⊂ E all . Suppose that there are N clients and the local dataset contains m i data instances on client i. For convenience, we separate the learning model or parameterized mapping from the input space X to Y into two consecutive parts: the feature extractor Φ

Invariant Learning
Invraint learning has been emerged as a promising approach for handling OOD generalization problem [Arjovsky et al., 2019, Ahuja et al., 2020, Liu et al., 2021a,b, Creager et al., 2021. The prevalent invariant learning assumes that there exists some invariant feature Φ(X) satisfying the invariance property: To discover the invariant representation Φ : X → H that elicits an invariant predictor w • Φ across all environments, IRM [Arjovsky et al., 2019] is proposed as a constrained optimization problem based on the empirical data from multiple accessible training environments E train . Out of efficiency concerns, a practical version of IRM is offered in that work: where R(f θ ; e) is the expected empirical loss on environment e. In particular, f θ is used as the entire invariant predictor, andw is a scalar and fixed "dummy" classifier as in [Arjovsky et al., 2019]. We define that L IRM (θ; E train ) = e∈Etrain R(f θ ; e) + λ · ∇w |w=1.0 R(w · f θ ; e) 2 in this paper.
Apart from IRM, another branch of approaches to OOD problem is worst-case generalization [Sagawa et al., 2019]. The target of worst-case generalization is to minimize the expected risk of the training enviroment which produces the worst risk such that the generated predictor can be simultaneously optimal for all environments. One typical method is GroupDRO given in [Sagawa et al., 2019], of which the objective is: where g = |E train | is the numbers of accessible training environments. Similarly, we define that L GroupDRO (θ; E train ) = max q∈∆g e∈Etrain q e · R(f θ ; e) in this paper.

Personalized invariance
In order to study the OOD generalization problem under Non-IID federated setting, we first dissect the data heterogeneity from two orthogonal perspectives and categorize the related works in Table 1 according to the coverage of their methods.
Client-level heterogeneity. The distributions of training datasets are usually heterogeneous across the clients. Since the local data on every client is scarce and of limited diversity, the clients in FL framework need to collaborate to mine the common/generalization knowledge with some shared/global objective. However, the client-level heterogeneity can result in the discrepancy between the optimas of local objective and global objective. In other words, the client-independent representation (i.e., global knowledge) can be biased for some participating clients. Therefore, preserving the personalization information is of great importance for dealing with the client-level data heterogeneity.
Context-level heterogeneity. In addition to the heterogeneity among the training datasets, the heterogeneity between the training and testing dataset is also worthy of attentions. In FL, the local training and testing dataset on each client may be generated in distinct contexts/environments 1 . For 1 In this paper, environment, context and domain are used equivalently. example, the training image samples on a client are mainly captured from the local cameras, while the testing images may come from the web and with different styles. From the perspective of context, the target learning models must be equipped with OOD generalization so that they can perform both well on unknown and distinct contexts.
As discussed above, we can conclude that solving the OOD problem under Non-IID federated setting needs to discover the invariant representation without dropping the important personalized information. When we consider to implement the distributed version of invariant learning, such as IRM and GroupDRO, each client can be regarded as an environment. In this way, both the context-specific (i.e., spurious) representation and the client-related (personalized) representation will be treated as spurious representations. Only the common invariant representation across the clients is extracted and utilized to elicit the invariant predictors. Consequently, the important personalized representation is dropped.
Assumption 1 (Heterogeneity of invariance) For each client i, there exists a set of invariant representations Φ i that satisfies the invariance property on the local set of environments E i all as defined in equation The heterogeneity condition in Assumption 1 is consistent with the Non-IID assumption in FL, and the informativeness assumption claims the existence of meaningful personalization. If we define In the prediction task, the optimal global and personalized invariant representations are given by Φ ⋆ i = arg max S⊂Φi I(Y ; S) and Φ ⋆ g = arg max S⊂Φg I(Y ; S), respectively.

Theorem 1 If the Assumption 1 holds in FL, the proposed personalized invariant representations can be constantly more informative than the global invariant representations obtained by the distributed implementation of existing invariant learning, for the prediction performance. That is,
where 0 < p < 1 is a constant and δ is a positive constant that is independent of N .
Theorem 1 demonstrates the importance of the proposed personalized invariance in improving the average prediction performance for OOD problems under Non-IID federated setting. The detailed proof of Theorem 1 is provided in the Appendix.

Dual-regularization constrained learning framework
Adhering to the prevalent setup of invariant learning, we suppose there are totally K training contexts in the federated learning system. On client i, the training data (X, y) ∈ D i is generated from K i contexts while the testing data comes from unknown contexts. That is,

Algorithm Design
In ideal circumstances, we can elicit the personalized invariant predictor for each client i We refer to 'ideal' circumstances as the scenarios where the following two conditions are met: 1) the number of training contexts on every client is sufficient for deriving the invariant predictor, 2) the data samples in every training context are of sufficient diversity. Unfortunately, both of the above two conditions can hardly be satisfied in FL setting since the local data is usually scarce [McMahan et al., 2017]. On the one hand, the latest efforts prove that the minimizer of L IRM will necessarily utilize the noninvariant features and therefore cannot universally generalize to unknown testing contexts when the number of training contexts is not sufficient [Rosenfeld et al., 2021]. On the other hand, the limited data diversity in each training contexts will make the obtained model easily trapped by overfitting.
To handle the challenges of insufficient training contexts and limited data diversity in each available context . In this paper, we elaborate a dual-regularization constrained optimization framework to handle these challenges of OOD generalization problems in federated scenarios. The overall objective on client i(i ∈ [N ]) is: Different from the popular single-regularized (i.e., global-regularized) personalized federated learning schemes [T Dinh et al., 2020, Hanzely and Richtárik, 2020, Deng et al., 2020, Hanzely et al., 2020, Li et al., 2021, the objective on each client is constrained by two regularizations. One is the 'local invariance' expressed by the first term L IN V (θ i ; E i train ) and nother is the 'global invariance' represented by the second term θ i − ν ⋆ 2 . The 'local invariance' is necessary for discovering the personalized invariant predictor, while the 'global invariance' is adopted to deal with the challenges of insufficient training contexts and limited data diversity in each context. Without loss of generality, we focus on studying the case where L IN V = L IRM in this paper. Therefore, the detailed objective on client i can be written as On each client, the outer problem in objective (2) can be solved locally with the guidance of the global model ν ⋆ downloaded from the server. In order to solve the inner problem in a collaborative manner, the objective (3) needs to be decomposed into N subproblems that can be individually and parallelly solved at the local clients. In fact, the objective of IRM (L IRM (ν; E D )) can be naturally decomposed into N subproblems: . The weight q i can be updated on the server using the uploaded R(f ν ; D i ), i ∈ [N ] following the update law in [Sagawa et al., 2019]. Our algorithm is shown in Algorithm 1.
1: Initialize the models ν 0 , {θ 0 i |i ∈ [N ]}. 2: for t = 0 to T − 1 do 3: Server sends the global model (ν t ) to the participating clients. 4: for local device i = 1 to N in parallel do 5: Local update for global model:

Theoretical analysis
In this section, we will provie detailed theoretical analysis on convergence rate and out-ofdistribution generalization guarantee of the proposed algorithm, and discuss how to improve the practical performance of our method based on the theoretical outcomes. For simplicity, we define L(ν) := 1 N L IRM (ν; E D ) in this section. It's mentioned that the penalty term of IRM is generally non-convex in [Arjovsky et al., 2019]. Therefore, we figure out the convergence rate of our algorithm under the non-convex and smooth case.
Assumption 2 (Bounded variance) The variance of local gradients to the aggregated average is upper bounded by 1 2. And, the convergence rate of the personalized models is given by: Corollary 1 Theorem 2 proves that the proposed algorithm achieves a convergence rate of O(1/T 2/3 ) under the non-convex and smooth case. The detailed proof is provided in the Appendix.
Theorem 3 (Out-of-distribution Generalization) As discussed in Section 3, the learning model can be written as f = Φ · ω. Suppose Assumption 1 is satisfied. Let the global invariant featurizer  Remark 1 Theorem 3 provides the personalized models with performance guarantee on any unseen contexts, even if both challenges of insufficient training contexts and limited data diversity in each available context exist. The detailed proof of Theorem 3 can be found in the Appendix. In particular, we find that choosing a appropriate value for the balancing weight β is significant for guaranteeing the out-of-distribution performance on each client. Empirically, the less training contexts a client has, the smaller the value of β should be. Therefore, personalized β can be adopted on heterogeneous clients by themselves, according to the number of available training contexts.

Experimental Setup
Datasets We evaluate the effectiveness of our method on three datasets that are frequently adopted in the related literature: 1) Rotated CMNIST (RC-MNIST), a variant of CMNIST [Arjovsky et al., 2019]. Firstly, We construct the CMNIST dataset according to the same law as in [Arjovsky et al., 2019]: each image having label 0 is colored green with probability p e and colored red with probability 1 − p e . In contrary, each image having label 1 is colored red with probability p e and colored green with probability 1 − p e . In the training and testing contexts, we set p e = p e train and p e = p e test to generate the data respectively. On the basis of CMNIST, we add rotation property to simulate the personal writing style and regard the rotation property as useful personalized information. To distribute the data to the clients in a Non-IID scheme, we construct four training contexts with p e train = 0.95, 0.90, 0.85, 0.80 and assign each context to a client as training data. For the testing data, we constrcut a out-of-distribution context with p e test = 0.10 for every client. The data used for constructing the four training/testing contexts is randomly sampled from the train-set/test-set of MNIST [LeCun et al., 1998] without replacement. In addition, all images (from both training and testing sets) in the four clients are rotated by 0 • , 90 • , 180 • and 270 • respectively. 2) Rotated Colored Fashion-MNIST (RC-FMNIST) [Ahuja et al., 2020], which is constructed using the same strategy as RC-MNIST, except that the original images come from FashionMNIST dataset. 3) Wa-terBird [Sagawa et al., 2019], which is constructed by placing the waterbird photographs onto the water background with probability p e and onto water background with probability 1 − p e . In the meanwhile, the landbird photographs are placed onto the land background with probability p e and onto water background with probability 1−p e . In this paper, we construct four training contexts with p e train = 0.95, 0.90, 0.85, 0.80 and the testing contexts with p e test = 0.10. To distribute the data in a Non-IID manner, we construct the four training contexts using the bird photograghs of disjoint bird classes from the bird dataset and background photographs randomly selected from the background dataset without replacement. Each training context is assigned to a client as training data. For the testing data in each client, we construct a testing contexts with probability p e test = 0.10, using the bird photographs of same bird classes (but distinct instances) as the corresponding training context and the background photographs are randomly selected from the background dataset.

Experimental Results
In order to comprehensively compare the performance of our method with that of the baselines, we conduct evaluation on five out-of-distribution (OOD) testing cases for each dataset, including p e test = 0.10, 0.20, 0.30, 0.40 and 0.50. All hyperparameters of the algorithms are tuned optimal, and more details are provided in the Appendix. We run each algorithm three times with different random seeds to record the mean and standard deviation of the test accuracy in every OOD case. Performance Comparison. The overall results on RC-MNIST, RC-FMNIST and WaterBird are displayed in Table 2, Table 3 and Table 4, respectively. In each table, the last column gives the mean and standard deviation of the results in the five OOD cases. From the results shown in the three tables, we can find that 1) our method PerInvFL can constantly outperform the baseline methods on both worst-case accuracy and average accuracy for diverse datasets. In particular, our method achieves an average accuracy of 73.99% which is about 9% higher than the second highest one on WaterBird dataset. 2) As shown in the last columns, the performance deviation of our method is much smaller than the existing federated learning methods and approximate to the invariant learning approach IRM, demonstrating that our method can effectively obtain the invariant predictor and hence achieve consistent performance in different out-of-distribution cases. These findings verify that the proposed method can effecrively extract the invarinat features and concurrently exploit the personalized information to improve the performance on out-of-distribution testing data. Effect of dual-regularized optimization. As explained in section 4, the elaborated dual-regularized optimization is formulated as the objective (2). To demonstrate the effect of the designed dualregularized franework, we replace the dual-regularized optimization with some prevalent singleregularized methods that are usually adopted in the state-of-the-art personalized federated learning, and keep the rest part of the overall objective (shown in equation (2) and (3)) unchanged. Concretely, we implement two typical personalization skills with the global model being achieved by distributional IRM that we introduce in section 4.1. One is the L2-norm regularizer which is widely used in PFL [T Dinh et al., 2020, Hanzely and Richtárik, 2020, Hanzely et al., 2020, Li et al., 2021, and we call this implementation IRM-L2. Another one is the local-finetune skill which is proved simple and effective in [Cheng et al., 2021]. In particular, the local-finetune skill can be viewed as a 'none' regularizer. We name the implementation with local-finetune skill as IRM-FT.
The comparison of results is shown in Table 5. We can find that combining the existing personalization terms with IRM cannot improve the performance of OOD problem under federated setting. On the contrary, the widely adopted personalization term (L2-norm and local-finetune) can even degrade the OOD performance, compared with the distributional version of IRM. The underlying reason is that the local objective with these personalization terms is to minimize the expected loss as long as the target model is not too different from the global model. However, when the realtionship with the global model is satisfied, minimizing the expected loss can readily make the trained model pick up the spurious correlations and hence decrease the performance on OOD testing data. By comparison, the designed dual-regularized optimization in our algorithm contains two constraints: 1) being close/similar to the 'global invariance' and 2) satisfying the 'local invariance' to exclude the spurious features. Therefore, our method can effectively exploit the personalized information and avoid 'picking up' the spurious information concurrently, so as to improve the OOD performance.

Conclusion
In this paper, we are the first to investigate the out-of-distribution problem under the Non-IID federated setting. Atfer formally analyzing the challenges, we propose the novel concept personalized invariance which can improve the model performance, by preserving the important personalized information and meanwhile eliminating the spurious correlations. To explore the optimal personalized invariance, we propose a objective: dual-regularization constrained optimization and design a practical algorithm PerInvFL to solve it. Both the theoretical and experimental results demonstrate the superiority of our method over the state-of-the-art federated learning and invariant learning methods.

A Appendix
In this appendix, we provide more details that are simplified in the main text duo to page limitation, including the complemte proofs, more details on experimental setup, and some further discussions.
A.1 Proof of Theorem 1 Theorem 1 If the Assumption 1 holds in FL, the proposed personalized invariant representations can be constantly more informative than the global invariant representations obtained by the distributed implementation of existing invariant learning, for the prediction performance. That is, where 0 < p < 1 is a constant and δ is a positive constant that is independent of N .
Proof: According to the definition, there are N clients in the federated learning system. The set of all possible environments on each client i is given by E i all , i ∈ [N ]. Then, the set of all possible environments on all the clients is the union: Because of the data heterogeneity across the clients, we have E i all = E all , i.e., E i all ⊂ E all , ∀i ∈ [N ]. For every invariant feature φ g ∈ Φ g across all the environments E all , we can get But, the converse is not true, due to the result in equation 7. Therefore, we have When the Heterogeneity condition in Assumption 1 is satisfied, we can conclude that When the Informativeness condition in Assumption 1 is satisfied, we can derive the average mutualinformation among the clients by Proof ends.
As discussed in the main content, the Theorem 1 demonstrates the superiority of personalized invariance on improving the average prediction performance in OOD and Non-IID federated setting, compared with the global invariance which is elicited by the distributional implementation of existing invariant learning methods. In paticular, the improvement pδ is independent of the number of clients and p is the percentage of the clients with heterogeneous invariance. In other words, p can represent the extent of data heterogeneity across the clients. Therefore, we can conclude that the performance improvement caused by the proposed personalized invariance can be enlarged as the herteroheneity of invariance among the clients increases.

A.2 Proof of Theorem 2
Theorem 2 Suppose the IRM loss function L IRM (θ; e i j ) is L F -smooth, ∀ i, j, and Assumption 2 holds. If γ ≤ γ0 αR ∀ α ≤ 1, R ≥ 1 and γ 0 := α √ 32(R+3)LF . Then we have 1. The convergence rate of the global model is given by: 2. And, the convergence rate of the personalized models is given by: where ∆ L := L(ν 0 ) − L(ν T ), C is a finite positive constant, and t ⋆ is uniformly sampled from {0, 1, ..., T − 1}. The constant C exists since the number of local iterations S is finite.
Proof: We know the local update of global model follows and the global update is Since the loss function is L-smooth, we have we first deal with E[ ν t i,r − ν t 2 ]. We can figure out that Thus, with Assumption 2, we can get Therefore, we can write We can get where C 1 = 4(L(ν 0 ) − L(ν T )), C 2 = 32δ 2 L L 2 F and C 3 = 32(1 + R)δ 2 L L 3 F . We consider the following two cases: • When γ 0 ≥ min Suppose there exists a model fθ i =Φ i ·ω i that is the minimizer of upper objective (4), but there isn't any apppropriate β such that fθ i guarantees the test error E (X,Y )∼P e [ℓ(fθ i (X), Y )] = min ω,Z⊂Φi E (X,Y )∼P e [ℓ(ω(Z(X)), Y )] for any e ∈ E i all .
where δ d is a constant. In other word, with appropriate β chosen, fθ i =Φ i ·ω i can guarantee that E (X,Y )∼P e [ℓ(fθ i (X), Y )] is minimized for all e ∈ E i all . This result contradicts the previous assumption.
Therefore, the conclusion 1 in Theorem 2 is proved.
Proof of conclusion 2 When the training contexts on local client is insufficient, the minimizer of the objective (4) can necessarily rely on the spurious features. However, with an appropriate β chosen, the minimizers can be constrained to be fθ i =Φ i ·ω i = f ν ⋆ . It has been proved f ν ⋆ can guarantee E[Y |Φ ν ⋆ (X), e] = E[Y |Φ ν ⋆ (X), e ′ ], f or all e, e ′ ∈ E all . Because E i all ⊂ E all holds for all i ∈ [N ], f ν ⋆ can naturally guarantee that E[Y |Φ ν ⋆ (X), e] = E[Y |Φ ν ⋆ (X), e ′ ], f or all e, e ′ ∈ E i all .
Proof ends.

A.4 Detailed experimental setup
In this chapter, we will provide the detailed experimental setup, including the dataset setup, model selection and more implementation details.
Dataset setup We give the detailed setup of the adopted datasets in Table 6. For the RC-MNIST dataset, we use the first 50000 images in the train-set of MNIST LeCun et al. [1998] to constrcut the train-sets for the clients, and use the other 10000 images in the train-set of MNIST LeCun et al.
[1998] to constrcut the test-sets for the clients. Finally, in every trial, each client has 12500 data instances for training and 2500 data instances for testing. In the original MNIST dataset, the shape of the images is 28 * 28. After the construction, the images in the obtained RC-MNIST dataset have the size of 28 * 28 * 2. To save the computation cost, we downsample the images to 14 * 14 * 2 before they are input into the first layer of the neural network. The RC-FMNIST dataset is constructed and processed using the same strategies as the RC-MNIST dataset. The WaterBird dataset is constructed using the bird dataset ( For each client, we randomly sample 400 instances from the index range (shown in Table 6) of bird dataset to generate the train-set and 100 instances from the same range to generate the testset. Besides, all of the corresponding background photographs are randomly sampled from the background dataset (Places Zhou et al. [2017]) without replacement.
Model selection For RC-MNIST and RC-FMNIST dataset, we adopt a deep neural network with two hidden layers (the dimension is 390 and 390 respectively) as the feature extractor and an subsequent fully-connected layer (the dimension is 390) as the classifier. Besides, after each haidden layer, there is a ReLU layer in the feature extractor. In the evaluation on WaterBird dataset, we adopt the standard ResNet-18 He et al. [2016] as learning model. Similarly, the part before the last fully-connected layer works as the feature extractor and the last fully-connected layer works as the classifier, and the output dimension of the feature extractor is 512.