Towards Optimal Adapter Placement for Efficient Transfer Learning

## Abstract

Abstract Parameter-efficient transfer learning (PETL) aims to adapt pre-trained models to new downstream tasks while minimizing the number of fine-tuned parameters.
Adapters, a popular approach in PETL, inject additional capacity into existing networks by incorporating low-rank projections, achieving performance comparable to full fine-tuning with significantly fewer parameters.
This paper investigates the relationship between the placement of an adapter and its performance. We observe that adapter location within a network significantly impacts its effectiveness, and that the optimal placement is task-dependent. To exploit this observation, we introduce an extended search space of adapter connections, including long-range and recurrent adapters. We demonstrate that even randomly selected adapter placements from this expanded space yield improved results, and that high-performing placements often correlate with high gradient rank. Our findings reveal that a small number of strategically placed adapters can match or exceed the performance of the common baseline of adding adapters in every block, opening a new avenue for research into optimal adapter placement strategies.

## 1 Introduction

Transfer learning is one of the key techniques in modern deep learning, frequently used to reduce the cost of training and to provide better generalization in the low-data regime (Zhai et al., ; Liu et al., ; Mustafa et al., ).
In transfer learning, pre-trained neural networks are fine-tuned to solve a new, often related, task. However, fine-tuning the entire model is costly in terms of compute, memory, and storage, especially considering the size of modern deep learning networks (Dehghani et al., ; Touvron et al., ; Chen et al., ; Chowdhery et al., ). This lead to the proliferation of parameter efficient transfer learning (PETL) methods (Pan et al., ; Edalati et al., ; Hu et al., ; Mercea et al., ; Pfeiffer et al., ; Hao et al., ; Jie & Deng, ), that aim to reduce the memory and storage cost by approximating the full fine-tuning solution using significantly less parameters.

One of the most popular approaches in PETL are *adapters* (Houlsby et al., ; Rebuffi et al., ) – small modules based on low-rank projections which are inserted into pre-trained models to facilitate transfer learning while minimizing parameter overhead.
While both the original and new parameters contribute to the output calculation, only the parameters of the adapters are updated during the optimization process. This results in a reduced memory footprint, making it practical to train large networks with limited resources.

In essence, adapters may be interpreted as a way to mimic the fine-tuning of a group of layers using smaller modules. Therefore they are often added *parallel to* or in-between existing layers. At the same time, existing work on transfer learning shows that layers in a pre-trained network have different importance during fine-tuning and that their parameters affect the performance in different amounts (Chatterji et al., ).
Despite this observation, however, adapters are typically added *uniformly* across the whole network, irrespective of these layer-specific differences. Consequently, we suspect such a practice to be sub-optimal and hypothesise that task specific adapter placement could further improve the fine-tuning performance and efficiency.

Motivated by the above, we investigate the effectiveness of adding adapters at different locations within a neural network. Our work highlights the importance of adapter placement and its influence on transfer performance. Our main contributions are:

- •
We verify that placing adapters in different layers leads to significant variations in test accuracy, with the effectiveness of each placement differing substantially. Furthermore, the distribution of the optimal adapter locations varies across tasks.
- •
We expand the search space for adapters beyond standard parallel and sequential placements by introducing long-range and recurrent adapters.
- •
When placing a single adapter, we observe that the recurrent adapter consistently performs best. The extended search space is also beneficial when adding multiple adapters, with even a small random search leading to improved results compared to the baselines.
- •
We investigate various metrics for identifying optimal adapter locations within the proposed search space and find that the rank of the gradient correlates most accurately with the final performance. Furthermore, a greedy strategy based on selecting adapters according to such rank not only outperforms alternative selection policies but also requires significantly less computation, paving the way for efficient exploration of optimal adapter placements.

## 2 Related Work

### 2.1 Parameter Efficient Transfer Learning

The goal of Parameter Efficient Transfer Learning is to adapt a pre-trained model to a downstream task while minimizing the number of trainable parameters (Han et al., ). A common approach in PETL are *adapters* – small trainable modules inserted into the pre-trained network (Rebuffi et al., ; Houlsby et al., ; Bapna et al., ), which have proven to be effective in various applications, including multi-task learning (Pfeiffer et al., , ; Stickland & Murray, ), knowledge injection (Wang et al., ) or continual learning (Lin et al., ; Yu et al., ). A related PETL approach is LoRA (Hu et al., ) and its numerous extensions (Karimi Mahabadi et al., ; Dettmers et al., ; Kopiczko et al., ; Liu et al., ; Hao et al., ; Zhang et al., ), which model the update of the parameters using linear low-rank projections, merging the new weights with the pre-trained ones at inference. Other alternatives include Prompt Tuning (Lester et al., ; Shi & Lipani, ) and Prefix Tuning (Li & Liang, ; Jia et al., ) that append a trainable vector of tokens to the layer input. Solutions based on Side-Tuning (Zhang et al., ) allow to bypass the gradient propagation through the backbone, accelerating the training (Mercea et al., ; Gupta et al., ; Wang et al., ; Munkhdalai et al., ). These various PETL methods can be applied together using algorithms designed to select their optimal configurations (Mao et al., ; Zhang et al., ; Zhao et al., ). In this work, instead of introducing another PETL approach, we focus on the adapters, examining how their performance is impacted by their placement.

### 2.2 Importance of Adapter’s Placement

A key design choice in PETL is determining where to introduce additional computational capacity to the model. For adapters, common placement strategies include the sequential and parallel approaches. Sequential placement inserts the adapters between consecutive layers (Houlsby et al., ; Mahabadi et al., ; Lauscher et al., ), while the parallel placement adds them using a separate residual connection within a layer (He et al., ; Zhu et al., ; Chen et al., ; Jie & Deng, ). Although adapters are usually inserted in every module of a transformer, multiple works find it sufficient to apply them only after the Feed Forward blocks (Luo et al., ; Bapna et al., ; Pfeiffer et al., ). Notably, Houlsby et al. () demonstrated that adapters in lower network layers can be removed without a significant performance drop.  Rücklé et al. () confirmed this observation, proposing an iterative approach that removes the adapters during the fine-tuning from selected layers. In the context of Mixture of Experts, higher layers were observed to require more LoRA adapters (Gao et al., ). At the same time, a study by Chen et al. () on parameter allocation policies in PETL concluded that uniform parameter distribution generally performs best on the GLUE benchmark. These findings suggest a non-trivial relationship between adapter placement and performance, motivating our investigation. While previous studies focused on adapting the layers locally, we extend the adapter architecture to include long-range and recurrent low-rank projections. Our goal is to understand how the location, by itself, impacts the adapter performance, and whether this influence can be predicted *a priori* to the training.

### 2.3 Rank-Based Metrics in Assessing Learning Capabilities

Measures based on the rank, especially estimates of effective dimensionality of the activations, have been studied in previous research to assess the learning capacity of models. For instance, in Reinforcement Learning, a decline in the feature rank of a value network can be associated with a decreased performance (Kumar et al., ). Similarly, Lyle et al. () suggest that a high feature rank is a necessary condition for learning progress. In transfer learning, a significant change in the rank can serve as an indicator for neuron growth or pruning within a layer during fine-tuning (Maile et al., ). Moreover, activation ranks tend to diminish with increasing network depth (Feng et al., ), which has been linked to a degraded performance of linear probe on out-of-distribution data (Masarczyk et al., ).
Those observations underscore the value of exploring rank-based metrics that estimate the importance of the placement of new computational capacity in the network.

## 3 Background

### 3.1 Adapters

