MixtureKit
Turn the fine-tuned models you already have into one Mixture-of-Experts model.
Merge Hugging Face checkpoints, train the routers, see which expert every token uses.
You have a base model and a few fine-tunes of it: one for math, one for code, one for a language. MixtureKit composes them into a single Mixture-of-Experts model whose routers learn, token by token, which expert to use, and shows you what they learned.
pip install "mixturekit[vis] @ git+https://github.com/MBZUAI-Paris/MixtureKit"
mixturekit build examples/configs/traditional_qwen3.yaml # merge the experts -> models_merge/qwen3moe2x
mixturekit train my_training.yaml # train the routers -> e.g. qwen3moe2x-trained
mixturekit visualize qwen3moe2x-trained # see which expert every token uses
mixturekit push qwen3moe2x-trained my-org/my-moe # share it, with a model card
my_training.yaml starts from mixture_training/config_training.yaml
(model_id: models_merge/qwen3moe2x, your dataset and output_dir). Merging runs on a
laptop; training the routers wants a GPU.
Try it in 15 minutes on a free GPU: the Colab notebook merges two Qwen3-0.6B models, trains the routers and shows the routing.
Why MixtureKit
- Three composition methods behind one config: Branch-Train-MiX (BTX), Mixtral-style MoE and Branch-Train-Stitch (BTS).
- Merges on a laptop: the experts are read and the merged model written tensor by tensor, so a merge needs memory for a few tensors at a time, not for the experts.
- Plain transformers models: the result loads with
AutoModelForCausalLM.from_pretrained(path, trust_remote_code=True), without MixtureKit, and is tested on transformers 4.52 to 5.19. - Router training included:
mixturekit traintrains the routers (or the BTS stitch layers) with a load balancing loss, optionally with LoRA on the experts, on one GPU or many. - Routing visualizer: an app, a shareable HTML page or an inline notebook view of which expert every token uses, layer by layer.
- Benchmarks:
mixturekit benchmarkscores the merged model next to its experts with lm-evaluation-harness and writes the table. - Hub ready:
mixturekit pushuploads the model with a generated model card. - Runs everywhere:
mixturekit exportturns a traditional MoE of Llama, Mistral or Qwen3 experts into a native Mixtral or Qwen3-MoE model, ready for GGUF and llama.cpp, vLLM or MLX.
Tested with Llama 3, Qwen 2.5, Qwen 3, Qwen 3.5, Gemma 3 and Gemma 4 experts (multimodal checkpoints are merged through their language model).
Which method?
| BTX | Traditional | BTS | |
|---|---|---|---|
| Kept per expert | the projections you choose | the feed-forward block | the whole model |
| Shared | everything else, averaged | everything else, averaged | nothing: experts run next to a hub |
| Trained | a router per routed projection | a router per layer | stitch layers |
| Compute per token | top-k routed projections | top-k feed-forward blocks | all the experts |
Start with traditional for fine-tunes of one base model. More in the guide.
A merge, in YAML or Python
moe_method: traditional # btx, traditional or bts
model_type: qwen3moe2x # the name of the merged model and of its folder
num_experts_per_tok: 2
experts:
- {expert_name: base, model_id: Qwen/Qwen3-0.6B-Base}
- {expert_name: chat, model_id: Qwen/Qwen3-0.6B}
alpha: 0.01 # load balancing weight
import torch
from MixtureKit import build_moe
config = {
"moe_method": "traditional",
"model_type": "qwen3moe2x",
"experts": [
{"expert_name": "base", "model_id": "Qwen/Qwen3-0.6B-Base"},
{"expert_name": "chat", "model_id": "Qwen/Qwen3-0.6B"},
],
"alpha": 0.01,
}
path = build_moe(config, torch_dtype=torch.bfloat16) # models_merge/qwen3moe2x
More configurations: examples/configs/. All the keys:
Configuration.
Documentation
mbzuai-paris.github.io/MixtureKit: quickstart · methods · command line · training · visualizer · export and GGUF · benchmarks · upgrading older models and limitations · API
Development
git clone https://github.com/MBZUAI-Paris/MixtureKit && cd MixtureKit
pip install -e ".[test]"
pytest # CPU, tiny models, no download
pip install -e ".[doc]" && sphinx-build docs docs/_build/html
Requirements: Python 3.10 or later, PyTorch 2.5 or later, transformers 4.52 to 5.x. Issues and pull requests are welcome: see CONTRIBUTING.md.
Citation
If MixtureKit is useful in your work, please cite the paper:
@article{chamma2025mixturekit,
title={MixtureKit: A General Framework for Composing, Training, and Visualizing Mixture-of-Experts Models},
author={Chamma, Ahmad and Herraoui, Omar El and Shang, Guokan},
journal={arXiv preprint arXiv:2512.12121},
year={2025}
}
Acknowledgements and license
MixtureKit builds on Branch-Train-MiX, Branch-Train-Stitch and ideas from mergoo. It is released under the BSD 3-Clause License.
Metadata
Release files for MixtureKit 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mixturekit-1.1.0.tar.gz | 1.6 MB | With provenance | Details for mixturekit-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mixturekit-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for mixturekit-1.1.0-py3-none-any.whl |
Total release size: 1.7 MB
Release files / mixturekit-1.1.0.tar.gz
| Download URL | mixturekit-1.1.0.tar.gz |
|---|---|
| Size | 1.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
767ff46729e6bd1b748152b15f84fe0ecdcbff47e5c7394f8379dd2a51c03fe9
|
|
BLAKE2b-256 checksum How to use checksums |
792e0296376501e0e0809d6acc30c3ca8f1ef8d02c46e88792dc5a41f871543d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logRelease files / mixturekit-1.1.0-py3-none-any.whl
| Download URL | mixturekit-1.1.0-py3-none-any.whl |
|---|---|
| Size | 56.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d72af2401ac912be3d6e085597c105371dfee15fcc499fbd03ca61892c15db7f
|
|
BLAKE2b-256 checksum How to use checksums |
1fc041e8be7606713254ecb25f435c25c5eafeed9ff16fc5d0d78f65e4c1bc0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logSecurity for MixtureKit 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mixturekit-1.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.