Skip to content
ImagineWorld

A Closer Look into Mixture-of-Experts in Large Language Models

node_idnode-paper_arxiv-2406.18219_closer-look-mixture-experts-large-language-models
node_typenode-paper
schema_profileworld.node_paper.v1
alternate_namesarxiv-2406.18219, lo-huang-mixture-of-experts-2025
statusactive
orthogonal_scopemanifold, entropy, authority, state
manifoldworld
entropymedium
authorityguides
stateexternal
domainimagineworld.net
node_interiorrosetta_contract
unisonThis paper is Tier 0 for the controlled-MoE-routing gap because it inspects how routers, expert norms, expert parameters, and layerwise diversity behave in deployed MoE LLMs. For imagineos, it grounds model-gateway and mesh-runtime routing design in observed expert-selection behavior rather than abstract MoE assumptions.
governed_byWORLD-MANIFOLD, CORPUS
constitutional_citationCONSTITUTION
evidence_bundleworld-bundle-paper
compared_byworld-comparison-pillar-e-ai-research-history-and-learning-theory
pillar_membershipE - mixture-of-experts routing, modular expert behavior, and controlled sparse activation
publication_classarxiv_preprint
paper_titleA Closer Look into Mixture-of-Experts in Large Language Models
paper_authorsKa Man Lo, Zeyu Huang, Zihan Qiu, Zili Wang, Jie Fu
paper_author_affiliationsUniversity of Macau, University of Edinburgh, Tsinghua University, INF Technology, Shanghai AI Lab
paper_abstractMixture-of-experts (MoE) is gaining increasing attention due to its unique properties and remarkable performance, especially for language tasks. By sparsely activating a subset of parameters for each token, MoE architecture could increase the model size without sacrificing computational efficiency, achieving a better trade-off between performance and training costs. However, the underlying mechanism of MoE still lacks further exploration, and its modularization degree remains questionable. In this paper, we make an initial attempt to understand the inner workings of MoE-based large language models. Concretely, we comprehensively study the parametric and behavioral features of four popular MoE-based models and reveal some intriguing observations, including 1) Neurons act like fine-grained experts; 2) The router of MoE usually selects experts with larger output norms; 3) The expert diversity increases as the layer increases, while the last layer is an outlier, which is further validated by an initial experiment. Based on the observations, we also provide suggestions for a broad spectrum of MoE practitioners, such as router design and expert allocation. We hope this work could shed light on future research on the MoE framework and other modular architectures. Code is available at https://github.com/kamanphoebe/Look-into-MoEs.
arxiv_id2406.18219
arxiv_urlhttps://arxiv.org/abs/2406.18219
arxiv_categories{"primary":"cs.CL","secondary":["cs.LG"]}
arxiv_v3
arxiv_submitted_at2024-06-26
arxiv_updated_at2025-06-21
arxiv_doi10.48550/arXiv.2406.18219
peer_review_venueNAACL 2025 Findings
source_pdforganism/imagineworld/00-intake/converting/arxiv-2406.18219.pdf
source_pdf_sha2563c0678d962b9f583cc75ea3a9be457021b993bb0c42a65244da89713405073b0
source_latex_archiveorganism/imagineworld/00-intake/converting/A Closer Look into Mixture-of-Experts in Large Language Models.tar.gz
source_latex_archive_sha256ae5e03cd4a459c53c547a444dfa70ecbbf8e1005ab764e0ef1b05c2bf5bb0bdf
ocr_sourcearxiv_latex_source
ocr_quality_classverbatim_latex
extraction_toolkimi-k2.6-codex-cli
extraction_pipeline_versionworld-ingest-arxiv-llm-prompt-template-v1.0
extracted_at2026-05-16T09:27:50+00:00
math_preserved_as_latextrue
figures_extractedtrue
references_structurally_parsedtrue
cites_arxiv{"arxiv_id":"2401.04088","title":"Mixtral of experts","in_sections":["extended-related-work","introduction","related-work"]}, {"arxiv_id":"2401.06066","title":"Deepseekmoe: Towards ultimate expert specialization in mixture-of-experts language models","in_sections":["extended-related-work","introduction","related-work"]}, {"arxiv_id":"2310.06825","title":"Mistral 7B","in_sections":["overview"]}, {"arxiv_id":"1701.06538","title":"Outrageously large neural networks: The sparsely-gated mixture-of-experts layer","in_sections":["introduction"]}, {"arxiv_id":"2403.05530","title":"Gemini 1.5: Unlocking multimodal understanding across millions of tokens of context","in_sections":["introduction"]}, {"arxiv_id":"2404.07413","title":"Jetmoe: Reaching llama2 performance with 0.1 m dollars","in_sections":["extended-related-work"]}, {"arxiv_id":"2012.14913","title":"Transformer feed-forward layers are key-value memories","in_sections":["weight-matrices-of-experts"]}, {"arxiv_id":"1609.07843","title":"Pointer sentinel mixture models","in_sections":["additional-datasets","analysis-of-dynamic-behaviours"]}, {"arxiv_id":"2302.13971","title":"Llama: Open and efficient foundation language models","in_sections":["preliminary-mixture-of-experts"]}, {"arxiv_id":"2402.02526","title":"CompeteSMoE--Effective Training of Sparse Mixture of Experts via Competition","in_sections":["discussion","limitations","norms-of-expert-outputs-and-gate-scores","related-work"]}, {"arxiv_id":"2204.09636","title":"Residual mixture of experts","in_sections":["matrix-level","related-work"]}, {"arxiv_id":"2110.09456","title":"Normformer: Improved transformer pretraining with extra normalization","in_sections":["norms-of-expert-outputs-and-gate-scores"]}, {"arxiv_id":"2402.13516","title":"ProSparse: Introducing and Enhancing Intrinsic Activation Sparsity within Large Language Models","in_sections":["intermediate-states-of-experts"]}, {"arxiv_id":"2210.06313","title":"The lazy neuron phenomenon: On emergence of activation sparsity in transformers","in_sections":["intermediate-states-of-experts"]}, {"arxiv_id":"2406.05955","title":"Turbo Sparse: Achieving LLM SOTA Performance with Minimal Activated Parameters","in_sections":["intermediate-states-of-experts"]}, {"arxiv_id":"2212.05055","title":"Sparse upcycling: Training mixture-of-experts from dense checkpoints","in_sections":["discussion"]}, {"arxiv_id":"2402.12233","title":"Empirical Study on Updating Key-Value Memories in Transformer Feed-forward Layers","in_sections":["weight-matrices-of-experts"]}, {"arxiv_id":"2310.10908","title":"Emergent Mixture-of-Experts: Can Dense Pre-trained Transformers Benefit from Emergent Modular Structures?","in_sections":["related-work"]}, {"arxiv_id":"2305.13999","title":"Towards a unified view of sparse feed-forward network in pretraining large language model","in_sections":["related-work"]}, {"arxiv_id":"2402.01739","title":"Openmoe: An early effort on open mixture-of-experts language models","in_sections":["extended-related-work","related-work"]}, {"arxiv_id":"2204.08396","title":"Stablemoe: Stable routing strategy for mixture of experts","in_sections":["related-work"]}, {"arxiv_id":"2110.04260","title":"Taming sparsely activated transformer with stochastic experts","in_sections":["related-work"]}, {"arxiv_id":"2310.01334","title":"Merge, Then Compress: Demystify Efficient SMoE with Hints from Its Routing Policy","in_sections":["related-work"]}, {"arxiv_id":"2402.14800","title":"Not All Experts are Equal: Efficient Expert Pruning and Skipping for Mixture-of-Experts Large Language Models","in_sections":["related-work"]}, {"arxiv_id":"2407.06204","title":"A survey on mixture of experts","in_sections":["analysis-of-dynamic-behaviours","extended-related-work"]}, {"arxiv_id":"2110.14168","title":"Training Verifiers to Solve Math Word Problems","in_sections":["additional-datasets","analysis-of-dynamic-behaviours"]}, {"arxiv_id":"2202.08906","title":"St-moe: Designing stable and transferable sparse expert models","in_sections":["extended-related-work"]}, {"arxiv_id":"2406.06563","title":"Skywork-MoE: A Deep Dive into Training Techniques for Mixture-of-Experts Language Models","in_sections":["discussion","extended-related-work"]}, {"arxiv_id":"2405.17976","title":"Yuan 2.0-M32: Mixture of Experts with Attention Router","in_sections":["extended-related-work"]}, {"arxiv_id":"2306.04640","title":"Moduleformer: Learning modular large language models from uncurated data","in_sections":["extended-related-work"]}, {"arxiv_id":"2210.05144","title":"Mixture of attention heads: Selecting attention heads per token","in_sections":["extended-related-work"]}, {"arxiv_id":"2405.14507","title":"Unchosen Experts Can Contribute Too: Unleashing MoE Models' Power by Self-Contrast","in_sections":["related-work"]}, {"arxiv_id":"2110.01786","title":"Moefication: Transformer feed-forward layers are mixtures of experts","in_sections":["discussion","overview","related-work"]}, {"arxiv_id":"2407.09590","title":"Diversifying the Expert Knowledge for Task-Agnostic Pruning in Sparse Mixture-of-Experts","in_sections":["related-work"]}, {"arxiv_id":"2407.09298","title":"Transformer layers as painters","in_sections":["overview"]}
cites_external{"doi":"None","title":"Qwen1.5-MoE: Matching 7B Model Performance with 1/3 Activated Parameters","venue":"https://qwenlm.github.io/blog/qwen-moe/"}, {"doi":"None","title":"A shortest augmenting path algorithm for dense and sparse linear assignment problems","venue":"DGOR/NSOR: Papers of the 16th Annual Meeting of DGOR in Cooperation with NSOR"}, {"doi":"None","title":"On the representation collapse of sparse mixture of experts","venue":"Advances in Neural Information Processing Systems"}, {"doi":"None","title":"Towards understanding the mixture-of-experts layer in deep learning","venue":"Advances in neural information processing systems"}, {"doi":"None","title":"Magicoder: Empowering code generation with oss-instruct","venue":"Forty-first International Conference on Machine Learning"}, {"doi":"None","title":"Unlocking Emergent Modularity in Large Language Models","venue":"Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers)"}
cited_by_arxiv
supersedes
superseded_by
distill_corpus_weight3
distill_corpus_tier0
distill_relevance_gapsgap-6-controlled-moe-routing, gap-10-production-llm-training-ops
distill_relevance_phase_i_guidesi-1-corpus-assembly-methodology
training_signal_rolemoe_routing_and_expert_behavior_anchor
training_signal_typetier_0_constitutional_for_controlled_moe_routing
pillar_normalizedE
created_at2026-05-16T09:27:50+00:00
updated_at2026-10-14T05:45:17Z
local graph

