Title: SwitchHead: Accelerating Transformers with Mixture-of-Experts Attention
Venue: NeurIPS 2024
Accepted: yes
Keywords: MoE

mixture of experts

attention

transformers
Abstract: Despite many recent works on Mixture of Experts (MoEs) for resource-efficient Transformer language models, existing methods mostly focus on MoEs for feedforward layers. Previous attempts at extending MoE to the self-attention layer fail to match the performance of the parameter-matched baseline. Our novel SwitchHead is an effective MoE method for the attention layer that successfully reduces both the compute and memory requirements, achieving wall-clock speedup, while matching the language modeling performance of the baseline Transformer. Our novel MoE mechanism allows SwitchHead to compute up to 8 times fewer attention matrices than the standard Transformer. SwitchHead can also be combined with MoE feedforward layers, resulting in fully-MoE "SwitchAll" Transformers. For our 262M parameter model trained on C4, SwitchHead matches the perplexity of standard models with only 44% compute and 27% memory usage. Zero-shot experiments on downstream tasks confirm the performance of SwitchHead, e.g., achieving more than 3.5% absolute improvements on BliMP compared to the baseline with an equal compute resource.

SwitchHead: Accelerating Transformers with Mixture-of-Experts Attention

Abstract

Despite many recent works on Mixture of Experts (MoEs) for resource-efficient Transformer language models, existing methods mostly focus on MoEs for feedforward layers. Previous attempts at extending MoE to the self-attention layer fail to match the performance of the parameter-matched baseline. Our novel SwitchHead is an effective MoE method for the attention layer that successfully reduces both the compute and memory requirements, achieving wall-clock speedup, while matching the language modeling performance of the baseline Transformer. Our novel MoE mechanism allows SwitchHead to compute up to 8 times fewer attention matrices than the standard Transformer. SwitchHead can also be combined with MoE feedforward layers, resulting in fully-MoE 'SwitchAll' Transformers. For our 262M parameter model trained on C4, SwitchHead matches the perplexity of standard models with only 44% compute and 27% memory usage. Zero-shot experiments on downstream tasks confirm the performance of SwitchHead, e.g., achieving more than 3.5% absolute improvements on BliMP compared to the baseline with an equal compute resource. 1

1 Introduction

Large language models (LLMs) have shown remarkable capabilities [1, 2, 3, 4] and great versatility [5]. However, training large Transformers [6, 7] requires a considerable amount of computing power and memory, which is not accessible to most researchers, academic institutions, and even companies.

Even running them in inference mode-typically much less resource-intensive-requires significant engineering effort [8]. Accelerating Transformers remains an important research question.

In this context, Mixture of Experts (MoE) layers [9, 10, 11] have become popular to efficiently scale up Transformers to a large number of parameters [12, 13, 14, 15, 16, 17]. However, most of these works mainly focus on applying MoE to the 2-layer feedforward blocks [6], i.e., the multi-layer perceptron (MLP) components of the Transformer, while keeping the self-attention layers unchanged. Given that attention also accounts for a considerable amount of compute and memory usage in Transformers (especially for long context sizes), using MoE for attention has potential to further improve resource efficiency in Transformers. While MoE-based attention remains underexplored in general, there are existing works on MoE approaches for attention [18, 19]. However, in practice, previously proposed methods typically require a lot of engineering tricks for successful training, and most importantly, only achieve a modest reduction in computing and memory requirements in the end (as we also confirm in our experiments).

Here, we present a novel MoE-based attention method, SwitchHead, whose mechanism allows to reduce the number of attention matrices that need to be computed and stored. Following σ -MoE [17], our method uses a non-competitive selection activation function (sigmoid), and does not require regularization or extra tricks for stable training. Importantly, we show that it is possible to compute the MoE projections outside of the attention core, which enables a significant reduction in the number of computed attention maps, resulting in significant resource savings. Our thorough investigation shows that it is enough to choose the value and output projections from a pool of experts and share keys and queries between them.

We evaluate our method on C4 [20], Enwik8 [21], peS2o [22] and Wikitext 103 [23], with two model sizes (47M and 262M). Additionally, we measure the zero-shot performance of our main models on Lambada [24], BLiMP [25], and Children's Books Test [26] datasets. Our experiments demonstrate that SwitchHead can achieve performance comparable to parameter-matched baselines with just a fraction of the compute and memory budget. In addition, we introduce 'SwitchAll', a fully MoE-based Transformer model, that combines a σ -MoE-based MLP layer with our SwitchHead attention, often outperforming dense baselines with the same parameter budgets.

Finally, we analyze the attention maps of our SwitchHead. We find that the attention maps taken over all heads are qualitatively similar to the dense baselines, indicating a significant reduction in redundancy without a loss of expressivity. In addition, expert selections are often interpretable.

2 Method

2.1 Background

The standard multi-head self-attention (MHA) layer [6] consists of four major steps: (1) compute key, query, and value projections, (2) compute the attention matrix, (3) use the attention matrix to project the values, and (4) map the projected values to the output. Let h , T , n heads , d model, d head denote positive integers. Let x ∈ R T × d model denote an input to the MHA layer with n heads heads, T be the sequence length, and d model denote the size of the hidden representations of the model. W h { K,V,Q } ∈ R d model × d head are the projection matrices for head h ∈ { 1 , ..., n heads } . Then K h = xW h K , Q h = xW h Q , and V h = xW h V (thus K h , Q h , V h ∈ R T × d head ) are the keys, queries, and values, respectively. The attention matrix for the head h , A h ∈ R T × T , and the output y ∈ R T × d model are calculated as follows:

where | denotes concatenation in the last dimension, the softmax( · ) is also over the last dimension, and W O ∈ R n heads d head × d model . However, an alternative formulation reflects the role of W O better. Let us divide W O along the first dimension into submatrices for each head, W h O ∈ R d head × d model , such that W O = ( W 1 O ⊺ | W 2 O ⊺ | ... | W n heads O ⊺ ) ⊺ . In this case, the output (Eq. 2) can be equivalently written as:

From this, it can be seen that all computations are local to each head. Computing the attention matrix A h and the readout A h V h requires compute in order of O ( n heads d head T 2 ) MACs (multiplicationaccumulation operation 2 ). During training, it requires the storage of O ( n heads T 2 ) for the attention matrices and O ( n heads Td head ) for storing the sub-results of the projections. Given a sufficiently long sequence, computing the attention matrix and projecting the values will dominate the compute requirements due to the quadratic dependence on the sequence length T .

2.2 From Dense to SwitchHead Attention Layer

Our goal is to obtain resource reductions while maintaining the fundamental properties of attention and retaining a fully expressive attention matrix. For that, we start from the following observation: modern LLMs use tens of heads [2, 27]. Are so many of them all necessary? As we show later in Sec. 3, indeed, naively reducing the number of heads (while keeping the same number of parameters by increasing the head dimension) results in performance loss. Explaining the reason for the need for many heads is beyond the scope of this paper. Nevertheless, here are some hypotheses: (1) they provide multiple inputs for the operations that the network performs in each step, (2) they are specialized and provide inputs only for specific operations (in this case, each operation would use a different subset of heads), (3) they may provide diverse outputs due to different initializations, some being more successful than others, thus enabling better learning. Among these, (2) and (3) may offer an opportunity for resource savings: if not all heads are needed at the same time, it might be possible to switch among them depending on the context.

One naive method to achieve this is to use a gating signal using a linear projection W S ∈ R d model × n heads , and use the heads with the highest score, by replacing Eq. 3 with Eq. 6:

where y [ t, c ] ∈ R denotes indexing the specific element of the output matrix y ∈ R T × d model , for timestep t and channel c , and k is the number of active experts. Following the σ -MoE method [17], we use a non-competitive selection function (sigmoid σ in Eq. 4). Now, let us define the source side of attention as the keys and values and the destination side as the queries and output. Intuitively, the above method corresponds to choosing a subset of attention heads based on the destination side alone 3 . Our preliminary experiments confirmed that this method is indeed feasible for language modeling on WikiText-103. However, it is difficult to achieve acceleration and memory savings with this method. To see why, notice that the entries of the attention matrix A h depend on pairs of tokens, one for the source and one for the destination side, but the choice is made only based on the destination side. Thus, in the worst case, for each destination, a different source might be chosen, in which case all possible source projections have to be computed for the keys and values, which we would like to avoid.

Alternatively, we propose to improve the method above by introducing conditional computations for the source and destination projections independently of each other. That is, we parameterize each of key, query, value, output projection by an independent MoE. This avoids conditional computations that involve the attention matrix itself. Our solution implements this using Mixtures of Experts (MoEs). The concepts of "heads" are no longer well defined in the conventional sense: we redefine a head as an instance of a computed attention matrix. We call the total number of them n heads. For each head h , we define a separate list of E experts. The total number of experts is then n heads · E . Then, the projection matrices become W h,e K , W h,e Q , W h,e V and W h,e O ∈ R d head × d model , where h denotes the head index and e the specific expert. Then we compute the source-side expert selection as follows:

where W h S ∈ R d model × E . We compute the destination-side experts similarly: s h D = σ ( xW h D ) , E h D = arg topk( s h D , k ) , E h S ⊂ { 1 , ..., E } , W h D ∈ R d model × E . Then, the value projection V h is computed as a weighted sum of the selected experts:

The key and query projections are computed similarly: K h = ∑ e ∈E h S s h S [ e ] xW h,e K , and Q h = ∑ e ∈E h D s h D [ e ] xW h,e Q . The output projection also becomes an MoE:

As we'll show, it is not necessary to make all projections MoEs. In Section 3.1 we show that keeping a single, head-specific copy of the query and key projections and reusing them for all experts is beneficial. We call this method SwitchHead.

Essentially, SwitchHead reduces the number of attention matrices that have to be computed ( n heads ) significantly, by using multiple experts per head. Note that our method does not depend on the specific implementation of the attention, allowing for easy experimentation and research. A schematic representation is shown in Figure 1.

