Long-Context Inference

Overview This post is divided into four parts; they are: • The Cost of a Long Context • Chunked Prefill • Managing Long-Lived KV State • Selecting Useful Context The Cost of a Long Context For full causal attention over a prompt of $N$ tokens, prefill attention computes a triangular portion of an $N times N$ score matrix.