A Closer Look into Mixture-of-Experts in Large Language Models

Section titled “A Closer Look into Mixture-of-Experts in Large Language Models”

Authors: Ka Man Lo, Zeyu Huang, Zihan Qiu, Zili Wang, Jie Fu arxiv: 2406.18219 · Venue: NAACL 2025 Findings Source: arxiv LaTeX A Closer Look into Mixture-of-Experts in Large Language Models.tar.gz (sha256: ae5e03cd4a459c53c547a444dfa70ecbbf8e1005ab764e0ef1b05c2bf5bb0bdf) · extracted 2026-05-16T09:27:50Z via kimi-k2.6-codex-cli


Mixture-of-experts (MoE) is gaining increasing attention due to its unique properties and remarkable performance, especially for language tasks. By sparsely activating a subset of parameters for each token, MoE architecture could increase the model size without sacrificing computational efficiency, achieving a better trade-off between performance and training costs. However, the underlying mechanism of MoE still lacks further exploration, and its modularization degree remains questionable. In this paper, we make an initial attempt to understand the inner workings of MoE-based large language models. Concretely, we comprehensively study the parametric and behavioral features of four popular MoE-based models and reveal some intriguing observations, including

  1. Neurons act like fine-grained experts; 2) The router of MoE usually selects experts with larger output norms; 3) The expert diversity increases as the layer increases, while the last layer is an outlier, which is further validated by an initial experiment. Based on the observations, we also provide suggestions for a broad spectrum of MoE practitioners, such as router design and expert allocation. We hope this work could shed light on future research on the MoE framework and other modular architectures. Code is available at https://github.com/kamanphoebe/Look-into-MoEs.

The advent of Large Language Models (LLMs) revolutionized the field of Natural Language Processing. LLM researchers are continually pushing the boundaries of Language Models by scaling up both model size and the column of training data, significantly enhancing the capabilities of these models. This escalation in training cost and complexity necessitates innovative solutions to better balance between pre-training efficiency and model performance. One emerging solution to this end is the Mixture-of-Experts (MoE) [Shazeer et al. 2017] architecture. The MoE framework facilitates the computational efficiency of the model by dynamically routing inputs to a subset of experts, allowing for substantial model scaling while maintaining training costs and leading to numerous influential advancements in the field [Reid et al. 2024; Jiang et al. 2024; Dai et al. 2024; Team 2024].

Beyond efficiency, another attractive trait of MoE architecture is its modular design and learning paradigm. This modularization allows for flexible and potentially more generalizable handling of diverse data and tasks within a single model by assigning them to specialized experts. Despite its widespread adoption, it remains an open question whether current MoE-based LLMs truly leverage this modularity in knowledge distribution and expert behaviors. In other words, is MoE a simple ensemble of homogeneous experts or a modular combination of heterogeneous experts? Answering this question comprehensively is non-trivial. Therefore, in this paper, we take the first step by investigating four popular MoE-based LLMs (Mixtral 8x7B [Jiang et al. 2024], Mixtral 8x22B, DeepSeekMoE [Dai et al. 2024], and Grok-11) from two critical perspectives: model parameters and model behaviors. We aim to explore common and distinct features and behaviors among different experts, further shedding light on the inner mechanisms of MoE-based models.

Specifically, we examine the correlation between experts’ parameters, gates, and their output features given text inputs. Before diving into deeper analyses, we briefly summarize some of our empirical conclusions (detailed in Section 6) and observations:

  • Neurons in the Feed-Forward Network (FFN) layer are fine-grained experts. Both the gate embedding matrix and the expert projection matrix WactW_{\text{act}} perform the choosing operation: the former determines the expert selection while the latter controls the neuron activation. We observe that the similarity heat maps exhibit correlations, suggesting that, from the perspective of WactW_{\text{act}}, the expert neurons can be considered as “tiny” experts, each represented by a single neuron.

  • Increasing the number of experts in deeper layers while reducing it in the last layer. This is experimented in Figure 5. Our observations indicate that the similarities between the parameters and outputs of the experts consistently decrease with increasing layer number, followed by a sudden increase in the last layer.

  • Using the norm as the routing mechanism is a reasonable choice. For both Mixtral 8x7B and DeepSeekMoE, we observe that the gate typically selects experts with larger output norms.

  • When analyzing the correlation between experts, measuring the similarities between weight matrices is, to some extent, equivalent to assessing the average similarities of expert outputs.

  • Training MoE from scratch promotes greater expert diversity than specific initialization schemes. This stems from the observations that stronger correlations (e.g., higher similarities) between parameters and behaviors in Mixtral experts. In contrast, DeepSeekMoE and Grok-1, which are trained from scratch, do not show these correlations.

Mixture-of-Experts models enhance transformers by replacing the original FFNs with ( N ) parallel FFNs combined with a router. These ( N ) FFNs are called experts and denoted as ( E_n ) for ( n \in [1, N] ). The gate ( g(\cdot; W_g, k) ), parameterized by ( W_g ) and an integer ( \operatorname{k} ), assigns the input ( x ) to a score distribution over the experts, ( g(x; W_g, \operatorname{k}) \in \mathbb{R}^N ). Typically, the gate ( g ) consists of a simple linear layer followed by a (\operatorname{softmax}) and a (\operatorname{Top-k}) function.

Given ( x \in \mathbb{R}^{d_{\text{hid}}} ), the output ( y \in \mathbb{R}^{d_{\text{hid}}} ) is the weighted sum of the outputs from all experts:

[ y = \sum_{n \in N} g_n(x; W_g, \operatorname{k}) E_n(x) ]

When ( \operatorname{k} ) for (\operatorname{Top-k}) is smaller than ( N ), only a subset of experts is involved in the computation. This is known as Sparse Mixture-of-Experts (SMoE).

