SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2401.04088 · 2024

Mixtral of Experts

Albert Jiang, Arthur Mensch, Alexandre Sablayrolles, Singh Devendra, Chris Bamford, Diego Chaplot, Gianna Bressand, Guillaume Lengyel, Pierre Lachaux, Thomas Lavril, Timothée Wang, William Lacroix, and 16 more

arXiv · PDF · Open in the Atlas

Code that ran

5 of 5 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (5 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 5 have 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/2401.04088.json · badge: /api/ran/2401.04088.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
jingyaogong/minimind community
Papers with Code archive
3 ran · 0 no recorded run
kamanphoebe/look-into-moes community
Papers with Code archive
2 ran · 0 no recorded run
FunctionStatusWhere it lives
FeedForward Ran
ran on a synthesized input · constructed an object; no result was computed
jingyaogong/minimind/model/model_minimind.py
code served (permissive licence) · get_code("549cdd919dd3f999")
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, FeedForward: 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
import torch.nn as nn
import math
from transformers.activations import ACT2FN

torch.manual_seed(0)

class MiniMindConfig:
    model_type = 'minimind'

    def __init__(self, hidden_size=768, num_hidden_layers=8, use_moe=False, **kwargs):
        self.hidden_size = hidden_size
        self.num_hidden_layers = num_hidden_layers
        self.use_moe = use_moe
        self.dropout = kwargs.get('dropout', 0.0)
        self.vocab_size = kwargs.get('vocab_size', 6400)
        self.bos_token_id = kwargs.get('bos_token_id', 1)
        self.eos_token_id = kwargs.get('eos_token_id', 2)
        self.flash_attn = kwargs.get('flash_attn', True)
        self.num_attention_heads = kwargs.get('num_attention_heads', 8)
        self.num_key_value_heads = kwargs.get('num_key_value_heads', 4)
        self.head_dim = kwargs.get('head_dim', self.hidden_size // self.num_attention_heads)
        self.hidden_act = kwargs.get('hidden_act', 'silu')
        self.intermediate_size = kwargs.get('intermediate_size', math.ceil(hidden_size * math.pi / 64) * 64)
        self.max_position_embeddings = kwargs.get('max_position_embeddings', 32768)
        self.rms_norm_eps = kwargs.get('rms_norm_eps', 1e-06)
        self.rope_theta = kwargs.get('rope_theta', 1000000.0)
        self.tie_word_embeddings = kwargs.get('tie_word_embeddings', True)
        self.inference_rope_scaling = kwargs.get('inference_rope_scaling', False)
        self.rope_scaling = {'beta_fast': 32, 'beta_slow': 1, 'factor': 16, 'original_max_position_embeddings': 2048, 'attention_factor': 1.0, 'type': 'yarn'} if self.inference_rope_scaling else None
        self.num_experts = kwargs.get('num_experts', 4)
        self.num_experts_per_tok = kwargs.get('num_experts_per_tok', 1)
        self.moe_intermediate_size = kwargs.get('moe_intermediate_size', self.intermediate_size)
        self.norm_topk_prob = kwargs.get('norm_topk_prob', True)
        self.router_aux_loss_coef = kwargs.get('router_aux_loss_coef', 0.0005)

config = MiniMindConfig(hidden_size=8, intermediate_size=16, hidden_act='silu')

ARGS = {
    'config': config,
    'intermediate_size': None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type FeedForward — 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 FeedForward 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
FeedForward Ran
ran on a synthesized input · constructed an object; no result was computed
kamanphoebe/look-into-moes/mixtral_instruct/modeling_mixtral_instruct.py
code served (permissive licence) · get_code("3678349ac16c8826")
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, FeedForward: 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
import torch.nn as nn

torch.manual_seed(0)

class Config:
    def __init__(self, hidden_size, intermediate_size):
        self.hidden_size = hidden_size
        self.intermediate_size = intermediate_size

config = Config(hidden_size=4, intermediate_size=8)

ARGS = {
    "config": config
}
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 FeedForward — 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 FeedForward 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
MOEFeedForward Ran
ran on a synthesized input · constructed an object; no result was computed
jingyaogong/minimind/model/model_minimind.py
code served (permissive licence) · get_code("ca104baa2bcf757c")
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, MOEFeedForward: 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
import torch.nn as nn
from transformers.activations import ACT2FN
import math

torch.manual_seed(0)

class MiniMindConfig:
    model_type = 'minimind'
    
    def __init__(self):
        self.hidden_size = 64
        self.num_hidden_layers = 2
        self.use_moe = True
        self.dropout = 0.0
        self.vocab_size = 256
        self.bos_token_id = 1
        self.eos_token_id = 2
        self.flash_attn = True
        self.num_attention_heads = 4
        self.num_key_value_heads = 2
        self.head_dim = self.hidden_size // self.num_attention_heads
        self.hidden_act = 'silu'
        self.intermediate_size = math.ceil(self.hidden_size * math.pi / 64) * 64
        self.max_position_embeddings = 512
        self.rms_norm_eps = 1e-6
        self.rope_theta = 1000000.0
        self.tie_word_embeddings = True
        self.inference_rope_scaling = False
        self.rope_scaling = None
        self.num_experts = 2
        self.num_experts_per_tok = 1
        self.moe_intermediate_size = self.intermediate_size
        self.norm_topk_prob = True
        self.router_aux_loss_coef = 0.0005

class FeedForward(nn.Module):
    def __init__(self, config, intermediate_size=None):
        super().__init__()
        intermediate_size = intermediate_size or config.intermediate_size
        self.gate_proj = nn.Linear(config.hidden_size, intermediate_size, bias=False)
        self.down_proj = nn.Linear(intermediate_size, config.hidden_size, bias=False)
        self.up_proj = nn.Linear(config.hidden_size, intermediate_size, bias=False)
        self.act_fn = ACT2FN[config.hidden_act]

    def forward(self, x):
        return self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))

class MOEFeedForward(nn.Module):
    def __init__(self, config):
        super().__init__()
        self.config = config
        self.gate = nn.Linear(config.hidden_size, config.num_experts, bias=False)
        self.experts = nn.ModuleList([FeedForward(config, intermediate_size=config.moe_intermediate_size) for _ in range(config.num_experts)])
        self.act_fn = ACT2FN[config.hidden_act]

    def forward(self, x):
        batch_size, seq_len, hidden_dim = x.shape
        x_flat = x.view(-1, hidden_dim)
        scores = torch.nn.functional.softmax(self.gate(x_flat), dim=-1)
        topk_weight, topk_idx = torch.topk(scores, k=self.config.num_experts_per_tok, dim=-1, sorted=False)
        if self.config.norm_topk_prob:
            topk_weight = topk_weight / (topk_weight.sum(dim=-1, keepdim=True) + 1e-20)
        y = torch.zeros_like(x_flat)
        for i, expert in enumerate(self.experts):
            mask = topk_idx == i
            if mask.any():
                token_idx = mask.any(dim=-1).nonzero().flatten()
                weight = topk_weight[mask].view(-1, 1)
                y.index_add_(0, token_idx, (expert(x_flat[token_idx]) * weight).to(y.dtype))
            elif self.training:
                y[0, 0] += 0 * sum((p.sum() for p in expert.parameters()))
        if self.training and self.config.router_aux_loss_coef > 0:
            import torch.nn.functional as F
            load = F.one_hot(topk_idx, self.config.num_experts).float().mean(0)
            self.aux_loss = (load * scores.mean(0)).sum() * self.config.num_experts * self.config.router_aux_loss_coef
        else:
            self.aux_loss = scores.new_zeros(1).squeeze()
        return y.view(batch_size, seq_len, hidden_dim)

config = MiniMindConfig()
moe_ff = MOEFeedForward(config)
x = torch.randn(2, 3, 64)

ARGS = {
    'config': config
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MOEFeedForward — 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 MOEFeedForward 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
MiniMindConfig Ran
ran on a synthesized input · constructed an object; no result was computed
jingyaogong/minimind/model/model_minimind.py
code served (permissive licence) · get_code("b2a516613396ed08")
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, MiniMindConfig: 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 math
import torch
import torch.nn as nn
from transformers import PretrainedConfig

torch.manual_seed(0)

ARGS = {
    'hidden_size': 768,
    'num_hidden_layers': 8,
    'use_moe': False,
    'dropout': 0.0,
    'vocab_size': 6400,
    'bos_token_id': 1,
    'eos_token_id': 2,
    'flash_attn': True,
    'num_attention_heads': 8,
    'num_key_value_heads': 4,
    'head_dim': 96,
    'hidden_act': 'silu',
    'intermediate_size': 1920,
    'max_position_embeddings': 32768,
    'rms_norm_eps': 1e-06,
    'rope_theta': 1000000.0,
    'tie_word_embeddings': True,
    'inference_rope_scaling': False,
    'rope_scaling': None,
    'num_experts': 4,
    'num_experts_per_tok': 1,
    'moe_intermediate_size': 1920,
    'norm_topk_prob': True,
    'router_aux_loss_coef': 0.0005,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MiniMindConfig — 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 MiniMindConfig 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
MoE Ran
ran on a synthesized input · constructed an object; no result was computed
kamanphoebe/look-into-moes/mixtral_instruct/modeling_mixtral_instruct.py
code served (permissive licence) · get_code("253c6ed84c1f2c72")
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, MoE: 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
import torch.nn as nn

torch.manual_seed(0)

class Config:
    def __init__(self):
        self.hidden_size = 4
        self.intermediate_size = 8
        self.num_experts = 3
        self.num_experts_per_token = 2
        self.single_expert = False
        self.one_gate = False
        self.norm_one_gate = False

config = Config()

ARGS = {
    'config': config
}
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 MoE — 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 MoE 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

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 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 2 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
FeedForward
brick of this paper's assembly: model
2 other papers
2 later · 2 only as an assembly brick
2402.14905 (2024-02)
MobileLLM: Optimizing Sub-billion Parameter Language Models for On-Device Use Cases
2601.18537 (2026-01)
SKETCH: Semantic Key-Point Conditioning for Long-Horizon Vessel Trajectory Prediction
MOEFeedForward
brick of this paper's assembly: entry
2 other papers
2 later · 2 only as an assembly brick
2402.14905 (2024-02)
MobileLLM: Optimizing Sub-billion Parameter Language Models for On-Device Use Cases
2601.18537 (2026-01)
SKETCH: Semantic Key-Point Conditioning for Long-Horizon Vessel Trajectory Prediction
MiniMindConfig
brick of this paper's assembly: helper
2 other papers
2 later · 2 only as an assembly brick
2402.14905 (2024-02)
MobileLLM: Optimizing Sub-billion Parameter Language Models for On-Device Use Cases
2601.18537 (2026-01)
SKETCH: Semantic Key-Point Conditioning for Long-Horizon Vessel Trajectory Prediction

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

We introduce Mixtral 8x7B, a Sparse Mixture of Experts (SMoE) language model. Mixtral has the same architecture as Mistral 7B, with the difference that each layer is composed of 8 feedforward blocks (i.e. experts). For every token, at each layer, a router network selects two experts to process the current state and combine their outputs. Even though each token only sees two experts, the selected experts can be different at each timestep. As a result, each token has access to 47B parameters, but only uses 13B active parameters during inference. Mixtral was trained with a context size of 32k tokens and it outperforms or matches Llama 2 70B and GPT-3.5 across all evaluated benchmarks. In particular, Mixtral vastly outperforms Llama 2 70B on mathematics, code generation, and multilingual benchmarks. We also provide a model finetuned to follow instructions, Mixtral 8x7B -Instruct, that surpasses GPT-3.5 Turbo, Claude-2.1, Gemini Pro, and Llama 2 70B -chat model on human benchmarks. Both the base and instruct models are released under the Apache 2.0 license.

For agents

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

get_harvested_code_for_paper("2401.04088")
get_code_for_paper("2401.04088")
have("2401.04088")

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

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

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

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

Connect an agent — have() is free.