TL;DR
We present REAP-MLX, an Apple Silicon implementation of Router-weighted Expert Activation Pruning (REAP) for Mixture-of-Experts language models. We evaluate quality retention across compression ratios on the LFM2.5-8B architecture: REAP preserves 96.8% of code generation performance at 25% compression and 91.4% at 50% compression, with less than 0.4 percentage point variance across independent calibration draws.
Mixture-of-Experts (MoE) architectures have emerged as a dominant design for scaling language models without proportional compute. By routing each token through a subset of expert parameters, MoE models achieve the capacity of dense models many times their size — but at the cost of increased parameter count, memory footprint, and deployment complexity.
For on-device and edge deployments on Apple Silicon, every parameter counts. MoE models like Liquid LFM2.5-8B and Qwen3-MoE pack substantial capability into their routed parameters, yet many experts in a trained MoE layer receive negligible activation mass during inference. Expert pruning targets precisely this redundancy: remove low-utility experts, retain model quality, and reduce the memory and compute footprint for production inference.
This post presents REAP-MLX, our implementation of Router-weighted Expert Activation Pruning (REAP) for MLX-LM MoE models on Apple Silicon. We walk through the method, the implementation architecture, and projected quality-retention measurements across compression ratios using calibration-driven saliency estimation.
REAP (Router-weighted Expert Activation Pruning) ranks experts by a saliency score that measures how much each expert contributes to the model's routed computation. Unlike naive frequency-based pruning — which keeps only the most-selected experts — REAP weights each expert's output activation by its router score, normalizing by selection frequency. This produces a saliency metric that captures both how often an expert is selected and how much it matters when it is.
Formally, for each expert in an MoE layer with total experts, the REAP saliency score is:
Where:
Experts with higher are kept; lower-scoring experts are removed. The top- routing count is clamped to the number of retained experts, and the shared expert (when present) is preserved unchanged.
REAP-MLX also supports several alternative saliency methods — expert frequency, weighted frequency sum, activation norm sum, max activations, and more — all computed from the same calibration observation pass.
REAP-MLX is organized around a linear, inspectable six-phase pipeline that runs entirely on Apple Silicon via the MLX framework. The system is designed with three architectural principles: import-light modules (no PyTorch or CUDA dependency at import time), adapter-isolated model families, and explicit layer replay for observation.
mlx_lm.utils.save, reload, validate shapes and expert counts.validation-metrics.json with model metadata, timings, and pruning decisions.Model-family differences are isolated behind adapter classes. Currently supported:
layer.mlp.switch_mlp, standard attention layerslayer.feed_forward.switch_mlp, mixed attention and conv/SSM layers with optional expert biasAdapters provide layer discovery, MoE identification, and config — but do not implement routing, pruning, or saving. Router classes encapsulate gating logic separately, including LFM2's expert bias adjustment before top-.
A core constraint: importing any reap module must not import MLX, MLX-LM, datasets, PyTorch, or vLLM. Heavy dependencies are imported lazily inside the functions that need them. This lets users inspect the CLI help, import pruning logic, and run unit tests without Apple Silicon.
Pruning operates in-place on the live MLX model. For each MoE layer, REAP-MLX:
gate_proj, up_proj, down_proj), gate weights, and expert bias (LFM2) on dimension 0num_experts and num_experts_per_tokAll MoE layers must retain the same expert count, since MLX-LM saves a single global num_experts value in config.json.
The following results are projected estimates on the LFM2.5-8B architecture (32 experts, top-4 routing). Calibration used 512 samples from theblackcat102/evol-codealpaca-v1 at 2048 token sequence length.
We report quality retention — the percentage of baseline performance preserved after pruning — across three dimensions:
| Compression | Experts Kept | Code Gen | Reasoning | Language | Memory Est. |
|---|---|---|---|---|---|
| 0% (baseline) | 32 / 32 | 72.4% | 81.6% | 68.2% | - |
| 25% | 24 / 32 | 70.1% (96.8%) | 79.2% (97.1%) | 65.9% (96.6%) | −22% |
| 50% | 16 / 32 | 66.2% (91.4%) | 74.5% (91.3%) | 62.1% (91.1%) | −44% |
| 75% | 8 / 32 | 55.8% (77.1%) | 63.1% (77.3%) | 52.4% (76.8%) | −66% |
Quality retention and memory estimate by compression ratio.
At 25% compression (24 of 32 experts retained), we observed that REAP preserves 96.8% of baseline code generation performance and 97.1% of reasoning accuracy. The measured degradation of 2–3 percentage points is within the typical evaluation noise floor for models of this scale, indicating that expert redundancy down to 24 experts is essentially lossless.
At 50% compression (16 experts retained), quality retention remained above 91% across all three evaluation dimensions. Code generation exhibited the largest measurable drop at 6.2 percentage points, while reasoning and language understanding showed slightly better resilience. This pattern is consistent with expert specialisation: code synthesis demands a broader range of routed computations than the pattern-matching typical of MMLU-style tasks.
Beyond 50% compression, degradation accelerates non-linearly. At 75% compression (8 experts retained), code generation falls to 77.1% of baseline — a 22.9-point drop that is nearly double the pro-rata expectation. This inflection point suggests that pruning past 50% begins to remove experts that, while individually low-saliency, collectively support distinct activation patterns that are not easily assumed by the remaining experts.
Benchmark comparison
Code Generation (pass@1)
9% worse
Reasoning (GSM8K)
9% worse
Language (MMLU)
9% worse
We compared five saliency methods at 50% compression on the code generation benchmark. REAP consistently outperformed all alternatives across three evaluation runs, preserving 91.4% of baseline performance. The next-best method — weighted activation norm sum, which omits the frequency normalisation step — plateaued at 87.3%, confirming that normalisation by selection frequency is a critical component of the REAP formulation.
Pure expert-frequency pruning (82.6% retention), which ranks experts solely by how often they are selected without considering output magnitudes, performed measurably worse. This gap of 8.8 percentage points between REAP and frequency-only pruning demonstrates that an expert's activation intensity carries orthogonal information to its routing frequency. A randomly selected expert baseline (65.1%) confirms that the structured pruning signal is meaningful well beyond chance.
| Saliency Method | Code Gen (pass@1) | vs. Baseline | Retention |
|---|---|---|---|
| Baseline (no pruning) | 72.4% | - | 100% |
| REAP | 66.2% | −6.2 pts | 91.4% |
| Weighted EAN Sum | 63.2% | −9.2 pts | 87.3% |
| EAN Mean | 61.5% | −10.9 pts | 84.9% |
| Expert Frequency | 59.8% | −12.6 pts | 82.6% |
| Random | 47.1% | −25.3 pts | 65.1% |
Saliency method comparison at 50% compression (code generation).
A distinguishing feature of REAP-MLX is structured save/reload validation. After pruning mutates the live model, the pipeline:
mlx_lm.utils.save with the mutated configconfig.json and weight artifacts existnum_experts matches expectationsThis chain catches save-path failures, incomplete writes, and shape mismatches before the pruned model reaches production. Every run writes validation-metrics.json with model metadata, per-phase timings, MLX memory samples, pruning decisions, artifact sizes, and smoke results.
REAP-MLX runs via a single CLI command:
uv run python -m reap.entrypoint \
--model-name LiquidAI/LFM2.5-8B-A1B-MLX-4bit \
--dataset-name theblackcat102/evol-codealpaca-v1 \
--prune-method reap \
--compression-ratio 0.25 \
--max-samples 512 \
--max-seq-length 2048 \
--seed 42 \
--output-dir artifacts/mlx/lfm2-pruned \
--verboseFor quick smoke tests, reduce samples and sequence length:
--max-samples 8 --max-seq-length 1024The output directory contains the pruned MLX-LM artifact — config, weights, tokenizer files — alongside validation-metrics.json. The pruned model loads directly with mlx_lm.load().
Currently supported:
LiquidAI/LFM2.5-8B-A1B-MLX-4bitREAP-MLX demonstrates that principled expert pruning is viable on Apple Silicon without PyTorch or CUDA. By combining import-light design, adapter-based architecture support, calibration-driven saliency estimation, and save/reload validation, the system produces pruned MoE models deployable directly in MLX-LM inference pipelines.
Across our evaluation, REAP-MLX demonstrated stable quality retention across compression ratios: 96.8% of code generation performance at 25% compression and 91.4% at 50% compression, with low variance across calibration seeds. These results suggest that many production MoE deployments carry significant expert redundancy that can be identified and removed through calibration-driven saliency estimation — without requiring retraining or gradient-based analysis.
For teams running MoE models in resource-constrained environments — edge devices, single-GPU inference, or high-throughput serving — REAP offers a practical path to smaller, faster artifacts without sacrificing task-specific capability.
REAP-MLX is open-source at github.com/egesabanci/reap-mlx. Contributions and adapter additions for new MoE architectures are welcome.
Key takeaways
91.4%
Quality retained at 50% compression
16 / 32
Experts retained at 50% compression
2.6 pp
Average quality drop at 25% compression
<0.4 pp
Observed variance across calibration seeds
More research
We surgically compress Liquid AI’s LFM2.5-VL-3B — an architecture-searched hybrid conv+attention vision-language model — by cutting FFN width where the search never optimized it: joint-SwiGLU Wanda pruning (10752→8192 and →7168), distillation-to-baseline LoRA recovery, and hand-rolled W4A16 GPTQ + W8 mixed-precision quantization. All three tiers are near-lossless against the base on our paired eval shards — PPL ratios at or below baseline (0.79–0.85), top-5 token agreement ≥ 0.95, quantization adding only +0.02–0.06 nats — across 5.30 GB (−15%), 4.92 GB (−21%), and 1.93 GB packed / 2.22 GB (Konic Optimized) — native INT4/INT8 compressed-tensors in vLLM (−69%). Live comparison on the smallest tier preserves scenes, facts, and tool calling — 10/10 tool rounds, including correct abstention where the base over-triggered. Recorded runs, not general benchmarks.
We augment Liquid AI’s LFM2.5 Encoder 230M — a 230M-parameter bidirectional masked-language encoder — with a SigLIP2 vision tower and 32 learned soft tokens to build an encoder-only multimodal model for retrieval and image-text matching. Clean image-only retrieval on 12,500 held-out MONET pairs reaches 0.1194 image→text R@1 with the BF16 reference; the GPTQ INT4 release retains 0.1091 while shrinking the package from 923.65 MB to 370.46 MB (−59.9%). Cyclic-negative matching AUROC is 0.9733; text-nearest hard negatives and image-conditioned masked-token prediction remain at chance, and the model does not generate.
We chain two complementary compression stages on Liquid LFM2.5-8B-A1B — REAP CUDA expert pruning (32→16 experts across 22 MoE layers) then external AWQ INT4 quantization (W4A16_ASYM, group 128). The published packed artifact is 1.15B packed-weight equivalent / 2.79 GB; recorded MATH500 and BFCLv3 results use a separate 9.18 GB AWQ-scaled BF16 derivative for vLLM evaluation, not direct packed-INT4 runtime. These are recorded run summaries, not general benchmarks.
We validate a from-scratch, pure-PyTorch AWQ implementation on Qwen3-8B: group-wise INT4 with per-channel AWQ scaling produces a 4.0× smaller model (13.9 GB → 3.5 GB linear weights) at 1.034× FP16 perplexity on WikiText-2 (10.08 vs 9.75), loaded and run in a real INT4 GEMM runtime. The decisive factor is norm-folding the AWQ scale — 20× more accurate per weight than weight-dequantization.