An adapter, $A_{\phi}$, is a small network with parameters $\phi$ that is injected into a pre-trained model (Houlsby et al., ; Rebuffi et al., ). Adapters are often used in transfer-learning, where the parameters of the pre-trained backbone remain frozen, and only the adapters weights are updated during fine-tuning.

We focus on the most common adapter architecture, which consists of a low-rank projection followed by a non-linear transformation in the bottleneck dimension (He et al., ; Chen et al., ):

$$ $A_{\phi}(x)=\alpha\big{(}\sigma(LN(x)\mathbf{W_{down}})\mathbf{W_{up}}\big{)},$ (1) $$

where $\mathbf{W_{down}}\in{\mathbb{R}}^{d_{model}\times r}$, $\mathbf{W_{up}}\in{\mathbb{R}}^{r\times d_{model}}$, $d_{model}$ is the hidden dimension of the network, $\sigma$ represents the non-linear activation function, and the parameter $\alpha$ is a trainable scalar that adjusts the scale of the output of the adapter. The function $LN(\cdot)$ indicates an optional layer normalization performed on the inputs of the adapter. For all types of adapters used in this work, we include this Layer-Norm operation, as we observe that it increases the stability of the learning. The bottleneck dimension $r$ of the down projection is called the *rank* of an adapter, and usually satisfies $r\ll d_{model}$.

Consider a block of layers $F_{\theta}(x)$ of the pre-trained model (e.g. the Multi-Head Attention or the Feed Forward module of a transformer). An adapter can be placed in parallel to the computational flow of the network by applying:

$$ $x_{i+1}=x_{i}+F_{\theta}(x_{i})+A_{\phi}(x_{i}),$ (2) $$

where $x_{i}+F_{\theta}(x_{i})$ represents the standard residual connection of the model. Such an approach is known as the *parallel adapter*, and was reported to perform better than the alternatives based on sequential addition (He et al., ; Zhu et al., ; Jia et al., ). Adapters are predominately used together with transformer-based architectures where they are injected at every block.

### 3.2 Datasets and Models

We consider transfer tasks for both image and text classification problems. We use the ViT-B/16 model (Dosovitskiy et al., ) pre-trained on Imagenet-21K (Deng et al., ) for the former, and the RoBERTa-Base model for the later (Liu et al., ).
Following earlier research on the topic (He et al., ), we employ two text classification tasks from the GLUE benchmark (Wang et al., ): MNLI, and the considerably smaller SST2. When adapting vision transformers, we use the iNaturalist18 (Van Horn et al., ) and Places 365 (Zhou et al., ) datasets. Additionally, to assess few-shot transfer accuracy, we include three tasks from the VTAB-1K benchmark: Clevr-Count-1K, dSpr-Loc-1K and SVHN-1K (Zhai et al., ).
The VTAB-1K datasets consist of 1,000 training examples, chosen to represent tasks that introduce a distribution shift compared to ImageNet. See Table 2 in the Appendix for the summary of the datasets.

### 3.3 Motivation: Adapter Placement Matters

Figure: Figure 1: The test accuracy of a single parallel adapter for different placements. The dashed horizontal lines mark the performance of the full-fine-tuned model (pink), linear probe (black) and a setup with all 24 parallel adapters placed in every layer, both after the MHA and FFN module (cyan). The obtained results of the single adapters are affected both by the task and selected placement.
Refer to caption: extracted/5932641/figures/parallel_placement_blue.png

We begin our investigation by evaluating the transfer performance of a *single* parallel adapter at different locations. To this end, we consider a transformer encoder architecture, where the adapter may be added in two places in each layer – between the Multi-Head Attention (MHA) module and the Feed Forward (FFN) module. Given a model with $L$ layers, this results in $n=2L$ possible locations. Separately for each such location, we insert a single parallel adapter with layer norm (recall Equation 2), and fine-tune it on the transfer tasks from Section 3.2. As baselines, we incorporate the linear probe (LP), the Full-Fine Tuning (FT), and the standard adapter recipe with all 24 parallel adapters added simultaneously (PA).(^1^11See Appendix B for further details on the training setup.) We share the results in Figure 1.

We find that the performance of a single adapter, as measured by the test accuracy after fine-tuning, is greatly influenced by its placement. Furthermore, the best locations are task dependant, even when the same pre-trained model is used. For instance, for SVHN, placing adapters at earlier layers leads to best results, while for Clevr-Count the same strategy is the worst choice. This stark difference highlights the importance of tailoring the placements to each task. This motivates us to explore an extended search space for adapter placements, moving beyond common strategies to discover optimal configurations for each transfer task.

## 4 Extended Search Space for Adapters

Connecting non-consecutive layers, especially given the importance of adapter placement, offers a promising opportunity to leverage non-local information for enhanced transfer performance. To explore this, we conceptualize the network as a graph where nodes correspond to distinct hidden representations, and edges define adapters. We describe this graphical representation using a transformer architecture in the following section.

Figure: (a)
Refer to caption: extracted/5932641/figures/graph_diagram.png

### 4.1 Adapter Graph

Consider a transformer encoder with $L$ blocks. Each block computes two intermediate values that can be potentially altered by the adapter: the post-MHA hidden states, and the post-FFN hidden states. Including the input to the first block, we obtain a total of $n=2L+1$ hidden states.

The placement of an adapter can be represented as an edge $(i,j)\in E$ in the Graph $G(V,E)$, where the vertex set $|V|=n$ indexes the network hidden states. For block $l$, vertices $2l+1$ and $2l+2$ indicate the post-MHA and post-FNN hidden states, respectively.(^2^22Note that for any $l$, the point $2l+2$ is also the input to layer $l+1$.) The index zero corresponds to the input to the first block. Below, we discuss how different graph edges define different adapter behaviours, and visualize them in Figure 2:

Parallel Adapters are represented by edges $(i,i+1)$ and, following Equation 2, are defined using a separate residual connection: $x_{i+1}=x_{i}+F_{i+1}(x_{i})+A(x_{i})$.

Sequential Adapters correspond to edges $(i,i)$ and directly modify the hidden representations in place by applying $x_{i}=A(z_{i})+z_{i}$ where $z_{i}=x_{i-1}+F_{i}(x_{i-1})$.

While various variants of parallel and sequential adapters have been extensively studied in the literature (Houlsby et al., ; Jia et al., ), they cover only a small fraction of all possible connections in the graph interpretation. For a graph with $n$ nodes, this fraction is equal to $(2n-1)/n^{2}$. For instance, in the ViT-B encoder with $12$ layers more than $92\%$ of possible connectivity patterns remain unexplored. This poses a question whether other placements of the adapters, going beyond the diagonal and parallel edges, can further enhance the results. To investigate this, we define two new groups: the long-range adapters (being an extension of the parallel ones), and recurrent adapters:

Long-Range Adapters may skip multiple layers by extending the definition of parallel adapters to edges $(i,j)$ where $i<j$, resulting in hidden states given by $x_{j}=x_{j-1}+F_{j}(x_{j-1})+A(x_{i})$.

#### Recurrent Adapters

are represented by edges $(i,j)$ where $i>j$. They connect later layers with lower layers in the model, resulting in a cycle in the computational flow. We consider a single recurrent step and define the recurrent adapters as following:

$$ $\displaystyle z_{j}$ $\displaystyle=x_{j-1}+F_{j}(x_{j-1})$ (3) $\displaystyle z_{i}$ $\displaystyle=x_{i}+A(z_{j})$ (4) $\displaystyle x_{i+1}$ $\displaystyle=z_{i}+F_{i+1}(z_{i})$ (5) $$

