Manuscript Offprint
arXiv:2610.20753Optimal Hydra: Model Heterogeneous Federated Learning for LLMs using Data-Informed Hydra-Nets
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Large language models (LLMs) trained on vast amounts of data have demonstrated impressive performance over a wide range of tasks, but future performance gains will require increasing amounts of data and compute. Federated Learning (FL) can facilitate training on decentralized private data, but client resource limitations can make FL training impractical, particularly as model sizes continue to expand. These resource constraints make the widely accepted assumption of a shared server–client architecture impractical. Model heterogeneous FL offers a promising alternative by adapting model size to client capabilities; however, previous work is limited to the pre-training setting, and these conclusions on sub-network selection do not necessarily hold for fine-tuning. Furthermore, prior approaches have created client sub-networks without considering their unique data distributions, thereby overlooking the opportunity to tailor sub-network architecture to local data. Motivated by evidence that attention heads exhibit task dependency within layer defined feature spaces, we propose Optimal Hydra, a transformer based heterogeneous FL framework for fine-tuning that combines global layer selection with client specific attention head selection aligned with local data distributions. Optimal Hydra makes explicit use of client data to produce client-specific sub-networks we call Hydra-nets. To our knowledge, this is the first model heterogeneous FL approach tailored to LLM fine-tuning. Experiments on three datasets show significant improvements over a number of baseline methods while also reducing local resource demands.
1 Introduction
Foundation models have demonstrated advanced abilities on diverse tasks and have been widely adopted in domains including healthcare, education and autonomous vehicles (Bommasani et al., 2021; Thirunavukarasu et al., 2023; Brown et al., 2020; Hu et al., 2023). Established scaling laws indicate that continued performance gains will require increasingly large amounts of data (Kaplan et al., 2020), a requirement at odds with the growing awareness of digital privacy. Federated learning (FL) (McMahan et al., 2017) offers a privacy preserving alternative that may create a greater willingness to share data Sani et al. (2024); however, the application of FL to foundation models is challenging due to large parameter counts that considerably exceed the capabilities of a typical edge device (Yao et al., 2024). Previous attempts to bridge this gap have largely relied on Parameter-Efficient Fine-Tuning (PEFT) (Babakniya et al., 2023a; Tian et al., 2024; Bai et al., 2024), but these methods can struggle to match the performance of full fine-tuning and are prone to overfitting when parameters are strictly limited (Chen et al., 2022). Furthermore, these methods still require homogeneous model architectures, so client nodes must have adequate resources to store and train the entire large model, which is often not the case (Yao et al., 2024). This creates a dilemma: either we limit model complexity to accommodate the most under resourced client or we exclude low resource clients from training. Neither of these options is ideal, since limiting model complexity eliminates our ability to train large SoTA models and excluding low resource clients from training creates a bias towards the data of those with better resources (Kairouz et al., 2021).
Model heterogeneous FL relaxes the assumption that server and client model architectures must be identical, it allows for federated training with heterogeneous models better suited to unique client capabilities. Early