The experts EnE_n of the models investigated in this paper follow the style in LLaMA [Touvron et al. 2023], which consists of three linear layers and operates as (the subscript nn is omitted for brevity):

E(x)=Wdown(Wupx⊙σ(Wactx))E(x)=W_{\text{down}}(W_{\text{up}}x \odot \sigma(W_{\text{act}}x))

where ⊙\odot represents element-wise multiplication and σ\sigma represents the activation function. Given the three projection matrices ( W_{\text{up}}, W_{\text{act}} \in \mathbb{R}^{d_{\text{mid}} \times d_{\text{hid}}} ) and ( W_{\text{down}} \in \mathbb{R}^{d_{\text{hid}} \times d_{\text{mid}}} ), we define a neuron as the combination of the row vectors ( W_{\text{up}}[i, :] ) and ( W_{\text{act}}[i, :] ), along with the column vector ( W_{\text{down}}[:, i] ). Thus, each expert contains ( d_{\text{mid}} ) neurons, each with size dhidd_{\text{hid}}.

Table 1. Basic information of models used for analysis. The abbreviations are used throughout our paper.

Our experiments are conducted on several open-source MoE models, namely Mixtral 8x7B, Mixtral 8x22B 2, DeepSeekMoE, and Grok-1. We choose these models due to their widespread use and impressive performance across various domains. Additionally, they exhibit complementary characteristics across several key attributes, enabling a robust comparative analysis using control variables. Details are discussed in Appendix B. To further study the similarities and differences between a standard transformer and a MoE model, we include Mistral 7B [Jiang et al. 2023] as one of our investigated models. Basic information about these models, along with the abbreviations used throughout our paper, is summarized in Table 1 and Table 4. The analysis is divided into two sections: one focusing on model parameters (static) and the other on model behaviors in response to text input (dynamic).

Unless otherwise stated (Section 5.1), cosine similarity is employed for all experiments involving similarity measurements. While we acknowledge the existence of other metrics, we primarily use cosine similarity as it is a widely adopted approach [Sun et al. 2024; Zhang et al. 2021].

From a high-level perspective, a model’s knowledge is encoded in its parameters, making the investigation of weight matrices a natural approach. In this section, we study the correlation between the parameters of:

  1. MoE experts (and FFNs for Mistral), and; 2) gate embeddings which are two vital components of the MoE architecture.

MoE models replace FFNs in standard transformers with experts. Following [Geva et al. 2020; Qiu et al. 2024], the projection matrices of the experts can be regarded as keys and values: the column vectors of WdownW_{\text{down}} represent potential outputs; the row vectors of WupW_{\text{up}} produce weights for each possible output; the row vectors of WactW_{\text{act}} determine whether to activate the corresponding neurons. Thus, examining the weight matrices provides a straightforward way to understand the expert behaviors. We analyze both the matrix and neuron levels to gain insights from different perspectives.

In this part, we explore the similarity of the three projection matrices WupW_{\text{up}}, WactW_{\text{act}}, and WdownW_{\text{down}} among all experts in each layer. The similarity is calculated based on the flattened matrices and is illustrated in Figure 1. We denote “F” as the Mistral FFN and “SE” as the DeepSeek shared expert. Note that the figures for different models do not share the same color bar.

**Common 3.} The heat maps of the three matrices exhibit similar patterns. Directly flattening the large weight matrices leads to high-dimensional vectors, so we use principal components analysis (PCA) to reduce these vectors to two-dimensional space. The resulting figures also show that, for Mixtral and DeepSeek, the expert distribution across the three weight matrices is generally comparable. Details on the PCA results are presented in Appendix D.1.

Mixtrals and Mistral. The cosine similarities between Mixtral experts (SeeS_{\text{ee}}) primarily range from 0.2 to 0.4, while the similarities between the experts and the Mistral FFN (SefS_{\text{ef}}) are about 0.6. Yet the values tend to be lower in the deeper layers (22nd^{\text{nd}}-30th^{\text{th}} for Mixtral and 35th^{\text{th}}-50th^{\text{th}} for Mixtral-22). A “dark cross” can be observed in some layers and corresponds to outliers in the 2D space projected by PCA, indicating that the associated expert is relatively distinct from the others. Interestingly, this cross appears most frequently in Expert 3 for Mixtral, suggesting that this expert may have learned some unique attributes. It is noteworthy that the cross usually extends across the entire heat map, including the last row of the FFN. Thus, when an Mixtral expert differs from other experts, it is also less similar to the Mistral FFN.

DeepSeek and Grok. The shared experts of DeepSeek are implemented as a single MLP block with a larger hidden size than the routed experts, preventing direct comparison of their flattened vectors; thus, we omit them from this experiment. Figure 1 demonstrates that the similarities between the DeepSeek routed experts and Grok experts are close to zero. While Mixtrals’ training method remains unrevealed, it is known that DeepSeek and Grok are trained from scratch. This suggests that Mixtrals may have been trained using special schemes, resulting in less diverse experts compared to those trained from scratch [Wu et al. 2022].

[figure owed: Figure 1. Matrix-level similarity heat maps of expert weight matrices. Each layer contains three heat maps, corresponding to W_{\text{up}}, W_{\text{act}}, and W_{\text{down}}, respectively. The tick numbers refer to the expert indices. "F" denotes the Mistral FFN.]

In Section 4.1, we measure the parameter similarity between experts at the matrix level. However, the calculation of cosine similarity is position-dependent. If the neurons of two experts are similar but in different orders, the similarity of their weight matrices will be significantly lower than expected. To address this, we propose two approaches to investigate the correlation at the neuron level: averaging and reordering. Averaging simply averages the rows (for WupW_{\text{up}} and WactW_{\text{act}}) or the columns (for WdownW_{\text{down}}) of the weight matrices, and then calculates the cosine similarity of the resulting vectors across experts. For reordering, we apply the Jonker-Volgenant algorithm [Jonker and Volgenant 1988], which is typically used for solving linear assignment problems, to find the optimal order of neurons so that the cosine similarity between two experts is maximized.

We describe the results of the reordering method below and provide the details of the averaging approach in Appendix E. Additionally, the projection of neurons into low-dimensional spaces using PCA can be found in Appendix D.2. Due to the heavy computation, we only select several layers for the reordering calculation. Note that the matrices are reordered separately. We measure Kendall’s τ\tau coefficient between the index sequences before and after reordering, whose value increases when the two sequences exist strong agreement. Table 2 depicts the common similarity growth after reordering and the average Kendall’s coefficient τˉ\bar\tau over the selected layers. The order of Mixtral neurons changes little (resulting in a large τ\tau), and hence nearly unchanged similarities. Despite the substantial similarity increase for DeepSeek and Grok after reordering, their overall values remain around 1e-2.

Table 2. Reordering results of expert neurons.

The gate embedding of our investigated MoE models is implemented as a linear layer WgW_g with size RN×Rdhid\mathbb{R}^{N}\times\mathbb{R}^{d_{\text{hid}}}, where NN is the number of experts.

The gate serves as a crucial component of MoE, making it essential to study its attributes to understand MoE functionality better. In addition, since each row vector in the gate embedding determines expert selection, some correspondence may exist between WgW_g and the expert weights.

To investigate this, we measure the similarities between the gate embedding vectors Wg[n,:]W_g[n,:] for n∈[1,N]n \in [1, N]. For computational simplicity, we compare them with the neuron-level averaging (instead of the reordering) heat maps of experts presented in Appendix E, with qualitative analyses detailed in Appendix F. Specifically, we found that, for all four MoE models, the patterns in the heat maps of gate vectors and of expert neurons Wact[i,:]W_{\text{act}}[i,:] are partially alike in some layers (i.e., the same coordinates in both heat maps exhibit relatively higher or lower values simultaneously).

