Efficient Data Driven Mixture-of-Expert Extraction from Trained Networks
Uranik Berisha, Jens Mehnert, Alexandru Paul Condurache
TL;DR
This work tackles the high computational cost of Vision Transformers by proposing a post-training extraction of Mixture-of-Experts (MoE) from pretrained networks. It uses activation clustering via HDBSCAN to identify activation patterns per layer and variance-based neuron selection to form data-driven expert subnetworks, with a lightweight cosine-based routing to mean input tokens. The resulting MoEE variants achieve substantial MACs and parameter reductions (up to ~36% and ~32%, respectively) while retaining most of the original performance after minimal fine-tuning on ImageNet-1k, especially for larger models, and generalize across architectures such as Swin and ConvNeXt. The approach provides deep insights into activation modularity, routing distributions, and expert formations, offering a practical, scalable path to efficient ViT deployment without full retraining.
Abstract
Vision Transformers have emerged as the state-of-the-art models in various Computer Vision tasks, but their high computational and resource demands pose significant challenges. While Mixture-of-Experts (MoE) can make these models more efficient, they often require costly retraining or even training from scratch. Recent developments aim to reduce these computational costs by leveraging pretrained networks. These have been shown to produce sparse activation patterns in the Multi-Layer Perceptrons (MLPs) of the encoder blocks, allowing for conditional activation of only relevant subnetworks for each sample. Building on this idea, we propose a new method to construct MoE variants from pretrained models. Our approach extracts expert subnetworks from the model's MLP layers post-training in two phases. First, we cluster output activations to identify distinct activation patterns. In the second phase, we use these clusters to extract the corresponding subnetworks responsible for producing them. On ImageNet-1k recognition tasks, we demonstrate that these extracted experts can perform surprisingly well out of the box and require only minimal fine-tuning to regain 98% of the original performance, all while reducing MACs and model size, by up to 36% and 32% respectively.
