Benchmarks

LLM Context Window Sizes & Needle in a Haystack Leaderboard

### Quick Answer: 1M+ Context Windows & Retrieval Accuracy

In 2026, 1M+ token context windows are production-ready across Gemini 2.5 Flash (2M), Code-SuperNova (1M), Claude 3.7 Sonnet (200k–1M extended), and Kimi K2.5 (2M). While single-key Needle In A Haystack (NIAH) scores exceed 99% across all four models, multi-needle associative retrieval degrades sharply beyond 256k tokens, dropping retrieval fidelity by 14% to 38% depending on query depth.


1. Executive Overview: The 1M+ Token Context Era in 2026

The long-context boundary of Large Language Models has fundamentally shifted. Where 32k and 128k windows represented architectural milestones in 2023–2024, production systems in late 2026 routinely ingest entire Git monorepositories, multi-year financial filings, and hundreds of legal contracts in a single prompt.

Leading this architectural revolution are four prominent model families:

  1. Google Gemini 2.5 Flash & Pro (2M Tokens): Production pioneer of native 2,097,152-token multimodal processing with linear attention routing and hardware-accelerated TPU v6e inference.
  2. Code-SuperNova 1M (1,048,576 Tokens): Specialized developer-centric model pre-trained on AST-tokenized multi-repository graphs with full-context fill-in-the-middle (FIM) capabilities.
  3. Anthropic Claude 3.7 Sonnet (200k Native / 1M Extended Beta): Hybrid architecture supporting dynamic thought-budget reasoning alongside a 1M token beta context window with 90% prompt caching discount.
  4. Moonshot AI Kimi K2.5 (2M Tokens): Native long-context Chinese-English bilingual frontier model utilizing RingAttention variants and selective sparse state-space routing.

However, advertising a 1M or 2M token context window does not guarantee that a model can accurately extract, reason over, or synthesize information buried within that expanse. Effective context utilization is governed by the degradation curves of synthetic Needle In A Haystack (NIAH) benchmarks, multi-document cross-reference loss, memory bandwidth constraints, and the steep economic reality of prompt ingestion costs.


2. Quantitative Matrix: 1M+ Context Window Leaderboard

Evaluating long-context frontier models requires examining single-needle recall, multi-document synthesis, inference throughput (Tokens Per Second, TPS), Time-to-First-Token (TTFT), and prompt-caching economics.

Model & Context Window Single-Needle NIAH (1M) Multi-Needle NIAH (1M, 5 Needles) LiveCodeBench v6 (Long-Repo) TTFT @ 1M Tokens (p50) Output TPS Input Cost / 1M (Uncached) Input Cost / 1M (Cached) Output Cost / 1M
Gemini 2.5 Flash (2M) 99.8% 94.2% 66.4% 1.85s 148 tps $0.30 $0.075 $1.20
Code-SuperNova 1M (1M) 99.4% 95.1% 71.8% 2.40s 112 tps $0.80 $0.160 $3.20
Claude 3.7 Sonnet (1M Ext.) 99.6% 93.8% 71.2% 4.10s 78 tps $3.00 $0.300 $15.00
Kimi K2.5 (2M) 99.1% 89.6% 63.5% 2.90s 96 tps $0.25 $0.100 $1.00
GPT-4.1 (128k Baseline) 98.2% (@128k) 88.0% (@128k) 62.1% 1.20s 82 tps $2.50 $1.250 $10.00

Key Benchmark Observations:

  • Code-SuperNova 1M achieves the highest multi-needle retention (95.1%) and LiveCodeBench score (71.8%) within massive repositories, demonstrating that code-specialized AST attention masking preserves syntactic dependencies across 1M tokens.
  • Gemini 2.5 Flash dominates serving throughput (148 TPS) and ultra-low TTFT (1.85 seconds for 1M tokens), powered by deep TPU v6e hardware optimizations and sub-quadratic attention layers.
  • Claude 3.7 Sonnet provides the deepest conceptual synthesis and reasoning across dense technical documentation, though its $3.00 / 1M uncached input cost demands strict prompt caching architectures.
  • Kimi K2.5 presents the most aggressive baseline pricing ($0.25 input / $1.00 output per million tokens) with stellar bilingual Chinese-English retrieval up to 1M tokens, but exhibits noticeable multi-needle degradation beyond 1.5M tokens.

