Wink Pings

Don't repeat prefill in multi-agent systems: Ramp Labs uses a 2.35B translator to translate caches across 7 models

Ramp Labs releases speculative encoding, a 2.35B MoE that translates hidden states across 7 models and 42 directions. It retains 96.9% native accuracy on 8k documents, makes time to first token up to 7.5x faster on 128k long documents, and a query-aware compressor compresses context by 128x. Code and checkpoints are open-sourced.

Multi-agent systems still mostly pass context between models as text. The receiver has to rerun prefill, pushing every token through its own layers to build a KV cache. The longer the context, the more expensive this duplicated computation becomes, and prefill cost grows quadratically with length. Ramp Labs has released speculative encoding to eliminate this duplicated computation: it trains a 2.35B-parameter MoE translator that directly translates the source model's hidden states into the target model's hidden states, and the target model then uses its own frozen weights to generate the KV cache.

Background: different model families have different tokenizers, widths, layer counts, and attention mechanisms. In its tweet, Ramp Labs uses an analogy: each model thinks in its own language. For Llama, Qwen's hidden states are like an image to a text model and must be treated as another modality. Their approach gives each model layer small projections and biases, sharing a transformer encoder-decoder and MoE experts. The source model encodes once to produce a memory, and any target model decodes from that memory. This way, translator parameters grow with the number of models, not with the number of model pairs.

Architecturally, the translator predicts the target model's hidden states rather than directly predicting the KV cache. The target model computes keys and values using its own frozen K/V matrices. This constrains predictions to a space familiar to the target model. Across tokenizers, the decoder initializes from the target model's own token embeddings. Attention only reads the most recent 8 tokens, because hidden states already encode prior context, so computation grows linearly with document length. Training has two stages: first cache fitting, making the translated cache close to the target's native cache; then KL distillation, making the target's output distribution on the translated cache close to that on the native cache. The 42 directions are trained jointly, with the base models fully frozen.

Results cover 7 models across 4 families: Qwen3 14B, Qwen3.5 9B, Llama 3.1 8B, Gemma 3 12B, Gemma 4 12B, Ministral 3 8B, and 14B. On 8k-token documents, at full depth, across 12 evaluation datasets and 42 directions, it retains 96.9% native accuracy on average, with the worst direction at 93.1%. Compared with the weaker of the two models, it retains 100.3% on average. Ramp Labs also notes that translated caches only carry what the source model understood, so a weak source caps the results.

accuracy

Long documents are the more direct value. Native prefill cost grows quadratically with input length, while speculative encoding grows linearly. At 128k tokens, time to first token is up to 7.5x faster, at the cost of predicting fewer hidden states per token and losing 1 to 2 points of retention. Full depth is 2.5x faster at 128k and about 4x at 32k. Long-document retention falls from 92% at 32k to 83% at 128k; these documents are 4 to 16 times longer than what was seen in training.

latency

There is also a query-aware compressor. Given the target model's question, it first uses SnapKV to select positions in the translated cache, then uses a module isomorphic to the decoder to synthesize a compressed cache. On 32k and 64k documents, even at 128x compression, retention remains within 2 points of the full translated cache. On 128k documents, retention with 64x compression is 4.3 points higher than that of the full cache. In multi-agent settings, an agent can query another agent's context and get back only the hidden states relevant to the question, shrinking context by 128x while retaining more than 90% accuracy.

Code and checkpoints are open-sourced. The vLLM repo is at github.com/b10-tv/speculative-encoding, and the HF checkpoints are at huggingface.co/RampPublic/speculative-encoding. The repository provides a CPU quickstart that runs the full API with a tiny random model; it also has a Baseten single-GPU demo and CLI where you can specify source, target, document, question, and compressor. The translator covers all 42 directions across 7 models; local checkpoints can be split, at about 1.5GB bf16 per model pair.

Limitations are clear. A weak source model limits how much information the translated cache can carry. Whether closed frontier models are willing to expose internal KV representations is another question. Some commenters under the tweet asked about cross-model KV sharing: it is technically feasible, but are providers willing to expose internal representations to each other? Ramp Labs also mentions that translation quality for token rows captured from non-prefill context has not yet been measured. The drop in long-document retention is also left for future work.

One notable point: treating hidden states from different models as different modalities to translate is more extensible than any single speedup number. A router can switch models mid-task, and the new model does not need to reread prior context; in an agent swarm, one agent can translate over only the part of the context the other agent's question needs. The premise is that the system is willing to share internal representations, and that the source model is not too weak.

发布时间: 2026-11-26 02:33