Therefore, we further conduct a quantitative analysis of their similarity values. In particular, we perform linear regression on the paired similarity dataset (X,Y)(X, Y), where XX denotes the similarities of Wg[n,:]W_g[n,:], and YY denotes the neuron-level similarities of WupW_{\text{up}}, WactW_{\text{act}}, or WdownW_{\text{down}}. Table 3 describes the average square of Pearson correlation coefficients over all layers (Ravg2R_{\text{avg}}^2), while Table 5 lists the Pearson correlation coefficient (RR) for each layer. As shown in Table 3, the correlation between the similarities of the gate vectors and those of WactW_{\text{act}} is significantly stronger than that with WupW_{\text{up}} and WdownW_{\text{down}}. For the (X,Yact)(X, Y_{\text{act}}) pair, although Mixtral and DeepSeek have similar Ravg2R_{\text{avg}}^2 values, the R2R^2 of Mixtrals fluctuate between 0.1 and 0.7, while the R2R^2 of DeepSeek remains close to 0.4. Furthermore, we can see from Table 5 that (X,Yact)(X, Y_{\text{act}}) for both Mixtral and DeepSeek show positive correlations, whereas (X,Yact)(X, Y_{\text{act}}) for Grok turn to negative correlations starting from the intermediate (after 25th^{\text{th}}) layers. We note that the function of WgW_g and WactW_{\text{act}} is analogous: the former determines expert selection while the latter is responsible for choosing which neurons to activate. Therefore, they may learn similar knowledge to effectively perform the choosing operation, which explains the observed correlation.

Table 3. Average square of Pearson correlation coefficients over all layers (Ravg2R_{\text{avg}}^2) for three paired dataset.

Here, we conclude the key observations from the analysis of static parameters:

[figure owed: Figure 2. Similarity heat maps of expert output features using the short input. The top k experts for each token are shown on top of each heat map. The tick numbers refer to the expert indices. "F" and "SE" denote the Mistral FFN and the DeepSeek shared expert, respectively.]

[figure owed: Figure 3. Average similarity heat maps of expert output features using the long input, plotted along with the matrix-level similarity heat maps. The tick numbers refer to the expert indices. "F" denotes the Mistral FFN.]

The previous experiments examine the MoE models via their parameters, without involving any input. In this section, we feed text sequences into the MoE models to further study their actual behaviours given various inputs. Specifically, we analyze the outputs of the experts and gates.

To this end, two stages are required for inference. In the first stage, we simply pass the input xx through the network using the original Top-k setting and store the output ziz_{i} of every layer ii. In the second stage, we iterate through the layers. During the ii-th iteration, we feed zi−1z_{i-1} into the ii-th layer (for the first layer, xx is employed as the input), set Top-k=ALL⁡\text{Top-k}=\operatorname{ALL}, and record the outputs from all the experts in the ii-th layer. Note that each layer has its own individual forward pass in the second stage. Intuitively, our goal is to examine the experts’ behaviors when provided with the original inputs.

Input data. We utilize a short input and a long input for the experiments in this section. For the short input, we employ the first few words of the input from another MoE-related work [Cai et al. 2024] 4. For the long input, we adopt 10 sequences from the test set of the WikiText-103 [Merity et al. 2016] dataset, totaling approximately 1100 tokens. The sequences in WikiText-103 cover a variety of domains, with the 10 sequences we used spanning topics such as music, design, and construction. To ensure the robustness of our findings, we repeat experiments requiring the long input (Section 5.1, Section 5.2) using additional datasets with over 80K tokens, including GSM8K [Cobbe et al. 2021] and Magicoder- Evol-Instruct-110K [Wei et al. 2024]. See Appendix G for details. The observations of these additional, subject-specific datasets align with the results described in the main context, demonstrating the universality of our conclusions.

We also conduct experiments for analyzing intermediate states of experts and routing patterns. Due to the page limit, these experiments are presented in Appendix I and Appendix J, respectively.

Since experts are ideally learned to specialize in different aspects, it is natural to question the similarities and differences between the outputs of selected and non-selected experts. In this experiment, we measure the correlation between the output feature vectors of experts. We plot the similarity heat maps for three tokens in the short input (Figure 2) and the average heat map across all tokens in the long input (Figure 3). For the long input, we use angular similarity instead of cosine similarity for measurement, as the similarities need to be averaged, ensuring that the values range from 0 to 1:

angularsim⁡=1−arccos⁡(cosinesim⁡)π.\operatorname{angular_sim} = 1 - \frac{\arccos{(\operatorname{cosine_sim}})}{\pi}.

For clarity, the average similarity heat maps are plotted alongside the matrix-level similarity graphs of the expert weight matrices. Figure 9 further depicts the results from additional datasets, which are consistent with those of the long input.

Mixtrals and Mistral. The graphs for the short input indicate that the outputs from chosen experts tend to be more similar, possibly due to their generally larger norms, which we will discuss in Section 5.2. Overall similarities are relatively low in the deeper (22nd^{\text{nd}}-27th^{\text{th}} for Mixtral and 30nd^{\text{nd}}-50th^{\text{th}} for Mixtral-22) layers, whereas many values exceed 0.8 in the last few layers. Furthermore, dark crosses often appear in the graphs, with the experts corresponding to these dark crosses often being more similar to the Mistral FFN (i.e., bright color in the last row). For the long input, the average heat maps show patterns akin to neuron-level similarity graphs, including the presence of dark crosses. The similarities also decrease with increasing layer depth, except in the last layer. In addition, we have See>SefS_{\text{ee}}>S_{\text{ef}} for both inputs. Most of these observations align with the previous analyses of static parameters (Section 4.3), implying that measuring the similarity of weights, in some aspects, is equivalent to measuring the average similarity of outputs.

DeepSeek. Given the short input, most similarities are around zero, while the values in the last layer are significantly larger. Again, the similarities between experts chosen by the gate are likely to be higher, although this difference occurs much less frequently than in Mixtrals. The average similarities for the long input also approach zero. Moreover, the number of “small rectangular” with relatively light color in the graphs decreases as the layer depth increases (except for the last layer), meaning that the average similarities gradually decline.

Grok. Surprisingly, the similarities between the output features remain high for all tokens in the short input, indicating the experts exhibit similar behaviours. However, the similarities of their weight matrices are mostly zeros (Section 4.1.1). We speculate that this may be due to the relatively large size of each Grok expert, allowing each to learn comprehensive knowledge and behave similarly despite having distinct parameters. When averaging the similarities for the long input, some of the resulting average heat maps display patterns similar to those of the WactW_{\text{act}} figures. This relationship aligns with the observations made for Mixtrals.

[figure owed: Figure 4. The experts' L2 norms and the gate scores of the short input. Each token's k experts are shown on top of each heat map. Each number in the horizontal axis refers to an expert index.]

In Section 5.1, we find that the outputs from chosen experts tend to be more alike. To investigate the possible reasons for this observation, we employ the short input to study the relationship between the experts’ L2 norm and the gate decision in this experiment. The calculated norms, along with the gate scores, are plotted in Figure 4. In Appendix H, we repeat this experiment using the long input and additional datasets, and the results also support the “higher norm, higher score” observation.

Mixtrals. We found that the two experts chosen by the gate usually output feature vectors with the highest norms, which reveals that the norm might be one of the key factors in gate decisions. This finding agrees with the router’s design in CompeteSMoE [Pham et al. 2024], which selects experts based on their output norms. It also helps explain why the outputs of the chosen Mixtrals and DeepSeek experts tend to be more alike (Section 5.1). In Figure 4, we observe that the gate scores assigned to the top-1 experts are usually much higher than those of the others, including the second place. This demonstrates that the gate is learned to strengthen the confidence of its decision during training.

On the other hand, the deeper the layer, the larger the norm, which is similar to the growth in standard models [Shleifer et al. 2021].

DeepSeek. In contrast to the observation about Mixtrals’ experts, the gate decision appears to depend less obviously on the output norms of DeepSeek experts. However, the top-1 experts often score much higher than the remaining candidates. The magnitude of the norms increases with depth, although the increment is less pronounced than in Mixtrals. In the last layer, the variance of norms becomes greater.

Grok. While the scores of the top-1 experts are higher than those of the others, no correspondence between the norms and the gate scores is observed. One possible reason could be the relatively low activation ratios of GeLU (see Appendix I), which may lead to a weaker dependence on the norm for gate decisions. Besides, unlike Mixtrals and DeepSeek, the magnitude of the norms hardly changes across depth, and some of the norm values can be less than 1, which is rare in the other two models.

[figure owed: Figure 5. Normalized model performance across benchmarks for the dynamic expert numbers experiment. Solid line represents lower is better, while dashed line represents higher is better. "Bench avg" refers to the average performance over the four benchmarks evaluated.]

The observations of dynamic behaviours are concluded below:

Based on our analyses, we offer several suggestions for MoE models across various aspects.

