SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2006.16668 · 2020

GShard: Scaling Giant Models with Conditional Computation and Automatic Sharding

Yanping Huang, Zhifeng Chen, Noam Shazeer, Dmitry Lepikhin, Dehao Chen

arXiv · PDF · Open in the Atlas

Code that ran

9 of 10 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, 1 violated it and 3 have no contract verdict; 5 failures of our instrument; 1 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/2006.16668.json · badge: /api/ran/2006.16668.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
lucidrains/mixture-of-experts community
Papers with Code archive
8 ran · 1 no recorded run
copy not recorded community
not in the paper's declared repositories
1 ran · 0 no recorded run
FunctionStatusWhere it lives
Experts Ran
ran on a synthesized input · constructed an object; no result was computed
lucidrains/mixture-of-experts/mixture_of_experts/mixture_of_experts.py
code served (permissive licence) · get_code("64ff1d169e3d5d58")
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, Experts: the run constructed the object and did not call it, so no result was computed. The image it ran in was 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
from torch import nn
import math

torch.manual_seed(0)

ARGS = {
    'dim': 4,
    'num_experts': 16,
    'hidden_dim': None,
    'activation': nn.GELU
}
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 Experts — 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 Experts 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
GELU_ Ran
ran on a synthesized input
lucidrains/mixture-of-experts/mixture_of_experts/mixture_of_experts.py
code served (permissive licence) · get_code("2e0378380cff133f")
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 2, dtype family float; 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 torch import nn
import math

class GELU_(nn.Module):

    def forward(self, x):
        return 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3))))


INIT_ARGS = {}

ARGS = {
    'x': torch.randn(2, 4)
}

if __name__ == '__main__':
    model = GELU_(**INIT_ARGS)
    output = model(**ARGS)
    print(output)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 2, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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)
Top2Gating Ran
ran on a synthesized input · constructed an object; no result was computed
lucidrains/mixture-of-experts/mixture_of_experts/mixture_of_experts.py
code served (permissive licence) · get_code("ed3578e7dda0ec22")
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, Top2Gating: the run constructed the object and did not call it, so no result was computed. The image it ran in was 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
from torch import nn

torch.manual_seed(0)

# Define ARGS dict with all parameters for Top2Gating.__init__
ARGS = {
    'dim': 4,
    'num_gates': 3,
    'eps': 1e-09,
    'outer_expert_dims': tuple(),
    'second_policy_train': 'random',
    'second_policy_eval': 'random',
    'second_threshold_train': 0.2,
    'second_threshold_eval': 0.2,
    'capacity_factor_train': 1.25,
    'capacity_factor_eval': 2.0,
}

# Create a sample input for forward pass testing
# Shape: (..., b, group_size, dim)
# where b=2, group_size=5, dim=4
sample_x = torch.randn(2, 5, 4)
sample_importance = torch.ones(2, 5)
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 Top2Gating — 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 Top2Gating 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
cast_tuple Ran
ran, violated the contract we drafted
this paper's copy was not recorded; identical code first harvested from lucidrains/compressive-transformer-pytorch
pointer only · get_code("369eced62e96d690")
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.