In practice, we implement the above equation by doing two forward-passes though the network. In the first pass, we propagate the information along all the layers, as it would happen in a standard network without any adapters. Effectively, this allows us to simultaneously compute values $z_{j}$ from Equation 3 for all recurrent adapters. In the second pass, we feed the same input batch to the network and apply all non-recurrent adapters, as well as all the recurrent ones using Equations 4 and 5. Consequently, each block $F_{i+1}$ operates on the most recent hidden representation. When there are no recurrent edges, we only perform the second pass, recovering the behaviour of regular adapters.

Although recurrent adapters, independent of their numbers, require one extra forward pass during training, the gradients of the activations are calculated only for the second pass. Thus, assuming that the cost of the forward and backward passes is equal(^3^33This is a reasonable assumption as the backward-pass cost is dominated by the activation gradients and adapter gradients are much cheaper in most settings.), recurrent adapters increase the total training cost by at most 50%(^4^44Note that the first pass would finish short if later activations are not used by any adapters.).

Figure: Figure 3: The test accuracy obtained for the single-adapter placement for various tasks. The y-axis (rows) represents the input node index $i$, while the x-axis (columns) corresponds to the output node index $j$. The vertical lines in the color bar indicate the performance of full fine-tuning (full FT), linear probe (LP), and parallel adapters (PA). With a bright yellow line we mark the performance of the best single adapter. The plots are normalized to the minimum and maximum performance of a single adapter for the given task. The three best performing adapters are also marked by yellow blocks in the plot (see Appendix D for top accuracy for each adapter type). Note that due to high computational cost, we subsample the adjacency matrix of all possible connections.
Refer to caption: extracted/5932641/figures/heatmaps.png

## 5 Experiments

This section evaluates the benefits of the extended adapter search space. Mirroring the study in Section 3.3, we first examine the effects of adding a single adapter. We then explore the more practical scenario of incorporating multiple adapters simultaneously, seeking placement strategies that outperform the standard parallel configuration.

### 5.1 Single Adapters

We use the same experiment setup as the one from Section 3.3, but extend the search space of the adapter placement to the full connectivity matrix associated with the adapters graph from Section 4. Since evaluating the performance for all $n^{2}=625$ placements would be computationally expensive, we subsample the connectivity matrix with a stride of 3, i.e. we select all edges $(i,j)$ for which $i=3l,j=3k$ for $l,k~{}\in~{}\{0,\ldots,8\}$.
For each placement, we compute the mean test accuracy over 3 runs and present the results in Figure 3.

#### Effectiveness of Recurrent Adapters

Similar to our earlier experiment, we observe that final test performance varies greatly with the placement of the adapter. Although the sequential and parallel adapters (corresponding to the diagonal and upper diagonal entries in the matrices) usually perform reasonably well, they are often not among the top-3 placements, as indicated by the yellow squares in the plot. Top locations predominantly include recurrent adapters, as seen for the iNaturalist18, Places365, Clevr-Count, SST2 and MNLI datasets. Even long-range recurrent connections perform very well (e.g., $(24,6)$ in iNaturalist18 and Places365). This may be due to the benefit of using high-level information when adapting low-level modules. It’s important to note that the success of recurrent adapters cannot be solely attributed to an increase in FLOPs; otherwise, the optimal placement would be at edge (24,0), which is clearly not the case.

#### Power of a Single Adapter

In Figure 3, we observe that even a single, well-placed adapter can significantly improve performance compared to the linear probe. In some cases, such as iNaturalist18 or dSpr-Loc-1K, the obtained results are comparable to or better than the baseline with 24 parallel adapters. This demonstrates that a more strategic approach to adapter placement, rather than uniform application across all layers, can yield significant parameter efficiency gains.

Figure: Figure 4: The spearman correlation between the test accuracies of adapters location for different datasets obtained using the data from Figure 3.
Refer to caption: extracted/5932641/figures/heatmap_corr.png

#### Correlation Between Transfer Tasks

Finally, we examine the relationship between the results obtained for different datasets. To this end, we calculate the correlations between the test accuracies of the sampled locations for each pair of datasets – see Figure 4. We observe low correlations, especially between the smaller VTAB-1K datasets. Consequently, apart from special cases (e.g. iNaturalist18 and Places365), the best placement for a given task is unlikely to transfer to another task. Therefore, any method of adapter placement selection needs to utilize the knowledge not only from the pre-trained model but also from the task itself.

### 5.2 Multiple Adapters

In the previous section, we showed that the best performing single adapters often reside within the extended search space, which includes the recurrent and long-range adapters. In this section, we analyze the scenario of simultaneously adding multiple adapters to the network. Our aim is to demonstrate the *existence* of better placement assignments. We uniformly sample 100 different combinations of 24 adapters from the grid of $n^{2}=625$ placements. We compare the maximum test performance obtained through this random sampling (averaged over 3 runs) with parallel and sequential adapters baselines in Table 1.(^5^55We use the maximum mean performance, since we are mainly interested in verifying the *existence* of a better set of locations for the given number of adapters. We study ways of identifying such sets efficiently in following sections.)

#### Random Search Finds Better Adapter Placements

The best adapter combination found in the extended search space significantly improves over other adapter baselines for iNaturalist18, dSpr-Loc, and SST2 datasets, and surpasses the full fine-tuning accuracy. For the remaining datasets, the results are comparable to each other, falling within one-standard deviation range. Note that there are $C(625,24)\sim 1.3e43$ possible combinations in the extended search space, out of which we only sample $1e2$. It is thus surprising that even with such a small sample size we are able to achieve substantial improvements.

**Table 1: The maximum mean test accuracy over 100 sampled setups of placement of 24 adapters (Extended Max), compared with full fine-tuning, linear probe, parallel adapters and sequential adapters. We bold-out the best result in each column and underline the scores which fall within one-standard deviation range of the best result.**
|  | iNaturalist18 | Places 365 | Clevr-Count | SVHN | dSpr-Loc | MNLI | SST2 |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Full FT | 75.43$\pm$0.29 | 58.53$\pm$0.05 | 32.32$\pm$0.18 | 82.65$\pm$0.45 | 74.10$\pm$0.71 | 87.59$\pm$0.09 | 94.56$\pm$0.35 |
| Linear Probe | 68.43$\pm$0.13 | 55.37$\pm$0.03 | 36.99$\pm$0.19 | 44.23$\pm$0.11 | 19.89$\pm$0.08 | 52.75$\pm$0.07 | 80.42$\pm$0.04 |
| Parallel Adapters | 74.38$\pm$0.05 | 58.03$\pm$0.06 | 79.57$\pm$1.92 | 88.53$\pm$0.63 | 76.63$\pm$0.71 | 86.77$\pm$0.21 | 94.69$\pm$0.23 |
| Sequential Adapters | 74.64$\pm$0.11 | 58.15$\pm$0.02 | 79.89$\pm$2.41 | 86.77$\pm$0.45 | 78.84$\pm$4.24 | 86.94$\pm$0.08 | 94.04$\pm$0.69 |
| Extended (MAX) | 75.62$\pm$0.20 | 58.26$\pm$0.08 | 77.87$\pm$2.30 | 88.06$\pm$0.70 | 95.63$\pm$1.12 | 86.96$\pm$0.24 | 95.00$\pm$0.25 |

## 6 Towards identifying Best Adapter Placement

### 6.1 Gradient as a Predictor of Adapter’s Performance