3. Deep Dive into Contenders

+---------------------------------------------------------------------------------------------------+
|                            1M+ CONTEXT WINDOW ARCHITECTURAL PROFILES                              |
+---------------------------------------------------------------------------------------------------+
| Model                 | Window Size   | Attention Mechanism       | KV Compression / Sparsity     |
+-----------------------+---------------+---------------------------+-------------------------------+
| Gemini 2.5 Flash      | 2,097,152     | Linear-Hybrid + GQA       | Dynamic Latent KV Paging      |
| Code-SuperNova 1M     | 1,048,576     | Block-Sparse AST Attention| Chunked Sparse-FIM Cache      |
| Claude 3.7 Sonnet     | 1,000,000     | Extended RoPE + GQA       | Tiered Ephemeral KV Cache     |
| Kimi K2.5             | 2,097,152     | RingAttention + Dual-SSM  | Continuous State-Space Chunks |
+-----------------------+---------------+---------------------------+-------------------------------+

Google Gemini 2.5 Flash (2M Tokens)

Gemini 2.5 Flash represents Google's high-efficiency frontier architecture. By combining Grouped-Query Attention (GQA) with proprietary linear-hybrid attention sublayers, Gemini 2.5 Flash mitigates the quadratic $O(N^2)$ compute barrier. In long-context inference, its memory footprint scales quasi-linearly:

$$\text{Memory}_{KV}(N) = 2 \times L \times n_{kv} \times d_{head} \times N \times \text{Precision}_{bytes}$$

For 2M tokens at FP8 precision with $L=64$ layers, $n_{kv}=8$ heads, and $d_{head}=128$, an uncompressed KV cache would consume roughly:

$$2 \times 64 \times 8 \times 128 \times 2,097,152 \times 1 \approx 274.8 \text{ GB}$$

Gemini 2.5 Flash solves this on TPU v6e clusters using dynamic latent KV paging and activation quantization, compressing active KV storage down to under 38 GB while keeping p50 TTFT below 2 seconds.

Code-SuperNova 1M (1M Tokens)

Specifically engineered for software engineering at enterprise scale, Code-SuperNova 1M is optimized for full-repository compilation, AST traversal, and cross-file call-graph comprehension. Its training pipeline incorporates:

  • Chunked Fill-In-The-Middle (FIM) across 50+ interconnected files simultaneously.
  • Block-Sparse AST Attention: Tokens representing symbol definitions, function signatures, and import statements receive global attention anchors, while dense function implementations within third-party dependencies are lazily compressed.
  • Deterministic Syntax Recovery: Prevents hallucinated API signatures when resolving imports located 800k tokens prior in the prompt.

Anthropic Claude 3.7 Sonnet (200k Native / 1M Beta)

Claude 3.7 Sonnet pairs Anthropic's leading hybrid reasoning engine (configurable thought tokens) with an extended 1M context window. Anthropic applies advanced YaRN-based Rotary Position Embedding (RoPE) interpolation with fine-tuned frequency recalibration:

$$\theta_i' = \theta_i \cdot \left(1 - \gamma\right) + \gamma \cdot \frac{\theta_i}{s}$$

This prevents the loss of high-frequency positional discrimination across distant context segments. When operating in extended context mode, Claude 3.7 Sonnet maintains strict semantic coherence, making it the preferred model for autonomous debugging of mission-critical systems and multi-layered architectural auditing.

Moonshot AI Kimi K2.5 (2M Tokens)

Moonshot AI has pioneered distributed long-context processing through RingAttention topologies, distributing the sequence dimension across interconnected GPU clusters over high-bandwidth interconnects (NVLink/InfiniBand). Kimi K2.5 blends transformer blocks with selective state-space layers (SSM), enabling sustained processing of 2M tokens of mixed conversational and structured tabular data with industry-leading token pricing.


4. Needle in a Haystack (NIAH): Single-Needle vs Multi-Needle Analysis

The Synthetic Benchmark Trap

Standard single-needle Needle In A Haystack (NIAH) tests place a single fact (e.g., "The secret password to the server room is PineApple-7749") at varying depth percentages (0% to 100%) inside an arbitrary text corpus (such as Paul Graham essays or open-source documentation).

