Richland Technology
Richland Technology
← Back to Blog
llmopen-sourceagentsresearchinferencekv-cache

Speculative encoding: one shared 2.35B MoE passes context between seven models without re-prefill

A shared 2.35B MoE translates one model's hidden states into another's KV cache across 42 directions — no re-prefill, Apache-2.0 code, and a vLLM connector with documented rough edges.

Richland AI Desk·27 November 2026·6 min read
Speculative encoding: one shared 2.35B MoE passes context between seven models without re-prefill

Ramp Labs and Base Labs (Baseten's research arm) released speculative encoding on November 25: a single shared 2.35B mixture-of-experts translator that converts one model's per-layer hidden states into another model's KV cache, so a multi-agent system can pass context between seven open models without re-prefilling. It ships as Apache-2.0 code and a vLLM connector (the weights themselves carry no license statement), and it collapses the n(n−1) pairwise translators that earlier cache-to-cache methods required into one network covering all 42 source→target directions.

What shipped

Multi-agent systems usually pass context between models as text. Every model that receives it has to prefill again — run each token through its own layers to rebuild the key-value cache the previous model already computed. Speculative encoding skips that repeated work by translating the context directly from one model's internal states into another's.

The architecture is a transformer encoder–decoder shared by all models, adapted per model layer with learned projections P_in/P_out (to and from each model's width) and per-model source and target biases injected into every self-attention, cross-attention, and feed-forward step. The feed-forward blocks are mixture-of-experts, so all the mappings stay in shared parameters. The encoder reads every source layer but only the last few tokens across the sequence, so cost grows linearly with document length instead of quadratically like prefill. Its output is a memory μ computed once per source and reused for any target. The decoder is initialized from the target's own token embeddings (which bridges different tokenizers) and predicts a reduced set of hidden states per token; the target then computes its own keys and values from those states with its frozen weights.

That choice — translating hidden states rather than KV entries — is the load-bearing decision. As the paper puts it, every layer of every model has only one hidden state per token, while per-token K/V caches differ by head count, head width, and positional encoding, and linear-attention layers keep no K/V at all. Forcing predicted hidden states through the target's frozen K/V matrices "constrains keys and values to a space that is well understood by the target model." It also means the method works across models with incompatible attention internals, including Qwen 3.5's linear-attention layers.

The translator covers seven frozen models from four families — Qwen3 14B, Qwen3.5 9B, Llama 3.1 8B, Gemma 3 12B, Gemma 4 12B, Ministral 3 8B, and Ministral 3 14B — in all 42 directions. An optional query-aware compressor shrinks the requested cache 16×, 64×, or 128×.

What shipped is runnable, not just a paper:

  • The paper by Ben Geist (Ramp Labs) and Thomas Villeneuve.
  • An Apache-2.0 GitHub repo with a CLI (encode, answer, split), a Python API, a vLLM connector and Hugging Face engine, and a run_on_baseten.py job for Baseten GPUs.
  • A ~9.8 GB Hugging Face checkpoint with the encoder, decoder, seven per-model adapters, and a 128× compressor.

Retention for all 42 source-to-target directions at full depth, averaged over 12 tasks and 3 seeds. Rows are sources, columns are targets.

The numbers, and what they actually cover

All accuracy and latency figures below are the labs' own; no independent replication exists yet.

SettingReported result
Documents up to 8,192 tokens (the training length), all 42 directions96.9% of the target's native accuracy; worst direction 93.1%
Tasks not seen in training vs. tasks seen in training97.4% vs. 96.5% retention
32k-token documents~4× faster time to first token than re-prefill, over 90% retention
128k tokens, full decoder depth2.5× faster, retention down to 83%
128k tokens, reduced decoder depth (L′ = 8 or 4)6.1× and 7.5× faster, costing 1–2 more retention points
Compressor at 128k, 64×4 points better than the full translated cache

The headline "up to 7.5×" is the most aggressive setting: 128k tokens with reduced decoder depth, where retention is already in the low 80s. The defensible planning number is the one Base Labs itself leads with — roughly 4× faster at 32k tokens while keeping over 90% of accuracy. The speedup-vs-retention tradeoff across depths is shown below.

Speedup in time to first token against retention over all 42 directions. Each curve is one translator, with points at 32k, 64k, and 128k tokens.

Why it matters

The architectural bet is the interesting part, and it's the part that generalizes. Earlier cache-to-cache methods trained one translator per model pair, so a system with n models needed n(n−1) of them. Speculative encoding shares one core and adds only thin per-model projections and biases — the seven adapter-*.pt files in the checkpoint. That makes many-to-many routing economically plausible: a document read once can be handed to any of several models without each one re-prefilling.

For people building multi-agent systems, the practical consequence is that context passing no longer has to be text-shaped. If you're willing to trust a translator, models can communicate in latent space, and the target model's own frozen weights still produce the cache it answers from. The README notes the translated cache is 5–7× smaller than the raw hidden states, and a split checkpoint loads about 1.5 GB per pair in bf16.

There's also a rare piece of public honesty here: the integration friction is documented by the downstream project itself. A vLLM RFC opened the same week names speculative encoding as a motivating workload and describes the connector's time.sleep(0.005) inside get_num_new_matched_tokens() — a polling hack to stop vLLM's scheduler from starving the background translation thread. The RFC proposes a proper zero-GPU-block WAITING_FOR_KV_PREPARE scheduler state; it's still in backlog, not merged.

Caveats

  • Everything is self-reported. No independent replication exists. The paper's Results section and Appendix A (exact expert counts, encoder/decoder sizes, the parameter breakdown behind "2.35B") weren't fully readable, so the parameter count and architecture details come from the labs' own materials.
  • Generalization beyond 8k is the weak spot. Training length is 8,192 tokens; retention falls as documents grow, and the authors say fixing that is future work.
  • The benchmark scope is narrow. Long-document speedups are target-side time-to-first-token on one H200 with the source memory already computed — not end-to-end pipeline time. Long-document retention is scored on multiple-choice questions only.
  • Serving is unfinished. The vLLM connector relies on a polling workaround, and scheduler overhead is expected with many concurrent translated requests.
  • Agent-to-agent handoff is unmeasured. Token-level relay of generated text is wired up, but the README says its translation quality is "unmeasured" — the translator was trained only on document-prefill rows.
  • Checkpoint hygiene. The Hugging Face page has no model card and no license statement; the Apache-2.0 license lives on the GitHub repo, not the weights.

Sources

Start a Conversation

Ready to build something like this?

Tell us about your project and we'll respond with a clear plan within one business day.

Tell Us About Your Project

Takes 3 minutes. We read every submission personally.