Neuron-level experts. Intuitively, the gate embedding matrix WgW_g determines expert selection while WactW_{\text{act}} is responsible for choosing which neurons to activate. Meanwhile, we find that the similarities of WgW_g and of WactW_{\text{act}} show association. This implies that neurons may function as more fine-grained experts. Therefore, operations on experts, such as division, construction, and composition, should be further studied at the micro level. For instance, MoEfication [Zhang et al. 2021] and EMoE [Qiu et al. 2024] construct MoE experts by splitting the MLP layers of a dense model, suggesting our findings from a similar perspective.

Model architecture. Given that the similarities between experts tend to be relatively low (high) in deep (last) layers, one can consider increasing the number of experts in the deeper layers while reducing it in the last layers. In addition, since the gate frequently selects experts with larger output norms, employing norm-based routing mechanism is a reasonable approach. Empirical evidence from [Pham et al. 2024] supports this effectiveness.

We conduct an initial experiment to provide practical experience into our suggestion regarding dynamic expert numbers across layers. Specifically, we train six MoE models from scratch, each containing 24 layers and 3.6B total parameters, using approximately 120B tokens. One of the six models is composed of 24 MoE layers, while the others comprise only 23 MoE layers, with one conventional non-MoE layer positioned at different indices. Details of the model architecture are provided in Table 7. As displayed in Figure 5 and Table 6, the average model performance (i.e., PPL and Bench avg) gradually degrades as the non-MoE layer index increases, whereas a slight improvement appears when the non-MoE layer is placed at the last position (24th^{\text{th}}). This highlights the growing importance of multiple expert networks in deeper layers, excluding the last one, which aligns with our observations and suggestions.

Correlation measurement.

Analyzing expert correlations through weight matrix similarities yields partially equivalent results to those from output feature vector similarities across considerable tokens. Thus, assessing weight matrices offers a broader overview, while examining individual token outputs allows for more detailed analysis.

Training scheme. The training method for Mixtral has not been publicly announced. However, we observed certain characteristicss shared by Mixtral experts (e.g., relatively high similarities of weight matrices), and a notable relationship between these experts and the Mistral FFN (e.g., similar intermediate states in Figure 12). Consequently, we conjecture that the Mixtral model may be trained using special initialization schemes other than from scratch, e.g., upcycling [Komatsuzaki et al. 2022] from Mistral, that is, copying all experts from the FFN. On the contrary, the experts of DeepSeek and Grok, which are known to be trained from scratch, show weaker correlations than Mixtral experts in our experiments. Similarly, [Wei et al. 2024] tracks changes in expert similarities throughout the training process, observing that upcycled experts exhibit greater similarity compared to those randomly initialized. Hence, we speculate that training a MoE model from scratch shows stronger potential to facilitate the diversification of experts compared with certain initialization approaches.

Due to the page limit, we focus on existing works analyzing MoEs. An extended related work section for MoE LLMs can be found in Appendix C.

Most existing works analyze MoE from the router’s perspective by observing expert selections. Early works have observed the unstable choices in the router [Zuo et al. 2021; Chi et al. 2022; Dai et al. 2022]. More recent studies find the standard routers do not show clear specialization at the domain level [Jiang et al. 2024; Dai et al. 2024] and primarily route based on token ID instead of high-level semantics [Xue et al. 2024]. [Shi et al. 2024] shows that Top-2 and Rank-k routing result in different model behaviours and proposes a new self-contrast decoding method to determine the next-token distribution based on this finding.

Other works investigate the expert’s similarity [Wu et al. 2022], uncovering and utilizing redundancies among experts for efficient inference [Li et al. 2023; Lu et al. 2024]. [Zhang et al. 2024] reveals the redundancy within experts and perform pruning based on their similarities. [Liu et al. 2023; Qiu et al. 2023] notice the connection between routing connection and expert computation, and utilize the average of the experts’ first-layer weights to guide routing. [Pham et al. 2024] proposes adding the expert’s output norm as a supervision signal for routing training. [Chen et al. 2022] empirically and theoretically proves that a two-layer MoE CNN is able to learn cluster-center features via specializing experts to specific portions of the data. While these works provide insights into MoE from one or two viewpoints, our work offers a systematic analysis and comparison focusing on transformer-based MoE LLMs.

As mentioned in previous sections, several existing works share some relevance to our findings, and thus can be seen as supportive. However, their proposed ideas and methods are different from ours. For instance, rather than revealing the nature of the preference for large output norms in (conventional top-k) routing, as we analyze, CompeteSMoE [Pham et al. 2024] designs a norm-based router to introduce this tendency manually; MoEfication [Zhang et al. 2021] splits MLP layers of a dense model to construct MoE experts, while our study highlights that the neurons of an expert can be seen as tiny experts. Moreover, many of our observations are novel, such as the correlation between the router embedding matrix and the expert weight matrix, as well as the equivalence between parameter and output measurement for experts. Therefore, we believe that our work offers valuable insights into MoE LLMs for the community.

In this paper, we initially attempt to investigate the inner working mechanisms of MoEs by studying the parameters and outputs of four different MoE models. We summarize our empirical observations and propose practical suggestions across various aspects. While it is premature to conclude whether MoEs genuinely learn heterogeneous experts, some of our experiments indicate that specific architectural designs (e.g., the number of experts) and training frameworks may facilitate expert specialization. We hope this work can provide inspiring insights and serve as a valuable foundation for future research on MoE and other modular architectures.

The limitations of our work include:

  1. Although the models we investigated cover several common designs of MoE, our analysis does not encompass all aspects (e.g., other routing strategies like top-1 routing or model architectures that place MoE layers at every other layer); 2) We mainly focus on the pretrained base model but seldom explore the behaviours of models after fine-tuning. Analyzing the changes in expert behaviours during the fine-tuning process could yield valuable insights.

Our experiments are conducted on Mixtral 8x7B, DeepSeekMoE, and Grok-1. We choose these models due to their widespread use and impressive performance across various domains. Additionally, these models are complementary in several crucial attributes, such as training scheme, activation functions, top-k settings, and the number of experts, as listed in Tab Table 1 and Tab Table 4. This allows for a comparative analysis with controlled variables and encompasses a wide range of parameter sizes, from rather small (16B) to relatively huge (314B). Hence, we believe that the findings derived from these four models are fairly robust, despite the limited number of models examined.

Table 4. Additional information of chosen models.

MoE LLMs. MoEs have garnered significant attention in recent years due to their ability to efficiently scale model capacity with minimal computational overhead. Most current transformer-based MoE LLMs adopt a typical architecture design that replaces the original FFN with multiple expert networks and a sparse gating network [Wei et al. 2024; Wu et al. 2024; Dai et al. 2024; Xue et al. 2024; Jiang et al. 2024; Zoph et al. 2022]. JetMoE [Shen et al. 2024] and ModuleFormer [Shen et al. 2023] incorporate Mixture of Attention Heads [Zhang et al. 2022] into their model, achieving further sparsity. A recent survey [Cai et al. 2024] provides a comprehensive review of both the algorithmic and system design aspects of MoEs. For this study, we select four representative candidates among current open-sourced MoE LLMs for analysis to gain intriguing insights.

Projection of Expert Matrices in Low-dimensional Space

Section titled “Projection of Expert Matrices in Low-dimensional Space”

[figure owed: Figure 6. Projection of expert matrices in 2D space. Each layer contains three graphs, corresponding to W_{\text{up}}, W_{\text{act}}, and W_{\text{down}}, respectively. For DeepSeek, the indices of the removed outliers are listed on top of each graph.]

To better understand the relationships among experts, we employ principal components analysis (PCA) to project the flattened vectors of weight matrices into two-dimensional space. The vectors are standardized before applying PCA. Figure 6 depicts the resulting 2D projection.

Mixtral and Mistral. Consistent with the observations in Section 4.1.1, the figures for the three matrices appear similar. Generally, about half of the Mixtral experts cluster closely together and near the Mistral FFN, while the others locate much farther away. Moreover, the outliers correspond to the dark crosses.

DeepSeek. Only routed experts are considered due to differences in hidden sizes. Because several outliers exist, causing the remaining data points to be densely gathered, we remove them using the DBSCAN algorithm with ϵ=50\epsilon=50 and plot the rest in Figure 6. It can be observed that the experts distribute rather densely, especially for WupW_{\text{up}}. Although the distribution of experts varies for three matrices, the figures for WupW_{\text{up}} and WdownW_{\text{down}} are more similar than those of the gate matrix.

