Shallow Prefill, Deep Decoding: Efficient Long-Context Inference via Layer-Asymmetric KV Visibility

TL;DR

SPEED method reduces long-context inference cost via shallow prefill and deep decode, enhancing efficiency.

cs.AI 🔴 Advanced 2026-05-07 34 views
Jungsuk Oh Hyeseo Jeon Hyunjune Ji Kyongmin Kong Jay-Yoon Lee
long-context language model KV cache efficiency optimization deep learning

Key Findings

Methodology

SPEED employs a phase-asymmetric KV-visibility policy, materializing non-anchor prompt-token KV states only in lower layers while keeping Decode-phase tokens full-depth. Unlike previous approaches, SPEED removes prefill tokens from the upper-layer Decode visibility set entirely.

Key Results

  • In Llama-3.1-8B, SPEED using 75% of layers achieves a 51.2 average score on OLMES benchmarks, close to the 51.4 of the full-depth baseline, with a 33% TTFT improvement, 22% TPOT improvement, and 25% KV memory reduction.
  • With BoS anchoring, SPEED maintains stability at 128K context, reducing upper-layer prefill KV state access.
  • Experiments show SPEED significantly reduces long-context inference costs without decreasing Decode depth.

Significance

SPEED significantly reduces computational and memory costs for long-context inference without notably impacting model performance. This is crucial for applications requiring extensive context processing, such as document QA and long-text summarization. By reducing KV cache redundancy, SPEED offers a more efficient solution for long-context inference.

Technical Contribution

SPEED introduces a novel KV visibility strategy that reduces redundant upper-layer prefill KV storage, offering a more efficient KV cache management approach compared to existing methods. This not only reduces memory usage but also enhances inference speed, providing new engineering possibilities for long-context inference.

Novelty

SPEED is the first to propose a phase-asymmetric KV visibility strategy, differing from traditional methods that reduce costs by compressing or sharing upper-layer KV states. By entirely removing upper-layer prefill tokens, SPEED optimizes long-context inference efficiency while maintaining Decode depth.

Limitations

  • SPEED may lead to quality degradation with extremely shallow cutoffs, especially in tasks requiring complex reasoning.
  • The use of BoS anchors may limit flexibility for certain tasks.

Future Work

Future research could explore optimal cutoff layers for different tasks and how to maintain stability without BoS anchors. Additionally, the applicability of SPEED in other model architectures could be investigated.

AI Executive Summary

Long-context inference in decoder-only language models is costly, especially when processing long prompts. Existing methods typically reduce costs by compressing or sharing upper-layer KV states, often sacrificing some performance. The SPEED method addresses this issue by introducing a phase-asymmetric KV visibility strategy. It materializes non-anchor prompt-token KV states only in lower layers while keeping Decode-phase tokens full-depth. Experiments show that SPEED significantly reduces computational and memory costs for long-context inference without notably impacting model performance. By reducing KV cache redundancy, SPEED offers a more efficient solution for long-context inference. However, SPEED may lead to quality degradation with extremely shallow cutoffs. Future research could explore optimal cutoff layers for different tasks and how to maintain stability without BoS anchors.

Deep Analysis

Background

Long-context inference is a key task for decoder-only language models, involving applications like document QA and long-text summarization. Traditional methods require caching KV states at every layer when processing long prompts, leading to high computational and memory costs.

Core Problem

The core problem of long-context inference is how to reduce redundant KV cache storage without degrading model performance. Existing methods often reduce costs by compressing or sharing upper-layer KV states, which may sacrifice some performance.

Innovation

The SPEED method introduces a phase-asymmetric KV visibility strategy, materializing non-anchor prompt-token KV states only in lower layers while keeping Decode-phase tokens full-depth. Unlike traditional methods, SPEED entirely removes prefill tokens from the upper-layer Decode visibility set.

Methodology

  • �� SPEED employs a phase-asymmetric KV visibility strategy. • Materializes non-anchor prompt-token KV states only in lower layers. • Keeps Decode-phase tokens full-depth. • Uses BoS anchors as a stability reference.

