SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2310.01334 · ICLR · 2024

Merge, Then Compress: Demystify Efficient SMoE with Hints from Its Routing Policy

Tianlong Chen, Yu Cheng, Mohit Bansal, Zhenyu Zhang, Yi-Lin Sung, Prateek Yadav, Pingzhi Li

arXiv · PDF · Open in the Atlas

Code that ran

7 of 7 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 4 honoured the contract we drafted, 2 violated it and 1 has no contract verdict; 0 failures of our instrument; 0 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2310.01334.json · badge: /api/ran/2310.01334.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
unites-lab/mc-smoe canonical (classifier label)
classifier basis: classifier_2025
4 ran · 0 no recorded run
UNITES-Lab/MC-SMoE canonical (classifier label)
classifier basis: census
3 ran · 0 no recorded run
FunctionStatusWhere it lives
ExpertsGrouperForSwitch Ran
ran on a synthesized input · constructed an object; no result was computed
unites-lab/mc-smoe/mcsmoe/merging/grouping.py
code served (permissive licence) · get_code("fd729d8d235a3757")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, ExpertsGrouperForSwitch: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import random
from transformers import SwitchTransformersConfig

torch.manual_seed(0)
random.seed(0)

# Create a minimal SwitchTransformersConfig
config = SwitchTransformersConfig(
    vocab_size=100,
    d_model=64,
    d_kv=32,
    d_ff=128,
    num_layers=8,
    num_heads=4,
    num_experts=8,
    encoder_sparse_step=2,
    decoder_sparse_step=2,
    expert_capacity_factor=1.0,
    router_z_loss_coef=0.1,
    router_aux_loss_coef=0.1,
)

