Manuscript Offprint

arXiv:2611.09709

RidgeFill: Training-Free Late-Layer Cache Fill for Faster Prefill

Dylan Johnston, Robert P. Smith

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

RidgeFill shortens prefill by not computing most of a model's upper layers for the prompt. The lower layers run exactly up to a split; from the split layer's state a per-layer map predicts every later layer's input, and each late layer writes its cache from that prediction. The design follows YOCO and DeepSeek-V4.1-Flash, where the projection is trained into the model. RidgeFill retrofits it onto models that were never trained for it: the map is a ridge regression fitted once in closed form from one pass over calibration text, the layer's own projections run unchanged, and a chosen set of rows, the last few thousand tokens, and every decoding step run the full model. Nothing is trained and no token is dropped.

Most of the work was in measurement, finding a repeatable methodology. Loss averaged over all tokens hides RidgeFill's error. Needle retrieval in the filled region, loss on tokens that depend on distant context, and splice tests that swap filled keys or values for exact ones show which component carries it: the keys on Llama-3.1-8B, half of it in their scale, and the values and the recurrent state on Qwen3.5-9B.

On Qwen3.8-27B in a llama.cpp fork on an A100, time to first token is 1.25 to 1.31× faster at 16K to 120K tokens with the maps in VRAM; RULER changes by -1.2 and -1.4 points and LongBench v2 by -1.4; the 95 % intervals include zero but do not rule out losses of a few points. On Qwen3.8-Flash-Next in vLLM it is 1.50 to 1.60× faster than exact at 9K to 32K tokens, with RULER's needle tasks at 99.8 against 100.0 and perplexity on novel tokens 2.65 % higher [-0.02 %, +4.93 %]. On three 8 to 9B reference models, at the same split and tail as the identity fill, the fitted map retrieves 49.1 and 49.6 more filled-region RULER points on the two dense models (at that split Llama's loss is worse), and its long-document loss is within 0.03 nats of the released SwiftKV checkpoint's.

1 Introduction

For a long prompt, prefill is the wait before a response, and the user sees nothing until it completes. Before the first output token, a decoder runs every prompt token through every layer. At 120,000 tokens on Qwen3.8-27B that is 128 seconds on an A100. Decoding the answer afterwards is comparatively fast.

RidgeFill shortens the wait by not fully computing most of the upper layers. It runs the lower layers exactly up to a split layer, whose depth is one of two settings a deployment chooses. From the split layer's hidden state, RidgeFill predicts the input to every later layer. Each late layer then computes only its key and value projections from that prediction, or in a Gated DeltaNet layer its recurrent state update, and skips the rest of the layer, MLP included, for most prompt tokens. Seen this way, the method is speculative decoding (Leviathan et al., 2023; Chen et al., 2023) run backwards (Figure 1). Decoding is bandwidth-bound and has compute to spare, so a draft model or head (DeepSeek-AI, 2024) spends that compute guessing tokens the model then verifies. Prefill is the opposite. Each weight read is reused across hundreds of prompt rows, so the GPU is limited by arithmetic, not by memory bandwidth. RidgeFill spends the spare bandwidth on extra reads: one map for each late layer, held in VRAM or in host memory. Each map predicts its layer's input. For most prompt rows, the layer writes its cache from that prediction and skips the rest of its computation.

Figure

Figure 1. Speculative decoding and RidgeFill each spend the resource their phase has spare. Decoding is bandwidth-bound, so a draft head spends the spare compute guessing tokens and the full model verifies every guess. Prefill reuses each weight read across hundreds of prompt rows, so it is limited by arithmetic. RidgeFill spends the spare bandwidth on extra reads, the fill maps from VRAM or host memory, and in return skips most of the late layers' arithmetic. A filled cache has no affordable verifier, so the rows most likely to matter are kept exact instead (§2.4).

The idea comes from DeepSeek-V4.1-Flash (DeepSeek-AI, 2026), which builds on YOCO (Sun et al., 2024). In that model the upper layers take their caches from a projection of a middle layer's state, and the whole model is trained to absorb the error. The day it came out, Hugging Face user "kishida" retrofitted the design onto Qwen3-8B as the KVA projector (kishida, 2026): trained per-layer heads that write the late layers' keys and values directly from the layer-18 state. RidgeFill differs in three ways (Figure 2). First, it predicts each late layer's input rather than its keys and values, so the layer's own projections run unchanged, and on a hybrid model so does its recurrent state update. Second, the map is a ridge regression, fitted once in closed form from one pass over calibration text. The process requires no training steps. Third, it does not approximate every token the same way. Some rows, meaning a token's entries in the late layers' caches, are computed exactly, and choosing which ones turned out to be most of the challenge.

Initial efforts focused on finding the method's ceiling. An approximation has random error in it, and the problem resembled digital-to-analog conversion: a lossy stage whose output has to land inside the next stage's acceptance band. So we reached for the tools that solve that problem in other domains, where they work. Jensen's inequality for the softmax, Gaussian closures for the keys, Nyquist's argument for what could be interpolated between exact samples. None of them beat what we already had. The Jensen and Gaussian corrections left the attention error they target unchanged or made it worse, by up to 80 %. The best of the other corrections lowered that error by 8.6 % and left the loss where it was. The fill's error is close to white noise from one row to the next, so there is nothing between exact samples to interpolate (Appendix I.1). The analogy fails on its premise. A converter normalizes its input and knows its target. A prompt is not known until it is being processed, it is different every time, and the only definition of the correct output is the full model run on it. Those tools also treat the error as independent of what will be asked. It isn't.

The underlying structure that we spent most of our time in pursuit of showed up initially in needle tests. The first results were not inspiring: on needles inside the filled region, the model

References (72)