Our results so far reveal the existence of better adapter placements within the extended search space. We would like to efficiently identify such placements for different fine-tuning tasks *a priori* to training. To do so, we propose ranking individual adapter locations using a scoring function and selecting a group of them in a greedy manner. As shown in Figure 3, the usefulness of adapters varies within each row and column, indicating that the ranking should depend on both the input and output of an adapter.

Inspired by works on adaptive growth and pruning in neural networks, we examine the information potentially hidden within the gradients of the adapter’s parameters, which naturally relies on the input and output nodes connected by the adapter. Intuitively, higher gradient magnitudes imply a larger change in the loss and, therefore, potentially faster learning. Consequently, gradient magnitude has often been used as an indicator of weight importance for pruning or growing parameters (Evci et al., , ; Lee et al., ).

Consider a linear adapter at edge $(i,j)$ represented by projection $A_{i,j}(x_{i})=x_{i}\mathbf{W_{i,j}}$. The adapter gradient is equal to the multiplication of the gradient of activations at node $j$ and the activations at input node $i$:

$$ $\frac{\partial L}{\partial\mathbf{W_{i,j}}}={x_{i}}^{T}\Big{(}\frac{\partial L }{\partial x_{j}}\Big{)}.$ (6) $$

We can then define a scoring function $s:\{n\}^{2}\rightarrow{\mathbb{R}}$

$$ $s(i,j)=f\Big{(}\mathop{\mathbb{E}}_{D}\Big{[}\frac{\partial{L(D)}}{\partial \mathbf{W_{i,j}}}\Big{]}\Big{)},$ (7) $$

where $s(i,j)$ is the score for an adapter connecting layers $i$ and $j$, calculated by applying a function $f$ (e.g., the norm) to the average gradient of the loss $L$ with respect to the adapter’s weights $W_{i,j}$, computed over a batch of data $D$ from the transfer task.

The remaining component of the above definition is the choice of function $f(\cdot)$, which aggregates the gradient matrix into a single scalar. We investigate various options, including the common matrix norms and find that the rank of the gradient matrix shows the strongest correlation with single-adapter training loss and test accuracy. We discuss alternative functions considered and their correlations with the obtained accuracies in Appendix F. We hypothesize that the rank is a more robust indicator of transfer performance due to its scale-invariance. For example, a rank-one matrix can have a large Frobenius norm despite containing minimal information. However, its rank remains unchanged regardless of its scale.

Let us note that although the proposed rank-based metric is computed using linear adapters, we confirm that the rankings of the best nonlinear adapters strongly correlate with those of the linear adapters (see Appendix E). We use zero-initialized linear adapters for scoring, as they eliminate the need to compute intermediate activations in the bottleneck dimension and do not influence the model’s forward pass.

Figure: Figure 5: The test accuracy obtained for a given location versus the gradient rank of that location for the different datasets. We report the Spearman’s correlation coefficient computed for each data (in brackets).
Refer to caption: extracted/5932641/figures/srank_0.01_scatter_test.png

We continue our study by calculating the numerical rank(^6^66We use the *srank* estimator defined as $r(A)=\operatorname*{argmin}_{i}\frac{\sum_{j=i}^{d}\lambda_{j}}{\sum_{j=1}^{d} \lambda_{j}}\leq\eta$, where $\lambda_{j}$ are the singular values of $A$ and $\eta$ is a thresholding parameter (Kumar et al., ).) of the adapter gradient using our transfer datasets and calculate the correlation between the computed score matrices and the test accuracies for each considered location. We present the results in Figure 5.

#### The Rank of the Gradient is Indicative of Adapter Performance

Both in the vision and text classification problems, we observe that the rank of the gradient correlates best for the more difficult, larger datasets like iNaturalist18, Places365 or MNLI. For the smaller tasks, the highest correlation is achieved on the Clevr-Count dataset, while the dSpr-Loc, SVHN, and SST2 obtain significantly lower correlations. Note that predicting the training dynamics and final transfer performance of a network at initialization is a challenging problem. It is therefore surprising that the rank of the gradient can serve as good predictor of the final test accuracy of an adapter, even if primarily for larger datasets. We now discuss how these findings can be incorporated into an algorithm for efficient identification of multiple adapter placements.

### 6.2 Placement Selection Algorithm

In the previous section we demonstrated that the rank score allows *a priori* identification of the optimal single adapter placement for selected datasets. However, in practice, we aim to choose an arbitrary number $N$ of locations. To this end, we propose a simple algorithm that uses a scoring function, such as that described in Equation 7, to rank locations and select the top performers.

Note that greedily picking the top-$N$ indices from the score matrix would predominantly return adapters that are placed within a localized neighborhood. Consequently, multiple adapters would modify the same input or contribute to the same output, introducing unnecessary redundancy and limiting exploration of the search space. To mitigate this, we propose the Gradient Gradient Adapters (GGA) algorithm, which discounts the scores for subsequent placements proportionally to the distance from the previously selected location.

#### Gradient Guided Adapters (GGA)

Given a desired number $N$ of adapters, the algorithm begins by calculating the scores for each possible location, creating the score matrix $s(i,j)$. After selecting the top position $(k,l)$, the score matrix is updated by discounting the scores of all entries proportionally to their distance from the chosen position, using $s(i,j)\odot d_{k,l}(i,j)$, with $d_{k,l}(i,j)=1-\gamma^{d_{1}((i,j),(l,k))}$, where $\gamma\in(0,1)$, $d_{1}(\cdot,\cdot)$ is the $L_{1}$ distance, and $\odot$ denotes the element-wise multiplication. The role of the discounting is to discourage the algorithm from placing further capacity within the close proximity of previously selected adapters. See Appendix I for details on the Algorithm.

Figure: (a) ViT-B/16 on iNaturalist18
Refer to caption: extracted/5932641/figures/scale_gga.png

We compare the placements found by GGA with discounting ($\gamma=0.6$) and without discounting ($\gamma=0$, resulting in choosing the top-*k* best scoring placements) to the random selection from Section 5.2 and two other baselines: the last-*k* selection, and the first-*k* selection. The last-*k* baseline, introduced by Rücklé et al. (), places parallel adapters only in the final *k* layers of the model. Conversely, the first-*k* selection applies parallel adapters only to the *k* layers closest to the input. We evaluate all methods on the iNaturalist18 and Places365 datasets across different adapter counts. Results are presented in Figure 6(a) and Figure 6(b), respectively.

#### GGA is Effective with Few Adapters

We observe that GGA is especially effective when the number of added adapters is low. In particular, we can match the performance of $24$ parallel adapters (PA) already with $3$ adapters for iNaturalist18 and $12$ for Places365. As the number of adapters increases, the effect of GGA diminishes, ultimately matching the performance of random selection for $24$ placements. Moreover, we note that GGA with discounting surpasses the purely greedy algorithm (top-*k*) up to the point of approximately $N=12$ adapters, after which both approaches perform similarly to random selection. In addition, we also find that the first-$k$ baseline is a better choice than last-$k$ when placing only a few adapters in the model, but this difference disappears when the number of adapters increases.

#### Varying Rank in Large-Scale Model

To demonstrate that GGA scales with the size of the model, we also consider the ViT-g/14 network (Zhai et al., ) fine-tuned on the iNaturalist18 dataset. The ViT-g/14 architecture has circa 1 billion parameters and $L=40$ layers, leading to $n^{2}=6561$ possible adapter locations. From this vast search space we select $N=40$ adapters using GGA and adjust their ranks to control the total number of added parameters. We compare GGA to the parallel adapters (PA) setting, where we inject the adapters only around the FFN blocks due to the large number of layers. Analyzing the results in Figure 6(c), we observe that GGA consequently outperforms the baseline approach. The difference is the more visible, the less trainable parameters are used.

