             Oracle-MoE: Locality-preserving Routing in the Oracle Space for

                 Memory-constrained Large Language Model Inference





    Jixian Zhou * 1 Fang Dong * 1 Ruijun Huang * 1 2 Hengjie Cao 1 Mengyi Chen 1 Yifeng Yang 1 Anrui Chen 1

       Mingzhi Dong 3 Yujiang Wang 4 Dongsheng Li 5 David A. Clifton 4 Qin Lv 6 Rui Zhu 7 Chun Zhang 8

                                   Fan Yang 9 Tun Lu 1 Ning Gu 1 Li Shang 1

.





                           Abstract                                         fore, better expert activation consistencies. Exper-

                                                                            iments on the pretrained GPT-2 architectures of

        Mixture-of-Experts (MoE) is widely adopted to                       different sizes (200M, 350M, 790M, and 2B) and

        deploy Large Language Models (LLMs) on edge                         downstream tasks demonstrate that without com-

        devices with limited memory budgets. Although                       promising task performance, our Oracle-MoE has

        MoE is, in theory, an inborn memory-friendly                        achieved state-of-the-art inference speeds across

        architecture requiring only a few activated ex-                     varying memory budgets, revealing its substantial

        perts to reside in the memory for inference, cur-                   potential for LLM deployments in industry.

        rent MoE architectures cannot effectively fulfill

        this advantage and will yield intolerable inference

        latencies of LLMs on memory-constrained de-                    1. Introduction

        vices. Our investigation pinpoints the essential

                                                                       The unprecedented prevalence of Large Language Models

        cause as the remarkable temporal inconsistencies

                                                                       (LLMs) calls for their sink from remote servers to local

        of inter-token expert activations, which generate

                                                                       edge devices for better accessibility, privacy protections,

        overly frequent expert swapping demands dom-

                                                                       and personalizations. Mixture-of-Experts (MoE) (Fedus

        inating the latencies. To this end, we propose a

                                                                       et al., 2022; Cai et al., 2024) is the most widely adopted

        novel MoE architecture, Oracle-MoE, to fulfill

                                                                       technique for the on-device deployment of LLMs. A well-

        the real on-device potential of MoE-based LLMs.

                                                                       established advantage of MoE is that it could effectively

        Oracle-MoE route tokens in a highly compact

                                                                       scale up LLMs’ capacities without increasing the inference

        space suggested by attention scores, termed the

                                                                       computational complexity, which is vital for their execu-

        oracle space, to effectively maintain the seman-

                                                                       tions on edge devices of less powerful computing hardware.

        tic locality across consecutive tokens to reduce

                                                                       However, we would like to underline a less-mentioned but

        expert activation variations, eliminating massive

                                                                       crucial property of MoE: it is, in theory, a memory-friendly

        swapping demands. Theoretical analysis proves

                                                                       architecture that could naturally satisfy the memory con-

        that Oracle-MoE is bound to provide routing de-

                                                                       straint of edge devices. Only a few activated experts are

        cisions with better semantic locality and, there-

                                                                       needed to reside in the device memory for a feedforward

    *

    Equal contribution 1 College of Computer Science and Arti-         MoE inference, and thus, the minimum memory occupa-

ficial Intelligence, Fudan University, Shanghai, China 2 Greater       tions of MoE-based LLMs can be significantly less than

Bay Area National Center of Technology Innovation, Research            their dense counterparts, which indicates the edge-friendly

Institute of Tsinghua University in Shenzhen, Shenzhen, China          nature of MoE architectures.

3

  University of Bath, Bath, UK 4 Oxford Suzhou Centre for Ad-

vanced Research, Suzhou, China 5 Microsoft Research Asia, Shang-       In practice, the fulfilling of MoE’s memory-saving advan-

hai, China 6 Department of Computer Science, University of Col-        tage, however, is still far from satisfying. To date, deploy-

orado Boulder, Colorado, USA 7 Bayes Business School, City St

George’s, University of London, London, UK 8 Research Institute        ing MoE-based LLMs on memory-constrained devices will

of Tsinghua University in Shenzhen, Shenzhen, China 9 School           commonly introduce intolerable inference latencies that sub-

of Microelectronics, Fudan University, Shanghai, China. Corre-         stantially impair the industrial values of LLMs. Those la-

spondence to: Li Shang <lishang@fudan.edu.cn>, Yujiang Wang            tencies are predominantly caused by the overheads from

<yujiang.wang@oscar.ox.ac.uk>.                                         frequently loading activated experts into the memory and

Proceedings of the 42 nd International Conference on Machine           cleaning old ones during successive inferences of tokens.

Learning, Vancouver, Canada. PMLR 267, 2025. Copyright 2025            As shown in Figure 1(a) (Top), the memory-constrained in-

by the author(s).                                                      ference of MoE-based LLMs can result in latencies approxi-



                                                                   1