3 Experiments

We conduct our experiments in a parameter-matched setting [17] which better reflects the task of language modeling (than the FLOPS-matched setting often used to evaluate MoEs). Our main experiments use Transformer XL, because we found them to consistently and significantly outperform RoPE-based baselines [28] for a fixed amount of compute. We provide the details of this analysis in Appendix A.4. The conclusions on the effectiveness of SwitchHead are consistent in both cases.

As an important specification, under this parameter-matched setting, we always configure Switchhead such that it matches the perplexity of the baseline dense Transformer, and we maximize its resource reductions . For this, we follow a systematic procedure. First, we set n heads ∗ E to be the same as n heads of the dense baseline. We start with setting n heads = 2 and k = 2 , which provide the most resource reductions. If the resulting model underperforms, we increase k . If k = 4 underperforms as well, we set n heads = 4 and k = 2 . We always set d head so that the total number of parameters of the resulting model matches the number of parameters of the baseline. This reasonably simple procedure ensures a good amount of resource savings, while avoiding doing an expensive hyperparameter search.

Note that all the perplexity gains seen in the main result tables are the byproduct of imperfect matching, and our goal is to achieve reductions in resource requirements , unless noted otherwise (See Sec. 3.5). Detailed hyperparameters of all our models can be found in Sec. A.5 in the Appendix. We use and adopt the Triton kernel of σ -MoE [17] for our purposes.

For all datasets except the character-level Enwik8 [21], we use sub-word units [29, 30] obtained with a SentencePiece tokenizer [31] with a vocabulary size of 8k tokens. For most of our experiments, we use Transformer XL [32] with the context size being twice the size of the active/current chunk, because we found it to be significantly more resource-efficient than the standard setup. However, in order to show that our method is also competitive in the standard Transformer with RoPE positional ecodings, we also demonstrate our main findings in this setup (Appendix A.4).

All models are trained for 100k batches. Some of the datasets we consider (C4 [20], and peS2o [22]) are much larger. In this case, we train on the first 10 5 ∗ T ∗ N batch tokens of the dataset.

3.1 Which Projections Require an MoE?

As discussed in Sec. 2.2, each linear projection (keys, values, queries, and output) can potentially be replaced independently by an MoE. Here we first check which projection benefits from such a replacement. As we target the parameter-matched setting, using MoE where it is not necessary can have a negative effect. Since experts use a significant part of the parameter budget, they can reduce the number of parameters available for the more useful parts of the model. Thus, we did a search over all possible combinations of MoE versus fixed projections with two active heads and compared them to the parameter-matched baseline. We find that the output projection is necessary to match the performance of the baseline (for detailed results refer to Tab. 6 in the appendix). Having MoE in the key and query projections turn out to be un necessary. Models without the output and value MoE underperform the dense baseline with n heads = 2 heads.

In sum, the best-performing model is the one using MoE for value and output projections. We use this model variant in the rest of experiments in this paper.

3.2 Comparison with MoA

The method most related to ours is the so-called Mixture of Attention Heads, or MoA [18]. Unlike SwitchHead, MoA uses a single key and value projection and chooses n heads active query and output projections from a pool of E experts.

MoA computes the attention map for each selected expert and computes their weighted average after the attention computation takes place. In contrast, SwitchHead calculates the weighted average of the K selected experts before and after attention computation. Because of this, in practice, the same perplexity is achieved with the required number of computed attention matrices ( n heads) which is much lower for SwitchHead compared to MoA, allowing significant resource savings.

Also, unlike MoA, SwitchHead uses a non-competitive activation function (sigmoid) [17]. We confirm that with this, our method performs well without any regularization, while MoA requires three different regularizers.

We compare our method with MoA in Table 1. It can be seen that while MoA can slightly outperform our method in terms of perplexity, it can only do so at the price of significantly more resource usage. Given a similar computation and memory budget, our method consistently outperforms MoA.

3.3 Performance on Different Datasets

We test our methods on a diverse set of language modeling datasets, including C4 [20], Enwik8 [21], peS2o [22], at two different scales: a 47M and a 262M parameters. We chose this experimental setting taking into account our compute-budget and confidence in our results which are consistent in across various configurations.

The results are shown in Table 2. We compare our models to two baselines: one with the same number of heads as the total number of experts ( n heads · E ) of the SwitchHead models, and the other has the same number of heads as the number of active attention matrices ( n heads) as our models. Our

models closely match the performance of the full, many-head baseline with the fraction of memory and compute requirements (see Sec. 3.7 for more details).

In addition, we verify the performance of our models trained on the C4 dataset downstream tasks in a zero-shot manner. We consider Lambada [24], BLiMP [25] and Children's Book Test (CBT) [26]. The results are shown in Table 4: our SwitchHead models consistently outperform or match the performance of the baseline dense Transformer models.

3.4 SwitchAll

The goal of achieving more resource-efficient Transformers includes reducing the resource requirements of both the MLP and the attention layers. σ -MoE [17] was recently proposed as a parameterefficient MoE method for accelerating the MLP layers. However, it remains unclear whether it can be efficiently combined with our SwitchHead, or can have some negative interaction effect if combined in a "SwitchAll", where every layer is MoE-based.

To verify this, we take the baseline architecture of Csordás et al. [17] without any hyperparameter change and replace the attention layer with SwitchHead. The hyperparameters for the attention are directly taken from the experiments shown in Tab. 2. The results are shown in Tab. 3. The combined, fully-MoE model often outperforms the dense baselines for each dataset and model size considered, except in the case of the 262M parameter model on the C4 dataset.

3.5 MAC-Matched Setup

All our experiments so far were calibrated so that the predictive performance (perplexity) matches to the performance of the baseline Transformer, and we were aiming for maximum resource savings. However, it is also a valid question to ask what is the performance of SwitchHead in a MAC-matched setup, where the compute requirements of our model are matched to those of the baseline. We achieve this by increasing d head and n heads until we have the same MAC requirements as the baseline. This results in a model with more parameters. For the small Transformer XL, we increase d head from 76 to

112 and n heads from 2 to 3. For large XL, we increase n heads from 4 to 6 and d head from 112 to 168. For the small RoPE model, we change n heads from 2 to 3 and d model from 64 to 84, for big n heads from 4 to 6 and d model from 112 to 168. We show the results in Tab. 4: MAC-matched models outperform the others by a large margin both in perplexity and in zero-shot task performance.

3.6 Shared Selection

For further time savings, we can share the expert selection between the source and destination side. Acceleration is achieved by reducing the number of sorting and top-k steps compared to the full SwitchHead. However, this results in a minor performance loss, which might be tolerated in some cases where the acceleration is more important. See Tab. 4 for more details.

3.7 Wall-Clock Time and Memory Usage Estimation

In all of our tables, we report the number of multiply-accumulate (MAC) operations following Zhang et al. [18]. The reason for this is that the actual wall-clock time is highly implementation and hardware-dependent. Nevertheless, we measured the runtime and total memory usage of our entire training pipeline (including the feedforward layer) to demonstrate that our current (suboptimal) implementation is already capable of providing wall-clock time acceleration. We show the results in Tab. 5. The measurements are taken on identical hardware with the same implementation (including for the attention core), the only difference being the MoE-based projections for the attention. It can be seen that for both scales, SwitchHead trains around 1.5 times faster, while using 61%-67% as much memory as the baseline.

We also report the performance of MoA for reference in Table 5. For measuring the resource usage of MoA, we chose the fastest MoA model that can match the performance of the dense baseline, or simply the best MoA model when no MoA model can match the baseline performance. This resulted in choosing MoA with H = 4 for the 47M model and MoA with H = 8 for the 262M parameter model. SwitchHead outperforms MoA on both scales, both in wall clock time and memory requirements. Note that these measurements also include the MLP layers, the optimizer, and the gradient synchronization in the case of multi-GPU training.

4 Analysis

In order to see how the network uses the attention heads, we trained a small, 6-layer, 8-head Transformer on ListOps [33, 34]. The reason for this choice is that small, algorithmic tasks tend to be more interpretable compared to language modeling tasks. We also train a parameter-matched, 2-head

SwitchHead model. Both models achieve around 95% accuracy on a held-out IID validation set, in contrast to the dense 2-head model, which saturates around 80%. Note that ListOps is a classification task and does not use autoregressive masking.

We visualize the maximum of attention heads for each layer, both for the standard Transformer (Fig. 2a) and SwitchHead (Fig. 2b). The attention maps are qualitatively similar. Due to different initialization and learning dynamics, thus the overlap between the two models would not be perfect. Complete attention map visualizations can be found in Fig. 4 and 3 in the appendix.

In addition, we anlyze individual attention heads for SwitchHead. We find that it is often possible to interpret the selection weights: on synthetic tasks, the output experts specialize according to different operations , while the input ones distinguish numbers and closed parentheses. The attention map itself appears to distribute information about contiguous chunks of numbers (see Fig. 5 in the appendix).

Attention maps of the language models are more difficult to interpret. However, we visualize the attention maps of the 47M parameter Transformer XL and the SwitchHead model from Tab. 2. We find them to be qualitatively similar. We also identified induction heads [35] in both models, some examples shown for SwitchHead in Fig. 6a and for Transformer in Fig. 6b in the appendix. Other typical vertical line-lined attention patterns are shown in Fig. 6c and 6d.

5 Related Work

The method most closely related to ours is MoA [18], which introduces a MoE style attention. It defines each attention head as an expert but shares the key and value projections between them. Unlike in our Switchhead, each of the selected experts requires a separate attention matrix, which significantly increases its memory usage. Due to the use of a competitive softmax-based activation function in the selection network, it requires complex regularization to prevent expert collapse [17]. In the original formulation, the number of active heads is high. Our experiments also confirm that MoA needs many attention heads to match the performance of the dense baseline (see Sec. 3.2), and it is only possible to do so with a significantly higher resource budget than our method.