Experiments

Experiments were conducted on the Llama-3.1-8B model, evaluated using OLMES benchmarks. The performance and efficiency of SPEED were assessed by comparing it to the full-depth baseline across different context lengths.

Results

SPEED using 75% of layers achieves a 51.2 average score on OLMES benchmarks, close to the 51.4 of the full-depth baseline, with a 33% TTFT improvement, 22% TPOT improvement, and 25% KV memory reduction.

Applications

SPEED is suitable for applications requiring extensive context processing, such as document QA and long-text summarization. By reducing KV cache redundancy, SPEED offers a more efficient solution for long-context inference.

Limitations & Outlook

SPEED may lead to quality degradation with extremely shallow cutoffs, especially in tasks requiring complex reasoning. The use of BoS anchors may limit flexibility for certain tasks.

Plain Language Accessible to non-experts

Imagine you're in a massive library looking for a book. Traditional methods require you to browse all the shelves from start to finish every time, which is time-consuming and exhausting. The SPEED method is like having a smart assistant in the library who knows roughly where your book is, so they only take you to the relevant shelves. This way, you save time and find the information you need faster. This assistant is like the BoS anchor in SPEED, helping you maintain direction in the complex shelves.

ELI14 Explained like you're 14

Imagine you're playing a super complex puzzle game. Every time, you have to start from scratch and recheck every piece, which is such a hassle! SPEED is like a smart helper who remembers the parts you've already solved, so you only need to focus on the new pieces. This way, you can finish the puzzle faster without starting over every time. Isn't that cool?

Glossary

KV Cache

A cache storing key-value pairs used to accelerate model inference.

In long-context inference, KV cache stores the states of prompt tokens.

BoS Anchor

A stability reference used to maintain model stability during shallow prefill.

SPEED uses BoS anchors to stabilize shallow prefill.

Decode Phase

The phase where new tokens are generated, using cached KV states.

SPEED keeps Decode-phase tokens full-depth.

Shallow Prefill

Materializing prompt-token KV states only in lower layers to reduce computational and memory costs.

SPEED reduces long-context costs via shallow prefill.

Phase-Asymmetric

Adopting different strategies in different phases to optimize performance and efficiency.

SPEED employs a phase-asymmetric KV visibility strategy.

Open Questions Unanswered questions from this research

  • 1 How to maintain model stability without using BoS anchors?
  • 2 What are the optimal cutoff layers for different tasks?
  • 3 How applicable is the SPEED method to other model architectures?

Applications

Immediate Applications

Document QA

Enhances efficiency in long-text question answering by reducing KV cache redundancy.

Long-term Vision

Long-text Generation

Supports the generation and processing of longer texts without sacrificing performance.

Abstract

Long-context inference in decoder-only language models is costly because long prompts are processed during Prefill, cached at every layer, and repeatedly attended to during autoregressive Decode. We introduce \emph{Shallow Prefill, dEEp Decode} (SPEED), a phase-asymmetric KV-visibility policy that materializes non-anchor prompt-token KV states only in lower layers while keeping Decode-phase tokens full-depth. Unlike previous approaches that make upper-layer prompt KV states cheaper to store or construct, SPEED removes prefill tokens from the upper-layer Decode visibility set altogether. With a minimal BoS anchor, this simple change preserves broad benchmark quality while reducing long-context cost. In a controlled Llama-3.1-8B instruction-tuning study, SPEED using only 75\% of layers for prefill tokens reaches 51.2 average score on OLMES-style benchmarks, compared with 51.4 for the full-depth baseline, while improving TTFT by 33\%, TPOT by 22\%, and reducing active KV memory by 25.0\% at 128K context. Layer-wise diagnostics suggest that this cutoff retains the main prompt-selection and representation-stabilization regions of the full-depth model. These results show that long-context prompt tokens need not always persist as full-depth KV-cache objects when Decode-phase tokens remain full-depth.

cs.AI