The results confirm the potential of the extended search space. Remarkably, even with a simple algorithm like GGA, the total number of adapters can be significantly reduced while still maintaining or exceeding the performance of parallel adapters.

## 7 Conclusions

This study examined the effect of adapter placement on transfer performance. We expanded the search space beyond the conventional parallel and sequential configurations by introducing long-range and recurrent adapters, allowing information to be updated along paths between any two blocks in a model. We tested this approach on tasks of varying modalities and difficulty, demonstrating that even random sampling from the extended search space yields adapter placements that surpass baseline methods. Furthermore, we found that the rank of a linear adapter’s gradient is strongly correlated with its performance on most transfer tasks. This insight led to the development of a simple greedy algorithm for optimal adapter placement, which outperforms baselines in parameter-efficient fine-tuning. Our results underscore the importance of understanding how the placement of additional computational capacity influences fine-tuning performance and open new avenues for research into efficient identification of such placements.

#### Limitations and Future Work

This study focused on adapter placement in transfer learning. Future research could investigate whether our findings extend to other PETL strategies, such as LoRA, Prefix-Tuning, and Side-Tuning. Recurrent adapters emerged as the most effective single-adapter type, suggesting further exploration of their potential and ways to adjust their computational cost. Additionally, we observed a strong correlation between adapter gradient rank and performance, though there were some exceptions. Studying the factors that influence this relationship could enhance our understanding of training dynamics in fine-tuned models and lead to more reliable performance metrics. Lastly, future work could aim to develop iterative placement algorithms, where gradients, ranks, and scores are recalculated after a set number of steps or each time a new adapter is added to the network.

## Appendix A Authors Contributions

Aleksandra Nowak contributed to defining the research objectives, preparing the code and implementation of the methods, conducting the experiments, analyzing the results, and writing the manuscript. Utku Evci set the initial research direction and plan, helped with the implementation of the experiments, reviewing the code, running experiments and writing the paper. Yann Dauphin advised on methods and experiments, helped debugging, and refining the paper. Otniel-Bogdan Mercea helped with running experiments on VTAB, provided information about the baselines and used datasets and helped in refining sections of the paper. Anurag Arnab helped with running experiments on VTAB, paper proof-reading and editing, as well as advising. Jonas Pfeiffer advised the research direction in early stages of the project.

## Appendix B Training Regime

Throughout the paper we consider both image classification and text classification problems and focus on the transformer architecture. If not specified otherwise, for vision we always use the ViT-B/16 model (Dosovitskiy et al., ) which is pre-trained on the Image21K (Deng et al., ) dataset. For text, we use the RoBERTa-Base (Liu et al., ) model. Below we discuss the used datasets and the exact setups and training hyperparameters used for each conducted experiment.

### B.1 Datasets

For vision problems we use two large datasets, iNaturalist18 (see "") and Places365 (Zhou et al., ), as well as three small tasks selected from the VTAB-1K benchmark: the Clevr-Count, dSpr-Loc and SVHN, each with 1000 total training samples. In the case of iNaturalist18 and Places365 we adapt their "validation" splits as the test splits. We extract 1% of the training set as new validation set and perform any hyper-parameter selection based on the performance on that set. For the VTAB tasks, we use the standard test/train split. The hyper-parameter selection is performed by conducting experiment on a validation set formed from extracting 200 samples from the training set, following Zhai et al. (). For text, we use the MNLI and SST2 datasets from the GLUE benchmark (Wang et al., ). We select those datasets, as they have been used in other works investigating the adapters performance (He et al., ). We use the development splits as the test splits, and extract 10% of the training data as validation set. In all cases, after hyper-parameter selection, we optimize the model on the full training dataset (including the validation splits) and report the final test performance (see following sections).

### B.2 Single Adapter Placement: Figure 1

The aim of the experiment is to capture what is the impact of the placement of single adapter on the performance of the network. We use three baseline methods: full fine-tuning (FT), linear probe (LP), and a setup including all 24 parallel adapters (PA). In the linear probe method, the backbone of the model is freezed, on top of which a trainable linear projection is added. In the all-adapters setup we use the standard parallel adapter as described in Section 3.1, which is placed in every layer, both after the multi-head attention (MHA) and feed-forward (FFN) blocks.

For the vision tasks we fine-tune the ViT model with the SGD optimizer with momentum 0.9 and weight decay 0.0 , using a batch size of 128 for the iNaturalist18 and Places365 datasets, and a batch size of 64 for the VTAB tasks. We use the cosine annealing scheduler for the learning rate. The base learning rate is selected by a hyperparameter search over the values of {1e-4, 1e-3, 1e-2, 1e-1}, averaging the validation performance over 3 seeds. In addition, for the VTAB task, we extend the hyperparameter search to a grid including different number of total training steps, investigating values from {500, 2000}. For the large datasets (iNaturalist18 and Places365) we train the models for 20000 steps. In both cases we use warm-ups with 500 steps, respectively. For all 24 parallel adapters (PA), we used a rank of 8 for the VTAB tasks, consistent with the configurations in Jie & Deng () and Zhang et al. (). For iNaturalist18 we sweep the rank of the adapter over the values of {32, 128, 512}, and select rank 128, as it achieved the best performance-to-parameters trad-off. We adapt the same rank for Places365, due to the similarity of size and difficulty of those datasets.

For text tasks, we again sweep over the best learning rate from the set of {1e-5, 1e-4, 1e-3, 1e-2} for full-fine tuning and {1e-4, 1e-3, 1e-2, 1e-1} for linear probe and adapters. All other hyper-parameters follow the same setup as in He et al. (), where the training is performed using the Adam optimizer, with weight decay 0.1 and a polynomial learning rate scheduler, including a warm-up equal to 6% of the total training steps. The SST2 dataset is trained for 10 epochs. For the MNLI dataset, we find that fine-tuning over 3 epochs gives the same performance as after 10 epochs, and use the first number to reduce the training time.

In order to obtain the single-adapter performance for each of the 24 possible placements (^7^7712 layers, and within each one placement after MHA and one after FFN) we add one single adapter and then perform the training with the same hyper-parameters as the ones used for the all-adapter setup. For all methods, we report the average test accuracy over 3 runs.

**Table 2: The summary of datasets used for transfer learning.**
| dataset | train size | test size | validation split |
| --- | --- | --- | --- |
| iNaturalist18 (Van Horn et al., ) | 437,513 | 24,426 | 1% of training |
| Places365 (Zhou et al., ) | 1,803,460 | 36,500 | 1% of training |
| MNLI (Williams et al., ) | 392,702 | 9796 | 10% of training set |
| SST2 (Socher et al., ) | 67,349 | 872 | 10% of training set |
| Clevr-Count-1K (Zhai et al., ) | 1,000 | 15000 | 20% of training set |
| dSpr-Loc-1K (Zhai et al., ) | 1,000 | 73728 | 20% of training set |
| SVHN-1K (Zhai et al., ) | 1,000 | 26032 | 20% of training set |

### B.3 Extended Search Space: Figure 3 and Table 1

For the Extended Search Space experiments from Figure 3 we use the exact same configuration as for the single parallel adapter experiment, computing the adapter’s output accordingly to equations introduced in Section4. The maximum performance over the random adapters selected from the extended search space is computed by first sampling 100 lists of 24 adapter locations. Next, for each of the seven datasets, we add the adapters represented by the list to the corresponding pre-trained model and fine-tune it using the same setup as described in Section B.2. For each list, we perform 3 runs and report the maximum average test accuracy.