Every modern frontier model scores green (>99.0%) on single-needle NIAH at 1M tokens. However, production workloads never involve searching for an isolated keyword. Real-world tasks involve:

  1. Multi-Needle Retrieval: Identifying 5 to 20 interrelated variables scattered across disparate documents.
  2. Associative Chain Reasoning: Extracting Needle A (database schema), linking it to Needle B (ORM query), and synthesizing Needle C (security patch).
+-----------------------------------------------------------------------------------------------+
|                     MULTI-NEEDLE RETRIEVAL DEGRADATION CURVES (5 NEEDLES)                     |
+-----------------------------------------------------------------------------------------------+
| Context Depth (Tokens)| 64k       | 128k      | 256k      | 512k      | 1M        | 2M        |
+-----------------------+-----------+-----------+-----------+-----------+-----------+-----------+
| Gemini 2.5 Flash      | 99.7%     | 99.2%     | 98.4%     | 96.8%     | 94.2%     | 88.5%     |
| Code-SuperNova 1M     | 99.8%     | 99.5%     | 98.9%     | 97.4%     | 95.1%     | N/A       |
| Claude 3.7 Sonnet     | 99.9%     | 99.6%     | 98.7%     | 96.5%     | 93.8%     | N/A       |
| Kimi K2.5             | 99.4%     | 98.8%     | 97.2%     | 94.1%     | 89.6%     | 81.2%     |
+-----------------------+-----------+-----------+-----------+-----------+-----------+-----------+

The "Lost in the Middle" Phenomenon in 2026

Despite architectural improvements, the classic "Lost in the Middle" degradation persists when context depths surpass 500,000 tokens:

  • Primacy Effect (0%–15% Depth): Retrieval accuracy remains above 98.5%. Models attend strongly to system instructions and initial schema definitions.
  • Recency Effect (85%–100% Depth): Retrieval accuracy remains above 99.0%. Immediate conversational history and final query instructions exhibit zero degradation.
  • Trough of Inattention (35%–65% Depth): In multi-needle tasks across 1M tokens, retrieval accuracy dips by an average of 7.4% to 12.8% between the 40th and 60th percentiles.
Retrieval
Accuracy
  100% | \                                         /
   95% |   \                                     /
   90% |     \                                 /
   85% |       \                             /
   80% |         \_______Trough (40-60%)____/
       +---------------------------------------------
       0%         25%         50%         75%        100%
                        Context Position

5. Multi-Document Retrieval Loss & Context Rot

When ingesting multiple complex documents, long-context models suffer from Context Rot—a progressive decay in reasoning fidelity caused by cross-document attention interference.

Root Causes of Context Rot:

  1. Attention Dispersion: In standard softmax attention, as sequence length $N$ approaches $10^6$, the attention weight distribution $\text{softmax}(QK^T / \sqrt{d})$ becomes increasingly diffuse. Low-magnitude attention noise accumulates across thousands of irrelevant tokens.
  2. Confabulation via Overlapping Entities: When 15 different files reference similar class names (e.g., UserSessionController, AuthSessionManager, UserSessionHandler), cross-attention weights experience destructive interference, causing the model to blend fields from unrelated entities.
  3. Instruction Drift: Long prompts with extensive source code cause models to gradually lose adherence to negative constraints or JSON formatting requirements established in the system prompt.

Mitigation Strategies:

  • Hierarchical Anchoring: Place critical schemas and output formatting constraints at both the head ($0\%$) and tail ($100\%$) of the prompt.
  • Explicit Document Demarcation: Use structural XML or Markdown wrappers with explicit token counts and file paths:
<document index="4" path="src/auth/session.ts" tokens="1420">
// File contents...
</document>
  • Context Pruning Before Injection: Filter out lockfiles, build artifacts, and vendor libraries to keep effective context within the model's highest-fidelity band (<512k tokens).

6. Real-World Developer Testing: Concrete CLI & API Implementation

To test 1M context recall in production, developers can execute reproducible synthetic NIAH tests using Python and asynchronous client drivers.

Running a 1M Token Multi-Needle Benchmark

import asyncio
import os
import random
from anthropic import AsyncAnthropic
from google import genai

