REAP prunes MoE experts by scoring each expert's importance using a combination of:
Router logit weights are renormalized to sum to 1 after pruning (critical for maintaining output scale). Pruning is applied layer-by-layer (layerwise mode).
Observations were collected over a mixed calibration dataset of 1,000 samples per category:
Max sequence length: 4096 tokens. Angular distance measure for expert similarity.
All evaluations run with vLLM (tensor-parallel across 8x RTX 3090), greedy decoding, 0-shot.
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_id = "0xSero/Qwen3.5-35B-A3B-REAP-20pct"
4
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForCausalLM.from_pretrained(
7 model_id,
8 torch_dtype="auto",
9 device_map="auto",
10)
11
12messages = [{"role": "user", "content": "Write a quicksort in Python."}]
13text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
14inputs = tokenizer(text, return_tensors="pt").to(model.device)
15outputs = model.generate(**inputs, max_new_tokens=512)
16print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
1vllm serve 0xSero/Qwen3.5-35B-A3B-REAP-20pct \
2 --tensor-parallel-size 4 \
3 --gpu-memory-utilization 0.9 \
4 --max-model-len 32768
1git clone https://github.com/cerebras/reap
2cd reap
3bash scripts/build.sh
4
5python -m reap.layerwise_prune \
6 --model_name Qwen/Qwen3.5-35B-A3B \
7 --dataset_name "theblackcat102/evol-codealpaca-v1:250,open-r1/Mixture-of-Thoughts[code]:250,open-r1/Mixture-of-Thoughts[math]:250,open-r1/Mixture-of-Thoughts[science]:250" \
8 --compression_ratio 0.20 \
9 --prune_method reap \
10 --seed 42 \
11 --renormalize_router_weights true
License inherited from the base model.
1@misc{lasby2025reap,
2 title = {REAP the Experts: Why Pruning Prevails for One-Shot MoE Compression},
3 author = {Mike Lasby and Ivan Lazarevich and Nish Sinnadurai and Sean Lie and Yani Ioannou and Vithursan Thangarasa},
4 year = {2025}, eprint = {2510.13999}, archivePrefix = {arXiv}
5}