cumsum_exclusive Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
lucidrains/mixture-of-experts/mixture_of_experts/mixture_of_experts.py
code served (permissive licence) · get_code("2458c57b5f0bfa20")
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 2, dtype family float, shape (2, 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.

import torch
import torch.nn.functional as F

torch.manual_seed(0)

# Create a small tensor with distinct dimensions
# Shape: (2, 4) - batch size 2, feature dim 4
t = torch.randn(2, 4)

# The function uses:
# - t.shape to get dimensions
# - F.pad() to pad the tensor
# - .cumsum(dim=dim) to compute cumulative sum
# - indexing with [..., slice(...), *pre_slice]
# The dim parameter defaults to -1 (last dimension)

ARGS = {
    "t": t,
    "dim": -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 Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 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: none by the harness; any seed is in the setup block
default Ran
ran; our contract draft was wrong, not the code
lucidrains/mixture-of-experts/mixture_of_experts/mixture_of_experts.py
code served (permissive licence) · get_code("dc9f7b2b73cab379")
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 str. The image it ran in was 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
from inspect import isfunction

torch.manual_seed(0)

def default(val, default_val):
    default_val = default_val() if isfunction(default_val) else default_val
    return val if val is not None else default_val

# Test case 1: val is not None, should return val
val_1 = "test_value"
default_val_1 = "default_value"

# Test case 2: val is None, default_val is a function
val_2 = None
default_val_2 = lambda: "computed_default"

# Test case 3: val is None, default_val is not a function
val_3 = None
default_val_3 = 42

# Test case 4: val is not None with numeric types
val_4 = 100
default_val_4 = 200

ARGS = {
    "val": val_1,
    "default_val": default_val_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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
init_ Ran
ran; our contract draft was wrong, not the code
lucidrains/mixture-of-experts/mixture_of_experts/mixture_of_experts.py
code served (permissive licence) · get_code("2aa1ea9fba4dce15")
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 2, dtype family float, shape (2, 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.

import torch
import math

torch.manual_seed(0)

# The function init_ takes a tensor t, accesses its shape[-1] to get the last dimension,
# and calls uniform_(-std, std) on it. This is an in-place operation.
# We need to pass a tensor that supports these operations.

t = torch.randn(2, 4)

ARGS = {
    "t": t
}
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 2, dtype family float, shape (2, 4) — shape (2, 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: none by the harness; any seed is in the setup block
safe_one_hot Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
lucidrains/mixture-of-experts/mixture_of_experts/mixture_of_experts.py
code served (permissive licence) · get_code("d082003bd635a9de")
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 2, dtype family int, shape (4, 5) 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 torch.nn.functional as F

torch.manual_seed(0)

# Create a small tensor of indexes
# The function calls indexes.max(), so indexes must be a tensor
# It then calls F.one_hot on it, so it should contain non-negative integers
indexes = torch.tensor([0, 2, 1, 3], dtype=torch.long)

# max_length parameter - an integer that specifies the output dimension
max_length = 5

ARGS = {
    "indexes": indexes,
    "max_length": max_length,
}
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 2, dtype family int, shape (4, 5) — shape (4, 5) 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
top1 Ran
ran; our contract draft was wrong, not the code
lucidrains/mixture-of-experts/mixture_of_experts/mixture_of_experts.py
code served (permissive licence) · get_code("213bf6a36ff4baa6")
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 tuple, ndim 2, dtype family float; 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

torch.manual_seed(0)

# The function expects a tensor `t` with a topk method
# It calls t.topk(k=1, dim=-1) which returns (values, index)
# Then it squeezes both along dim=-1
# So we need a tensor with at least 2 dimensions

t = torch.randn(2, 4)

ARGS = {
    "t": t
}
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 tuple, ndim 2, dtype family float — a tuple 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
MoE Not yet run
unverified (harvested, no recorded run)
lucidrains/mixture-of-experts/mixture_of_experts/mixture_of_experts.py
code served (permissive licence) · get_code("928216f4fee84bf9")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 7 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 7 later) and 3 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
cast_tuple
brick of this paper's assembly: helper
5 other papers
4 dated earlier, 1 later · 1 only as an assembly brick
1812.01243 (2018-12)
Efficient Attention: Attention with Linear Complexities
1910.06764 (2019-10)
Stabilizing Transformers for Reinforcement Learning
1911.05507 (2019-11)
Compressive Transformers for Long-Range Sequence Modelling
and 2 more not named here
top1
brick of this paper's assembly: helper
2 other papers
2 later · 1 only as an assembly brick
2208.02813 (2022-08)
Towards Understanding Mixture of Experts in Deep Learning
2402.03226 (2024-02)
FuseMoE: Mixture-of-Experts Transformers for Fleximodal Fusion
GELU_
brick of this paper's assembly: helper
1 other paper
1 later · 1 only as an assembly brick
2402.03226 (2024-02)
FuseMoE: Mixture-of-Experts Transformers for Fleximodal Fusion
cumsum_exclusive
brick of this paper's assembly: helper
1 other paper
1 later
2402.03226 (2024-02)
FuseMoE: Mixture-of-Experts Transformers for Fleximodal Fusion
default
brick of this paper's assembly: helper
1 other paper
1 later · 1 only as an assembly brick
2402.03226 (2024-02)
FuseMoE: Mixture-of-Experts Transformers for Fleximodal Fusion
init_
brick of this paper's assembly: helper
1 other paper
1 later · 1 only as an assembly brick
2402.03226 (2024-02)
FuseMoE: Mixture-of-Experts Transformers for Fleximodal Fusion
safe_one_hot
brick of this paper's assembly: helper
1 other paper
1 later · 1 only as an assembly brick
2402.03226 (2024-02)
FuseMoE: Mixture-of-Experts Transformers for Fleximodal Fusion

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

Neural network scaling has been critical for improving the model quality in many real-world machine learning applications with vast amounts of training data and compute. Although this trend of scaling is affirmed to be a sure-fire approach for better model quality, there are challenges on the path such as the computation cost, ease of programming, and efficient implementation on parallel devices. GShard is a module composed of a set of lightweight annotation APIs and an extension to the XLA compiler. It provides an elegant way to express a wide range of parallel computation patterns with minimal changes to the existing model code. GShard enabled us to scale up multilingual neural machine translation Transformer model with Sparsely-Gated Mixture-of-Experts beyond 600 billion parameters using automatic sharding. We demonstrate that such a giant model can efficienctly be trained on 2048 TPU v3 accelerators in 4 days to achieve far superior quality for translation from 100 languages to English compared to the prior art. Preprint. Under review.

For agents

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

get_harvested_code_for_paper("2006.16668")
get_code_for_paper("2006.16668")
have("2006.16668")

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

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

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

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

Connect an agent — have() is free.