Nguyen et al. [36] analyze the attention matrices, and they conclude that they are usually low rank. Motivated by this, the authors construct a few (e.g., 2) "global attention matrices", and they compute each local matrix for specific heads by a weighted average of those. However, they average the logits,

B

[MED

[MED

[MIN 0

8 9

5 ]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN 2

6 ]

5 ]

1 5

4 ]

5 ]

] E

src

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

0.2

0.4

0.6

0.8

(a) Transformer, Layer 3

B

[MED

[MED

[MIN 0

8 9

5 ]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN 2

6 ]

5 ]

1 5

4 ]

5 ]

] E

src

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

0.2

0.4

0.6

0.8

(b) SwitchHead Layer 3

not the final matrix, so each individual head-specific matrix has to be computed. This means that in the best case, they can only save half of the computation associated with the attention matrix because the readout (Eq. 3) is still needed. For the same reason, memory savings are also low.

Peng et al. [19] propose to reweight the contribution of each head by a gating function. However, they only reduce the number of total attention heads by one, presumably to compensate for the parameters used by the selection logic. Their goal was not to reduce resource usage but to have better predictive performance, which they achieve. They use a softmax-based competitive selection mechanism. To avoid collapse, the gating function is trained only in some steps.

More broadly, there have been several works on MoE to accelerate language models. Shazeer et al. [11] introduce sparsely-gated mixture of experts. Fedus et al. [37] introduce Mixture of Experts in Transformers. Lepikhin et al. [13] train a MoE-based LLM, and Clark et al. [15] analyze the scaling laws of MoE models. Lewis et al. [12] introduce an alternative method for preventing collapse. However, none of these methods focus on the important, parameter-matched setting. Csordás et al. [17] introduce the non-competitive activation based MoE method, σ -MoE, which was shown to be successful in such a setting, but the authors only focused on accelerating the MLPs and not the attention.

Multi-Query attention [38] uses a single key and value projection that is shared between the heads while using multiple queries. Our findings show that such a configuration is suboptimal: using multiple output and value projections is the most important choice in our model design.

Dao et al. [39] provides a hardware-aware CUDA implementation of the entire attention layer, which avoids storing the attention matrix. By saving memory bandwidth in this way, they achieve a significant wall clock time speedup, despite that the attention matrix should be recomputed in the backward pass. This is orthogonal to our method and they can be combined for further acceleration.

6 Limitations

Our models are modest in size compared to the current state-of-art LLMs. However, training such models is estimated to cost millions of dollars, which we cannot afford. Instead, we aim to show the versatility of our model by choosing a diverse set of datasets, including Enwik 8, Wikitext 103, C4 and peS2o, and different positional encodings, such as Transformer-XL-style relative positional encoding and RoPE. We also demonstrate the competitiveness of our models in zero-shot downstream tasks. We believe that the evidence we provided is enough for a research group with a larger amount of resources at their disposal to verify our findings in a state-of-the-art model.

The Triton kernel that we used is currently around 60% of the speed of a single dense matrix multiplication of the size of a single expert with cuBLAS. Even this, we showed wall-clock time speedup. We estimate that 80-90% should be achievable with a more optimal kernel. Model-parallel training requires the implementation of a load-balancing system that can dynamically move experts between GPUs.

7 Conclusion

On a wide range of language modeling datasets with different model sizes, our novel Mixtureof-Experts (MoE) based attention method called SwitchHead achieves performance of parametermatched dense counterparts, with only a fraction of the computational cost and memory usage. SwitchHead drastically reduces the number of attention matrices that have to be computed, by using MoE for the value and output projections. Our method is stable and does not need additional regularization to prevent degenerate solutions (a well-known practical issue in many existing MoE models). Our method can also be successfully combined with MoE MLP layers, to obtain 'SwitchAll" where every layer of the Transformer is MoE-based, achieving a huge reduction in resource requirements.

References

Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. 2019.

Tom B Brown et al. Language models are few-shot learners. In Proc. Advances in Neural Information Processing Systems (NeurIPS) , Virtual only, December 2020.

OpenAI. Chatgpt. https://openai.com/blog/chatgpt , 2022.

OpenAI. GPT-4 technical report. Preprint arXiv:2303.08774 , 2023.

Sébastien Bubeck, Varun Chandrasekaran, Ronen Eldan, Johannes Gehrke, Eric Horvitz, Ece Kamar, Peter Lee, Yin Tat Lee, Yuanzhi Li, Scott M. Lundberg, Harsha Nori, Hamid Palangi, Marco Túlio Ribeiro, and Yi Zhang. Sparks of artificial general intelligence: Early experiments with GPT-4. Preprint arXiv:2303.12712 , 2023.

Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Proc. Advances in Neural Information Processing Systems (NIPS) , pages 5998-6008, Long Beach, CA, USA, December 2017.

Jürgen Schmidhuber. Learning to control fast-weight memories: An alternative to recurrent nets. Neural Computation , 4(1):131-139, 1992.

Georgi Gerganov. llama.cpp. https://github.com/ggerganov/llama.cpp , 2023.

John B. Hampshire II and Alexander H. Waibel. The meta-pi network: connectionist rapid adaptation for high-performance multi-speaker phoneme recognition. In Proc. IEEE Int. Conf. on Acoustics, Speech and Signal Processing (ICASSP) , pages 165-168, Albuquerque, New Mexico, USA, April 1990.

Robert A. Jacobs, Michael I. Jordan, Steven J. Nowlan, and Geoffrey E. Hinton. Adaptive mixtures of local experts. Neural Compututaion , 3(1):79-87, 1991.

Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton, and Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts layer. In Int. Conf. on Learning Representations (ICLR) , Toulon, France, April 2017.

Mike Lewis, Shruti Bhosale, Tim Dettmers, Naman Goyal, and Luke Zettlemoyer. BASE layers: Simplifying training of large, sparse models. In Proc. Int. Conf. on Machine Learning (ICML) , volume 139, pages 6265-6274, Virtual only, July 2021.

Dmitry Lepikhin, HyoukJoong Lee, Yuanzhong Xu, Dehao Chen, Orhan Firat, Yanping Huang, Maxim Krikun, Noam Shazeer, and Zhifeng Chen. GShard: Scaling giant models with conditional computation and automatic sharding. In Int. Conf. on Learning Representations (ICLR) , Virtual only, May 2021.

William Fedus, Barret Zoph, and Noam Shazeer. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. Journal of Machine Learning Research (JMLR) , 23(1):5232-5270, 2022.

Aidan Clark, Diego de Las Casas, Aurelia Guy, Arthur Mensch, Michela Paganini, Jordan Hoffmann, Bogdan Damoc, Blake A. Hechtman, Trevor Cai, Sebastian Borgeaud, George van den Driessche, Eliza Rutherford, Tom Hennigan, Matthew Johnson, Katie Millican, Albin Cassirer, Chris Jones, Elena Buchatskaya, David Budden, Laurent Sifre, Simon Osindero, Oriol Vinyals, Jack W. Rae, Erich Elsen, Koray Kavukcuoglu, and Karen Simonyan. Unified scaling laws for routed language models. Preprint arXiv:2202.01169 , 2022.

Zewen Chi, Li Dong, Shaohan Huang, Damai Dai, Shuming Ma, Barun Patra, Saksham Singhal, Payal Bajaj, Xia Song, Xian-Ling Mao, Heyan Huang, and Furu Wei. On the representation collapse of sparse mixture of experts. In Proc. Advances in Neural Information Processing Systems (NeurIPS) , New Orleans, Louisiana, USA, December 2022.

Róbert Csordás, Kazuki Irie, and Jürgen Schmidhuber. Approximating two-layer feedforward networks for efficient transformers. In Findings of the Association for Computational Linguistics: EMNLP 2023 , November 2023.

Xiaofeng Zhang, Yikang Shen, Zeyu Huang, Jie Zhou, Wenge Rong, and Zhang Xiong. Mixture of attention heads: Selecting attention heads per token. In Proc. Conf. on Empirical Methods in Natural Language Processing (EMNLP) , pages 4150-4162, Abu Dhabi, United Arab Emirates, December 2022.

Hao Peng, Roy Schwartz, Dianqi Li, and Noah A. Smith. A mixture of h - 1 heads is better than h heads. In Proc. Association for Computational Linguistics (ACL) , pages 6566-6577, Virtual only, July 2020.

Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research (JMLR) , 21:140:1-140:67, 2020.

Marcus Hutter. The human knowledge compression prize. http://prize.hutter1.net , 2006.

Luca Soldaini and Kyle Lo. peS2o (Pretraining Efficiently on S2ORC) Dataset. Technical report, Allen Institute for AI, 2023. https://github.com/allenai/pes2o .

Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. Pointer sentinel mixture models. In Int. Conf. on Learning Representations (ICLR) , Toulon, France, April 2017.

Denis Paperno, Germán Kruszewski, Angeliki Lazaridou, Quan Ngoc Pham, Raffaella Bernardi, Sandro Pezzelle, Marco Baroni, Gemma Boleda, and Raquel Fernández. The LAMBADA dataset: Word prediction requiring a broad discourse context. In Proc. Association for Computational Linguistics (ACL) , Berlin, Germany, August 2016.

Alex Warstadt, Alicia Parrish, Haokun Liu, Anhad Mohananey, Wei Peng, Sheng-Fu Wang, and Samuel R. Bowman. Blimp: The benchmark of linguistic minimal pairs for english. Transactions of the Association for Computational Linguistics (TACL) , 8:377-392, 2020.

Felix Hill, Antoine Bordes, Sumit Chopra, and Jason Weston. The goldilocks principle: Reading children's books with explicit memory representations. In Int. Conf. on Learning Representations (ICLR) , San Juan, Puerto Rico, May 2016.

Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aurélien Rodriguez, Armand Joulin, Edouard Grave, and Guillaume Lample. LLaMA: Open and efficient foundation language models. Preprint arXiv:2302.13971 , 2023.