Figure 1: Each model is represented as a set of horizontal rectangles denoting transformer layers. The segregation of each layer represents attention heads present in the layer. Note: for simplicity, attention heads are the only architectural components depicted. Hydra-Net selection algorithm: Clients first collaboratively select a subset of common layers from which no attention heads may be removed; these layers are highlighted in orange to indicate the protected status of their attention heads during the individual head selection process. Next, clients individually select a subset of heads in each unimportant layer via a gradient based scoring mechanism. Heads that were not selected by clients in the individual selection process are grey to indicate their removal from the sub-network. The end result is a unique, data aligned Hydra-Net for each client that is subsequently used in the model heterogeneous FL framework, Optimal Hydra.
work used static (Diao et al., 2020; Horvath et al., 2021) or random (Wen et al., 2022) sub-networks that trained model parameters unequally, making them susceptible to client drift (Karimireddy et al., 2020). Subsequent work improved stability by training model parameters more equally (Alam et al., 2022; Liao et al., 2025); however, all of these approaches overlook the fact that optimal sub-networks are intrinsically linked to the data they encounter (Frankle & Carbin, 2018). For FL in particular, client data distributions are often highly heterogeneous and tailoring sub-network architectures to local data presents an important opportunity to capture distribution-specific features. Notably, while prior work focuses exclusively on the pre-training setting, our work addresses fine-tuning and we will show that previous conclusions regarding strictly equal parameter training in the pre-training setting do not necessarily hold in the context of fine-tuning.
We propose Optimal Hydra, a method that adapts model-heterogeneous FL for LLM fine-tuning. Prior research has focused exclusively on pre-training (Alam et al., 2022; Diao et al., 2020; Liao et al., 2025; Wen et al., 2022; Horvath et al., 2021); we address this gap in the literature by being the first to investigate model-heterogeneous FL in the fine-tuning setting, a setting that has become increasingly relevant as large foundation models become the norm. We also take the opportunity to improve upon the random sub-network selection used in previous works by creating data-informed sub-networks we call Hydra-Nets that are tailored to local client data to better capture distribution-specific features. Fig. 1 provides a high level overview of our Hydra-Net selection method that proceeds in two steps; common layer selection and individual head selection. Common layer selection is motivated by the fact that transformer layers govern macro level feature transformations (Voita et al., 2019) and that in FL a lack of consensus amongst client sub-networks can negatively affect global model convergence (Diao et al., 2020; Horvath et al., 2021; Babakniya et al., 2023b). We adapt a metric used to determine the relative importance of transformer layers by He et al. (2024) to enable clients to collaboratively identify a small subset of “important” layers, establishing a shared structural backbone across clients from which no attention heads may be removed. Subsequently, each individual client will select a unique subset of attention heads to keep from each “unimportant” layer via a gradient based scoring metric, the rest will be discarded. Ultimately, Hydra-Net selection is motivated by the task dependent nature of attention heads to create targeted sub-networks, informed by each client’s unique local data distributions.
Our key contributions are as follows:
-
We propose Optimal Hydra for model heterogeneous federated fine-tuning using data-informed LLM sub-networks. As the first model-heterogeneous FL method to tailor sub-network architectures to local client data, Optimal Hydra achieves up to a 42.5% improvement over the best performing baseline in challenging model heterogeneous conditions and achieves reductions in computational and memory resource utilization up to 32.0% and 29.3%, respectively.
-
We demonstrate that assumptions from the pre-training about evenly distributing parameters can be relaxed in the fine-tuning regime due to the strong initial representations provided by the pre-trained model.
-
Based on representation dynamics and prior work suggesting that attention heads may be linked to specific tasks within layer feature spaces, we combine common layer selection to create Hydra-Nets, data-informed sub-networks that are better able to capture distribution specific features.
HeteroFL (Diao et al., 2020), widely regarded as the first example of model heterogeneous FL in the literature, creates static sub-models that train model parameters unequally. FedDrop (Wen et al., 2022) randomly drops a fraction of neurons in each layer, which can lead to inconsistent updates and convergence instability, particularly when data are not independently and identically distributed (i.i.d.). FedRolex (Alam et al., 2022) and FedBRB (Liao et al., 2025) improve upon these methods by iterating through model parameters so they are all trained evenly, yet these approaches fail to consider the quality of the sub-models and how differences in local data distributions can affect the suitability of the selected sub-network from round to round. These approaches are designed for pre-training, use relatively small models and focus primarily on computer vision tasks. Due to the learning differences that exist between federated pre-training and fine-tuning (Nguyen et al., 2022; Legate et al., 2023), we cannot assume their suitability for large model fine-tuning. Additionally, pervious model heterogeneous FL experiments have used convolutional neural networks (CNNs), none of them have been adapted for the transformer architecture, ubiquitous in modern machine learning.
The opacity of an LLMs internal mechanisms makes improving the efficiency of supervised fine-tuning (SFT) methods challenging. Previous attention head focused interpretability studies suggest that they exhibit a high degree of task specificity (Zhao et al., 2024; Yin et al., 2024) and redundancy (Michel et al., 2019; Diao et al., 2020) during the SFT process. Zhao et al. (2024) observe rapid task adaptation of attention heads during SFT, they also show task dependence by targeting specific heads, which consistently provides better performance. LoFiT (Yin et al., 2024) trains small localized adapters to fine tune attention heads. The authors find that identifying and targeting task heads most important for a task is more effective than standard fine-tuning, random head selection or targeting specific layers identified by probing. Michel et al. (2019) find that while many heads are task dependent, some are universally important regardless of task.
3 Optimal Hydra
Optimal Hydra adapts model heterogeneous FL for transformer models using heterogeneous client sub-networks called Hydra-Nets, clients train their Hydra-Nets locally and send updates back to the server for aggregation. While aggregating updates from heterogeneous local sub-networks into a single global model has presented a significant challenge for model heterogeneous FL, our approach overcomes this difficulty through direct index-mapping. During the aggregation phase, local updates are mapped back to their original coordinates in the global transformer architecture and parameter averaging is scaled by the total number of data samples residing in clients contributing to the update of a given parameter instead of the typical FL approach of scaling updates according to the number of data samples residing in all clients participating in the federated round (McMahan et al., 2017). This approach lets the global model accumulate specialized, data-informed gradients from specific heads without the gradient interference present from full parameter federated averaging.
3.1 Problem Formation
In FL, distributed optimization occurs over clients where each client possesses data containing samples drawn from distribution . We define the total number of samples across all clients as . The data at each node may be drawn from different distributions and/or may be unbalanced with some clients possessing more training samples than others. The typical objective function for federated optimization is given by Eq. 1 (McMahan et al., 2017) where are the model weights and is the objective function.
We undertake federated fine-tuning of a server-side LLM by a set of resource heterogeneous client nodes. Federated clients typically possess relatively small datasets and might not require an LLMs full capability for performance on unrelated domains. We define as an sd-dimensional set of Hydra-Net parameters for client where and modify Eq. 1 as follows.
The relationship between Hydra-Nets for two clients and where is that they share at least the set of globally common layers, and can share all, none or some of the individually selected heads in the remaining layers.
Hydra-Net selection applies to multi-head attention, decoder only, transformer architecture with a set of heads, H and layers, L. In what follows, we will use to indicate the set of heads in layer , belonging to client , the absence of a superscript denotes the server model. Multi-head a ttention involves the concatenation of multiple self-attention blocks computed using query, key and value matrices , and for each head (Vaswani et al., 2017).
3.2 Hydra-Net Selection
Model heterogeneity creates particular challenges for model aggregation in FL and these systems are particularly sensitive to client drift (Karimireddy et al., 2020) because of their un-equal parameter training
(Alam et al., 2022). One of our key contributions is the use of data-informed sub-networks to stabilize aggregation and improve training outcomes. To this end, we combine a number of previous insights to optimize our Hydra-Net selection. Attention heads have been shown to exhibit a high degree of task specificity (Zhao et al., 2024; Yin et al., 2024) and certain attention heads exhibit universal importance across domains Michel et al. (2019). Because these critical heads concentrate within key functional layers that drive core feature transformations (Voita et al., 2019) we establish a two stage Hydra-Net selection strategy: common layer selection and individual head selection. As shown in Fig. 1, clients first work collaboratively to select a small number of layers from which no attention heads are dropped. They subsequently select attention heads with high sensitivity to their own local data distributions, which they keep from the remaining layers while dropping the rest. In what follows, we present a detailed discussion of the procedures for common and individual head selection.
3.2.1 Common Layer Selection
Algorithm 1 SelectCommonLayers
Require: Client set , local data , pre-trained params
1: for all do 2: 3: end for 4: for to do 5: for all do 6: 7: 8: end for 9: 10: end for 11: 12: 13: 14: return
When developing sub-network selection strategies, it is tempting to consider individual client properties in isolation; however, this approach over simplifies the problem and a lack of consensus between client sub-networks can inhibit global model convergence and cause serious performance degradation (Babakniya et al., 2023b; Alam et al., 2022). To prevent this from occurring in Hydra-Nets, all clients retain a common subset of parameters. Instead of attempting to negotiate consensus on individual attention heads which risks over-specializing or missing critical head interactions, we select common parameters by layer instead of opting for fine grained head-selection. He et al. (2024) use a metric based on cosine similarity to score the relative importance of transformer layers, where layers with high similarity between inputs and outputs are deemed redundant. This provides a computationally efficient proxy to identify layers that drive critical representation shifts. We evaluate layer redundancy locally at each client using activation similarity statistics of each transformer block (Alg. 1, lns. 5–8), and apply a mixture model (Dempster et al., 1977) (Alg. 1, ln. 12) to separate them into three distinct categories.
-
low redundancy i.e. cosine similarity near zero
-
medium redundancy i.e. cosine similarity
-
high redundancy i.e. cosine similarity > 0.9
Very few layers (empirically, ) fall into the low and medium redundancy categories, so we select all of these layers and for simplicity, and retain all of their attention heads. The remaining layers will be used for personalized attention head selection via Algo. 2. These two disjoint subsets are the end goal of Algo. 1 where they are defined as and , respectively. Common layers serve two purposes: preserve the functionality of the most important layers, and provide a shared structural backbone between all clients to defend against client drift.
3.2.2 Individual Head Selection
Algorithm 2 SelectIndividualHeads
Require: , , (from Alg. 1), , ,
1: Initialize
2: for do
3:
4: Solve for and :
5:
6: s.t. ,
7: ,
8: ,
9: for all do
10:
11: end for
12: end for return
Following a consensus on common layers, we must determine how to personalize the selection of attention heads within the remaining layers , with respect to each client's local data. Common methods for determining parameter significance in neural networks include magnitude-based scoring of individual weights (Frankle & Carbin, 2018), gradient-based importance measures using gradient magnitude as an indicator of a parameter's influence on model output (Wang et al., 2023; Panos et al., 2025), and higher-precision methods that use second-order derivatives to examine the curvature of the loss landscape (LeCun et al., 1989). We select gradient-based scoring because it provides the most information about the importance of the attention head for a specific client's final representations, without the computational overhead of second-order methods (Agarwal et al., 2017). Specifically, we adopt the scoring metric of Panos et al. (2025) who fine-tune Vision-Language Models (VLM) on domain specific datasets by targeting the most informative attention heads for localized parameter updates. To identify these attention heads, they extract the gradients of the loss function with respect to parameters , and , we denote these as , and , respectively. They then define an importance score for each head, as shown in Eq. 11.
During the course of our experiments, we discover that the term dominates (see Appendix) so we simplify Eq. 11, as shown in Eq. 4 and adopt this simplified score as our head scoring metric where we denote the score for head of layer for client as
Previous work has demonstrated that model performance suffers when parameters are not trained evenly (Alam et al., 2022; Liao et al., 2025; Babakniya et al., 2023a). This constraint rules out the naive solution in which each client simply retains their top-k scoring heads without considering the choices of the others. In what follows, we formalize the constraints for attention head selection in one layer, , across all clients, , for the selection of attention heads out of the total set of attention heads, in layer .
Let
Let
Let
(5)
Eq. 5 creates hard bounds, enforcing a strictly even distribution of local parameters between clients, a constraint widely accepted as necessary based on previous work (Alam et al., 2022; Liao et al., 2025); however, these methods were developed for pre-training and federated fine-tuning behaviour can differ considerably (Nguyen et al., 2022; Legate et al., 2023). We hypothesize that pre-trained model weights, particularly those of large foundation models with strong initial representations, may show more tolerance when it comes to the necessity of even parameter training between clients, so we relax these hard bounds with slack variables and where and and use them to define a more flexible objective function in Eq. 6.
Eq. 6 optimizes head assignments by taking into account per-client head scores defined in Eq. 4 and enforces balanced assignments according to hyperparameter which governs how strictly balanced parameter training should be enforced (Ins. 4-8 of Algo. 2). The result of Algo. 2 is Q, a data structure that contains attention head assignments for each client, , for each layer . These assignments provide the recipe to create each client's unique, data-informed Hydra-Net.
4 Experiments
While Optimal Hydra is feasible for any number of attention heads dropped, we study model heterogeneity by focusing on four discreet sizes; all attention heads kept, or full (F), three quarters of attention heads kept (3Q), half of attention heads kept (H), one quarter of attention heads kept (Q). Heterogeneous configurations are indicated by F, 3Q, H, Q, followed by the number of clients assigned that model size in brackets.
Datasets We consider three datasets, Natural Instructions (NI) (nat, 2022), Alpaca (Taori et al., 2023) and Dolly-15K (Conover et al., 2023). Dolly-15K samples are distributed between clients using a Dirichlet distribution with . The creative writing task of Dolly-15K is not included in any of the local client data distributions and is instead used for global evaluation. The Alpaca dataset does not include pre-determined task categories, so we define six categories, summarization, reasoning, classification, mathematics, QA and other, and assign each sample a classification by searching for keywords in the input. As with Dolly-15K, samples are distributed between clients using a Dirichlet distribution with . The “other” task is selected for global evaluation. For NI, which has 857 unique tasks, 119 test tasks are held-out and used for global evaluation, while each of the remaining 738 tasks is uniquely assigned to one client. This isolated task distribution makes the NI dataset particularly challenging.
Training Details We use the DataJuicer-1.3 model, a Llama-1.3B model pre-trained on an open source corpus of data (Chen et al., 2024) and the Rouge-L (Lin, 2004) metric to evaluate fine-tuned model performance, reported scores are the mean of four seeds. Each experiment has 20 clients and all of them participate fully in

