RidgeFill:免训练的后层缓存填充以加速预填充
研究论文 · 2026/11/11
RidgeFill 是一种无需训练即可加速预填充的方法:它不计算提示词在模型大部分上层中的表示,而是从分割层的状态出发,用逐层岭回归映射预测后续每一层的输入,并据此写入缓存。该方法将原本需训练进模型的投影(如 YOCO 和 DeepSeek-V4.1-Flash 中的设计)改造为对未训练模型的一次性闭式拟合,且不丢弃任何 token。在 Qwen3.8-27B 上,16K 至 120K token 时首 token 时间加速 1.25–1.31 倍,RULER 和 LongBench v2 分数略有下降;在 Qwen3.8-Flash-Next 上,9K 至 32K token 时加速 1.50–1.60 倍,RULER 针检索任务接近无损。
RidgeFill 提供了一种无需训练、不丢 token 的预填充加速方案,在长上下文场景下实现 1.25–1.60 倍加速,且质量损失较小、误差来源可分析,对部署大模型有实际参考价值。
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.31x 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.60x 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 +/-0.03 nats of the released SwiftKV checkpoint's.