### B.4 Selecting the Aggregation Function: Table 4

In order to compare different choices of the aggregated function $f(\cdot)$ we first pre-train the head of the model for 2.5% of all training steps, keeping all other adapter and backbone parameters fixed. Next, we calculate the gradient of the linear adapter and average its value over a batch of 512 examples. We then aggregate the result using common norms as described in Table 4. This results in a separate score matrix $s(i,j)$ for each of the norms, where a given entry contains the score computed for the corresponding placement. Those values are then used to compute the correlation with the test accuracies and training loss from the sub-sampled space from Figure 3. We select the rank norm for further consideration, as it resulted in the best training loss correlation (see Appendix F and Appendix H).

To compute the rank score matrices for the rest of the data we use the same procedure as for iNaturalist18, pre-training the head of the model for each of the datasets for 2.5% of all the training steps. We use batch size 512 to compute the scores for iNaturlaist18, Places365, MNLI and SST2. For the VTAB-tasks we use the entire training set from the first fold (i.e. 800 samples).

### B.5 Adapter Selection Algorithm: Figure 6(a)

In the experiment in Figure 6 we vary the number of total adapters over the set of {1, 3, 6, 12, 24} and compare GGA to baseline approaches of random selection, selecting first-k adapters, and selecting last-k adapters. We consider two variants of GGA: with and without discounting. When using the discounting, we perform a hyperparameter sweep over the discounting factor $\gamma\in\{0.5,0.6,0.7\}$, and select 0.6 as the best value. For all methods, we perform 3 runs and report the average test accuracy. All other parameters for training and metrics evaluation match the ones described in previous sections.

### B.6 Large Scale Model: ViT-g

We use the ViT-g model to investigate how GGA performs on large scale architectures. The ViT-g transformer consist of $L=40$ layers. Due to the size model, when analyzing the all-adapters setup, we decide to place the adapter module only to update the output of the FFN block, so that that the total number of placed adapters is equal to the total number of layers. We use GGA to select the same number of adapters from the extended search space. We compare the results of parallel adapters to that of GGA for increasing rank ($r\in\{4,8,32,128\}$). We increase the discount $\gamma$ from 0.6 to 0.8, since in initial experiments with rank 32 the second value performed better on the validation set. Due to the significantly larger search space of 6561 positions stronger discounting is needed to enforce the algorithm to explore non-local connections. For each rank, we report the mean over 3 runs.

## Appendix C MHA or FFN parallel placement

A common question addressed in adapter research is whether to insert the parallel adapter after the Multi-Head Attention or after the Feed-Forward layer in an encoder block (He et al., ). The latter approach is considered to be the more popular solution (Chen et al., ; Luo et al., ; Zhang et al., ; Pfeiffer et al., ). In here, we revisit this question using the data gathered in the experiment from Section 3.3. We separately visualize the test accuracy obtained by the single FFN and MHA parallel-adapters for each block in the encoder architecture in Figure 7.

In most of the studied cases, the difference between the FFN and MHA placement is not significant. The exceptions are the Clevr-Count and dSpr-Loc datasets. For Clevr-Count using FFN adapters in the later stages of the model leads to better test accuracy. In contrast, the same blocks in the dSpr-Loc task per-from better with an MHA adapter. That being said, neither strategy emerges as universally predominately better over the other. In consequence, selecting the best *block* is more impactful than choosing between locations within that block.

Figure: Figure 7: The comparison between the performance of a single adapter placed either after MHA or FFN within an encoder block. The index of the encoder block is presented on the x-axis. The dashed lines correspond to full fine-tuning (pink), linear probe (light orange) and the setup with 24 parallel adapters (black).
Refer to caption: extracted/5932641/figures/parallel_placement_mha_ffn.png

## Appendix D Best Accuracy of a Single Adapter for Each Adapter Type

In addition to the Figure 3 from the main text, we also provide the single best performance obtained for different adapter types in Table 3. We observe that in all cases, apart from the dSpr-Loc dataset, the recurrent adapter is either significantly better, or comparable to the parallel adapters.

**Table 3: The best test accuracy obtained for a single adapter for different adapter types. We bold-out the best results in each column and underline the scores which fall within one-standard deviation range from the best result.**
| adapter type | iNat18 | places 365 | Clevr-Count | dSpr-Loc | SVHN | MNLI | SST2 |
| --- | --- | --- | --- | --- | --- | --- | --- |
| PA | 0.734$\pm$0.002 | 0.570$\pm$0.000 | 0.661$\pm$0.018 | 0.837$\pm$0.047 | 0.846$\pm$0.008 | 0.805$\pm$0.059 | 0.930$\pm$0.012 |
| SEQ | 0.734$\pm$0.001 | 0.571$\pm$0.001 | 0.594$\pm$0.011 | 0.819$\pm$0.032 | 0.829$\pm$0.008 | 0.803$\pm$0.058 | 0.927$\pm$0.015 |
| LR | 0.731$\pm$0.001 | 0.570$\pm$0.001 | 0.636$\pm$0.019 | 0.802$\pm$0.011 | 0.838$\pm$0.009 | 0.801$\pm$0.058 | 0.928$\pm$0.019 |
| REC | 0.742$\pm$0.002 | 0.572$\pm$0.001 | 0.683$\pm$0.015 | 0.799$\pm$0.040 | 0.841$\pm$0.015 | 0.810$\pm$0.061 | 0.932$\pm$0.015 |

## Appendix E Linear vs Non-Linear Adapters

In the main paper we propose to look at the gradient of the linear adapter as a source of information indicating where to place the adapter module. Using the gradient of linear adapter simplifies the computations and does not require storing any additional data in the model, since it can be computed by a simple multiplication of gradients incoming to the output of the adapter and the intermediate activation. Such approach, however, assumes there is a monotonic relationship between the performance of linear and non-linear adapters.

To verify this claim, we compute the performance of single linear adapter for each of the placement studied in Figure 3 for the SST2 dataset. The linear adapter is implemented simply as a linear projection. We use the same training regime as for the non-linear adapters, and average each result over 3 runs. We present the results in Figure 8.

Indeed, we observe that the performance of linear adapters correlates well with the nonlinear ones, both in terms of Pearson and Spearman’s rank coefficients. In addition, it is evident that the linear adapters achieve very good results, outperforming their non-linear counterparts in most of the locations (note that the points in right plot of Figure 8 lie below the diagonal). We expect this to be the result of larger parameter count in the linear adapters - please note that they are implemented using a straightforward linear projection and do not contain a low-rank bottleneck.

Figure: Figure 8: Left: The test accuracy for single linear adapters computed for the SST2 dataset. Right: The test accuracy of the non-linear adapters (y-axis) versus the test accuracy for the same placement obtained by a linear adapter (x-axis) on the SST2 dataset.
Refer to caption: extracted/5932641/figures/linear_heatmap.png

#### Effect of activation for varying number of adapters

In addition to the previous experiment, we also study how the change of the activation function in the bottleneck dimension of the adapter affects the performance. To this end we vary the number of adapters and place them only on the parallel positions (recall Figure 2). If the number of adapters is less then 24, we distribute the adapters locations uniformly, so that the distance between neighbouring adapters is the same. If only a single adapter is placed in the network, it is added on the first parallel position (edge 0-1). We compare the GeLU activation function with the ReLU activation and with using no activation (i.e. a linear adapter with low-rank projection). We plot the results in Figure 9. We observe that all variants of activation functions achieve similar performance. However, the non-linear activations seem to be more important when using a larger number of adapters.