NI f(5)3q(5)h(5)q(5)
NI 3q(6)h(7)q(7)
NI 3q(2)h(2)q(16)
NI h(10)q(10)
NI h(5)q(15)

Dolly f(5)3q(5)h(5)q(5)
Dolly 3q(6)h(7)q(7)
Dolly 3q(2)h(2)q(16)
Dolly h(10)q(10)
Dolly h(5)q(15)

Figure 2: Each row consists of results for one dataset (1. Alpaca 2. Natural Instructions 3. Dolly 15K) and each column corresponds to one model heterogeneous FL configuration (1. F(5)3Q(5)H(5)Q(5) 2. 3Q(6)H(7)Q(7) 3. 3Q(2)H(2)Q(16) 4. H(10)Q(10) 5. H(5)Q(15)). Each sub-figure contains the mean Rouge-L ± std. dev. of four seeds for Optimal Hydra (blue), and our transformer adapted HeteroFL (orange) and FedRolex (green) baselines. The black dotted line indicates the FedAvg baseline whose values are reported in Tab.2. Optimal Hydra performs better than the baselines in all cases, it does particularly well with the very data heterogeneous NI dataset and the very resource constrained 3Q(2)H(2)Q(16) model heterogeneous configuration.
each round of training. Since and some distributions may be more amenable than others to optimal sub-net selection, client-side data distributions are important variables to control. To remove any ambiguity that may result from local data variation, we manually set a seed for each experiment to ensure that each client's local data remains the same for each set of experiments done on each model heterogeneity configuration. Additional training details and hyper-parameter settings are provided in the Appendix.
Baselines Since there are no pre-existing model heterogeneous FL transformer architectures in the literature, we make appropriate transformer based adaptations of HeteroFL and FedRolex to compare against Optimal Hydra. We additionally evaluate Optimal Hydra against the zero-shot performance of the pre-trained model and full federated training using FedAvg (McMahan et al., 2017).
Adapted HeteroFL and FedRolex: HeteroFL (Diao et al., 2020) trains static sub-networks with parameters distributed un-equally between clients. Since Optimal Hydra is focused on attention head selection, the adapted HeteroFL baseline retains the first heads in each layer. FedRolex (Alam et al., 2022) rotates consecutive sub-network parameters for clients after each round of training. To adapt FedRolex we select consecutive attention heads starting at a random head index in each layer. Continuity is achieved by rolling indices so that, following head index N, the next consecutive index is 0. The initial head index for each layer is incremented by 1 after each round, and client sub-networks are updated accordingly.
Table 1: Memory and compute requirements for the different resource allocation configurations we study. We provide both the absolute value and a percentage improvement over full FedAvg fine-tuning. Configurations are ordered from most to least resource intensive.
| CONFIG | COMP. (GFLOPS) | % IMPR. W.R.T. FULL | MEM. (GB) | % IMPR. W.R.T. FULL |
|---|---|---|---|---|
| F(20) | 56.6 | - | 61.9 | - |
| 3Q(20) | 50.6 | 10.7 | 55.8 | 9.7 |
| F(5)3Q(5)H(5)Q(5) | 47.6 | 16.0 | 52.8 | 14.6 |
| H(20) | 44.5 | 21.3 | 49.8 | 19.5 |
| 3Q(6)H(7)Q(7) | 44.2 | 21.9 | 49.5 | 20.0 |
| H(10)Q(10) | 41.5 | 26.7 | 46.8 | 24.4 |
| 3Q(2)H(2)Q(16) | 40.3 | 28.8 | 45.6 | 26.4 |
| H(5)Q(15) | 40.0 | 29.3 | 45.3 | 26.8 |
| Q(20) | 38.5 | 32.0 | 43.7 | 29.3 |
Table 2: Rouge-L (%) ± the std. dev. for four seeds, is reported for The full model zero-shot and FedAvg baselines as well as the setting in which all clients have homogeneous, but limited resource capabilities.
| ALPACA | NATURAL INSTRUCTIONS | DOLLY | |||||||
|---|---|---|---|---|---|---|---|---|---|
| HYDRA | HETEROFL | FEDROLEX | HYDRA | HETEROFL | FEDROLEX | HYDRA | HETEROFL | FEDROLEX | |
| F(20) ZS | 17.157 | 5.698 | 26.694 | ||||||
| F(20) FEDAVG | 31.668 (±.002) | 26.915 (±.002) | 32.465 (±.001) | ||||||
| 3Q(20) | 31.267(±.001) | 26.183(±.002) | 30.186(±.001) | 25.593(±.005) | 22.991(±.005) | 25.630(±.004) | 34.295(±.005) | 29.535(±.002) | 34.714(±.003) |
| H(20) | 30.621(±.005) | 24.077(±.003) | 29.258(±.005) | 22.738(±.010) | 17.821(±.012) | 22.157(±.004) | 35.489(±.002) | 31.516(±.001) | 35.431(±.002) |
| Q(20) | 25.232(±.008) | 8.264(±.080) | 15.224(±.129) | 7.990(±.006) | 8.077(±.002) | 7.609(±.004) | 29.104(±.007) | 28.881(±.002) | 20.552(±.027) |
Improved Resource Utilization: Tab. 1 provides memory and compute comparisons for the resource allocation configurations in each of our experiments. These values are also expressed as the percentage improvement each configuration provides over the full FedAvg baseline. In the most extreme case where each client selects only of the attention heads, we achieve savings of for computation and for memory. Values provided in Tab. 1 are calculated using a sequence length of 2048; however, since computational requirements depend heavily on sequence length, we note that an increase in sequence length to achieves savings in computational resources. This computational sequence length dependence theoretically makes Optimal Hydra an attractive prospect for FL with long context LLMs.
Results: The results in Tab. 2 consider a homogeneous resource setting in which all clients retain the same number of attention heads, but may retain different subsets of heads. In this scenario, clients have equal resource capabilities, although these budgets may still be substantially smaller than those required for full-model fine-tuning. We also report the zero-shot performance of the pre-trained model and the performance of full-model FedAvg.
In this setting, the relative performance of the methods is mixed. Optimal Hydra achieves the best score in the majority of configurations and is consistently the best-performing method or competitive with the strongest baseline. The adapted HeteroFL and FedRolex baselines exhibit less consistency; HeteroFL performs substantially worse than the other methods for H(20) on Alpaca, and FedRolex exhibits a similar sub-standard performance for Q(20) on Dolly-15K. These results suggest that, when all clients have the same resource budget, the benefit of data-informed head selection is present but relatively modest, and the choice of which heads are retained becomes increasingly important as the available model capacity decreases.
Fig. 2 considers a more challenging setting in which clients have substantially different resource constraints. We assign different fractions of clients different model sizes, with particular emphasis on configurations where most clients are under-resourced. Unlike the homogeneous-resource setting, Optimal Hydra consistently outperforms both baselines across all heterogeneous resource configurations. The advantage is most pronounced for the NI dataset, which has the most heterogeneous task distribution and supports our hypothesis that sub-network selection should account for both the resource constraints and client data distributions. Optimal Hydra also performs particularly well in the aforementioned low-resource setting where it achieves a 42.5% improvement over FedRolex, the next highest scoring baseline, on the 3Q(2)H(2)Q(16) configuration for the NI dataset.
Finally, model heterogeneity does not necessarily result in a performance degradation relative to full-model FedAvg. We observe that Optimal Hydra and the adapted baselines sometimes outperform the full-model FedAvg baseline, one possible explanation is that removing attention heads acts as a form of regularization during fine-tuning. This effect is most pronounced on Dolly-15K where the pre-trained model already provides strong initial representations.
Equal Parameter Training in the Fine-Tuning Setting: Previous work in the pre-training setting has motivated the importance of evenly training model parameters (Alam et al., 2022; Liao et al., 2025); however, application of this principle to fine-tuning has not been closely examined, despite indications of behavioural differences between these two regimes (Legate et al., 2023; Nguyen et al., 2022). The objective in Eq. 6 introduces an additional hyperparameter, , which controls how strictly equal parameter training is enforced. When , the balance penalty vanishes and head assignments are determined solely by client-specific importance scores. As increases, the objective increasingly favors equal head distribution across clients, effectively recovers the hard-bounded objective in Eq. 5, enforcing an even distribution of heads between clients for each layer.
Dolly-15K has the lowest attention head score diversity between clients, with clients selecting similar subsets of heads in each layer. The best Rouge-L scores were often achieved when or , indicating that the strict requirement for equal parameter training established in federated pre-training may be greatly relaxed during fine-tuning. NI displayed the greatest attention head score diversity, with clients naturally gravitating towards different attention heads. NI generally achieved better Rouge-L scores with larger values of , sometimes as high as 500 or 1000, indicating a greater need for enforced attention head diversity.
To account for the difference in optimal values, we turn to the zero-shot performance strength of the pretrained representations. Dolly-15K had zero-shot performance of 26.694, significantly higher than the 5.698 achieved on NI. The strong initial representations available to Dolly-15K make strictly even parameter fine-tuning unnecessary. The weaker initial representations available for NI may make greater participation of all parameters more important, resulting in behavior more similar to the equal parameter training observed in the pre-training regime.
5 Conclusion
We introduced Optimal Hydra, a model-heterogeneous federated learning framework for fine-tuning large language models under heterogeneous client resource constraints. Optimal Hydra creates data-informed Hydra-Nets that permit resource limited clients to adapt to their available resources, by retaining model parameters best suited to their own local data. Across three datasets and multiple resource configurations, Optimal Hydra consistently outperformed adapted model-heterogeneous FL baselines in the most resource-heterogeneous settings while reducing local computational and memory requirements by up to 32.0% and 29.3%, respectively. Our results also challenge the assumption that model parameters must be trained equally across clients. In the fine-tuning setting, the necessary degree of parameter balancing depends on the strength of the pretrained representations and the heterogeneity of the local data distributions.
References
Super-naturalinstructions: Generalization via declarative instructions on 1600+ nlp tasks. In Yoav Goldberg, Zornitsa Kozareva, and Yue Zhang (eds.), Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, EMNLP 2022, Proceedings of the 2022 Conference on Empirical Methods in
Natural Language Processing, EMNLP 2022, pp. 5085–5109. Association for Computational Linguistics (ACL), 2022. doi: 10.18653/v1/2022.emnlp-main.340.
Naman Agarwal, Brian Bullins, and Elad Hazan. Second-order stochastic optimization for machine learning in linear time. Journal of Machine Learning Research, 18(116):1–40, 2017.
Samiul Alam, Luyang Liu, Ming Yan, and Mi Zhang. Fedrolex: Model-heterogeneous federated learning with rolling sub-model extraction. Advances in neural information processing systems, 35:29677–29690, 2022.
Sara Babakniya, Ahmed Roushdy Elkordy, Yahya H Ezzeldin, Qingfeng Liu, Kee-Bong Song, MOSTAFA EL-Khamy, and Salman Avestimehr. Slora: Federated parameter efficient fine-tuning of language models. In International Workshop on Federated Learning in the Age of Foundation Models in Conjunction with NeurIPS 2023, 2023a.
Sara Babakniya, Souvik Kundu, Souvik Prakash, Yue Yue, Ram Rajagopal, Massoud Pedram, and Murali Annavaram. Revisiting sparsity hunting in federated learning: Client drift and incoherent masks. In International Conference on Learning Representations (ICLR), 2023b.
Jiamu Bai, Daoyuan Chen, Bingchen Qian, Liuyi Yao, and Yaliang Li. Federated fine-tuning of large language models under heterogeneous tasks and client resources. Advances in Neural Information Processing Systems, 37:14457–14483, 2024.
Rishi Bommasani, Drew A Hudson, Ehsan Adeli, Russ Altman, Simran Arora, Sydney von Arx, Michael S Bernstein, Jeannette Bohg, Antoine Bosselut, Emma Brunskill, et al. On the opportunities and risks of foundation models. arXiv preprint arXiv:2108.07258, 2021.
Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020.
Daoyuan Chen, Yilun Huang, Zhijian Ma, Hesen Chen, Xuchen Pan, Ce Ge, Dawei Gao, Yuexiang Xie, Zhaoyang Liu, Jinyang Gao, et al. Data-juicer: A one-stop data processing system for large language models. In Companion of the 2024 International Conference on Management of Data, pp. 120–134, 2024.
Guanzheng Chen, Fangyu Liu, Zaiqiao Meng, and Shangsong Liang. Revisiting parameter-efficient tuning: Are we really there yet? In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pp. 2612–2626, 2022.
Mike Conover, Matt Hayes, Ankit Mathur, Jianwei Xie, Jun Wan, Sam Shah, Ali Ghodsi, Patrick Wendell, Matei Zaharia, and Reynold Xin. Free dolly: Introducing the world's first truly open instruction-tuned llm, 2023. URL https://www.databricks.com/blog/2023/04/12/dolly-first-open-commercially-viable-instruction-tuned-llm.
Arthur P Dempster, Nan M Laird, and Donald B Rubin. Maximum likelihood from incomplete data via the em algorithm. Journal of the Royal Statistical Society: Series B (Methodological), 39(1):1–22, 1977.
Enmao Diao, Jie Ding, and Vahid Tarokh. Heterofl: Computation and communication efficient federated learning for heterogeneous clients. In International Conference on Learning Representations, 2020.
Jonathan Frankle and Michael Carbin. The lottery ticket hypothesis: Finding sparse, trainable neural networks. In International Conference on Learning Representations, 2018.
Shwai He, Guoheng Sun, Zheyu Shen, and Ang Li. What matters in transformers? not all attention is needed. CoRR, abs/2406.15786, 2024. URL https://doi.org/10.48550/arXiv.2406.15786.
Samuel Horvath, Stefanos Laskaridis, Mario Almeida, Ilias Leontiadis, Stylianos Venieris, and Nicholas Lane. Fjord: Fair and accurate federated learning under heterogeneous targets with ordered dropout. Advances in Neural Information Processing Systems, 34:12876–12889, 2021.
Yihan Hu, Jiazhi Yang, Li Chen, Keyu Li, Chonghao Sima, Xizhou Zhu, Yaren Chai, Senyao Du, Tianwei Lin, Wenhai Wang, et al. Planning-oriented autonomous driving. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 17853–17862, 2023.
Peter Kairouz, H Brendan McMahan, Brendan Avent, Aurélien Bellet, Mehdi Bennis, Arjun Nitin Bhagoji, Kallista Bonawitz, Zachary Charles, Graham Cormode, Rachel Cummings, et al. Advances and open problems in federated learning. Foundations and trends® in machine learning, 14(1–2):1–210, 2021.
Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei. Scaling laws for neural language models. arXiv preprint arXiv:2001.08361, 2020.
Sai Praneeth Karimireddy, Satyen Kale, Mehryar Mohri, Sashank Reddi, Sebastian Stich, and Ananda Theertha Suresh. Scaffold: Stochastic controlled averaging for federated learning. In International conference on machine learning, pp. 5132–5143. PMLR, 2020.
Yann LeCun, John Denker, and Sara Solla. Optimal brain damage. In D. Touretzky (ed.), Advances in Neural Information Processing Systems, volume 2. Morgan-Kaufmann, 1989. URL https://proceedings.neurips.cc/paper_files/paper/1989/file/6c9882bbac1c7093bd25041881277658-Paper.pdf.
Gwen Legate, Nicolas Bernier, Lucas Page-Caccia, Edouard Oyallon, and Eugene Belilovsky. Guiding the last layer in federated learning with pre-trained models. In A. Oh, T. Naumann, A. Globerson, K. Saenko, M. Hardt, and S. Levine (eds.), Advances in Neural Information Processing Systems, volume 36, pp. 69832–69848. Curran Associates, Inc., 2023. URL https://proceedings.neurips.cc/paper_files/paper/2023/file/dcc0ac74ac8b95dc1939804acce0317d-Paper-Conference.pdf.
Tianchi Liao, Ziyue Xu, Qing Hu, Hong-Ning Dai, Huaiwei Huang, Zibin Zheng, and Chuan Chen. Fedbrb: A solution to the small-to-large scenario in device-heterogeneity federated learning. IEEE Transactions on Mobile Computing, 2025. doi: 10.1109/TMC.2025.3610985.
Chin-Yew Lin. ROUGE: A package for automatic evaluation of summaries. In Text Summarization Branches Out, pp. 74–81, Barcelona, Spain, July 2004. Association for Computational Linguistics. URL https://aclanthology.org/W04-1013.
Brendan McMahan, Eider Moore, Daniel Ramage, Seth Hampson, and Blaise Aguera y Arcas. Communication-efficient learning of deep networks from decentralized data. In Artificial intelligence and statistics, pp. 1273–1282. PMLR, 2017.
Paul Michel, Omer Levy, and Graham Neubig. Are sixteen heads really better than one? Advances in neural information processing systems, 32, 2019.
John Nguyen, Jianyu Wang, Kshitiz Malik, Maziar Sanjabi, and Michael Rabbat. Where to begin? on the impact of pre-training and initialization in federated learning. In The Eleventh International Conference on Learning Representations, 2022.
Aristeidis Panos, Rahaf Aljundi, Daniel Olmeda Reino, and Richard E. Turner. Efficient few-shot continual learning in vision-language models. Transactions on Machine Learning Research, 2025. ISSN 2835-8856. URL https://openreview.net/forum?id=sQ1w92WW0V.
Lorenzo Sani, Alex Iacob, Zeyu Cao, Bill Marino, Yan Gao, Tomas Paulik, Wanru Zhao, William F Shen, Preslav Aleksandrov, Xinchi Qiu, et al. The future of large language model pre-training is federated. In International Workshop on Federated Foundation Models in Conjunction with NeurIPS 2024, 2024.
Noam Shazeer. Glu variants improve transformer. arXiv preprint arXiv:2002.05202, 2020.
Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos Guestrin, Percy Liang, and Tatsunori B. Hashimoto. Stanford alpaca: An instruction-following llama model. https://github.com/tatsu-lab/stanford_alpaca, 2023.
Arun James Thirunavukarasu, Darren Shu Jeng Ting, Kabilan Elangovan, Laura Gutierrez, Tien – En Tan, and Daniel Shu Wei Ting. Large language models in medicine. Nature Medicine, 29(8):1930–1940, 2023. doi: 10.1038/s41591-023-02448-8.
Chunlin Tian, Zhan Shi, Zhijiang Guo, Li Li, and Cheng-Zhong Xu. Hydralora: An asymmetric lora architecture for efficient fine-tuning. Advances in Neural Information Processing Systems, 37:9565–9584, 2024.
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
Elena Voita, David Talbot, Andreas Federmann, and Rico Sennrich. Analyzing multi-head self-attention: What does it learn, how can it be pruned? In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics (ACL), pp. 5797–5808, 2019.
Lean Wang, Lei Li, Damai Dai, Deli Chen, Hao Zhou, Fandong Meng, Jie Zhou, and Xu Sun. Label words are anchors: An information flow perspective for understanding in-context learning. In The 2023 Conference on Empirical Methods in Natural Language Processing, 2023.
Dingzhu Wen, Ki-Jun Jeon, and Kaibin Huang. Federated dropout – a simple approach for enabling federated learning on resource constrained devices. IEEE Wireless Communications Letters, 11:1–1, 05 2022. doi:10.1109/LWC.2022.3149783.
Feijie Wu, Zitao Li, Yaliang Li, Bolin Ding, and Jing Gao. Fedbiot: Llm local fine-tuning in federated learning without full model. In Proceedings of the 30th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, pp. 3345–3355, 2024.
Yifan Yao, Jinhao Duan, Kaidi Xu, Yuanfang Cai, Zhibo Sun, and Yue Zhang. A survey on large language model (llm) security and privacy: The good, the bad, and the ugly. High-Confidence Computing, 4(2):100211, 2024.
Fangcong Yin, Xi Ye, and Greg Durrett. Lofit: localized fine-tuning on llm representations. In Proceedings of the 38th International Conference on Neural Information Processing Systems, pp. 9474–9506, 2024.
Yang Zhao, Li Du, Xiao Ding, Kai Xiong, Ting Liu, and Bing Qin. Supervised fine-tuning achieve rapid task adaption via alternating attention head activation patterns. arXiv preprint arXiv:2409.15820, 2024.
A Memory and Compute Calculations
This section develops the rationale behind the values presented in the Improved Resource Utilization part of the Experiments section in the main body of the paper. Table 3 summarizes the variables and values used in the calculations in sections A.1 and A.2:
A.1 Compute
Here we adopt the convention that matrix multiplication operations of the form require 2MKN flops. We define a scaling factor to account for the reduction in attention heads .
Attention Block Attention in each transformer block consists of weights , , and , each with dimension .
• Linear Proj: Accounting for , , and with scaling for head reduction, we get:
• Score: multiplies with the KV cache for each head:
• Value Aggregation: Similar ops to score:
Attention Total (per layer):
| Name | Var. | DataJuicer-1.3B |
|---|---|---|
| No. trf blocks 1 | ||
| Hidden dim. | ||
| Tot. No. heads | ||
| Reduced No. heads | variable | |
| Head dim. | ||
| FF dim. | ||
| Vocab. size | ||
| Seq. Len. |
Table 3: Provides a summary of variables and their values for the DataJuicer-1.3B model architectures
Feed Forward Block Llama used SwiGLU Shazeer (2020) which has weights , , both with dimension and with dimension . Operations for each set of weights cost flops.
FF Total (per layer):
Output map final hidden state back to the vocabulary. This is a matrix multiplication .
Output Total (one time contribution):
Combining the contributions of these operations over layers, we get the following formula for the number of flops required for one forward pass.
Since many of these values are constant for a given model architecture, we get the following expressions as a function of and sequence length, for DataJuicer-1.3B.
DataJuicer-1.3B
A.2 Memory
For memory calculations we assume 16-bit precision giving us 2 bytes per parameter. Memory requirements can be divided into two categories: static memory resulting from model weights and dynamic memory resulting from the KV-cache.
Static Memory Using the previously provided weight dimensions and scaling factor, we can compute static memory requirements as follows
- Attention: Weights , , and account for: bytes per layer
- FF: Weights , , and account for: bytes per layer
- Output/Embedding: accounts for: bytes
Total Static Memory:
Dynamic Memory The KV-cache contribution is bytes per layer.
Total Dynamic Memory:
Combining the contributions of static and dynamic memory, we get the following formula for the number of bytes required for one forward pass.
Again, many of these values are constant for a given model architecture, so we get the following expressions as a function of and sequence length, for DataJuicer-1.3B.
DataJuicer-1.3B
B Experimental Settings
Experiments were run across multiple compute clusters using a variety of GPUs including L4OS (48GB), RTX8000 (48GB), A100L (80GB), A100 (40GB), V100 (32GB), A6000 (48GB), H100 (80GB). Each experiment was executed using 2 or 4 GPUs, depending on the compute availability.
C Hyper-parameter Searches
Hyperparameter tuning was conducted using a grid search over the relevant hyper-parameters. Federated learning has numerous tunable parameters including server and client learning rates, and , respectively, the number of gradient steps (i.e. iterations) taken prior to client aggregation, , and the number of federated rounds, . Optimal Hydra additionally requires tuning of hyper-parameter that governs the degree to which equal parameter training is enforced.
We first specify hyper-parameters that are common for all datasets and heterogeneity configurations:
and are tuned individually per method, dataset and heterogeneity combination, grid search ranges were specified by dataset as follows:
-
Alpaca: ,
-
Natural Instructions: ,
-
Dolly 15K: ,
Tab. 4 specifies the final hyper-parameter combinations used for each result,
| Dataset | Config | ||||
| Alpaca | 3Q(20) | 100 | |||
| H(20) | 10 | ||||
| Q(20) | 100 | ||||
| F(5)3Q(5)H(5)Q(5) | 25 | ||||
| H(10)Q(10) | 25 | ||||
| 3Q(6)H(7)Q(7) | 50 | ||||
| H(5)Q(15) | 25 | ||||
| 3Q(2)H(2)Q(16) | 100 | ||||
| Dolly 15K | 3Q(20) | 0 | |||
| H(20) | 100 | ||||
| Q(20) | 0 | ||||
| F(5)3Q(5)H(5)Q(5) | 25 | ||||
| H(10)Q(10) | 50 | ||||
| 3Q(6)H(7)Q(7) | 25 | ||||
| H(5)Q(15) | 1 | ||||
| 3Q(2)H(2)Q(16) | 5 | ||||
| NI | 3Q(20) | 500 | |||
| H(20) | 100 | ||||
| Q(20) | 5000 | ||||
| F(5)3Q(5)H(5)Q(5) | 100 | ||||
| H(10)Q(10) | 100 | ||||
| 3Q(6)H(7)Q(7) | 100 | ||||
| H(5)Q(15) | 50 | ||||
| 3Q(2)H(2)Q(16) | 500 |
Table 4: Provides selected hyper-parameters for Optimal Hydra each dataset, heterogeneity combination evaluated in the main body of the paper. OH stands for Optimal Hydra, HFL and Rolex for our modified HeteroFL and FedRolex baselines, respectively.
D Dominates Head Scoring
In the Individual Head Selection section of the main paper we reference an importance score utilized in the determination of attention head importance by Panos et al. (2025)) (Eq. 11)
We justified our simplification of the scoring function to Eq. 4 by claiming that in our experiments the term dominates, the following plots have been selected to demonstrate this claim.

Figure 3: For Client 1 at round 20 and transformer layer 1, we see head 7 is unimportant to both and and important to and showing the dominance of in the scoring mechanism proposed in Eq. 11

Layer 13
Layer 13
Layer 13
Figure 4: For Client 3 at round 5 and transformer layer 13, we see head 2 is important to both and and unimportant to and again that is dominant.
Figs. 3 and 4 show selected instances of scores for a particular client, layer and training round to illustrate the dominance of . Plots show scores for (orange), (green), (purple) and (blue) were generated for federated rounds , for each transformer block and each client. Results indicate that the score from Eq. 11 is largely dominated by .