---
title: "Mixture of Experts (MoEs) in Transformers"
description: "Hugging Face transformers v5 reworks its internals to treat Mixture of Experts models as first-class: a WeightConverter pipeline packs per-expert checkpoint tensors into contiguous runtime tensors with async, lazy materialization, cutting Qwen1.5-110B load time from ~66s to ~21s (10s with tensor parallelism) on an A100."
url: "https://swe.quest/articles/mixture-of-experts-moes-in-transformers-670e279baa41a80a"
canonical: "https://huggingface.co/blog/moe-transformers"
source: "Hugging Face"
published: "2026-02-26"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 10
tags: ["inference","llms","model-training","performance","python"]
---

# Mixture of Experts (MoEs) in Transformers

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2026-02-26, 10 min read, Deep dive. Original: [https://huggingface.co/blog/moe-transformers](https://huggingface.co/blog/moe-transformers)

## Summary

Hugging Face transformers v5 reworks its internals to treat Mixture of Experts models as first-class: a WeightConverter pipeline packs per-expert checkpoint tensors into contiguous runtime tensors with async, lazy materialization, cutting Qwen1.5-110B load time from ~66s to ~21s (10s with tensor parallelism) on an A100. A pluggable Experts Backend dispatches tokens via eager, batched\_mm (torch.bmm) or grouped\_mm (torch.\_grouped\_mm) strategies, suited respectively to debugging, small-batch and large-batch/memory-constrained workloads. Expert parallelism shards experts across GPUs with a single config flag, and a collaboration with Unsloth using Triton grouped-GEMM + LoRA kernels yields ~12× faster MoE training with \>35% less VRAM.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- Transformer architecture ([easy posts on System design](https://swe.quest/tags/system-design.md?difficulty=easy))
- PyTorch
- tensor parallelism basics ([easy posts on Concurrency](https://swe.quest/tags/concurrency.md?difficulty=easy))
- GEMM kernels

## Keywords

Mixture of Experts, Hugging Face Transformers, WeightConverter, expert parallelism, torch.\_grouped\_mm, Unsloth, gpt-oss, DeepSeek-V3

## Related posts

- [Mixture of Experts Explained](https://swe.quest/articles/mixture-of-experts-explained-5efff8fe17f2e9ca.md): Hugging Face · 2023-12-11 · Hard · 21 min read · LLMs, Model training, Inference & serving, Machine learning
  Mixture of Experts (MoE) transformers replace dense feed-forward layers with sparse expert layers and a learned router that sends each token to only a few experts.
- [180B Parameters, 32GB of RAM: Pushing MoE Inference to the Limit with Transformers](https://swe.quest/articles/180b-parameters-32gb-of-ram-pushing-moe-inference-to-the-limit-with-transformers-63cd3cf21432f7c3.md): Hugging Face · 2026-11-18 · Hard · 11 min read · Inference & serving, LLMs, Performance engineering, Caching, Hardware
  Streaming MoE experts from SSD through a bounded device-side slot pool lets Transformers run Qwen3.8-Flash-Next (121 GB of experts) on a 32 GB MacBook M5 at ~13.9 tok/s, within 6% of the specialized Strata engine on decode and slightly faster on prefill.
- [Welcome Mixtral - a SOTA Mixture of Experts on Hugging Face](https://swe.quest/articles/welcome-mixtral-a-sota-mixture-of-experts-on-hugging-face-8678082efd21a0bd.md): Hugging Face · 2023-12-11 · Medium · 11 min read · LLMs, Inference & serving, Model training, Machine learning
  Mixtral 8x7B is Mistral's sparse Mixture-of-Experts LLM. It replaces feed-forward layers with MoE layers that route each token to 2 of 8 experts, so it has about 45B total parameters but decodes at roughly the speed of a 12B dense model.
- [Native-speed vLLM transformers modeling backend](https://swe.quest/articles/native-speed-vllm-transformers-modeling-backend-cb3f698fe9046ce3.md): Hugging Face · 2026-07-08 · Hard · 5 min read · Inference & serving, LLMs, Performance engineering, Python
  The transformers modeling backend in vLLM now matches or beats vLLM's hand-written native implementations in throughput.
- [SegMoE: Segmind Mixture of Diffusion Experts](https://swe.quest/articles/segmoe-segmind-mixture-of-diffusion-experts-11821c390645523e.md): Hugging Face · 2024-02-03 · Medium · 5 min read · Computer vision, Machine learning, Inference & serving, Python
  SegMoE is a framework for building Mixture-of-Experts diffusion models by merging pretrained Stable Diffusion or SDXL checkpoints.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