Figure: Figure 9: The test accuracy versus the number of adapters placed in the network for different activation functions of the adapter’s module.
Refer to caption: extracted/5932641/figures/linear_vs_nonlinear_num_adapters.png

## Appendix F Different Aggregation Functions

One key component of the score proposed in Section 6 is the choice of the function $f(\cdot)$. We investigate various transforms, including the minimum absolute column sum, the maximum absolute column sum norm, the Frobenius norm, the spectral norm, the nuclear norm, and the rank computed using the singular decomposition of the gradient – see Table 4 for summary. We compute the score matrices for each of those functions using the ViT-B/16 model fine-tuned on the iNaturalist18 dataset. Since the gradient at the beginning of the training may be heavily influenced by the initialization of the linear head of the model, we also find it beneficial to first pre-train the head for a number of $n_{steps}$, before computing the average gradients (see Appendix B and H for details). For each score matrix, we calculate the Spearman’s rank correlation between the scores for each location and the train loss and test accuracy obtained for that location. We present the results in Table 4. In addition to the results from Table 4, we include the obtained score matrices and plot the relationship of the score matrix for each of the choice of function $f(\cdot)$ in Figure 10. It is visible that only the rank achieves promising correlation.

Figure: Figure 10: Top: The visualization of score matrices obtained for different choice of norm $f(\cdot)$. Bottom: The scatter plots depicting the relationship between the training loss for a given adapter location and the computed score. We report the Spearman’s rank coefficient at the top of the plot.
Refer to caption: extracted/5932641/figures/metrics_all_iNAT.png

**Table 4: Different forms of function $f(\cdot)$ with their definitions for a given matrix $A\in R^{d\times d}$. The symbol $\lambda_{i}$ refers to the $i$-th largest singular value from the SVD decomposition of matrix $A$, with $\lambda_{max}$ = $\lambda_{1}$. The value $\eta$ is a thresholding hyperparameter (see Appendix H for tested values). We report the Spearman’s correlation between the scores at each location with the training loss and test accuracy of the ViT-B/16 model fine-tuned on the iNaturalist18 dataset.**
| name | notation | description | train loss | test accuracy |
| --- | --- | --- | --- | --- |
|  |  |  | correlation | correlation |
| min. abs. column sum | $\lVert A\rVert_{-1}$ | $\min_{j}\sum_{i}|A_{i,j}|$ | 0.209687 | 0.562722 |
| max. abs. column sum | $\lVert A\rVert_{1}$ | $\max_{j}\sum_{i}|A_{i,j}|$ | 0.118575 | 0.002784 |
| frobenius norm | $\lVert A\rVert_{fro}$ | $\sqrt{\sum_{i,j}|A_{i,j}|^{2}}$ | 0.106483 | 0.421068 |
| spectral norm | $\lVert A\rVert_{2}$ | $\sqrt{\lambda_{max}}$ | 0.170864 | 0.392636 |
| nuclear norm | $\lVert A\rVert_{nuc}$ | $\sum_{i=0}\lambda_{i}$ | -0.158678 | 0.546193 |
| rank | $r(A)$ | $\underset{i}{\operatorname*{argmin}}\frac{\sum_{j=i}^{d}\lambda_{j}}{\sum_{j=1<br>}^{d}\lambda_{j}}\leq\eta,\ \eta=0.01$ | -0.930429 | 0.823797 |

## Appendix G Correlation with Training Loss

We study how the proposed metric correlates with the training loss for the various datasets in Figure 11. As expected, similarly to the correlation with the test accuracy, the placements with the largest gradient rank have also the smallest training loss. In addition, for some datasets, like SVHN and Clevr-Count, we observe that the few locations with lowest ranks and relatively high test accuracy from Figure 5 (main text) have worse training loss than the locations with higher gradients, indicating that some of the discrepancy in the computed metric may be due to generalization problems. To further study this claim, we compute the correlation between the final test accuracy and training loss for different datasets, and visualize it in Figure 12. We observe that for some tasks, the low training loss does not necessarily guarantee improved test accuracy (consider SST2 with correlation of only 0.56 or the Clever-Count with correlation 0.78), which may potentially affect the workings the effectiveness of the rank metric.

Figure: Figure 11: The logarithm of the training loss versus the computed gradient for different datasets.
Refer to caption: extracted/5932641/figures/srank_0.01_scatter.png

Figure: Figure 12: The final test accuracy obtained for a given location versus the final logarithm of the training loss for the same location computed for various datasets.
Refer to caption: extracted/5932641/figures/generalize.png

## Appendix H Effect of Rank Threshold and Number of Pre-training Steps on the Metric Score.

In this section we study how the threshold hyperparameter $\eta$ and the number of pretraining steps of the head $n_{steps}$ affect the correlation computed between the rank of the gradient and the performance of adapters. We present the results in Figure 13. In general, it is clear that the longer the head of the model is pretrained in isolation, the better the correlation.

Figure: Figure 13: Left: The correlation between the training loss and the computed rank of the gradient for various numbers of pretraining steps (rows) and thresholds $\eta$ (columns) obtained for the iNaturalist18 dataset. Right: The same as left, but the correlation is computed between the test accuracy and the rank of the gradient.
Refer to caption: extracted/5932641/figures/effect_of_threshold.png

## Appendix I The GGA Algorithm

Figure: Algorithm 1 Gradient Guided Adapters (GGA)

The GGA is a simple score-based approach, that given a score-matrix and required number of adapters $N$, returns the top-$N$ placements with highest scores.
Additionally, as mentioned in the main text, we decide to include a heuristic that discourages the algorithm for repeatedly selecting adapters from the same neighbourhood. The scores of placements in the vicinity of the last picked connection are reduced by multiplying them by the factor:

$$ $d_{k,l}(i,j)=1-\gamma^{d_{1}((i,j),(l,k))},$ $$

where $d_{1}$ is the L1 distance, and $(l,k)$ is the last picked edge. We refer to $d_{k,l}(i,j)$ as the *discount matrix* for edge $(i,j)$. Note that we prefer the choice of the $L_{1}$ distance in the computation of $d_{k,l}(i,j)$ over the $L_{2}$ distance, since we we would like to penalize placements in the same rows or columns more than those on the diagonal directions. The strength of the discounting is determined by the choice of the $\gamma$ hyperparameter. After the update, the new matrix $\hat{s}(i,j)$ is used for the next selection and the procedure is repeated until we choose all $N$ placements. We summarize this method in Algorithm 1. In Figure 14 we also depict an example of the discounting matrix and visualize the end state of a score matrix used when selecting $N=24$ adapters.

Figure: Figure 14: Left: An example of a discount matrix $d_{k,l}(i,j)$ computed for indices $(i,j)=(16,7)$ using discount factor $\gamma=0.6$. Right: The visualization of the score matrix after placing $24$ adapters using GGA.
Refer to caption: extracted/5932641/figures/dicount_inat.png

Note that although in line 2 of the algorithm we use the rank of the gradient as the score function, the algorithm itself can work with arbitrary score matrices. We focus on the rank of the gradient of the linear adapters due to its promising correlation with the training loss.

## Appendix J Single Adapter versus Multiple Parallel Adapters

**Table 5: The test accuracy of fine-tuning a single adapter, versus fine-tuning 12 adapters placed in the FFN modules of a transformer, obtained for different ranks. The data was obtained by training on the iNaturalist18 dataset using the ViT-B/16 model.**
| rank | all parallel (FFN) | single (best) |
| --- | --- | --- |
| 16 | 74.1 | 74.1 |
| 8 | 74.0 | 74.2 |
| 4 | 73.8 | 73.9 |
| 2 | 73.5 | 73.8 |