Jianlin Su, Yu Lu, Shengfeng Pan, Bo Wen, and Yunfeng Liu. RoFormer: Enhanced transformer with rotary position embedding. Preprint arXiv:2104.09864 , 2021.

Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words with subword units. In Proc. Association for Computational Linguistics (ACL) , pages 1715-1725, Berlin, Germany, August 2016.

Mike Schuster and Kaisuke Nakajima. Japanese and korean voice search. In Proc. IEEE Int. Conf. on Acoustics, Speech and Signal Processing (ICASSP) , pages 5149-5152, Kyoto, Japan, March 2012.

Taku Kudo and John Richardson. Sentencepiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. In Proc. Conf. on Empirical Methods in Natural Language Processing (EMNLP) , pages 66-71, Brussels, Belgium, October 2018.

Zihang Dai, Zhilin Yang, Yiming Yang, Jaime G Carbonell, Quoc Le, and Ruslan Salakhutdinov. Transformer-XL: Attentive language models beyond a fixed-length context. In Proc. Association for Computational Linguistics (ACL) , pages 2978-2988, Florence, Italy, 2019.

Nikita Nangia and Samuel R. Bowman. ListOps: A diagnostic dataset for latent tree learning. In Proc. North American Chapter of the Association for Computational Linguistics on Human Language Technologies (NAACL-HLT) , pages 92-99, New Orleans, USA, June 2018.

Róbert Csordás, Kazuki Irie, and Jürgen Schmidhuber. The neural data router: Adaptive control flow in transformers improves systematic generalization. In Int. Conf. on Learning Representations (ICLR) , Virtual only, April 2022.

Catherine Olsson, Nelson Elhage, Neel Nanda, Nicholas Joseph, Nova DasSarma, Tom Henighan, Ben Mann, Amanda Askell, Yuntao Bai, Anna Chen, Tom Conerly, Dawn Drain, Deep Ganguli, Zac Hatfield-Dodds, Danny Hernandez, Scott Johnston, Andy Jones, Jackson Kernion, Liane Lovitt, Kamal Ndousse, Dario Amodei, Tom Brown, Jack Clark, Jared Kaplan, Sam McCandlish, and Chris Olah. In-context learning and induction heads. Transformer Circuits Thread , 2022. https://transformer-circuits.pub/2022/in-context-learning-and-inductionheads/index.html.

Tan Nguyen, Tam Nguyen, Hai Do, Khai Nguyen, Vishwanath Saragadam, Minh Pham, Duy Khuong Nguyen, Nhat Ho, and Stanley J. Osher. Improving transformer with an admixture of attention heads. In Proc. Advances in Neural Information Processing Systems (NeurIPS) , New Orleans, LA, USA, November 2022.

William Fedus, Barret Zoph, and Noam Shazeer. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. Preprint arXiv:2101.03961 , 2021.

Noam Shazeer. Fast transformer decoding: One write-head is all you need. Preprint arXiv:1911.02150 , 2019.

Tri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra, and Christopher Ré. FlashAttention: Fast and memory-efficient exact attention with IO-awareness. In Proc. Advances in Neural Information Processing Systems (NeurIPS) , New Orleans, Louisiana, USA, December 2022.

Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In Int. Conf. on Learning Representations (ICLR) , San Diego, CA, USA, May 2015.

A Appendix

A.1 A Comment on Flash Attention

The resource reductions from Flash Attention might be, in many cases, larger than those from our method alone. However, Flash Attention depends on GPU-specific memory bandwidth/compute trade-offs, which might not be available on all hardware, especially on edge devices. SwitchHead and FlashAttention can also be combined for further speedups. We demonstrated the viability of this setup in our RoPE experiments. Additionally, certain architectures, such as shared-layer transformers, might require a drastic increase in the number of heads, which FlashAttention alone might not be able to do.

A.2 Resource Usage of Different Methods

In this section, we discuss the compute and memory usage of different attention variants. We will define the compute in terms of the number of multiply-accumulate operations (MACs, also used by Zhang et al. [18]), which is arguably better defined than FLOPs (e.g., does one step of the matrix multiplication count as 1 FLOP or 2? Do we include the softmax?). All calculations will be presented for a single attention layer for a single sequence, and they are presented this way in all our tables. Both the memory and compute requirements scale linearly with both the batch size and the number of layers.

Consider a sequence of inputs of length T , with representation size d model. Let d head be the width of the key, query and value projections used for the attention layer. For Transformer XL-style attention, let the size of the context be CT , where C -1 is the number of past chunks included in the context of the current attention step. We can divide the computation into two major parts: calculating the projections, which do not involve the attention map, and calculating the attention map and projecting the sequence of values using it.

First, consider the case of the standard Transformer XL [32]. Here, from the input x ∈ R T × d model , we calculate the K h , Q h , V h ∈ R T × d head using projection matrices of shape R d model × d head . The output after the attention is projected in a similar manner (Eq. 3). Thus, the projections take a total of 4 Td model d head MACs per head. For backpropagation, we have to store all the intermediate results. This takes Td head numbers of K h , Q h and V h . Also, the projected values should be stored. They have an identical shape, therefore, the total memory used by projections is 4 Td head numbers per head. Now consider the resource usage related to the attention matrix. It involves calculating the product of Q h K h ⊺ , which takes d head CT 2 MACs (multiplication by C is needed because the shape of K h and V h for Transformer XL is CT × d head). The projection of the values with the attention matrix A h V h is similar. For the memory usage, the attention needs CT 2 numbers, but it needs to be stored both before and after the activation function. In addition, calculating the projection of the position encodings is necessary. This depends on the implementation, but in our case, it involves a matrix multiplication, and the total amount of computation is 2 d head d model TC , and it needs 2 d head TC numbers of storage. Thus the resource requirements are:

The resource usage of SwitchHead is different. First, the number of heads n heads is significantly reduced, but d head is typically larger. Additionally, there are k experts active at the same time. Here, we only consider the case where the value and outputs are experts, but Q h and K h are not (this version performs the best; see Sec. 3.1). Then, we have two projections that are identical with that of Transformer XL, and two MoE-based projections. These use Tkd model d head MACs to calculate the projection and another Tkd head to calculate their weighted average. With a smart kernel implementation, memory usage is not affected by k , thus the formula remains the same as Eq. 12 (note, however, that n heads and d head are very different in practice). The compute requirement can be calculated as:

Additionally, the expert selection logic needs minimal additional resources, which can be ignored. Note that the comparison between the MACs of the standard (Eq. 11) and SwitchHead (Eq. 13) depends on the exact values of the hyper-parameters. However, as we'll see in Sec. 3, in our typical

configurations, SwitchHead provides good predictive performance with significantly lower n heads compared to the standard Transformer, resulting in reduced resource usage in the end.

The resource requirements of MoA [19] are very similar to those of Transformer XL , except that it uses a single shared key and value projection for each head.

A.3 The Importance of Different Projections

In order to analyze which projections are the most important to be mixture-of-experts, we exhaustively tried all combinations. We analyze our 47M parameter models on WikiText 103 dataset. We show the results in Tab. 6. We also include a parameter-matched baseline with two heads, which serves as a lower bound for the performance. We found that the value and output projections are the most important, and having key and query projections hurts the performance. This is possible because we perform all our experiments in a parameter-matched setting. Allocating parameters to these projections uses the budget that can be otherwise spent on other parts of the network. In our preliminary experiments, we found that, allowing the parameter budget to increase, more experts always help.

A.4 RoPE Positional Encodings

All of our experiments in the main paper have used a Transformer XL model. Thus, it remains unclear whether SwitchHead is specific to this model or can be also used with other attention methods. As an alternative, we consider RoPE positional encodings [28] without the XL cache (thus, the attention matrices are square). This is the standard setup used by modern language models, such as all versions of Llama [27]. We tested these models in Wikitext 103 and C4. The results are shown in Tab. 7, and zero-shot performance on downstream tasks in Tab. 8. This shows that SwitchHead also performs well in the standard setup and is not tied to Transformer XL.

A.5 Hyperparameters

We train all our models with Adam optimizer [40], with a batch size of 64, a learning rate of 0.00025, and gradient clipping with a maximum norm of κ . Large models ( > 200 K parameters) use a learning

rate warm-up of 4k steps. All models, except the SwitchAll model, use a dropout on the MLP layers, 0 . 1 for the small models and 0 . 2 for the large ones. Detailed hyperparameters are shown in the Tab. 9. σ -MoE related hyperparameters for the SwitchAll models are identical to those of Csordás et al. [17]. For Transformer XL models, we always use a single additional chunk of context, both in training and validation time. d head and d ff are derived in a systematic way, see Sec. 3 for more details.

A.6 A Note on the Parameter Count of the SwitchAll

It can be seen in Tab. 3 that the parameter count of the SwitchAll models is often less than that of their dense counterparts. The reason is that we normally compensate for the final difference in the number of parameters by increasing d ff (see Sec. 3 for details of the parameter matching). However, that can only be done in a very coarse-grained way with σ -MoE: the size of all experts must be increased at once, and the CUDA kernel supports only sizes of multiple of 4. Therefore, increasing the size of the experts would add too many parameters and the model would outgrow the baseline. For this reason, we simply keep the hyperparameters for Csordás et al. [17] and combine them with our SwitchHead configuration from Tab. 2.

A.7 Visalizing all Attention Heads

As discussed in Sec. 4, we analyze the attention maps of SwitchHead and compare them with the dense models. We show all the attention maps of the models trained on ListOps in Fig. 3 and Fig. 3. We show individual heads of SwitchHead, including the expert selection scores in Fig. 5. Some selected attention maps of our 47M parameter models on Wikitext 103 are shown in Fig. 6.

A.8 Compute Requirements

We report the compute used for our experiments, including the GPU type, count (the number of GPUs used per experiment, and not the total in the machine), and the runtime in 'hh:mm' format