Grok. Typically, about half of the Grok experts densely gather for WupW_{\text{up}} and WdownW_{\text{down}}. The other half turns out to be outliers even though no dark cross were observed before. . Furthermore, the outliers of the three matrices partially coincide.

[figure owed: Figure 7. Projection of expert neurons in 2D/3D space. Each layer contains three graphs, corresponding to W_{\text{up}}, W_{\text{act}}, and W_{\text{down}}, respectively.]

To project the neurons into a 2D or 3D space, each row vector of WupW_{\text{up}} and WactW_{\text{act}}, or each column vector of WdownW_{\text{down}}, is treated as a single data point. Standardization is then applied, following by PCA. The visualization of the principal components is illustrated in Figure 7. Different colors refer to neurons belonging to different experts.

Common. The vast majority of neurons gather in the low-dimensional space. In some layers, the distribution of neurons forms a special shape, such as a cross or a thick line, which appears the most often for WdownW_{\text{down}}, followed by WupW_{\text{up}}, and finally WactW_{\text{act}}. Compared to ellipses, these shapes indicate that the neurons are relatively more similar.

Mixtral and Mistral. The neurons in the Mistral FFN distribute more densely than those of the Mixtral experts. Notably, the distribution shape of neurons in the FFN and experts are usually alike, even for the outliers.

DeepSeek and Grok. The number of outliers is a bit greater tahn that observed in Mixtral.

To investigate expert correlation at the neuron level, the averaging approach simply averages the rows (for WupW_{\text{up}} and WactW_{\text{act}}) or the columns (for WdownW_{\text{down}}) of the weight matrices and then calculates the similarity of the resulting vectors across experts. Figure 8 displays the graphs.

Common. The heat maps of WupW_{\text{up}} and WdownW_{\text{down}} are nearly identical to those presented in Section 4.1.1. Yet the similarities of WactW_{\text{act}} significantly increase.

Mixtral and Mistral.

The dark crosses sometimes disappear. In the figures for WactW_{\text{act}}, the similarities between the experts and the Mistral FFN are often lower than the similarities among the experts themselves (i.e., See>SefS_{\text{ee}}>S_{\text{ef}}), which is contrary to previous observations. This can happen if the expert neurons in different positions are alike. For instance, given three vectors f=(0,0)f=(0, 0), e1=(1,0)e_1=(1, 0), and e2=(0,1)e_2=(0, 1), the vector similarity Se1e2S_{e_1e_2} is lower than Se1fS_{e_1f} and Se2fS_{e_2f}. If averaging the elements, we have fˉ=(0)\bar{f}=(0), eˉ1=(0.5)\bar{e}_1=(0.5), and eˉ2=(0.5)\bar{e}_2=(0.5), then Se1e2S_{e_1e_2} becomes the highest.

DeepSeek. The growth of the WactW_{\text{act}} similarity values is directly proportional to the layer depth.

Gork. In the heat map of WactW_{\text{act}}, dark crosses frequently appear in various positions.

[figure owed: Figure 8. Similarity heat maps of gate embedding (leftmost graph of each layer) along with the neuron-level similarity heat maps using averaging method. The tick numbers refer to the expert indices.]

Table 5. Pearson correlation coefficients (RR) of the paired dataset (X,Yact)(X, Y_{\text{act}}).

Since the gate embedding matrix WgW_g determines the gate decision, there may be a relationship between WgW_g and the experts. To investigate this, we measure the similarities between the gate embedding vectors, Wg[n,:]W_g[n,:] for n∈[1,N]n \in [1, N], and compare them with the neuron-level averaging heat maps of experts presented in Section 4.1.2. The qualitative analysis of the combined graphs shown in Figure 8 is detailed in this section. The table containing the RR values for each layer (Table 5) is appended at the end.

Mixtral. Focusing on the heat maps of WgW_g, the similarities typically range from 0.2 to 0.4, with a noticeable increase in the last layer. Moreover, dark crosses are rarely found. Surprisingly, the patterns in the heat maps of WgW_g and of expert neurons in WactW_{\text{act}} are partially alike in some layers. This implies that the way a gate selects experts might be relevant to how an expert activates its neurons.

DeepSeek. Unlike the almost all-zero heat maps of WupW_{\text{up}} and WdownW_{\text{down}}, the similarities of gate neurons sometimes exceed 0.4. In addition, the heat maps of WgW_g and WactW_{\text{act}} show similar patterns. However, the overall similarities of WgW_g decrease with depth while the similarities of WactW_{\text{act}} gradually grow. This indicates that as the layer depth increases, the gate “looks” at the input feature in more diverse ways when assigning scores to different experts, even as the neuron activations of the experts become more similar.

Grok. Both dark and bright crosses commonly exist in the heat maps of WgW_g, whose patterns are similar to those of WactW_{\text{act}}. Specially, their patterns show opposite color tendency (i.e., deep color positions in one heat map becomes light color in another) starting form the intermediate layers. The similarities of WgW_g decrease when the layer depth increases, except for the last few layers.

To ensure the universality of our findings, we repeat the experiments that require the long input (§ 5.1, § 5.2) using additional datasets. Specifically, we utilize the entire test set of WikiText-103 [Merity et al. 2016] (266K tokens) and of a math dataset GSM8K [Cobbe et al. 2021] (84K tokens), and 1000 sequences from the code dataset Magicoder-Evol-Instruct-110K [Wei et al. 2024] (188K tokens). As shown in Figure 9, Figure 11, Figure 13, the new figures of Mixtral and DeepSeek align with the previous results illustrated in the main context, even when using datasets of specific subjects like math and code (we did not test on the Grok model due to limited computation resources). These supplementary results demonstrate that our findings are general and not limited to the initial input sources.

[figure owed: Figure 9. Average similarity heat maps of expert output features using (1) the long sequence, (2) WikiText-103, (3) GSM8K, and (4) Magicoder-Evol-Instruct-110K. The tick numbers refer to the expert indices. "F" and "SE" denote the Mistral FFN and the DeepSeek shared expert, respectively.]

[figure owed: Figure 10. Counts of the gate score ranking for each norm ranking using the long input. The larger the rank number, the larger the norm or score.]

[figure owed: Figure 11. Counts of the gate score ranking for Mixtral expert ourput norm rankings using additional datasets, namely WikiText-103 (top), GSM8K (middle), and Magicoder-Evol-Instruct-110K (bottom). The larger the rank number, the larger the norm or score.]

Table 6. Model performance on various benchmarks for the dynamic expert numbers experiment. “Bench avg” refers to the average performance over the four evaluated benchmarks.

[figure owed: Figure 12. Intermediate state values of Mixtral experts. The top k experts are shown on top of each heat map. Each number in the vertical axis refers to an expert index while the horizontal axis represents the number of neurons.]

[figure owed: Figure 13. Counts of the gate score ranking for DeepSeek expert ourput norm rankings using additional datasets, namely WikiText-103 (top), GSM8K (middle), and Magicoder-Evol-Instruct-110K (bottom) The larger the rank number, the larger the norm or score.]

In Section 5.2, we notice that in some MoE models, the two experts chosen by the gate usually produce feature vectors with the highest norms. To further investigate this, we repeat the experiment using the long input and additional datasets, and the statistical results are shown in Figure 10, Figure 11, Figure 13.

Mixtral. It is evident that the expert which outputs the largest norm is most frequently assigned the highest score. Surprisingly, for every ii, the ii-th highest score is most likely assigned to the expert with the ii-th highest output.

DeepSeek. For the experts that generate the first few largest norms (rank 60th^{\text{th}} to 64th^{\text{th}}), they are most likely to receive the highest scores. But we do not observe a similar relationship for the rest of the experts. On the contrary, the gate assigns relatively high scores more frequently than low scores to the experts with the smallest norms. For experts ranked 49th^{\text{th}} to 59th^{\text{th}} in terms of output norms, they tend to receive either low scores or high scores.

Grok. In contrast to the previous models, the output norms of the Grok experts tend to have an inverse relationship with the scores. More generally, the experts with the first few highest outputs are frequently assigned either low scores or high scores. One possible explanation could be the relatively low activation ratios of GeLU (see Appendix I), which may result in a weaker dependence on the norm for gate decisions.