ARGS = {
    'config': config,
    'similarity_fn': 'cosine',
    'similarity_base': 'weight',
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
scipy, sklearn, torch, tqdm, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ExpertsGrouperForSwitch — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a ExpertsGrouperForSwitch output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
generate_random_group_labels Ran
ran, honoured the contract we drafted
unites-lab/mc-smoe/mcsmoe/merging/grouping.py
code served (permissive licence) · get_code("e5839c1e066ffc90")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 1, dtype family int, shape (10,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import random

torch.manual_seed(0)
random.seed(0)

ARGS = {
    "num_experts": 10,
    "num_groups": 3,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 1, dtype family int, shape (10,) — shape (10,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
sanitize_merging_layers Ran
ran, violated the contract we drafted
unites-lab/mc-smoe/mcsmoe/msmoe-merging.py
code served (permissive licence) · get_code("654f3d919093632b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned list, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

# Test case 1: None input
ARGS_1 = {
    "layers": None
}

# Test case 2: String with comma-separated values
ARGS_2 = {
    "layers": "1,3,5,7"
}

# Test case 3: Empty string
ARGS_3 = {
    "layers": ""
}

# Test case 4: Single integer
ARGS_4 = {
    "layers": 5
}

# Test case 5: List of integers
ARGS_5 = {
    "layers": [2, 4, 6, 8]
}

# Use the first test case as the primary ARGS
ARGS = ARGS_1
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
sanitize_merging_layers Ran
ran, violated the contract we drafted
unites-lab/mc-smoe/mcsmoe/losparse-downstream.py
code served (permissive licence) · get_code("5a9a3df7db5c12d8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned list, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from typing import Union, List

torch.manual_seed(0)

# Test case 1: None input
ARGS_1 = {
    "layers": None
}

# Test case 2: String with comma-separated values
ARGS_2 = {
    "layers": "1,3,5,7"
}

# Test case 3: Empty string
ARGS_3 = {
    "layers": ""
}

# Test case 4: Integer input
ARGS_4 = {
    "layers": 5
}

# Test case 5: List input
ARGS_5 = {
    "layers": [2, 4, 6, 8]
}

# Use the first test case as the primary ARGS
ARGS = ARGS_1
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
sanitize_merging_layers Ran
ran, honoured the contract we drafted
UNITES-Lab/MC-SMoE/mcsmoe/prune-non-core-experts-and-kd-downstream.py
code served (permissive licence) · get_code("97f21e77592be7a0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

ARGS = {
    "layers": "1,3,5,7,9"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
sanitize_pruning_layers Ran
ran, honoured the contract we drafted
UNITES-Lab/MC-SMoE/mcsmoe/switch-finetune-with-task-specific-pruning.py
code served (permissive licence) · get_code("cd6cf7dbefcd9099")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from typing import Union, List

def sanitize_pruning_layers(layers: Union[str, List, int]):
    if layers is None:
        layers = list(range(1, 12, 2))
    elif isinstance(layers, str) and len(layers) > 0:
        layers = [int(x) for x in layers.split(',')]
    elif isinstance(layers, str) and len(layers) == 0:
        layers = []
    elif isinstance(layers, int):
        layers = [layers]
    return layers

# Test case 1: None input
ARGS_1 = {"layers": None}

# Test case 2: string with comma-separated values
ARGS_2 = {"layers": "1,3,5,7"}

# Test case 3: empty string
ARGS_3 = {"layers": ""}

# Test case 4: single integer
ARGS_4 = {"layers": 5}

# Test case 5: list input
ARGS_5 = {"layers": [2, 4, 6, 8]}

# Use the first test case as the main ARGS
ARGS = ARGS_1
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
sanitize_pruning_layers Ran
ran, honoured the contract we drafted
UNITES-Lab/MC-SMoE/mcsmoe/fsgpt-zero-shot-losparse.py
code served (permissive licence) · get_code("e4c849c6d01182d2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from typing import Union, List, Optional

torch.manual_seed(0)

# Test case 1: None input
ARGS_1 = {"layers": None}

# Test case 2: String with comma-separated integers
ARGS_2 = {"layers": "1,3,5,7"}

# Test case 3: Empty string
ARGS_3 = {"layers": ""}

# Test case 4: Single integer
ARGS_4 = {"layers": 5}

# Test case 5: List of integers
ARGS_5 = {"layers": [1, 2, 3, 4]}

# We'll use the first test case as the primary ARGS
ARGS = ARGS_1
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 1 later) and 4 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
generate_random_group_labels
brick of this paper's assembly: helper
1 other paper
1 later
2410.08589 (2024-10)
Retraining-Free Merging of Sparse MoE via Hierarchical Clustering

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Sparsely activated Mixture-of-Experts (SMoE) has shown promise to scale up the learning capacity of neural networks, however, they have issues like: (a) High Memory Usage, due to duplication of the network layers into multiple copies as experts; and (b) Redundancy in Experts, as common learning-based routing policies suffer from representational collapse. Therefore, vanilla SMoE models are memory inefficient and non-scalable, especially for resource-constrained downstream scenarios. In this paper, we ask: Can we craft a compact SMoE model by consolidating expert information? What is the best recipe to merge multiple experts into fewer but more knowledgeable experts? Our pilot investigation reveals that conventional model merging methods fail to be effective in such expert merging for SMoE. The potential reasons are: (1) redundant information overshadows critical experts; (2) appropriate neuron permutation for each expert is missing to bring all of them in alignment. To address these challenges, we propose a novel merging algorithm for SMoE, i.e., M-SMoE, which leverages routing statistics to guide expert merging. Specifically, it starts with neuron permutation alignment for experts; then, dominant experts and their "group members" are formed based on routing policies; lastly, every expert group is merged into a single expert by utilizing each expert's activation frequency as their weight for merging, thus diminishing the impact of insignificant experts. Moreover, we draw an interesting observation that our proposed merging promotes a low dimensionality in the merged expert's weight space, naturally paving the way for additional compression. Hence, our final method, MC-SMoE (i.e., Merge, then Compress SMoE), further decomposes the merged experts into low-rank and structural sparse alternatives. Extensive experiments across 8 benchmarks validate the effectiveness of our proposals. For instance, our MC-SMoE achieves up to 80% memory and a 20% FLOPs reduction, with virtually no loss in performance. 1

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2310.01334")
get_code_for_paper("2310.01334")
have("2310.01334")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2310.01334.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2310.01334.svg)](https://syntology.ai/paper/2310.01334)

Connect an agent — have() is free.