in Tab. 10. We report the total number of CPUs ( N CPU) and RAM because they are shared between concurrent runs. Note that most of the experiments were done prior to the much faster, Triton-based kernel implementation. Because of this, the runtimes appear longer for SwitcHead compared to the baseline. For timing benchmarks with our new kernel, see Tab. 5.

Note that we only report the resources used for the paper here. We estimate that the total cost of the failed experiments and preliminary runs is around 10 times higher than this.

B

[MED

[MED

[MIN 0

8 9

5 ]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN 2

6 ]

5 ]

1 5

4 ]

5 ]

] E

src

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

(a) Layer 1

B

[MED

[MED

[MIN 0

8 9

5 ]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN 2

6 ]

5 ]

1 5

4 ]

5 ]

] E

src

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

0.2

0.4

0.6

0.8

(b) Layer 2

B

[MED

[MED

[MIN 0

8 9

5 ]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN 2

6 ]

5 ]

1 5

4 ]

5 ]

] E

src

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

0.2

0.4

0.6

0.8

(c) Layer 3

B

[MED

[MED

[MIN 0

8 9

5 ]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN 2

6 ]

5 ]

1 5

4 ]

5 ]

] E

src

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

0.025

0.050

0.075

0.100

0.125

0.150

0.175

(d) Layer 4

B

[MED

[MED

[MIN 0

8 9

5 ]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN 2

6 ]

5 ]

1 5

4 ]

5 ]

] E

src

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

0.05

0.10

0.15

0.20

0.25

(e) Layer 5

B

[MED

[MED

[MIN 0

8 9

5 ]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN 2

6 ]

5 ]

1 5

4 ]

5 ]

] E

src

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

0.05

0.10

0.15

0.20

0.25

0.30

0.35

(f) Layer 6

1111111-111

B

[MED

[MED

[MIN 0

8 9

5 ]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN 2

6 ]

5 ]

1 5

4 ]

5 ]

] E

src

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

0.2

0.4

0.6

0.8

(a) Layer 1

B

[MED

[MED

[MIN 0

8 9

5 ]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN 2

6 ]

5 ]

1 5

4 ]

5 ]

] E

src

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

0.2

0.4

0.6

0.8

(b) Layer 2

B

[MED

[MED

[MIN 0

8 9

5 ]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN 2

6 ]

5 ]

1 5

4 ]

5 ]

] E

src

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

0.2

0.4

0.6

0.8

(c) Layer 3

B

[MED

[MED

[MIN 0

8 9

5 ]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN 2

6 ]

5 ]

1 5

4 ]

5 ]

] E

src

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

0.2

0.4

0.6

0.8

(d) Layer 4

B

[MED

[MED

[MIN 0

8 9

5 ]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN 2

6 ]

5 ]

1 5

4 ]

5 ]

] E

src

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

(e) Layer 5

B

[MED

[MED

[MIN 0

8 9

5 ]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN 2

6 ]

5 ]

1 5

4 ]

5 ]

] E

src

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

0.05

0.10

0.15

0.20

0.25

0.30

0.35

0.40

(f) Layer 6

PTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

o

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

B

[MED

[MED

[MIN

0 8

9 5

]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN

2 6

]

5 ]

1 5

4 ]

5 ]

] E

src

v

(a) Layer 1, head 1

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

o

0.05

0.10

0.15

0.20

0.25

0.30

0.35

B

[MED

[MED

[MIN

0 8

9 5

]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN

2 6

]

5 ]

1 5

4 ]

5 ]

] E

src

v

(b) Layer 1, head 2

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

o

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

B

[MED

[MED

[MIN

0 8

9 5

]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN

2 6

]

5 ]

1 5

4 ]

5 ]

] E

src

v

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

o

0.2

0.4

0.6

0.8

B

[MED

[MED

[MIN

0 8

9 5

]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN

2 6

]

5 ]

1 5

4 ]

5 ]

] E

src

v

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

o

0.2

0.4

0.6

0.8

B

[MED

[MED

[MIN

0 8

9 5

]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN

2 6

]

5 ]

1 5

4 ]

5 ]

] E

src

v

(e) Layer 3, head 1

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

o

0.0

0.2

0.4

0.6

0.8

B

[MED

[MED

[MIN

0 8

9 5

]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN

2 6

]

5 ]

1 5

4 ]

5 ]

] E

src

v

(f) Layer 3, head 2

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

o

0.025

0.050

0.075

0.100

0.125

0.150

0.175

B

[MED

[MED

[MIN 0

8 9

5 ]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN 2

6 ]

5 ]

1 5

4 ]

5 ]

] E

src

v

(g) Layer 4, head 1

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

o

0.02

0.04

0.06

0.08

0.10

0.12

0.14

0.16

B

[MED

[MED

[MIN

0 8

9 5

]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN

2 6

]

5 ]

1 5

4 ]

5 ]

] E

src

v

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

o

0.05

0.10

0.15

0.20

0.25

B

[MED

[MED

[MIN

0 8

9 5

]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN

2 6

]

5 ]

1 5

4 ]

5 ]

] E

src

v

(i) Layer 5, head 1

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

o

0.02

0.04

0.06

0.08

0.10

0.12

0.14

0.16

B

[MED

[MED

[MIN

0 8

9 5

]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN

2 6

]

5 ]

1 5

4 ]

5 ]

] E

src

v

(j) Layer 5, head 2

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

o

0.05

0.10

0.15

0.20

0.25

0.30

0.35

B

[MED

[MED

[MIN

0 8

9 5

]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN

2 6

]

5 ]

1 5

4 ]

5 ]

] E

src

v

(k) Layer 6, head 1

B

[MED

[MED

[MIN

0

8

9

5

]

8

8

0

9

]

6

9

6

[MAX

7

6

[MAX

4

[MAX

5

[MAX

3

8

0

8

]

[MIN

2

6

]

5

]

1

5

4

]

5

]

]

E

dest

o

0.025

0.050

0.075

0.100

0.125

0.150

0.175

0.200

B

[MED

[MED

[MIN 0

8 9

5 ]

8 8

0 9

]

6 9 6

[MAX 7 6

[MAX 4

[MAX 5

[MAX 3

8 0

8 ]

[MIN 2

6 ]

5 ]

1 5

4 ]

5 ]

] E

src

v

(l) Layer 6, head 2

TTTTTTT

lob

ster

red

"

on

cook

ing

. M

ating

occurs

in

the

summer

,

producing

eggs

which

are

car ied

by

the

females

for

up

to

a

year

before

h

atch

ing

into

pl

ank

ton

ic

lar

v

ae

. H

om ar

us

g

am

us

is

a

highly

est

e

emed

food

,

and

is

widely

caught

using

lob

ster

p

ots

,

mostly

around

the

British

Is

les

.

= =

Desc

ription

= = H

om ar

us

g

am

us

is

a

large

cr

ust

ace

an

,

with

a

body

length

up

to

6

0

cent

imet

res

(

2

4

in

)

and

we

igh

ing

up

to

5

6

kil

og

rams

src

ster

red

"

on

cook

ing

.

M

ating

occurs

in

the

summer

,

producing

eggs

which

are

car ied

by

the

females

for

up

to

a

year

before

h

atch

ing

into

pl

ank

ton

ic

lar

v

ae

.

H

om

ar

us

g

am

us

is

a

highly

est

e

emed

food

,

and

is

widely

caught

using

lob

ster

p

ots

,

mostly

around

the

British

Is

les

.

=

=

Desc

ription

=

=

H

om

ar

us

g

am

us

is

a

large

cr

ust

ace

an

,

with

a

body

length

up

to

6

0

cent

imet

res

(

2

4

in

)

and

we

igh

ing

up

to

5

6

kil

og

rams

