Skip to main content

Latent-MoE

Implementation of LatentMoEToward Optimal Accuracy per FLOP and Parameter in Mixture of Experts (Elango et al., NVIDIA 2026) — in Pytorch. A single-file, dependency-light layer you can drop in place of a standard MoE FFN.

The idea is simple. A standard MoE routes and computes its experts in the model hidden dimension d. LatentMoE first projects each token down into a smaller latent dimension l = d / alpha with a shared down-projection, runs all routed experts inside that latent space, then projects back up to d. Because dispatch traffic and expert weights now live in l rather than d, both all-to-all communication volume and per-expert weight-loading memory drop by a factor of alpha.

Those savings are reinvested by scaling the number of experts N' = alpha * N, exponentially expanding the space of expert combinations. Two flavors:

  • l-MoE_eff — keep top-k K fixed → match baseline accuracy at lower inference cost.
  • l-MoE_acc — scale top-k K' = alpha * K → match baseline cost while improving accuracy (recommended, Pareto-optimal).

The router and shared experts continue to operate in the original dimension d, since they are not the memory/communication bottleneck.

Install

$ pip install -r requirements.txt

Usage

import torch
from latent_moe import LatentMoE, LatentMoEConfig

config = LatentMoEConfig(
    d = 2048,          # model hidden dim
    m = 1408,          # expert intermediate width
    n_experts = 64,    # base routed experts (N)
    top_k = 6,         # base active experts per token (K)
    alpha = 4,         # latent compression factor (l = d / alpha)
    n_shared = 2,      # always-on shared experts
    variant = "acc",   # "acc" (iso-cost, higher accuracy) or "eff" (cheaper)
)

layer = LatentMoE(config)

x = torch.randn(2, 128, config.d)  # (batch, seq, d)
y = layer(x)                       # (batch, seq, d)

assert y.shape == x.shape

Inspect the asymptotic cost quantities from Table 1 of the paper:

for k, v in layer.cost_summary().items():
    print(f"{k}: {v:,.2f}")

Citations

@article{elango2026latentmoe,
    title   = {LatentMoE: Toward Optimal Accuracy per FLOP and Parameter in Mixture of Experts},
    author  = {Elango and others},
    journal = {arXiv preprint arXiv:2601.18089},
    year    = {2026},
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

latent_moe-0.0.1.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

latent_moe-0.0.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file latent_moe-0.0.1.tar.gz.

File metadata

  • Download URL: latent_moe-0.0.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.3 Darwin/24.6.0

File hashes

Hashes for latent_moe-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f4d7d8588e1b3adc317fd1671064cf336d1389bb5eba2b0a3c2f1b5d0e445226
MD5 83b174f69cba092311c96996573c05eb
BLAKE2b-256 2905b2a26ba2a9cb4027e2d82abd3a308da3a1ca9a8ff4831c5ed89e50399a27

See more details on using hashes here.

File details

Details for the file latent_moe-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: latent_moe-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.3 Darwin/24.6.0

File hashes

Hashes for latent_moe-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e32f4c83de0738e2d8f24e79918c1b751acbce42c95f39bf6729c1c9bad015d4
MD5 1de11456ee406810a3f01e41042c6e06
BLAKE2b-256 931518ae609f34d9eb195d01a61f2fa167630645edf60aee5f504703ea539214

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page