Long-Context Architectures Explained: Gated DeltaNet and Sparse Attention

    This article explains the public principles, trade-offs, and evaluation methods behind long-context techniques. It covers fixed-state memory with Gated DeltaNet, on-demand retrieval with sparse attention, how the two can be combined, a checklist for evaluating long-context models, and deployment considerations. It is written for developers who need to choose or assess models for long-context workloads. It does not cover product release dates or speculate about unpublished model architectures.

    Why Long Context Is Hard

    Standard Transformer self-attention requires each token to compute its relevance to every previous token. The compute cost therefore grows quadratically with sequence length n. During inference, every layer also keeps a KV cache, and its memory footprint grows linearly with length. Going from 30,000 tokens to 300,000 tokens increases attention compute by about 100x and KV cache size by about 10x. Together, these two bottlenecks make long-text inference slow and memory-intensive.

    Gated DeltaNet: Replacing Full History with a Fixed State

    Linear attention compresses the history into a state matrix of fixed size. When the model reads a new token, it updates only this matrix and does not store each past token separately.

    The DeltaNet update rule first reads the state’s prediction for a given key, then corrects the state using the prediction error. As a result, new information can overwrite old memory. The gating mechanism adds a decay factor at each step, so the model can learn when to keep old information and when to forget it.

    This design has a direct benefit. The state size does not depend on sequence length, so memory use and per-step compute stay stable during inference, and throughput on long texts is clearly higher than with full attention.

    The costs are equally clear. A fixed state has limited capacity, so the more information written into it, the more likely older information is to be overwritten or blurred. The model also struggles to reproduce early tokens verbatim the way full attention can. As a result, pure linear architectures generally underperform full attention on tasks that require exact recall or precise localization at multiple points in the text. Gated DeltaNet is better suited to holistic understanding and persistent memory. On its own, it cannot cover every long-text task.

    Sparse Attention: Screen First, Then Read Closely

    Sparse attention keeps the computational form of standard attention, but each query accesses only part of the history. A common approach splits the context into blocks. A lightweight scoring or routing module first selects the blocks most relevant to the current query. Full attention is then computed only over those blocks.

    Several representative public approaches are worth reviewing. The DeepSeek team proposed Native Sparse Attention (NSA), which combines three branches: compression, selection, and sliding window. The team also published DeepSeek Sparse Attention (DSA) in the DeepSeek-V3.2 series, which uses a lightweight indexer to select the top-k historical tokens for each query. For implementation details, refer to the original papers and official technical reports.

    Sparse attention has three main costs. The first is missed retrieval. If routing does not select a block that contains the answer, the relevant information is ignored, and the model usually gives no indication that this happened. The second is routing overhead. The scoring module consumes compute and memory, and if blocks are divided too finely, this overhead can cancel out the savings. The third is implementation complexity. Sparse indexing requires efficient kernels. Without them, the theoretical compute savings may not materialize on real hardware.

    How the Two Mechanisms Work Together

    Pairing a compressed state with sparse retrieval is a reasonable division of labor. The compressed state maintains global context, and sparse retrieval returns to specific positions when needed.

    In practice, many hybrid architectures do not use the same mechanism in every layer. A common approach alternates linear and full-attention layers at a set ratio, or adds sparse selection on top of full-attention layers.

    The table below compares the main differences among three common approaches.

    Dimension Full attention with KV cache Gated DeltaNet (fixed state) Sparse attention (on-demand retrieval)
    Memory vs. length Grows linearly Essentially fixed The KV cache must still be stored, but compute is reduced
    Compute vs. length Grows quadratically Approximately linear Depends on the number of selected blocks
    Exact recall Strongest Weaker, depends on state capacity Depends on whether routing hits the right blocks
    Main risk High cost for long text Information overwriting and forgetting Missed retrieval and routing overhead
    Typical use Short-to-medium text and high-precision tasks Persistent memory over long text Locating information and question answering in long documents

    Static leaderboards do not fully reflect long-context capability. When evaluating a model, check the following six items.

    1. Task coverage: Include long-document question answering, multi-document summarization, code repository understanding, and multi-turn conversational memory. Do not test only one task type.
    2. Fact localization: Place key facts at different lengths and positions. Record recall rates, and plot accuracy against length and position.
    3. Multi-hop reasoning: Require the model to combine two or more pieces of information that are far apart in the text. This tests whether compression and retrieval actually work together.
    4. Resistance to leaderboard gaming: Use private test sets or test sets that are refreshed regularly. Record when each test set was constructed to reduce the risk of training data leakage.
    5. Consistent cost reporting: Use the same hardware, batch size, and input and output lengths. Report time to first token, generation throughput, and peak memory usage.
    6. Stability: Run the same question multiple times. Report the mean and the range of variation, and do not draw conclusions from a single run.

    Evaluation results are sensitive to decoding parameters. When reporting results, state the temperature, sampling method, and prompt template. Otherwise, the results cannot be reproduced.

    Deployment Considerations

    Before deploying a long-context model, prepare by addressing the following points.

    • Estimate GPU memory in three parts: model weights, KV cache, and activations. In long-context workloads, the KV cache is often the largest variable.
    • Set a reasonable context limit. Summarize or retrieve content that exceeds the limit, rather than passing everything in as one full input.
    • Track latency and cost by input length bucket. This makes it easier to spot request types with unusual cost patterns.
    • Long contexts can easily include unrelated personal information. Filter inputs before sending them to the model, and restrict access to the model service.
    • For cloud deployment, compare compute instance specifications, elastic scaling options, and inference framework support. Make the final decision based on load-test results from your own workloads.

    Summary

    The central trade-off in long-context technology is cost versus memory precision. Gated DeltaNet trades exact recall for stable inference cost by using a fixed state. Sparse attention trades routing overhead for precise access to details. Each has clear limits, and real systems often combine them with other mechanisms. When choosing a model, developers should first determine how much exact recall their task requires. Then they should validate performance with a consistent evaluation process rather than relying on a single leaderboard score.