(

dest

0.0

0.2

0.4

0.6

0.8

(a) SwitchHead Layer 12. Induction head.

lob

ster

red

"

on

cook

ing

. M

ating

occurs

in

the

summer

,

producing

eggs

which

are

car ied

by

the

females

for

up

to

a

year

before

h

atch

ing

into

pl

ank

ton

ic

lar

v

ae

. H

om ar

us

g

am

us

is

a

highly

est

e

emed

food

,

and

is

widely

caught

using

lob

ster

p

ots

,

mostly

around

the

British

Is

les

.

= =

Desc

ription

= = H

om ar

us

g

am

us

is

a

large

cr

ust

ace

an

,

with

a

body

length

up

to

6

0

cent

imet

res

(

2

4

in

)

and

we

igh

ing

up

to

5

6

kil

og

rams

src

ster

red

"

on

cook

ing

.

M

ating

occurs

in

the

summer

,

producing

eggs

which

are

car ied

by

the

females

for

up

to

a

year

before

h

atch

ing

into

pl

ank

ton

ic

lar

v

ae

.

H

om

ar

us

g

am

us

is

a

highly

est

e

emed

food

,

and

is

widely

caught

using

lob

ster

p

ots

,

mostly

around

the

British

Is

les

.

=

=

Desc

ription

=

=

H

om

ar

us

g

am

us

is

a

large

cr

ust

ace

an

,

with

a

body

length

up

to

6

0

cent

imet

res

(

2

4

in

)

and

we

igh

ing

up

to

5

6

kil

og

rams

(

dest

0.0

0.2

0.4

0.6

0.8

(b) Transformer XL Layer 10. Induction head.

lob

ster

red

"

on

cook

ing

. M

ating

occurs

in

the

summer

,

producing

eggs

which

are

car ied

by

the

females

for

up

to

a

year

before

h

atch

ing

into

pl

ank

ton

ic

lar

v

ae

. H

om ar

us

g

am

us

is

a

highly

est

e

emed

food

,

and

is

widely

caught

using

lob

ster

p

ots

,

mostly

around

the

British

Is

les

.

= =

Desc

ription

= = H

om ar

us

g

am

us

is

a

large

cr

ust

ace

an

,

with

a

body

length

up

to

6

0

cent

imet

res

(

2

4

in

)

and

we

igh

ing

up

to

5

6

kil

og

rams

src

ster

red

"

on

cook

ing

.

M

ating

occurs

in

the

summer

,

producing

eggs

which

are

car ied

by

the

females

for

up

to

a

year

before

h

atch

ing

into

pl

ank

ton

ic

lar

v

ae

.

H

om

ar

us

g

am

us

is

a

highly

est

e

emed

food

,

and

is

widely

caught

using

lob

ster

p

ots

,

mostly

around

the

British

Is

les

.

=

=

Desc

ription

=

=

H

om

ar

us

g

am

us

is

a

large

cr

ust

ace

an

,

with

a

body

length

up

to

6

0

cent

imet

res

(

2

4

in

)

and

we

igh

ing

up

to

5

6

kil

og

rams

(

dest

0.0

0.2

0.4

0.6

0.8

(c) SwitchHead Layer 9. Stripe pattern.

lob

ster

red

"

on

cook

ing

. M

ating

occurs

in

the

summer

,

producing

eggs

which

are

car ied

by

the

females

for

up

to

a

year

before

h

atch

ing

into

pl

ank

ton

ic

lar

v

ae

. H

om ar

us

g

am

us

is

a

highly

est

e

emed

food

,

and

is

widely

caught

using

lob

ster

p

ots

,

mostly

around

the

British

Is

les

.

= =

Desc

ription

= = H

om ar

us

g

am

us

is

a

large

cr

ust

ace

an

,

with

a

body

length

up

to

6

0

cent

imet

res

(

2

4

in

)

and

we

igh

ing

up

to

5

6

kil

og

rams

src

ster

red

"

on

cook

ing

.

M

ating

occurs

in

the

summer

,

producing

eggs

which

are

car ied

by

the

females

for

up

to

a

year

before

h

atch

ing

into

pl

ank

ton

ic

lar

v

ae

.

H

om

ar

us

g

am

us

is

a

highly

est

e

emed

food

,

and

is

widely

caught

using

lob

ster

p

ots

,

mostly

around

the

British

Is

les

.

=

=

Desc

ription

=

=

H

om

ar

us

g

am

us

is

a

large

cr

ust

ace

an

,

with

a

body

length

up

to

6

0

cent

imet

res

(

2

4

in

)

and

we

igh

ing

up

to

5

6

kil

og

rams

(

dest

0.0

0.2

0.4

0.6

0.8

(d) Transformer XL Layer 8. Stripe pattern.

NeurIPS Paper Checklist

1. Claims

Question: Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope?

Answer: [Yes]

Justification: We summarized the motivation, method, and main findings in these sections.

Guidelines:

The answer NA means that the abstract and introduction do not include the claims made in the paper.

The abstract and/or introduction should clearly state the claims made, including the contributions made in the paper and important assumptions and limitations. A No or NA answer to this question will not be perceived well by the reviewers.

The claims made should match theoretical and experimental results, and reflect how much the results can be expected to generalize to other settings.

It is fine to include aspirational goals as motivation as long as it is clear that these goals are not attained by the paper.

2. Limitations

Question: Does the paper discuss the limitations of the work performed by the authors?

Answer: [Yes]

Justification: We discuss the limitations in Sec. 6.

Guidelines:

The answer NA means that the paper has no limitation while the answer No means that the paper has limitations, but those are not discussed in the paper.

The authors are encouraged to create a separate "Limitations" section in their paper.

The paper should point out any strong assumptions and how robust the results are to violations of these assumptions (e.g., independence assumptions, noiseless settings, model well-specification, asymptotic approximations only holding locally). The authors should reflect on how these assumptions might be violated in practice and what the implications would be.

The authors should reflect on the scope of the claims made, e.g., if the approach was only tested on a few datasets or with a few runs. In general, empirical results often depend on implicit assumptions, which should be articulated.

The authors should reflect on the factors that influence the performance of the approach. For example, a facial recognition algorithm may perform poorly when image resolution is low or images are taken in low lighting. Or a speech-to-text system might not be used reliably to provide closed captions for online lectures because it fails to handle technical jargon.

The authors should discuss the computational efficiency of the proposed algorithms and how they scale with dataset size.

If applicable, the authors should discuss possible limitations of their approach to address problems of privacy and fairness.

While the authors might fear that complete honesty about limitations might be used by reviewers as grounds for rejection, a worse outcome might be that reviewers discover limitations that aren't acknowledged in the paper. The authors should use their best judgment and recognize that individual actions in favor of transparency play an important role in developing norms that preserve the integrity of the community. Reviewers will be specifically instructed to not penalize honesty concerning limitations.

3. Theory Assumptions and Proofs

Question: For each theoretical result, does the paper provide the full set of assumptions and a complete (and correct) proof?

Answer: [NA]

Justification: This is an empirical paper.

Guidelines:

The answer NA means that the paper does not include theoretical results.

All the theorems, formulas, and proofs in the paper should be numbered and crossreferenced.

All assumptions should be clearly stated or referenced in the statement of any theorems.

The proofs can either appear in the main paper or the supplemental material, but if they appear in the supplemental material, the authors are encouraged to provide a short proof sketch to provide intuition.

Inversely, any informal proof provided in the core of the paper should be complemented by formal proofs provided in appendix or supplemental material.

Theorems and Lemmas that the proof relies upon should be properly referenced.

4. Experimental Result Reproducibility

Question: Does the paper fully disclose all the information needed to reproduce the main experimental results of the paper to the extent that it affects the main claims and/or conclusions of the paper (regardless of whether the code and data are provided or not)?

Answer: [Yes]

Justification: We show all the hyperparameter configurations in Appendix A.5, and we provide the code for our experiments.

Guidelines:

The answer NA means that the paper does not include experiments.

If the paper includes experiments, a No answer to this question will not be perceived well by the reviewers: Making the paper reproducible is important, regardless of whether the code and data are provided or not.

If the contribution is a dataset and/or model, the authors should describe the steps taken to make their results reproducible or verifiable.

Depending on the contribution, reproducibility can be accomplished in various ways. For example, if the contribution is a novel architecture, describing the architecture fully might suffice, or if the contribution is a specific model and empirical evaluation, it may be necessary to either make it possible for others to replicate the model with the same dataset, or provide access to the model. In general. releasing code and data is often one good way to accomplish this, but reproducibility can also be provided via detailed instructions for how to replicate the results, access to a hosted model (e.g., in the case of a large language model), releasing of a model checkpoint, or other means that are appropriate to the research performed.

While NeurIPS does not require releasing code, the conference does require all submissions to provide some reasonable avenue for reproducibility, which may depend on the nature of the contribution. For example

(a) If the contribution is primarily a new algorithm, the paper should make it clear how to reproduce that algorithm.

(b) If the contribution is primarily a new model architecture, the paper should describe the architecture clearly and fully.

(c) If the contribution is a new model (e.g., a large language model), then there should either be a way to access this model for reproducing the results or a way to reproduce the model (e.g., with an open-source dataset or instructions for how to construct the dataset).

(d) We recognize that reproducibility may be tricky in some cases, in which case authors are welcome to describe the particular way they provide for reproducibility. In the case of closed-source models, it may be that access to the model is limited in some way (e.g., to registered users), but it should be possible for other researchers to have some path to reproducing or verifying the results.

5. Open access to data and code

Question: Does the paper provide open access to the data and code, with sufficient instructions to faithfully reproduce the main experimental results, as described in supplemental material?

Answer: [Yes]

Justification: We provide the code for our experiments. It automatically downloads all the data that it needs.

Guidelines:

The answer NA means that paper does not include experiments requiring code.

Please see the NeurIPS code and data submission guidelines ( https://nips.cc/ public/guides/CodeSubmissionPolicy ) for more details.

While we encourage the release of code and data, we understand that this might not be possible, so 'No' is an acceptable answer. Papers cannot be rejected simply for not including code, unless this is central to the contribution (e.g., for a new open-source benchmark).

The instructions should contain the exact command and environment needed to run to reproduce the results. See the NeurIPS code and data submission guidelines ( https: //nips.cc/public/guides/CodeSubmissionPolicy ) for more details.

The authors should provide instructions on data access and preparation, including how to access the raw data, preprocessed data, intermediate data, and generated data, etc.

The authors should provide scripts to reproduce all experimental results for the new proposed method and baselines. If only a subset of experiments are reproducible, they should state which ones are omitted from the script and why.

At submission time, to preserve anonymity, the authors should release anonymized versions (if applicable).

Providing as much information as possible in supplemental material (appended to the paper) is recommended, but including URLs to data and code is permitted.

6. Experimental Setting/Details

Question: Does the paper specify all the training and test details (e.g., data splits, hyperparameters, how they were chosen, type of optimizer, etc.) necessary to understand the results?

Answer: [Yes]

Justification: Our methodology is explained in Sec. 3, and the full table of hyperparameters is presented in Appendix A.5.

Guidelines:

The answer NA means that the paper does not include experiments.

The experimental setting should be presented in the core of the paper to a level of detail that is necessary to appreciate the results and make sense of them.

The full details can be provided either with the code, in appendix, or as supplemental material.

7. Experiment Statistical Significance

Question: Does the paper report error bars suitably and correctly defined or other appropriate information about the statistical significance of the experiments?

Answer: [No]

Justification: Our experiments involve large models that are very expensive to train, and we do not have sufficient compute resources to run multiple seeds of them.

Guidelines:

The answer NA means that the paper does not include experiments.

The authors should answer "Yes" if the results are accompanied by error bars, confidence intervals, or statistical significance tests, at least for the experiments that support the main claims of the paper.

The factors of variability that the error bars are capturing should be clearly stated (for example, train/test split, initialization, random drawing of some parameter, or overall run with given experimental conditions).

The method for calculating the error bars should be explained (closed form formula, call to a library function, bootstrap, etc.)

The assumptions made should be given (e.g., Normally distributed errors).

It should be clear whether the error bar is the standard deviation or the standard error of the mean.

It is OK to report 1-sigma error bars, but one should state it. The authors should preferably report a 2-sigma error bar than state that they have a 96% CI, if the hypothesis of Normality of errors is not verified.

For asymmetric distributions, the authors should be careful not to show in tables or figures symmetric error bars that would yield results that are out of range (e.g. negative error rates).

If error bars are reported in tables or plots, The authors should explain in the text how they were calculated and reference the corresponding figures or tables in the text.

8. Experiments Compute Resources

Question: For each experiment, does the paper provide sufficient information on the computer resources (type of compute workers, memory, time of execution) needed to reproduce the experiments?

Answer: [Yes]

Justification: We report the type of hardware used for our main experiments in Appendix A.8.

Guidelines:

The answer NA means that the paper does not include experiments.

The paper should indicate the type of compute workers CPU or GPU, internal cluster, or cloud provider, including relevant memory and storage.

The paper should provide the amount of compute required for each of the individual experimental runs as well as estimate the total compute.

The paper should disclose whether the full research project required more compute than the experiments reported in the paper (e.g., preliminary or failed experiments that didn't make it into the paper).

9. Code Of Ethics

Question: Does the research conducted in the paper conform, in every respect, with the NeurIPS Code of Ethics https://neurips.cc/public/EthicsGuidelines ?

Answer: [Yes]

Justification: We read the Ethics guidelines, and to the best of our knowledge, we are complying with it.

Guidelines:

The answer NA means that the authors have not reviewed the NeurIPS Code of Ethics.

If the authors answer No, they should explain the special circumstances that require a deviation from the Code of Ethics.

The authors should make sure to preserve anonymity (e.g., if there is a special consideration due to laws or regulations in their jurisdiction).

10. Broader Impacts

Question: Does the paper discuss both potential positive societal impacts and negative societal impacts of the work performed?

Answer: [Yes]

Justification: We consider our paper to be a foundational research paper without direct consequences.

Guidelines:

The answer NA means that there is no societal impact of the work performed.

If the authors answer NA or No, they should explain why their work has no societal impact or why the paper does not address societal impact.

Examples of negative societal impacts include potential malicious or unintended uses (e.g., disinformation, generating fake profiles, surveillance), fairness considerations (e.g., deployment of technologies that could make decisions that unfairly impact specific groups), privacy considerations, and security considerations.

The conference expects that many papers will be foundational research and not tied to particular applications, let alone deployments. However, if there is a direct path to any negative applications, the authors should point it out. For example, it is legitimate to point out that an improvement in the quality of generative models could be used to generate deepfakes for disinformation. On the other hand, it is not needed to point out that a generic algorithm for optimizing neural networks could enable people to train models that generate Deepfakes faster.

The authors should consider possible harms that could arise when the technology is being used as intended and functioning correctly, harms that could arise when the technology is being used as intended but gives incorrect results, and harms following from (intentional or unintentional) misuse of the technology.

If there are negative societal impacts, the authors could also discuss possible mitigation strategies (e.g., gated release of models, providing defenses in addition to attacks, mechanisms for monitoring misuse, mechanisms to monitor how a system learns from feedback over time, improving the efficiency and accessibility of ML).

11. Safeguards

Question: Does the paper describe safeguards that have been put in place for responsible release of data or models that have a high risk for misuse (e.g., pretrained language models, image generators, or scraped datasets)?

Answer: [NA]

Justification: The models in this paper are small by modern standards and we do not release pre-trained weights.

Guidelines:

The answer NA means that the paper poses no such risks.

Released models that have a high risk for misuse or dual-use should be released with necessary safeguards to allow for controlled use of the model, for example by requiring that users adhere to usage guidelines or restrictions to access the model or implementing safety filters.

Datasets that have been scraped from the Internet could pose safety risks. The authors should describe how they avoided releasing unsafe images.

We recognize that providing effective safeguards is challenging, and many papers do not require this, but we encourage authors to take this into account and make a best faith effort.

12. Licenses for existing assets

Question: Are the creators or original owners of assets (e.g., code, data, models), used in the paper, properly credited and are the license and terms of use explicitly mentioned and properly respected?

Answer: [Yes]

Justification: Justification: Our code is under MIT license and the paper is CC-BY 4.0. To the best of our knowledge, we always credit the reused code if we reuse any.

Guidelines:

The answer NA means that the paper does not use existing assets.

The authors should cite the original paper that produced the code package or dataset.

The authors should state which version of the asset is used and, if possible, include a URL.

The name of the license (e.g., CC-BY 4.0) should be included for each asset.

For scraped data from a particular source (e.g., website), the copyright and terms of service of that source should be provided.

If assets are released, the license, copyright information, and terms of use in the package should be provided. For popular datasets, paperswithcode.com/datasets has curated licenses for some datasets. Their licensing guide can help determine the license of a dataset.

For existing datasets that are re-packaged, both the original license and the license of the derived asset (if it has changed) should be provided.

If this information is not available online, the authors are encouraged to reach out to the asset's creators.

13. New Assets

Question: Are new assets introduced in the paper well documented and is the documentation provided alongside the assets?

Answer: [Yes]

Justification: We provide the source code and instructions on how to run it.

Guidelines:

The answer NA means that the paper does not release new assets.

Researchers should communicate the details of the dataset/code/model as part of their submissions via structured templates. This includes details about training, license, limitations, etc.

The paper should discuss whether and how consent was obtained from people whose asset is used.

At submission time, remember to anonymize your assets (if applicable). You can either create an anonymized URL or include an anonymized zip file.

14. Crowdsourcing and Research with Human Subjects

Question: For crowdsourcing experiments and research with human subjects, does the paper include the full text of instructions given to participants and screenshots, if applicable, as well as details about compensation (if any)?

Answer: [NA]

Justification: We do not work with human subjects.

Guidelines:

The answer NA means that the paper does not involve crowdsourcing nor research with human subjects.

Including this information in the supplemental material is fine, but if the main contribution of the paper involves human subjects, then as much detail as possible should be included in the main paper.

According to the NeurIPS Code of Ethics, workers involved in data collection, curation, or other labor should be paid at least the minimum wage in the country of the data collector.

15. Institutional Review Board (IRB) Approvals or Equivalent for Research with Human Subjects

Question: Does the paper describe potential risks incurred by study participants, whether such risks were disclosed to the subjects, and whether Institutional Review Board (IRB) approvals (or an equivalent approval/review based on the requirements of your country or institution) were obtained?

Answer: [NA]

Justification: We do not work with human subjects.

Guidelines:

The answer NA means that the paper does not involve crowdsourcing nor research with human subjects.

Depending on the country in which research is conducted, IRB approval (or equivalent) may be required for any human subjects research. If you obtained IRB approval, you should clearly state this in the paper.

We recognize that the procedures for this may vary significantly between institutions and locations, and we expect authors to adhere to the NeurIPS Code of Ethics and the guidelines for their institution.

For initial submissions, do not include any information that would break anonymity (if applicable), such as the institution conducting the review.

Peer reviews:
{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper introduces SwitchHead, a novel MoE architecture for the attention layer. Unlike the existing MoA approach, which computes the output of the attention layer as a weighted average of the top-k heads determined by a learnable routing mechanism, SwitchHead independently applies expert mixtures to the heads' key, value, and output projections. This design allows SwitchHead to achieve comparable or superior performance to MoA and dense Transformers while requiring less computational power.  The reduced compute cost is achieved by performing fewer matrix multiplications: since fewer heads need to be instantiated, the attention matrix operations are performed less frequently (same number of params is ensured by setting d_head accordingly). Reduced memory cost is achieved by having to store less activations for the backward pass. The paper points out that only applying MoE to value and output projection in each head performs sufficiently well as compared to applying MoE to the key and query projections as well.\n\nSTRENGTHS:\nOverall, this is a well-crafted paper that presents a straightforward yet effective method for efficiently integrating MoE layers into self-attention blocks.\n\nOriginality: good. The idea of implementing of transforming self-attention into an MoE is not new, yet the specific method presented and analyzed here is novel enough.\n\nQuality: good. The claims are well supported by evidences. Experiments are well designed and seem to be sufficient overall.\n\nClarity: the paper is well organized. In terms of writing, some formulations require further clarifications (see weaknesses/questions)\n\nSignificance: good. The paper makes a moderate contribution to the field and can potentially impacting future research.\n\nWEAKNESSES:\nI cannot identify any fundamental weaknesses with the paper beyond several confusing passages that might require further clarification, and a couple of potentially missing citations (see questions).\n\nQUESTIONS:\n- similar techniques for transforming attention heads into MoE have been proposed in the context of parameter efficient MoEs for the fine-tuning stage where experts are represented with LoRA adapters, authors can consider mentioning these works [2,3,4 inter alia]\n- ll. 88 - 91: \"Intuitively, the above method corresponds to choosing a subset of attention heads based on the destination side alone\": given that routing vector s is calculated conditioned on the input x, I do not understand why is it the case that attention heads are selected based on the destination (queries and outputs) side alone. In my understanding the attention head selection is dependent on the input x.\n- ll. 93 - 96 (related to above point) the explanation is somewhat confusing, why is it the case that in the worst case all possible source projections have to be computed?\n- l. 439: does the 4 in the calculation of the total MACs for the projections already include the output projection?\n- ll. 158 - 161: it might be worth noting that the idea of sharing key and value projection across heads has been introduced in earlier work on multi-query attention [1]. Additionally, to enhance the overall clarity, it could be useful to explicitly highlight how exactly MoA differs from the naive attention head mixing technique described in the first part of the Sec. 2.2.\n- ll. 119 - 120: it would be helpful if authors could provide a brief discussion clarifying how and why exactly parameter-matched setting \"better reflects the task of language modelling\"? \n- ll. 225 - 227: the visualization in Fig. 2 is only for 1 layer, and not for all layers as stated in the text\n- ll. 282 - 287: does not exactly fit into the \"Limitations\" section, since, according to the authors (ll. 266-269) FlashAttention is orthogonal to SwitchHead\n- how important is it to have MoE in the attention the the fully-connected block is already an MoE? Could authors add comparison to σ-MoE?\n \nOverall solid paper, I am happy to revisit my score upon the rebuttal.\n\n[1] Shazeer, Noam. \"Fast transformer decoding: One write-head is all you need.\" arXiv preprint arXiv:1911.02150 (2019).\n\n[2] Page-Caccia, Lucas, et al. \"Multi-head adapter routing for cross-task generalization.\" Advances in Neural Information Processing Systems 36 (2024).\n\n[3] Zadouri, Ted, et al. \"Pushing mixture of experts to the limit: Extremely parameter efficient moe for instruction tuning.\" arXiv preprint arXiv:2309.05444 (2023).\n\n[4] Ostapenko, Oleksiy, et al. \"Towards modular llms by building and reusing a library of loras.\" arXiv preprint arXiv:2405.11157 (2024).\n\nLIMITATIONS:\nLimitations are addressed in section 6.", "TITLE": "Official Review", "RECOMMENDATION": 6, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2024-07-03"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper introduces SwitchHead, a Mixture of Experts (MoE) method for improving the efficiency of the self-attention layer in Transformers. Unlike traditional MoE methods focused mainly on feedforward layers, SwitchHead effectively reduces both compute and memory requirements, achieving significant wall-clock speed improvements without compromising language modeling performance. This is accomplished by reducing the number of attention matrices needed, offering substantial savings in computational resources, which is validated through extensive experiments across multiple datasets and model sizes.\n\nSTRENGTHS:\nThe paper is well-written and easy to follow. The proposed method demonstrates substantial improvements in computational efficiency by reducing the number of attention matrices needed, which leads to lower compute and memory usage compared to standard Transformers.\n\nWEAKNESSES:\nThe proposed SwitchHead method shares similarities with the Mixture of Attention Heads (MoA), but a key distinction lies in its use of a non-competitive activation function (sigmoid) instead of SoftMax. This design choice is important to understand, and I would appreciate an explanation for opting for the sigmoid activation function over SoftMax in this context.\n\nQUESTIONS:\n1. The authors mention employing a parameter-matched setting to better reflect the task of language modeling. However, the paper lacks explicit justification for why this setting is more representative of language modeling tasks. Additionally, the description of parameters in Table 1 is ambiguous—it should be clarified whether the numbers represent total parameters or only those that are actively used during inference.\n\n2. The paper occasionally uses notations without adequate explanations, which can lead to confusion. For instance, the term “Shared selection” used in Table 4 is not clearly defined.\n\n3. In Table 5, the authors present the training times for the baseline Transformer and SwitchHead models, but the training time for the MoA model is not included. To provide a comprehensive comparison and better evaluate the efficiency of SwitchHead relative to other models, it would be beneficial if the authors could also include the training time data for the MoA model.\n\nLIMITATIONS:\nThe authors have discussed the limitations of their study.", "TITLE": "Official Review", "RECOMMENDATION": 6, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2024-07-08"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper presents SwitchHead, a Mixture of Experts (MoE) method applied to the self-attention layer in transformer blocks. By applying MoE to the self-attention layer, SwitchHead reduces computational and memory costs while maintaining language modeling performance comparable to traditional dense models. It can be combined with existing MoE methods for feedforward layers, resulting in a fully MoE-based transformer, SwitchAll transformers. Tests on various language modeling datasets (C4, Enwik8, peS2o) show that SwitchHead performs well compared to models with parameter-matched settings.\n\nSTRENGTHS:\n- The proposed MoE method applied to self-attention layer reduces computational and memory requirements while preserving language modeling performance of dense baselines.\n- The authors make effort to provide a fair comparison between the baselines and the proposed model in parameter-matched settings. They also include both the MAC and wall-clock speedup comparisons, clearly demonstrating the efficiency of the proposed method.\n- The author performs extensive ablation studies to show that the proposed method performs well with different types of models and datasets. They also provide the hyperparameters used for each experiment, which helps in reproducing the benchmark results.\n\nWEAKNESSES:\n- The paper only evaluates the proposed method on language modeling datasets, lacking demonstration of its effectiveness on other important NLP tasks such as document summarization or open-domain question answering.\n- While the authors claim similarity between SwitchHead and dense baseline attention maps, the provided figures suggest simplification in SwitchHead's maps. The lack of quantitative analysis (e.g., entropy measurements) weakens this claim.\n- There's a concern that the simplified attention maps produced by SwitchHead could lead to performance degradation when SwitchHead used in encoder-based models due to information bottleneck, which isn't addressed in the current evaluation.\n- The paper doesn't clearly explain why regularization methods used in σ-MoE (e.g., entropy maximization, expert dropout) are unnecessary for SwitchHead, potentially leaving gaps in the method's theoretical foundation.\n- The paper suggests that Top-K selection can be treated as a hyperparameter, but doesn't provide a clear analysis of the method's sensitivity to different K values, leaving questions about the necessity of hyperparameter search.\n- The paper mentions \"preliminary experiments\" multiple times without proper citation or section indicators, which may confuse readers and reduce the reproducibility of the work.\n\nQUESTIONS:\n- While the paper demonstrates strong performance on language modeling tasks, it would be beneficial to see results on a broader range of NLP tasks. How does SwitchHead perform on tasks such as document summarization[1] or open-domain question answering[2]? This would help demonstrate the method's versatility and potential impact beyond language modeling.\n- The paper claims that attention maps from SwitchHead and dense baseline models (Transformer XL) are qualitatively similar. However, Figures 2 and 6 suggest that SwitchHead produces simplified attention maps. Could you provide quantitative analysis (e.g., entropy measurements) to more rigorously demonstrate the complexity and quality of SwitchHead's attention maps compared to the dense baseline?\n- If SwitchHead indeed produces simplified attention maps, there's a concern about potential information bottleneck in encoder-based models. Have you considered evaluating SwitchHead's performance when applied to the query encoder in a retrieval-augmented generation (RAG) setup for open-domain QA tasks[2]? This could help address concerns about information loss in more complex, multi-step tasks.\n- The paper mentions that SwitchHead doesn't require the extra regularization techniques used in σ-MoE, such as entropy maximization for load balancing or expert dropout. Could you clarify what specific differences between σ-MoE and SwitchHead make these extra tricks unnecessary? A more detailed explanation of this point would strengthen the theoretical foundation of your approach.\n- You demonstrate that K in Top-K selection can be treated as a hyperparameter in the proposed method. How sensitive is the model's performance to different K values? If the sensitivity is low, is extensive hyperparameter searching always necessary, or could a default value be recommended for most use cases?\n- The paper mentions \"Our preliminary experiments\" several times (e.g., lines 91, 473) without providing citations or section indicators. Could you clarify these references to improve the paper's clarity and reproducibility? Consider either expanding on these preliminary experiments in the main text or including them in an appendix.\n\n[1] Nallapati, Ramesh, et al. \"Abstractive text summarization using sequence-to-sequence rnns and beyond.\" arXiv preprint arXiv:1602.06023 (2016).\n\n[2] Kwiatkowski, Tom, et al. \"Natural questions: a benchmark for question answering research.\" Transactions of the Association for Computational Linguistics 7 (2019): 453-466.\n\nLIMITATIONS:\n- In section 6 and appendix A.1, the authors appropriately present the limitations and societal impacts of their work. This acknowledgment of their model framework's constraints effectively strengthens the motivation for additional research topics in future work. The authors' awareness of these limitations demonstrates a commendable level of scientific rigor and transparency. However, the claim that performance can potentially reach 80-90% raises some questions. While this projection is intriguing, it would be more convincing if supported by more robust quantitative assessments. The addition of more detailed quantitative evaluations could provide valuable insights and significantly aid future research efforts. For instance, a breakdown of current performance bottlenecks and a roadmap for potential optimizations would offer clearer guidance for researchers looking to build upon this work. Furthermore, a more granular analysis of the trade-offs between model size, computational resources, and performance could enhance the paper's contribution to the field. Overall, while the authors have done a commendable job in addressing limitations and societal impacts, the inclusion of more quantitative metrics and projections would further solidify the paper's value as a foundation for future research in this area.", "TITLE": "Official Review", "RECOMMENDATION": 5, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2024-07-12"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis work proposes a novel Multi-Head-Attention (MHA) mechanism which is more efficient than the standard MHA used in most transformers. The method---called SwitchHead---is relying on Mixture-of-Experts (MoEs) to save computation while retaining the same model capacity and performance. To achieve this, instead of naively selecting which head should be computed for each token, a small number of heads are **always** computed, and MoEs are used to modulate the value and output projections for each head. Using multiple transformer variants and datasets, they empirically show how SwichHead transformers reach a similar perplexity as the baseline, for the same number of parameters, while requiring fewer operations and memory. They also show how their approach can yield a significant speedup during training.\n\nSTRENGTHS:\nThe paper is well written and well motivated. \nWhile the components of the proposed method are not particularly novel, they are combined in a simple yet novel way. \nI find the experiments convincing. Matching the parameters and perplexity allows to clearly appreciate the gains in memory and MACs. The results of the MAC-matched experiments and the time comparisons further reinforce the potential impact of the proposed method.\n\nWEAKNESSES:\n- As mentioned in the limitations section, the models are relatively small. \n- I could not find the sequence length used in your experiments, which prevents me from computing the number of tokens used during training. \n- I find it odd that dropout is used for the baseline but not for the switchAll models, on C4 I'm expecting dropout to slow down learning. \n- What is explaining the differences in the transformers' PPLs in table 4 compared to the PPLs in table 2?\n\nQUESTIONS:\nSee above.\n\nLIMITATIONS:\nLimitations have been discussed adequately.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 3, "SOUNDNESS_CORRECTNESS": 4, "DATE": "2024-07-13"}