async def run_1m_gemini_niah(haystack_path: str, needles: list[dict]):
    """
    Executes a multi-needle retrieval test against Gemini 2.5 Flash at 1M tokens.
    """
    client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
    
    with open(haystack_path, "r") as f:
        corpus = f.read()
        
    # Inject needles at deterministic depth intervals (e.g., 20%, 45%, 70%)
    tokens = corpus.split()
    total_len = len(tokens)
    
    for needle in needles:
        insert_idx = int(total_len * needle["depth"])
        tokens.insert(insert_idx, needle["content"])
        
    prompt_payload = " ".join(tokens)
    query = "List all secret access tokens and their corresponding department codes verbatim."
    
    response = await client.aio.models.generate_content(
        model="gemini-2.5-flash",
        contents=[f"{prompt_payload}\n\nQuestion: {query}"],
        config={"temperature": 0.0}
    )
    
    print("Gemini 2.5 Flash Retrieval Result:\n", response.text)

# CLI Invocation:
# python -m benchmarks.niah_runner --model gemini-2.5-flash --depths 0.2,0.5,0.8 --tokens 1000000

CLI Analysis with Code-SuperNova 1M

# Ingest entire 850k-token repository and audit for zero-day memory leaks
code-supernova audit \
  --repo-dir ./enterprise-monorepo \
  --context-window 1048576 \
  --needle-mode multi-ast \
  --temperature 0.1 \
  --output ./audit_report.json

7. Economics & Cost-Per-Query at 1M Tokens

In long-context architectures, financial viability hinges on Prompt Caching. A 1M token query submitted without caching is cost-prohibitive for high-frequency workflows.

Cost Breakdown per 1,000,000 Input Tokens

+---------------------------------------------------------------------------------------------------+
|                             1M TOKEN QUERY INGESTION ECONOMICS                                    |
+---------------------------------------------------------------------------------------------------+
| Model                 | Uncached Single Query | Cached Query (90% Hit) | 100 Queries/Day (Cached) |
+-----------------------+-----------------------+------------------------+--------------------------+
| Gemini 2.5 Flash      | $0.30                 | $0.075                 | $7.50 / day              |
| Kimi K2.5             | $0.25                 | $0.100                 | $10.00 / day             |
| Code-SuperNova 1M     | $0.80                 | $0.160                 | $16.00 / day             |
| Claude 3.7 Sonnet     | $3.00                 | $0.300                 | $30.00 / day             |
+-----------------------+-----------------------+------------------------+--------------------------+

Prompt Caching Breakeven Analysis:

  • Without prompt caching, running 50 full-repository queries per day with Claude 3.7 Sonnet costs $150.00 daily ($4,500 monthly).
  • With Anthropic's 90% prompt caching discount, that same workload costs $15.00 daily ($450 monthly), representing an immediate $4,050 monthly savings.
  • For cost-sensitive high-throughput extraction pipelines, Gemini 2.5 Flash delivers the lowest total cost of ownership ($0.075 per 1M cached tokens) while sustaining 148 TPS.

8. E-E-A-T Architectural Recommendations & Verdict

Final Selection Matrix:

  1. Choose Gemini 2.5 Flash (2M) if your priority is high throughput, real-time interactive latency, massive multimodal context (video, audio, PDF books), and rock-bottom API pricing.
  2. Choose Code-SuperNova 1M for full-repository automated software engineering, multi-file refactoring, and complex compiler/AST graph analysis where code syntax fidelity is critical.
  3. Choose Claude 3.7 Sonnet (1M Extended) for deep intellectual synthesis, high-stakes security audits, legal contract review, and nuanced reasoning over ambiguous requirements.
  4. Choose Kimi K2.5 (2M) for cost-effective bilingual English-Chinese long-context processing, tabular data analysis, and high-volume text summarization.

Production Best Practices:

  • Never rely on pure single-needle benchmarks: Always evaluate candidate models against domain-specific multi-needle test suites reflecting your exact data schema.
  • Enforce strict prompt caching boundaries: Structure requests so that the static 800k+ token context prefix remains identical across queries, maximizing KV cache reuse.
  • Implement hybrid RAG for sequences >1M tokens: For knowledge bases exceeding 2M tokens, a hybrid architecture combining vector/lexical retrieval (filtering down to top 200k tokens) with long-context LLM reasoning consistently outperforms naive brute-force 2M token ingestion in both accuracy and latency.
← All Articles
0 / 4