Instructions to use thatacube/Qwen3.8-27B-MoE with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use thatacube/Qwen3.8-27B-MoE with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="thatacube/Qwen3.8-27B-MoE") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("thatacube/Qwen3.8-27B-MoE") model = AutoModelForMultimodalLM.from_pretrained("thatacube/Qwen3.8-27B-MoE", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use thatacube/Qwen3.8-27B-MoE with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "thatacube/Qwen3.8-27B-MoE" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thatacube/Qwen3.8-27B-MoE", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/thatacube/Qwen3.8-27B-MoE
- SGLang
How to use thatacube/Qwen3.8-27B-MoE with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "thatacube/Qwen3.8-27B-MoE" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thatacube/Qwen3.8-27B-MoE", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "thatacube/Qwen3.8-27B-MoE" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thatacube/Qwen3.8-27B-MoE", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use thatacube/Qwen3.8-27B-MoE with Docker Model Runner:
docker model run hf.co/thatacube/Qwen3.8-27B-MoE
Qwen3.8-27B-MoE
Qwen3.8-27B turned into a Mixture-of-Experts model: the same weights, split into experts, with a router that uses only part of each feed-forward layer per token. It generates about 1.5× faster on an 8 GB GPU (model partly in system RAM) and stays close to the original in quality.
At a glance
| Qwen3.8-27B | Qwen3.8-27B-MoE | |
|---|---|---|
| parameters | 27.3B | 27.3B (same weights, regrouped) |
| non-embedding parameters used per token | 24.4B | 17.8B |
| feed-forward layer | dense | 32 experts × 512 neurons + shared expert of 1,024, 19 of 32 active |
| generation, RTX 5060 8 GB + RAM (Q4_K_M) | 3.2–4.1 tok/s | 5.4–6.1 tok/s (1.47–1.68×) |
| generation, 2× T4, whole model on GPU (Q4_K_M) | 13.5 tok/s | 16.3 tok/s (1.21×) |
| MMLU / GSM8K / valid tool calls | 83.5 / 79.9 / 93.8% | 78.6 / 83.6 / 95.8% |
| thinking and non-thinking modes | yes | yes (same chat template) |
| multi-token prediction head | yes | yes (MoE, healed), works as a draft model in llama.cpp |
| vision encoder | yes | kept unchanged, not evaluated |
Quick start (llama.cpp)
GGUF quants (Q8_0, Q4_K_M, IQ4_XS and a 16 GB Mac file) are in thatacube/Qwen3.8-27B-MoE-GGUF.
llama-server -hf thatacube/Qwen3.8-27B-MoE-GGUF:Q4_K_M -c 16384 -ctk q8_0 -ctv q8_0 -fa on --fit on
- llama.cpp b12110 or newer.
-hfdownloads the file; with a file already on disk use-m <file>.gguf. --fit onputs as much as fits on the GPU and moves expert tensors to system RAM first. A manual alternative is-ngl 99 -ncmoe N(the experts of N layers stay in RAM).- 8 GB card with a real context: keep all experts in RAM (
-ngl 99 -ncmoe 65, all 64 layers and the MTP layer). The rest of the model with a 16k KV cache already takes about 7.3 GB; two expert layers more on the GPU overflowed VRAM and halved the speed (RTX 5060). N = 60 was the best only with almost no context. - Speculative decoding with the model's own MTP head (
--spec-type draft-mtp --spec-draft-n-max 3) helped when the whole model was on the GPU (2× T4: 67% of the drafts accepted, 1.08× faster). With the experts in system RAM it slowed generation down (RTX 5060: 35–40% accepted, 5.0–5.4 instead of 5.7 tok/s), so leave it off there. - Sampling as recommended for Qwen3.8-27B. Thinking mode: temperature 1.0, top_p 0.95, top_k 20. Non-thinking: temperature 0.7, top_p 0.8, top_k 20, presence_penalty 1.5.
LM Studio (load settings of the model):
- GPU Offload: max, and "Number of layers for which to force MoE weights onto CPU": all layers (on an 8 GB card).
- Number of Experts: 19, the value from the file. With fewer experts the model is clearly worse.
- MTP speculative decoding off when the experts are in RAM; CPU Thread Pool Size: the number of physical cores.
- RTX 5060 8 GB, context 16k, KV cache q8_0: 5.68 tok/s.
Which file for which hardware:
| hardware | file | note |
|---|---|---|
| 8–12 GB GPU, 32 GB RAM | Q4_K_M or IQ4_XS | measured on RTX 5060 8 GB: 5.4–6.1 tok/s |
| 16 GB GPU | IQ4_XS | weights 14.3 GiB: with real context a few layers' experts go to RAM (not measured) |
| 24 GB GPU or 2× 16 GB | Q4_K_M | whole model on GPU; measured on 2× T4: 16.3 tok/s |
| Mac with 16 GB | IQ3_XXS-mac16 | the only one that fits; clearly lower quality (see Files); not tested on Apple hardware |
| Mac with 24 GB | IQ4_XS | not tested on Apple hardware |
| 32 GB+ unified memory, or more VRAM | Q4_K_M or Q8_0 |
Files
This repository: the bf16 weights (model-*.safetensors, 55.6 GB) for transformers, vLLM and your own quants.
- The LoRA is merged into the weights and rounded to bf16. Against the exact (unrounded) model this gives KL 0.0044 / top-1 98.0% (4,096 held-out tokens), about twice the bf16 noise of the original itself (KL 0.0022 / 99.0%) and under 2% of the distance to the original. The benchmarks below were run on the exact model.
GGUF quants: thatacube/Qwen3.8-27B-MoE-GGUF.
| GGUF | size | KL / top-1 vs Q8_0 |
|---|---|---|
| Q8_0 | 29.1 GB | reference |
| Q4_K_M (recommended) | 16.85 GB | 0.031 / 93.3% |
| IQ4_XS | 15.35 GB | 0.033 / 92.4% |
| IQ3_XXS-mac16 (experts IQ2_XXS, rest IQ3_XXS) | 9.35 GB | 0.217 / 80.3% |
- KL / top-1: the loss of the quantization alone, against the Q8_0 of this model (llama-perplexity, 19.8k held-out tokens). How far the model is from the original is in "Quality compared with the original" below.
- Experts in IQ3_XXS or IQ2_XS were slower than IQ4_XS on both test GPUs (T4, and RTX 5060 with RAM offload): decoding those formats costs more than the smaller reads save. They are not published.
Speed
| RTX 5060 8 GB, Ryzen 5 5600, 32 GB RAM (tokens/s) | dense Q4_K_M | MoE Q4_K_M | speed-up |
|---|---|---|---|
| llama.cpp auto split, context 0 | 3.72 | 5.47 | 1.47× |
| llama.cpp auto split, context 4,096 | 3.22 | 5.40 | 1.68× |
| best manual split | 4.06 | 6.08 | 1.50× |
| 2× Tesla T4, whole model on GPU (tokens/s) | dense Q4_K_M | MoE Q4_K_M | speed-up |
|---|---|---|---|
| context 0 | 13.48 | 16.34 | 1.21× |
| context 4,096 | 13.20 | 16.11 | 1.22× |
| context 128k (KV cache q8_0) | 3.27 | 3.46 | 1.06× |
| context 256k (KV cache q8_0) | 1.45 | 1.65 | 1.14× |
llama-benchtg128 (generation of 128 tokens), llama.cpp b12110. Prompt processing is on par with the dense model (0.91–1.01×).- Best manual split:
-ncmoe 60(MoE) and-ngl 28(dense), measured with almost no context. With a 16k context the MoE needs all experts in RAM on this card: 5.68 tok/s in LM Studio (its own llama.cpp build, KV cache q8_0, MTP off, 512-token answer). - The gain is largest when the model does not fit in VRAM: per token the MoE reads only the chosen experts from system RAM. On a GPU that holds everything the gain is about 1.2×. With very long context, attention over the KV cache (the same in both models) takes most of the time per token.
Quality compared with the original
Both models in bf16 on the same questions (JAX on TPU, lm-evaluation-harness 0.4.13 with a JAX backend). Next to each score: the difference to the original with a 95% bootstrap interval, and the share of questions where this model gives the same answer as the original.
| benchmark | Qwen3.8-27B | Qwen3.8-27B-MoE | difference | same answer |
|---|---|---|---|---|
| MMLU (14,042, 0-shot) | 83.5% | 78.6% | −4.9 [−5.5, −4.3] | 85.4% |
| ARC-Easy + ARC-Challenge | 74.2% | 73.4% | −0.8 [−1.8, +0.3] | 86.6% |
| HellaSwag (3,000, acc_norm) | 82.4% | 78.7% | −3.6 [−4.5, −2.7] | 92.9% |
| Belebele, 15 languages | 89.2% | 84.5% | −4.8 [−5.2, −4.2] | 88.6% |
| GSM8K (1,319, chat, no thinking) | 79.9% | 83.6% | +3.7 [+2.0, +5.5] | 76.3% |
| tool calls: valid call | 93.8% | 95.8% | +2.0 | same function 98.5% |
| needle in a haystack, 4k–32k | 100% | 100% | 0 |
- Raw prompts without the chat template (the harness default), except GSM8K.
- GSM8K: part of the gain is answer format. The original more often ends without "The final answer is" (204 unparsed answers against 149); with the flexible answer filter it is 84.8% against 81.7%.
- Tool calls: 288 tool-call points from held-out agent conversations (history from the original); the same arguments as the original in 82.2% of the calls.
By language (Belebele): English −2.2; French, Spanish, Italian −1.2 to −1.4; Chinese, Russian −1.7; German, Japanese, Korean, Turkish about −3; Arabic −3.9; Polish −4.2; Urdu −6.2; Swahili −16.0, Amharic −19.1. Low-resource languages lose the most; for them the original is the better choice.
Next-token fidelity (held-out data; KL divergence from the original's next-token distribution, 0 = identical, and how often both pick the same most likely token):
| data | KL | same top-1 token |
|---|---|---|
| text, 4k tokens | 0.268 | 81.4% |
| long documents, 16k tokens | 0.180 | 85.4% |
| agent conversations | 0.124 | 88.6% |
Other ways to run
transformers (tested with 5.22.1, architecture Qwen3_5MoeForConditionalGeneration):
from transformers import AutoProcessor, Qwen3_5MoeForConditionalGeneration
model = Qwen3_5MoeForConditionalGeneration.from_pretrained("thatacube/Qwen3.8-27B-MoE", dtype="auto", device_map="auto")
processor = AutoProcessor.from_pretrained("thatacube/Qwen3.8-27B-MoE")
vLLM: not tested with this model. The checkpoint uses the layout of the official Qwen3.5-MoE models
(qwen3_5_moe), which vLLM supports, so vllm serve thatacube/Qwen3.8-27B-MoE is expected to work.
Limitations
- Knowledge and reading comprehension are 4–5 points below the original (MMLU, HellaSwag, Belebele), low-resource languages much more (see above).
- Close to the original, not a copy of it: greedy answers share on average the first 17 tokens with the original (the first 64 tokens are identical for 16.8% of prompts, and for 81% at tool-call points of agent loops).
- Vision was not evaluated. The vision encoder is the original's, but image and video inputs through the MoE language model were not tested.
- Context: healed on 4,096-token sequences and evaluated up to 32k tokens (needle 100%); a 128k needle test passed 5/5 before healing. The architecture supports 262k like the original.
How it was made
- Statistics of every feed-forward neuron of the original on a calibration set.
- Expert split: the neurons of each layer grouped into 32 experts of 512 plus a shared expert of 1,024 by their contribution to the output. Picking, for each token, the 19 experts with the largest output would reach KL 0.227 on 4k text: the upper bound for a router without further training.
- Routers trained per layer to predict that choice (k = 19 of 32).
- Healing (fine-tuning to recover the quality lost by the split): KL distillation from the original, 2,980
steps × 8 sequences × 4,096 tokens (97.6M tokens), LoRA rank 16 on attention, Gated DeltaNet and the
feed-forward weights, plus the routers, the shared-expert gates and the norms; learning rate 1e-4, decayed
linearly to 0 over the last 1,000 steps; Kaggle TPU v5e-8, about 12 hours.
- Data: general text (web, books, code, math) 58%; conversations, tool calls and agent loops from the datasets below in the Qwen chat template 32%; answers generated by Qwen3.8-27B itself (mostly with thinking) to prompts from those datasets 10%. The target is always the original's own next-token distribution on these sequences, not the datasets' text. English and code first; other languages 9.1% of the tokens.
- Healing took KL on 4k text from 0.523 (routers only) to 0.268, and MMLU from 69.3% to 78.6%.
- Export: LoRA merged into the weights, in the layout of the official Qwen3.5-MoE checkpoints, so transformers, vLLM and llama.cpp read it without conversion rules of their own.
License and attribution
Apache-2.0, as the base model. This is a modified version of Qwen3.8-27B by the Qwen team: the feed-forward layers are regrouped into experts, routers are added and the weights are fine-tuned (merged LoRA). If you use it, please also cite Qwen (see the base model card).
Healing data, with attribution as required by their licenses:
- ODC-By 1.0: FineWeb-Edu, FineWeb-2, FinePDFs, FinePDFs-Edu, FineMath (Hugging Face), FineWeb2-HQ (EPFL), WildChat (AllenAI), self-oss-instruct (BigCode);
- CC BY 4.0 (NVIDIA): Nemotron-Agentic, Nemotron-Post-Training (tool calling), Nemotron-RL tool-use and function-calling pivots, When2Call, Nemotron Instruction-Following Chat, Nemotron-Science, OpenMathReasoning, OpenCodeReasoning, HelpSteer3, Nemotron-SFT-Multilingual (CC BY 4.0 parts only);
- Apache-2.0: oasst2 (OpenAssistant), Aya dataset (Cohere Labs), NuminaMath-1.5, Toucan-1.5M, smoltalk2, OpenThoughts3, PG-19 (public-domain books);
- code: stackv2_edu_filtered (Common Pile) and CommitPackFT (BigCode), permissively licensed files only.
- Downloads last month
- 63