In this section we analyze how a *single* adapter compares with the standard setup of placing parallel adapters in every block of the encoder. For the latter, we use the method of placing adapters only between the Feed-Forward module of the transformer, as suggested, e.g. in He et al. (). We manipulate the rank of the single adapter so that the number of parameters is approximately the same in both scenarios. This gives a total of 12 adapters with rank $r$ for the *all parallel* setup versus one adapter with rank $r*12$ in the *single adapter* setup. We fine-tune the new parameters on the iNaturalist18 dataset, varying the values of the rank. For the single adapter, we test all the sub-sampled placements (recall the experiment from Figure 3), and report the best test accuracy among all the locations. We present the results in Table 5. We observe that the single adapter from the extended search space, if well placed, is already able to match or marginally outperform the standard setup with multiple FFN adapters.

## Peer Reviews

confidence: 2
contribution: 3
initial_rating: 6
presentation: 3
questions: Related to question 1 in terms of weaknesses, the authors suggest that the placement of adapters significantly impacts performance. In the case of multiple adapters, as shown in Figure 6, using the same number of adapters (e.g., 6, 12, 24) results in varied performance. The only difference is the placement of these adapters, while other conditions remain the same.
soundness: 3
strengths: 1. The designs for the adapter in Equation 2 and the recurrent searching graph appear solid. It seems that using the recurrent approach is more effective than the parallel sequential or long-range approach.

2. Based on experiments, a single, well-placed adapter can significantly improve performance compared to the linear probe.
summary: This work investigates efficient strategies for placing adapters in transfer learning, specifically within the context of parameter-efficient transfer learning (PETL). A key finding is that the location of adapters within a network significantly impacts effectiveness, and the optimal placement depends on the specific task. By adapting pre-trained models to new tasks with minimal parameter adjustments, this study emphasizes maximizing effectiveness through strategic adapter placement rather than uniformly adding adapters across network layers.
weaknesses: I think the paper could benefit if the author addresses the following question related to multiple adapters and the corresponding search and replacement algorithms:

1. How many adapters would achieve optimal performance? From Section 5.2, it appears that the authors aim to use multiple adapters with random search to improve transfer learning quality, yet it remains unclear how many adapters are necessary to achieve robust performance coverage. Based on Figure 6 and the GGA section, performance appears to continue increasing as more adapters are added. While I understand that the optimal number of adapters is task-dependent, is there a mathematical formalization that explicitly demonstrates how many adapters are sufficient? It seems that GGA is largely observational and based on gradient analysis. Is it possible that adding too many adapters could lead to an over-parameterized model, potentially causing a drop in accuracy?


2. The authors suggest that GGA is effective with a few adapters (as shown in Figure 6, where 12 GGA-based adapters achieve similar or higher performance). I believe it would be beneficial if the authors provided comparisons of computational complexity and memory usage for these methods. Specifically, what is the training complexity compared to the compressed approach in this paper? Calculating gradients may introduce additional time and memory costs, as it requires retaining the graph during training. Additionally, what is the inference complexity? For instance, to reach the same accuracy, full fine-tuning does not incur additional costs associated with adapters (which could treated as upper bound). How does GGA compare with other approaches in terms of these factors?

---

confidence: 4
contribution: 2
initial_rating: 5
presentation: 2
questions: The GGA algorithm shows promise, but it only works on the use of a limited number of adapters. This limitation is problematic given that adapters are usually lightweight and commonly stacked layer-wise in practical. As a result, the applicability of GGA in real-world scenarios is severely constrained.
soundness: 2
strengths: * The motivation is clear and the adapter placement is worth researching.
* The proposed Gradient Guided Adapters (GGA) algorithm is interesting.
summary: This paper investigates the impact of adapter placement within pre-trained neural networks on their transfer learning performance. Besides, the paper introduces an extended search space for adapter placement, including long-range and recurrent adapters, and proposes a method to identify optimal placements using gradient rank as a predictor of adapter performance. The experiments across datasets and model scales demonstrate that strategically placed adapters can match or exceed the performance of uniformly distributed adapters.
weaknesses: * The recurrent adapters require two forward processes, further deteriorating the efficiency of pre-trained models.
* Results in table 1 lack the comparison with related works.
* The paper lacks a clear and actionable conclusion. While the findings are interesting, it remains unclear how these results can be directly applied to practical scenarios.

---

confidence: 4
contribution: 3
initial_rating: 6
presentation: 4
questions: see weakness above
soundness: 4
strengths: 1. The authors introduced a novel extension of the adapter placement search space, including long-range and recurrent adapters, which go beyond traditional uniform placement. This provides more flexibility and improves fine-tuning results.

2. The proposed gradient rank metric offers a practical and computationally efficient method for predicting the best adapter placements a priori, significantly reducing the computational cost of fine-tuning large models.

3.  The method shows that even with a small number of well-placed adapters, performance can match or exceed the standard uniform approach, highlighting the method's efficiency.
summary: This paper investigates optimal adapter placement strategies in Parameter Efficient Transfer Learning (PETL) for deep neural networks. The authors introduce an extended search space for adapter connections, including long-range and recurrent adapters, which allows the adapters to exploit non-local information. They demonstrate that the placement of adapters is critical for the overall model performance and that strategically placed adapters can outperform standard uniform adapter placements. Additionally, they propose a gradient rank-based metric to identify optimal adapter locations efficiently.
weaknesses: 1. **Dataset Limitation**: While the paper demonstrates the method's effectiveness on several datasets, the reviewer is curious about its performance on larger and more diverse datasets, such as ImageNet. Testing on such datasets would better illustrate the method's scalability and generalization capabilities.

2. **Adapter Complexity**: Introducing long-range and recurrent adapters increases overall model complexity. However, the paper does not fully explore the trade-offs between this complexity and the performance gains. The reviewer is curious if the added complexity of long-range and recurrent adapters could lead to instability during training or inference, particularly in large-scale applications.

3. **Task-Specific Adapter Placement**: The method's reliance on task-specific adapter placement strategies may limit its practicality for general-purpose applications. The reviewer wonders if there is potential to reduce the task-specific nature of adapter placement, making the method more widely applicable without requiring custom placement strategies for each task.

Meta-review: The paper proposes a method to place adapters based on the tasks with the premise that adaptation of the network is task dependent. This is done through a method called Gradient Guided Adapters. As pointed out by one of the reviewers,  It is true that there is a rich literature of task specific adaptation for instance (a very small selection) 
Budget-Aware Adapters for Multi-Domain Learning
Rodrigo Berriel, Stéphane Lathuilière, Moin Nabi, Tassilo Klein, Thiago Oliveira-Santos, Nicu Sebe, Elisa Ricci 

TAIL: Task-specific Adapters for Imitation Learning with Large Pretrained Models
Zuxin Liu, Jesse Zhang, Kavosh Asadi, Yao Liu, Ding Zhao, Shoham Sabach, Rasool Fakoor

and many more. Hence, the paper does seem to have a gap in the prior work and comparison in that area. However, the uses of recurrent and adapters is a novelty of the method. Hence it is unclear what the efficacy of the proposed method is with respect to the existing methods. Further, there are some other benchmarks on which these can be compared against for instance the ImageNet to Sketch benchmark and the domainnet benchmark. While these are older, they will help compare across many methods that have used them. 

Given this fact as well as the reviewer ratings, this paper unfortunately is not ready for the ICLR audience.

Decision: Reject