Table 7. Model architecture for the dynamic expert numbers experiment.

While Section 5.1 focused on the final outputs of experts, we continue our analysis here by examining their intermediate outputs to examine the inner states of the experts. Given an input xx, the intermediate state of an expert refers to the output of σ(Wactx)∈Rdhid\sigma(W_{\text{act}}x) \in \mathbb{R}^{d_{\text{hid}}} , where σ\sigma denotes an activation function. These intermediate vectors control the activation of neurons, so we simply record them for analysis with the short input used. Mixtral, Mistral, and DeepSeek utilize SiLU as the activation function, while Grok adopts GeLU. Figure 12 depicts the magnitude of the vectors for Mixtral across three tokens.

Common. Each figure contains some horizontal lines, indicating the presence of an “outlier” expert with either the highest or lowest activation values. Nonetheless, there is no clear relationship between these phenomena and the gate decisions.

Mixtral and Mistral.

For a single token, we found that, on average, the absolute activation value of 99.6% elements in each expert exceeds 0.001 after applying the SiLU activation function. This high ratio indicates that the vast majority of neurons in an expert are activated.

In Figure 12, some vertical lines across all experts are commonly found, meaning that the WactW_{\text{act}} matrices of different experts assign similar activation values to neurons with the same indices. In addition, the magnitude of the intermediate states grows along with layer depth, which aligns with the observation in Section 5.1.

DeepSeek. On average, 99.7% of the neurons in each expert have an absolute activation value exceeding 0.001 after applying SiLU. Vertical lines rarely exist in the DeepSeek model. Similarly, the elements in the intermediate state vectors get larger as the layer goes deeper.

Grok. With GeLU as the activation function, only 25.3% neurons per Grok expert attain an absolute activation value greater than 0.001. The activation values are generally smaller than those in Mixtral and DeepSeek. [Li et al. 2022; Song et al. 2024] suggest such difference largely stems from the distinct activation functions used.

Interestingly, [Song et al. 2024] further utilize the sparsity in experts within SMoE to achieve SOTA performance when activating the same number of parameters.

[figure owed: Figure 14. Routing patterns of different models. Deeper colors mean higher gate scores assigned to the corresponding experts. Only scores of the top k experts are illustrated.]

This experiment aims to examine the routing patterns. We feed an input prompt with about 64 tokens into the MoE models and record the gate scores (after applying softmax) for the selected experts for each token. In addition to the base model of Mixtral (Mixtral-Base), we also include its instruct version (Mixtral-Instruct) in this experiment. The results are depicted in Figure 14.

Mixtral. In Mixtral-Base, the experts are selected fairly evenly across tokens, and it is common to see sequences of more than four tokens routed to the same expert. But the “special expert” with the dark cross in previous similarity graphs turns out to be an exception. These special experts are chosen less frequently and tend to receive relatively low scores. The routing pattern of Mixtral-Instruct is largely identical to that of Mixtral-Base, which indicates fine-tuning has little impact on gate decisions.

DeepSeek. In some layers, there is an expert selected by most tokens. However, no distinct characteristics for these experts are observed in the previous similarity heat maps. Note that the gate scores for DeepSeek are typically lower than those for Mixtral because DeepSeek applies softmax before the top-k operation, while Mixtral adopts the reverse way.

