Millie 2, a new system from the LLMs For All group, runs a 177-billion-parameter language model with a one-million-token context window on a phone with 12 GB of RAM. At that context length, the compressed weights and attention data together occupy 69.5 GB, roughly six times the phone's memory. The authors report 14.1 tokens per second at short context and 9.9 tokens per second when answering a question about a million-token document, measured on an iPhone 18 Pro.

The result matters because on-device inference has usually meant small dense models with short contexts. Millie 2 argues that memory capacity does not have to be the hard limit if the runtime can predict what it needs and fetch it early. This post walks through the two streaming mechanisms, the training fix that keeps quality intact, and what to check before relying on the numbers.

A large mixture-of-experts (MoE) model has two memory consumers at long context. The first is the weights: a 177B model stays far beyond 12 GB even after compression. The second is the attention history, the per-token keys and values (the KV cache) that grow with every token in a million-token document.

Both can be kept on flash storage, but fetching data on demand stalls the compute pipeline. Millie 2's approach is to treat storage as the main home for weights and history, treat RAM as a cache, and make the model's own routing decisions cooperate with that cache.

In an MoE layer, a router picks a small subset of experts for each token, so only a fraction of the weights is needed at any step. Millie 2 uses this sparsity. It predicts which experts a layer will use before that layer runs, so the runtime can begin loading them early. It also biases selection toward experts whose weights are already in RAM.

The trade-off is that biased routing changes what the model computes. Choosing a resident expert over a better-scoring non-resident one saves a fetch but can lower output quality. The authors address this in training rather than only at inference, covered below.

For practitioners, the useful idea is that routing is a tunable resource-allocation decision. Cache hit rate becomes a variable the model can optimize alongside accuracy.

The second mechanism is Residency-Biased Attention (RBA), which applies the same principle to attention data. The method works in these steps:

This is a block-sparse retrieval scheme. The compact index stands in for the full history during selection, so the model never needs to read every key and value. Overlapping the fetch with the computation of earlier layers hides storage latency, which is why the system can keep a double-digit tokens-per-second rate at a million tokens.

The residency bonus plays the same role as the expert-selection bias. In both cases the model is nudged toward data that is cheap to access, and the runtime hides the cost of the rest.

A runtime that changes which experts fire and which blocks are attended to can drift from the parent model. The authors keep the compressed weights fixed and train only their shared scales, using the same expert-selection constraints that apply on the phone. The model learns to compensate for the residency bias without a full retraining run.

Training under the deployment constraint, instead of validating a constrained runtime after the fact, is a pattern worth borrowing. The reported outcome is that the resulting model scores close to its parent across reasoning, coding, instruction-following, and agentic benchmarks. The abstract says "close to" and does not give a single aggregate number, so the exact gap should be read from the per-benchmark tables in the paper.

The team also evaluated browser and Android agents with model inference running on the phones themselves. That is a more demanding test than static benchmarks, because agent loops involve long, growing contexts and many sequential calls.

The code is available in the authors' millie-runtime repository on GitHub, which makes it possible to inspect the streaming implementation directly.

Two threads are worth following. The first is whether residency-aware routing and attention become standard features of MoE training recipes, so that models are designed for tiered memory from the start. The second is independent reproduction on other hardware, particularly Android devices with different flash performance. If the throughput holds up, the practical question for developers shifts from whether a large model fits on a device to which parts of it should live in RAM at any given moment.

原文来源:dev.to