SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2101.03961 · 2021

Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity

Barret Zoph, William Fedus, Noam Shazeer, Alexander Clark

arXiv · PDF · Open in the Atlas

Code that ran

7 of 13 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 4 failures of our instrument; 6 no recorded run), measured 2026-11-23; 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/2101.03961.json · badge: /api/ran/2101.03961.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
zyphra/blackmamba extension (classifier label)
classifier basis: classifier_2025
5 ran · 2 no recorded run
efeslab/fiddler application (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
copy not recorded community
not in the paper's declared repositories
1 ran · 0 no recorded run
tensorflow/mesh application (classifier label)
classifier basis: classifier_2025
0 ran · 4 no recorded run
FunctionStatusWhere it lives
MLP Ran
ran on a synthesized input · constructed an object; no result was computed
zyphra/blackmamba/switch_mlp.py
pointer only (licence: NONE) · get_code("ff4dfeb7df35fff6")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, zyphra/blackmamba when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

MambaConfig Ran
ran on a synthesized input · constructed an object; no result was computed
zyphra/blackmamba/switch_mlp.py
pointer only (licence: NONE) · get_code("1db09a0131e40faf")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, zyphra/blackmamba when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

MixtralBlockSparseTop2MLP Ran
ran on a synthesized input
efeslab/fiddler/benchmarks/mixtral_offloading/src/custom_layers.py
code served (permissive licence) · get_code("74374c911af39f6c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 4) 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.

from transformers.models.mixtral.configuration_mixtral import MixtralConfig
from transformers.activations import ACT2FN
import torch
from torch import nn

class MixtralBlockSparseTop2MLP(nn.Module):

    def __init__(self, config: MixtralConfig):
        super().__init__()
        self.ffn_dim = config.intermediate_size
        self.hidden_dim = config.hidden_size
        self.w1 = nn.Linear(self.hidden_dim, self.ffn_dim, bias=False, dtype=torch.float16)
        self.w2 = nn.Linear(self.ffn_dim, self.hidden_dim, bias=False, dtype=torch.float16)
        self.w3 = nn.Linear(self.hidden_dim, self.ffn_dim, bias=False, dtype=torch.float16)
        self.act_fn = ACT2FN[config.hidden_act]

    def forward(self, hidden_states):
        current_hidden_states = self.act_fn(self.w1(hidden_states)) * self.w3(hidden_states)
        current_hidden_states = self.w2(current_hidden_states)
        return current_hidden_states


config = MixtralConfig(
    hidden_size=4,
    intermediate_size=8,
    hidden_act="silu"
)

INIT_ARGS = {
    "config": config
}

ARGS = {
    "hidden_states": torch.randn(2, 3, 4, dtype=torch.float16)
}

module = MixtralBlockSparseTop2MLP(**INIT_ARGS)
output = module(**ARGS)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 3, 4) — shape (2, 3, 4) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
init_method_normal Ran
ran; our contract draft was wrong, not the code
zyphra/blackmamba/switch_mlp.py
pointer only (licence: NONE) · get_code("58a3d812be2f2018")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, zyphra/blackmamba when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

scaled_init_method_normal Ran
ran; our contract draft was wrong, not the code
zyphra/blackmamba/switch_mlp.py
pointer only (licence: NONE) · get_code("c319770f5ead4490")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, zyphra/blackmamba when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

selective_scan_ref Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from state-spaces/mamba
pointer only · get_code("ba7b868fec181b57")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

sinkhorn Ran
ran; our contract draft was wrong, not the code
zyphra/blackmamba/switch_mlp.py
pointer only (licence: NONE) · get_code("bfbd162761e2e475")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, zyphra/blackmamba when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

SwitchMLP Not yet run
unverified (harvested, no recorded run)
zyphra/blackmamba/switch_mlp.py
pointer only (licence: NONE) · get_code("02e5457338807a13")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, zyphra/blackmamba when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

_add_token_emb_to_gate_inputs Not yet run
unverified (harvested, no recorded run)
tensorflow/mesh/mesh_tensorflow/transformer/moe.py
code served (permissive licence) · get_code("898627b88bfd6d44")
How it ran

no invocation recorded.

_router_z_loss Not yet run
unverified (harvested, no recorded run)
tensorflow/mesh/mesh_tensorflow/transformer/moe.py
code served (permissive licence) · get_code("7179ac118906b2a5")
How it ran

no invocation recorded.

_stochastically_use_non_top_expert Not yet run
unverified (harvested, no recorded run)
tensorflow/mesh/mesh_tensorflow/transformer/moe.py
code served (permissive licence) · get_code("da4ea018ee62163d")
How it ran

no invocation recorded.

_switch_gating Not yet run
unverified (harvested, no recorded run)
tensorflow/mesh/mesh_tensorflow/transformer/moe.py
code served (permissive licence) · get_code("2d4e03e49ac8f264")
How it ran

no invocation recorded.

selective_scan_fn Not yet run
unverified (harvested, no recorded run)
zyphra/blackmamba/ops/selective_scan_interface.py
pointer only (licence: NONE) · get_code("c48b9d686b548496")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, zyphra/blackmamba when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 3 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 3 later) and 10 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
selective_scan_ref 13 other papers
13 later
2402.05608 (2024-02)
Scalable Diffusion Models with State Space Backbone
2403.16899 (2024-03)
State Space Models as Foundation Models: A Control Theoretic Overview
2404.09498 (2024-04)
FusionMamba: Dynamic Feature Enhancement for Multimodal Image Fusion with Mamba
and 10 more not named here
selective_scan_fn 2 other papers
2 later
2405.15731 (2024-05)
Understanding the Differences in Foundation Models: Attention, State Space Models, and Recurrent Neural Networks
2505.02010 (2025-05)
Meta-Black-Box-Optimization through Offline Q-function Learning
sinkhorn
brick of this paper's assembly: helper
1 other paper
1 later
2603.14392 (2026-03)
WestWorld: A Knowledge-Encoded Scalable Trajectory World Model for Diverse Robotic Systems

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-23.

Repositories linked to this paper

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

Abstract

In deep learning, models typically reuse the same parameters for all inputs. Mixture of Experts (MoE) models defy this and instead select different parameters for each incoming example. The result is a sparsely-activated model-with an outrageous number of parameters-but a constant computational cost. However, despite several notable successes of MoE, widespread adoption has been hindered by complexity, communication costs, and training instability. We address these with the introduction of the Switch Transformer. We simplify the MoE routing algorithm and design intuitive improved models with reduced communication and computational costs. Our proposed training techniques mitigate the instabilities, and we show large sparse models may be trained, for the first time, with lower precision (bfloat16) formats. We design models based off T5-Base and T5-Large (Raffel et al., 2019) to obtain up to 7x increases in pre-training speed with the same computational resources. These improvements extend into multilingual settings where we measure gains over the mT5-Base version across all 101 languages. Finally, we advance the current scale of language models by pre-training up to trillion parameter models on the "Colossal Clean Crawled Corpus", and achieve a 4x speedup over the T5-XXL model. 12

For agents

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

get_harvested_code_for_paper("2101.03961")
get_code_for_paper("2101.03961")
have("2101.03961")

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

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

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

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

Connect an agent — have() is free.