Grok. The expert selection is rather even and some relatively high scores exist in the deeper (>30th^{\text{th}}) layers. Same as DeepSeek, softmax is applied before the top-k operation for Grok.

  1. [cai2024survey] Weilin Cai, Juyong Jiang, Fan Wang, Jing Tang, Sunghun Kim, and Jiayi Huang. 2024. \newblock A survey on mixture of experts. \newblock arXiv preprint arXiv:2407.06204.
  2. [chen2022towards] Zixiang Chen, Yihe Deng, Yue Wu, Quanquan Gu, and Yuanzhi Li. 2022. \newblock Towards understanding the mixture-of-experts layer in deep learning. \newblock Advances in neural information processing systems, 35:23049--23062.
  3. [chi2022representation] Zewen Chi, Li Dong, Shaohan Huang, Damai Dai, Shuming Ma, Barun Patra, Saksham Singhal, Payal Bajaj, Xia Song, Xian-Ling Mao, et al. 2022. \newblock On the representation collapse of sparse mixture of experts. \newblock Advances in Neural Information Processing Systems, 35:34600--34613.
  4. [cobbe2021gsm8k] Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Mark Chen, Heewoo Jun, Lukasz Kaiser, Matthias Plappert, Jerry Tworek, Jacob Hilton, Reiichiro Nakano, Christopher Hesse, and John Schulman. 2021. \newblock Training verifiers to solve math word problems. \newblock arXiv preprint arXiv:2110.14168.
  5. [dai2024deepseekmoe] Damai Dai, Chengqi Deng, Chenggang Zhao, RX Xu, Huazuo Gao, Deli Chen, Jiashi Li, Wangding Zeng, Xingkai Yu, Y Wu, et al. 2024. \newblock Deepseekmoe: Towards ultimate expert specialization in mixture-of-experts language models. \newblock arXiv preprint arXiv:2401.06066.
  6. [dai2022stablemoe] Damai Dai, Li Dong, Shuming Ma, Bo Zheng, Zhifang Sui, Baobao Chang, and Furu Wei. 2022. \newblock Stablemoe: Stable routing strategy for mixture of experts. \newblock arXiv preprint arXiv:2204.08396.
  7. [geva2020transformer] Mor Geva, Roei Schuster, Jonathan Berant, and Omer Levy. 2020. \newblock Transformer feed-forward layers are key-value memories. \newblock arXiv preprint arXiv:2012.14913.
  8. [jiang2023mistral] Albert Q Jiang, Alexandre Sablayrolles, Arthur Mensch, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Florian Bressand, Gianna Lengyel, Guillaume Lample, Lucile Saulnier, et al. 2023. \newblock Mistral 7b. \newblock arXiv preprint arXiv:2310.06825.
  9. [jiang2024mixtral] Albert Q Jiang, Alexandre Sablayrolles, Antoine Roux, Arthur Mensch, Blanche Savary, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Emma Bou Hanna, Florian Bressand, et al. 2024. \newblock Mixtral of experts. \newblock arXiv preprint arXiv:2401.04088.
  10. [jonker1988shortest] Roy Jonker and Ton Volgenant. 1988. \newblock A shortest augmenting path algorithm for dense and sparse linear assignment problems. \newblock In DGOR/NSOR: Papers of the 16th Annual Meeting of DGOR in Cooperation with NSOR/Vorträge der 16. Jahrestagung der DGOR zusammen mit der NSOR, pages 622—622. Springer.
  11. [komatsuzaki2022sparse] Aran Komatsuzaki, Joan Puigcerver, James Lee-Thorp, Carlos Riquelme Ruiz, Basil Mustafa, Joshua Ainslie, Yi Tay, Mostafa Dehghani, and Neil Houlsby. 2022. \newblock Sparse upcycling: Training mixture-of-experts from dense checkpoints. \newblock arXiv preprint arXiv:2212.05055.
  12. [li2023merge] Pingzhi Li, Zhenyu Zhang, Prateek Yadav, Yi-Lin Sung, Yu Cheng, Mohit Bansal, and Tianlong Chen. 2023. \newblock Merge, then compress: Demystify efficient smoe with hints from its routing policy. \newblock arXiv preprint arXiv:2310.01334.
  13. [li2022lazy] Zonglin Li, Chong You, Srinadh Bhojanapalli, Daliang Li, Ankit Singh Rawat, Sashank J Reddi, Ke Ye, Felix Chern, Felix Yu, Ruiqi Guo, et al. 2022. \newblock The lazy neuron phenomenon: On emergence of activation sparsity in transformers. \newblock arXiv preprint arXiv:2210.06313.
  14. [liu2023towards] Zeyu Leo Liu, Tim Dettmers, Xi Victoria Lin, Veselin Stoyanov, and Xian Li. 2023. \newblock Towards a unified view of sparse feed-forward network in pretraining large language model. \newblock arXiv preprint arXiv:2305.13999.
  15. [lu2024not] Xudong Lu, Qi Liu, Yuhui Xu, Aojun Zhou, Siyuan Huang, Bo Zhang, Junchi Yan, and Hongsheng Li. 2024. \newblock Not all experts are equal: Efficient expert pruning and skipping for mixture-of-experts large language models. \newblock arXiv preprint arXiv:2402.14800.
  16. [merity2016pointer] Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. 2016. \newblock Pointer sentinel mixture models. \newblock arXiv preprint arXiv:1609.07843.
  17. [pham2024competesmoe] Quang Pham, Giang Do, Huy Nguyen, TrungTin Nguyen, Chenghao Liu, Mina Sartipi, Binh T Nguyen, Savitha Ramasamy, Xiaoli Li, Steven Hoi, et al. 2024. \newblock Competesmoe—effective training of sparse mixture of experts via competition. \newblock arXiv preprint arXiv:2402.02526.
  18. [qiu2023emergent] Zihan Qiu, Zeyu Huang, and Jie Fu. 2023. \newblock Emergent mixture-of-experts: Can dense pre-trained transformers benefit from emergent modular structures? \newblock arXiv preprint arXiv:2310.10908.
  19. [qiu2024unlocking] Zihan Qiu, Zeyu Huang, and Jie Fu. 2024{\natexlab{a}}. \newblock Unlocking emergent modularity in large language models. \newblock In Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers), pages 2638—2660.
  20. [qiu2024empirical] Zihan Qiu, Zeyu Huang, Youcheng Huang, and Jie Fu. 2024{\natexlab{b}}. \newblock Empirical study on updating key-value memories in transformer feed-forward layers. \newblock arXiv preprint arXiv:2402.12233.
  21. [reid2024gemini] Machel Reid, Nikolay Savinov, Denis Teplyashin, Dmitry Lepikhin, Timothy Lillicrap, Jean-baptiste Alayrac, Radu Soricut, Angeliki Lazaridou, Orhan Firat, Julian Schrittwieser, et al. 2024. \newblock Gemini 1.5: Unlocking multimodal understanding across millions of tokens of context. \newblock arXiv preprint arXiv:2403.05530.
  22. [shazeer2017outrageously] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton, and Jeff Dean. 2017. \newblock Outrageously large neural networks: The sparsely-gated mixture-of-experts layer. \newblock arXiv preprint arXiv:1701.06538.
  23. [shen2024jetmoe] Yikang Shen, Zhen Guo, Tianle Cai, and Zengyi Qin. 2024. \newblock Jetmoe: Reaching llama2 performance with 0.1 m dollars. \newblock arXiv preprint arXiv:2404.07413.
  24. [shen2023moduleformer] Yikang Shen, Zheyu Zhang, Tianyou Cao, Shawn Tan, Zhenfang Chen, and Chuang Gan. 2023. \newblock Moduleformer: Learning modular large language models from uncurated data. \newblock arXiv preprint arXiv:2306.04640.
  25. [shi2024unchosen] Chufan Shi, Cheng Yang, Xinyu Zhu, Jiahao Wang, Taiqiang Wu, Siheng Li, Deng Cai, Yujiu Yang, and Yu Meng. 2024. \newblock Unchosen experts can contribute too: Unleashing moe models’ power by self-contrast. \newblock arXiv preprint arXiv:2405.14507.
  26. [shleifer2021normformer] Sam Shleifer, Jason Weston, and Myle Ott. 2021. \newblock Normformer: Improved transformer pretraining with extra normalization. \newblock arXiv preprint arXiv:2110.09456.
  27. [song2024prosparse] Chenyang Song, Xu Han, Zhengyan Zhang, Shengding Hu, Xiyu Shi, Kuai Li, Chen Chen, Zhiyuan Liu, Guangli Li, Tao Yang, et al. 2024{\natexlab{a}}. \newblock Prosparse: Introducing and enhancing intrinsic activation sparsity within large language models. \newblock arXiv preprint arXiv:2402.13516.
  28. [song2024turbo] Yixin Song, Haotong Xie, Zhengyan Zhang, Bo Wen, Li Ma, Zeyu Mi, and Haibo Chen. 2024{\natexlab{b}}. \newblock Turbo sparse: Achieving llm sota performance with minimal activated parameters. \newblock arXiv preprint arXiv:2406.05955.
  29. [sun2024transformer] Qi Sun, Marc Pickett, Aakash Kumar Nain, and Llion Jones. 2024. \newblock Transformer layers as painters. \newblock arXiv preprint arXiv:2407.09298.
  30. [qwen_moe] Qwen Team. 2024. \newblock \href {https://qwenlm.github.io/blog/qwen-moe/} {Qwen1.5-moe: Matching 7b model performance with 1/3 activated parameters”}.
  31. [touvron2023llama] Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, et al. 2023. \newblock Llama: Open and efficient foundation language models. \newblock arXiv preprint arXiv:2302.13971.
  32. [wei2024skywork] Tianwen Wei, Bo Zhu, Liang Zhao, Cheng Cheng, Biye Li, Weiwei Lü, Peng Cheng, Jianhao Zhang, Xiaoyu Zhang, Liang Zeng, et al. 2024{\natexlab{a}}. \newblock Skywork-moe: A deep dive into training techniques for mixture-of-experts language models. \newblock arXiv preprint arXiv:2406.06563.
  33. [wei2024magicoder] Yuxiang Wei, Zhe Wang, Jiawei Liu, Yifeng Ding, and Lingming Zhang. 2024{\natexlab{b}}. \newblock Magicoder: Empowering code generation with oss-instruct. \newblock In Forty-first International Conference on Machine Learning.
  34. [wu2022residual] Lemeng Wu, Mengchen Liu, Yinpeng Chen, Dongdong Chen, Xiyang Dai, and Lu Yuan. 2022. \newblock Residual mixture of experts. \newblock arXiv preprint arXiv:2204.09636.
  35. [wu2024yuan] Shaohua Wu, Jiangang Luo, Xi Chen, Lingjun Li, Xudong Zhao, Tong Yu, Chao Wang, Yue Wang, Fei Wang, Weixu Qiao, et al. 2024. \newblock Yuan 2.0-m32: Mixture of experts with attention router. \newblock arXiv preprint arXiv:2405.17976.
  36. [xue2024openmoe] Fuzhao Xue, Zian Zheng, Yao Fu, Jinjie Ni, Zangwei Zheng, Wangchunshu Zhou, and Yang You. 2024. \newblock Openmoe: An early effort on open mixture-of-experts language models. \newblock arXiv preprint arXiv:2402.01739.
  37. [zhang2022mixture] Xiaofeng Zhang, Yikang Shen, Zeyu Huang, Jie Zhou, Wenge Rong, and Zhang Xiong. 2022. \newblock Mixture of attention heads: Selecting attention heads per token. \newblock arXiv preprint arXiv:2210.05144.
  38. [zhang2024diversifying] Zeliang Zhang, Xiaodong Liu, Hao Cheng, Chenliang Xu, and Jianfeng Gao. 2024. \newblock Diversifying the expert knowledge for task-agnostic pruning in sparse mixture-of-experts. \newblock arXiv preprint arXiv:2407.09590.
  39. [zhang2021moefication] Zhengyan Zhang, Yankai Lin, Zhiyuan Liu, Peng Li, Maosong Sun, and Jie Zhou. 2021. \newblock Moefication: Transformer feed-forward layers are mixtures of experts. \newblock arXiv preprint arXiv:2110.01786.
  40. [zoph2022st] Barret Zoph, Irwan Bello, Sameer Kumar, Nan Du, Yanping Huang, Jeff Dean, Noam Shazeer, and William Fedus. 2022. \newblock St-moe: Designing stable and transferable sparse expert models. \newblock arXiv preprint arXiv:2202.08906.
  41. [zuo2021taming] Simiao Zuo, Xiaodong Liu, Jian Jiao, Young Jin Kim, Hany Hassan, Ruofei Zhang, Tuo Zhao, and Jianfeng Gao. 2021. \newblock Taming sparsely activated transformer with stochastic experts. \newblock arXiv preprint arXiv:2110.04260. \end{thebibliography}
  1. https://github.com/xai-org/grok-1 ↩

  2. For the Mixtral 8x22B model, we only conduct most of the analyses mentioned in the main context (excluding those in the appendix) due to time limit. ↩

  3. The observations shared by all of our investigated models are written in the Common part. ↩

  4. The specific tokens are , As, an, open, source, alternative, to, where the start of the sentence symbol does not applicable for the Grok tokenizer. ↩