Zurück zum Ranking

davidmrau/mixture-of-experts

Python

PyTorch Re-Implementation of "The Sparsely-Gated Mixture-of-Experts Layer" by Noam Shazeer et al. https://arxiv.org/abs/1701.06538

moemixture-of-expertssparsely-gated-mixture-of-expertspytorchre-implementation
Sterne-Wachstum
Sterne
1.2k
Forks
112
Wochenwachstum
Issues
6
5001k
Juli 2019Nov. 2021März 2024Juli 2026
ArtefaktePyPIpip install mixture-of-experts
README

The Sparsely Gated Mixture of Experts Layer for PyTorch

source: https://techburst.io/outrageously-large-neural-network-gated-mixture-of-experts-billions-of-parameter-same-d3e901f2fe05

This repository contains the PyTorch re-implementation of the sparsely-gated MoE layer described in the paper Outrageously Large Neural Networks for PyTorch.


from moe import MoE
import torch

# instantiate the MoE layer
model = MoE(input_size=1000, output_size=20, num_experts=10,hidden_size=66, k= 4, noisy_gating=True)

X = torch.rand(32, 1000)

#train
model.train()
# forward
y_hat, aux_loss = model(X)

# evaluation

model.eval()
y_hat, aux_loss = model(X)

Requirements

To install the requirements run:

pip install -r requirements.py

Example

The file example.py contains a minimal working example illustrating how to train and evaluate the MoE layer with dummy inputs and targets. To run the example:

python example.py

CIFAR 10 example

The file cifar10_example.py contains a minimal working example of the CIFAR 10 dataset. It achieves an accuracy of 39% with arbitrary hyper-parameters and not fully converged. To run the example:

python cifar10_example.py

Used by

FastMoE: A Fast Mixture-of-Expert Training System This implementation was used as a reference PyTorch implementation for single-GPU training.

Acknowledgements

The code is based on the TensorFlow implementation that can be found here.

Citing

@misc{rau2019moe,
    title={Sparsely-gated Mixture-of-Experts PyTorch implementation},
    author={Rau, David},
    journal={https://github.com/davidmrau/mixture-of-experts},
    year={2019}
}
Ähnliche Repositories
vllm-project/vllm

A high-throughput and memory-efficient inference and serving engine for LLMs

PythonPyPIApache License 2.0gptllm
vllm.ai
86.8k19.7k
hiyouga/LlamaFactory

Unified Efficient Fine-Tuning of 100+ LLMs & VLMs (ACL 2024)

PythonPyPIApache License 2.0fine-tuningllama
llamafactory.readthedocs.io
73.4k9k
hiyouga/LLaMA-Factory

Unified Efficient Fine-Tuning of 100+ LLMs & VLMs (ACL 2024)

PythonPyPIApache License 2.0fine-tuninglanguage-model
huggingface.co/papers/2403.13372
43.5k5.3k
sgl-project/sglang

SGLang is a high-performance serving framework for large language models and multimodal models.

PythonPyPIApache License 2.0cudainference
sglang.io
30.6k7.3k
modelscope/ms-swift

Use PEFT or Full-parameter to CPT/SFT/DPO/GRPO 600+ LLMs (Qwen3.6, DeepSeek-V4, GLM-5.1, InternLM3, Llama4, ...) and 300+ MLLMs (Qwen3-VL, Qwen3-Omni, InternVL3.5, Ovis2.5, GLM4.5v, Gemma4, Llava, Phi4, ...) (AAAI 2025).

PythonPyPIApache License 2.0llmlora
swift.readthedocs.io/zh-cn/latest/
14.9k1.5k
NVIDIA/TensorRT-LLM

TensorRT LLM provides users with an easy-to-use Python API to define Large Language Models (LLMs) and supports state-of-the-art optimizations to perform inference efficiently on NVIDIA GPUs. TensorRT LLM also contains components to create Python and C++ runtimes that orchestrate the inference execution in a performant way.

PythonPyPIOtherblackwellcuda
nvidia.github.io/TensorRT-LLM
14.2k2.6k
flashinfer-ai/flashinfer

FlashInfer: Kernel Library for LLM Serving

PythonPyPIApache License 2.0gpularge-large-models
flashinfer.ai
6k1.2k
czy0729/Bangumi

:electron: An unofficial https://bgm.tv ui first app client for Android and iOS, built with React Native. 一个无广告、以爱好为驱动、不以盈利为目的、专门做 ACG 的类似豆瓣的追番记录,bgm.tv 第三方客户端。为移动端重新设计,内置大量加强的网页端难以实现的功能,且提供了相当的自定义选项。 目前已适配 iOS / Android。

TypeScriptnpmMIT Licensereact-nativemobx
5.8k167
zai-org/GLM-4.5

GLM-4.5: Agentic, Reasoning, and Coding (ARC) Foundation Models

PythonPyPIApache License 2.0agentllm
z.ai/blog/glm-4.5
4.4k468
PKU-YuanGroup/MoE-LLaVA

【TMM 2025🔥】 Mixture-of-Experts for Large Vision-Language Models

PythonPyPIApache License 2.0large-vision-language-modelmixture-of-experts
arxiv.org/abs/2401.15947
2.3k139
MoonshotAI/MoBA

MoBA: Mixture of Block Attention for Long-Context LLMs

PythonPyPIMIT Licenseflash-attentionllm
2.2k157
uccl-project/uccl

UCCL is an efficient communication library for GPUs, covering collectives, P2P (e.g., KV cache transfer, RL weight transfer), and EP (e.g., GPU-driven)

C++Apache License 2.0aiallreduce
uccl-project.github.io
1.5k162