TL;DR
Handing a massive novel or an hour-long video to an AI model in one giant gulp slows it down, degrades its accuracy, and crashes into context-window walls. Recent prompting tricks fix this by slicing the input into a 2D grid and asking the model about each row and column separately—but at the painful cost of re-reading the entire book for every single question. Factorized Context Attention (FCA) brings this exact grid trick inside the model's attention layers, letting existing frozen models read massive inputs way past their context limits, with much higher accuracy, while encoding the data only once.
What Problem Does This Paper Address?
When large language and vision-language models read a massive input in a single forward pass (a "monolithic read"), three things go wrong: quadratic attention costs make it sluggish, distracting noise causes accuracy to plummet well before the context limit, and the model hits a hard wall at its maximum context window.
Recently, training-free methods known as grid probing found a clever workaround. Instead of feeding a 150,000-token novel all at once, you arrange chunks of the text (or frames of a video) into a hypothetical $K \times K$ grid. You then prompt the frozen model $2K$ separate times—once per row (contiguous "local" spans) and once per column (evenly spaced "strided" spans)—and pool the answers. Because each prompt is short, the model stays sharp and can read inputs far larger than its window. The catch? It is brutally expensive. Every question requires encoding the entire input twice from scratch, and nothing can be cached or reused for follow-up questions.
Methods
The authors start with a crisp observation: grid probing is just emulated attention—using external prompts to restrict what tokens a query can see, which is literally the job of an attention mask. To get the benefits without the redundant compute, they propose Factorized Context Attention (FCA), which runs this pattern as native attention inside a frozen model using standard attention kernels (like FlashAttention-2) and zero retraining.
FCA splits the work into two steps:
- Encode Once: The input is chunked into $N$ blocks on a $K \times K$ grid ($K = \lceil\sqrt{N}\rceil$). FCA encodes the $K$ rows (local spans) in a single batched pass, where tokens only attend to earlier tokens in their own row, and saves the Key-Value (KV) cache.
- Batched Masked Querying: When a question arrives, FCA runs $2K$ short sequences in one batch over the cached keys and values—gathering blocks for each row and column—and pools their log-odds scores (against an "abstain" option) to either answer directly or select the top $K$ blocks for a clean, focused read.
To make this work with Rotary Position Embeddings (RoPE) without retraining, FCA introduces stair positions. In native attention, a block's position is fixed during encoding. If you use true document positions, strided column spans take massive positional leaps and fall outside the model's trained window. Instead, FCA assigns the block at grid cell $(i, j)$ a starting position proportional to $(i + j - 2)\sigma$ (where $\sigma$ is block length). Moving one step right or one step down adds exact $\sigma$ tokens! Both rows and columns magically read as smooth, contiguous text well inside the model's comfort zone, expanding a window of size $W$ to hold up to $W^2/(4c)$ tokens (for chunk size $c$).
Datasets
Because FCA is strictly training-free, datasets are used purely for evaluation across three modalities:
- Long Text: InfiniteBench (En.MC), SCBench (multi-turn QA and multiple-choice), and synthetic RULER needle-in-a-haystack tests injected into novels up to 512k tokens.
- Long Video: LongVideoBench, Video-MME (long split), and a custom video needle benchmark where a TextVQA image replaces a single frame in videos up to 2,025 frames long.
- Images (Evidence Localization): RefCOCOg and TextVQA (evaluating spatial grounding against AnswerMap).
Key Insights and Ideas
- Prompting strategies can be compiled into attention masks: Realizing that multi-prompt aggregation is just "attention in disguise" bridges black-box prompting and white-box KV-cache serving. Emulated attention is best for closed APIs or tiny memory budgets; native attention wins on open weights and multi-turn speed.
- The "strided approximation" barely hurts: In FCA, strided columns gather blocks that were originally encoded alongside their row neighbors, not their column neighbors. Ablations show this tiny approximation leaves local spans nearly identical to grid probing, and re-reading the top-$K$ selected blocks recovers almost any lost accuracy.
- Geometry tames RoPE: The stair position schedule is a wonderfully clean mathematical trick—turning a 2D grid into 1D contiguous steps along both axes simultaneously so frozen positional encodings don't break on 500k+ token inputs.
Key Results
Across frozen models (Qwen3, Llama-3.1, InternVL3.5, Qwen3-VL), FCA matches grid probing's accuracy and reach at a fraction of the compute:
- Big accuracy boosts over monolithic reads: FCA gains ~10 percentage points on LongVideoBench (56.3% vs. 46.4% on InternVL3.5-2B) and 9 to 14 points on long novels in InfiniteBench En.MC (e.g., 79.0% vs. 65.5% on Qwen3-4B).
- Massive speedups on follow-up questions: Because the context is encoded once, answering subsequent questions on a novel takes 1/10th to 1/7th the time of Periscope (e.g., 1.1s warm TTFT vs. 16.6s on Llama-3.1-8B), and multi-turn SCBench answers arrive 5–7$\times$ faster.
- Reading 4$\times$ past the context window: On Llama-3.1-8B (131k window), monolithic reads miss most needles past the prefix (36.4%), while FCA hits 98.5% accuracy on texts up to 512k tokens—and finds single-frame needles in 2,025-frame videos where monolithic InternVL drops by ~17 points.
Limitations and Future Work
FCA has three clear trade-offs:
- Requires open models: Unlike prompt-level grid probing, FCA modifies attention masks and position IDs, so it cannot run on closed-source APIs.
- Memory footprint: It stores the KV cache of the entire input in GPU memory (around 42 GB for InfiniteBench novels, compared to 12–20 GB for single-span probing).
- Approximate strided spans: Column blocks don't attend to each other during encoding (fixing this requires a second encoding pass, doubling prefill cost).
For future work, the authors suggest training models natively with the FCA pattern, translating other prompting workflows into native attention masks, and exploiting the fact that FCA's rows are completely independent—allowing the KV cache to grow seamlessly with streaming data or be sharded effortlessly across multiple GPUs.
Summary updated