← Latest papers
🤖 machine learning

MoE-nD: Per-Layer Mixture-of-Experts Routing for Multi-Axis KV Cache Compression

MoE-nD introduces a per-layer mixture-of-experts routing framework that dynamically assigns unique token eviction ratios and quantization bit-widths to each transformer layer under a global memory budget, achieving up to 14x KV cache compression while maintaining accuracy comparable to uncompressed baselines on long-context reasoning tasks.

Original authors: Libo Sun, Peixiong He, Po-Wei Harn, Xiao Qin

Published 2026-04-21
📖 5 min read🧠 Deep dive

Original authors: Libo Sun, Peixiong He, Po-Wei Harn, Xiao Qin

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

The Big Problem: The "Overstuffed Backpack"

Imagine a Large Language Model (LLM) as a brilliant student trying to solve a very long story or a complex math problem. To do this, the student needs to keep a running list of everything they've read so far in their "working memory" (called the KV Cache).

For short stories, this memory fits easily in a backpack. But for long contexts (like a whole book or a 16,000-word document), the backpack gets so heavy and big that:

  1. It slows the student down (latency).
  2. It rips the backpack open (Out-of-Memory errors) on standard computers.

The Old Solution: "One Size Fits All"

To fix this, researchers tried to shrink the backpack. They used two main tools:

  1. Eviction (Throwing things out): Deleting old notes to make space.
  2. Quantization (Writing in shorthand): Writing notes in smaller, less precise handwriting (e.g., using 4-bit numbers instead of 16-bit).

The Flaw: Previous methods treated the student's brain like a cookie cutter. They applied the same rule to every part of the brain.

  • Example: "Throw away 50% of the notes from the entire story, and write all remaining notes in tiny shorthand."

Why this fails: The student's brain isn't uniform.

  • Layer 1 (The beginning): Might be crucial for understanding the plot. If you throw away 50% of these notes, the student forgets the story entirely.
  • Layer 20 (The middle): Might be full of fluff. Throwing away 50% here does almost no harm.
  • Layer 28 (The end): Might need high precision to solve the final math equation. Writing in "tiny shorthand" here causes calculation errors.

Treating every layer the same is like wearing a winter coat in the summer and a t-shirt in the winter because you decided to wear the "average" outfit for the whole year.

The New Solution: MoE-nD (The "Smart Wardrobe")

The authors propose MoE-nD, which stands for Mixture-of-Experts for n-Dimensional routing.

Think of this as a Smart Wardrobe Manager for the student's backpack. Instead of one rule for everyone, the manager looks at every single layer of the brain individually and asks: "What does this specific part of the brain need right now?"

It has three "Experts" (options) to choose from for each layer:

  1. The Trash Can (Eviction): How much of this layer's memory can we delete?
  2. The Shorthand Pen (K-Quantization): How small can we write the "Key" notes?
  3. The Shorthand Pen (V-Quantization): How small can we write the "Value" notes?

How it works:

  1. The Map (Offline Calibration): Before the student starts the test, the system runs a quick, cheap test to see how sensitive each layer is. It creates a map: "Layer 5 hates being deleted. Layer 10 hates being written in shorthand. Layer 20 doesn't care about either."
  2. The Budget (Global Limit): The student has a strict backpack size limit (e.g., 136 MB).
  3. The Greedy Solver: A smart algorithm looks at the map and the budget. It plays a game of "best value."
    • It says: "Okay, Layer 5 is super sensitive to deletion, so let's keep it full size. But Layer 10 is fine with tiny shorthand, so let's shrink that. Layer 20 can lose half its notes without crying."
  4. The Result: The backpack is compressed to 1/14th of its original size, but the student's performance is exactly the same as if they had the full, uncompressed backpack.

The Key Discovery: "The Trash Can is the Hero"

The paper did a cool experiment to see which part of the strategy mattered most. They tested three versions:

  1. Uniform: Same rules for everyone. (Terrible results).
  2. Smart Shorthand: Different shorthand sizes for different layers, but same trash rules. (Still bad).
  3. Smart Trash: Same shorthand sizes, but different trash rules for different layers. (This was the winner!)

The Analogy:
Imagine you are packing for a trip.

  • Uniform: You throw away 50% of your clothes and shrink the rest. You freeze and can't dress properly.
  • Smart Shorthand: You keep all your clothes but shrink the fabric. You still have too many clothes; the bag is too heavy.
  • MoE-nD (Smart Trash): You realize your "socks" (some layers) are useless and throw 90% of them away, but you keep your "jacket" (critical layers) perfectly intact. The bag becomes light, but you are still warm and ready.

The Results: Magic on Long Stories

When they tested this on hard benchmarks (like reading a 16,000-word story or solving complex math):

  • Old methods: When they tried to shrink the memory, the model got confused and failed (accuracy dropped to near zero).
  • MoE-nD: It shrank the memory by 14 times (from 1.9 GB down to 136 MB) and the model performed just as well as the giant, uncompressed version.

When Does It Not Work?

The paper is honest about its limits. It doesn't help with short tasks (like a simple 500-word math problem).

  • Why? If the story is short, the backpack is already small. The "Smart Manager" looks at the layers and says, "Hey, we have plenty of room! Let's keep everything."
  • In this case, the system just defaults to "keep everything," and the fancy routing doesn't add any value. It's like using a GPS to navigate a room you can see clearly; you don't need the complex directions.

Summary

MoE-nD is a technique that stops treating AI brains like a single block of clay. Instead, it treats every layer as a unique individual, giving some layers a "delete" button, others a "shrink" button, and others a "keep safe" button. By customizing the compression for every single layer, it allows AI to remember long stories without needing a supercomputer's memory.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →