Kreasof AI
← Back to research

ATMA: Long-Context Language Modeling via Polar Attention and Gated-Delta Compression Memory

What happens when we judge a long-context model by retrieval, document likelihood, short-context quality, reasoning, and serving—rather than one flattering score?

Research byKreasof AI
12 August 2026Preprint
Explore all ablations ↗ Code ↗ Technical manuscript ↓

TL;DR

  • We introduce ATMA, a 378M-parameter hybrid language model that combines Polar Attention with gated-delta recurrent memory.
  • Across a complete 120-cell recipe sweep, memory improves Polar’s teacher-forced 64K retrieval score in all 20 matched cells, by 47.8 percentage points on average.
  • After matched 9.816B-token pretraining at 2K, Polar retains 34.4% target-token accuracy at 256K, compared with 0.6% for NoPE and 0.0% for RoPE.
  • The result has a hard boundary: Polar reaches 18.0% exact retrieval on synthetic 256K contexts but 0.0% on FinePDFs. This is retained signal, not solved real-text retrieval.
  • There is no universal winner. Raven leads adapted BABILong and fixed-state decode; Polar leads retrieval and likelihood among the matched attention variants.
  • A post-hoc audit finds single near-unit memory gates in NoPE and Polar. An inference-only cap on one head largely restores long-document likelihood and improves Polar retrieval, while RoPE does not recover. This diagnoses a checkpoint failure; it is not a new trained method.
Diagram showing the Local, Local, Global, Local schedule repeated four times and an expanded Polar Attention global block with content, count, and recurrent memory paths.
Figure 1. ATMA repeats Local → Local → Global → Local four times, giving 12 gated-convolution layers and four global Polar Attention layers at blocks 3, 7, 11, and 15. Each global block combines normalized content direction, bounded participation magnitude, and gated-delta compression memory before gated projection and residual addition.

1. Introduction

Long-context language modeling is often compressed into a single retrieval curve. That curve matters, but it is not the whole problem. A useful model must preserve relevant information as context grows without giving up document likelihood, ordinary short-context quality, reasoning performance, or practical inference cost.

These objectives compete. Full attention preserves direct access to tokens, but its compute and cache grow with sequence length and its probability mass can disperse over more keys. Recurrent models keep fixed-size state, but that state must compress the past and can lose detail. We therefore treat long-context modeling as a Pareto problem: an architecture is an operating point on a multi-objective frontier, not a winner by one number.

The problem with more keys

Standard softmax attention normalizes over every available key. As the sequence grows, irrelevant scores create a larger noise field. Positional schemes such as RoPE change how order enters the score, but they do not by themselves separate the direction of the retrieved value from the amount of evidence that participated in the match.

That distinction motivates Polar Attention. We want one channel to represent what matched, without its norm growing simply because more keys were present, and another bounded channel to express how much matched.

Our approach

ATMA is a 16-layer decoder that repeats Local → Local → Global → Local four times: 12 gated-convolution layers and four global attention layers at blocks 3, 7, 11, and 15. The global layers use Polar Attention and also maintain gated-delta recurrent memory. The attention path can still read the full context; the recurrent path supplies a compressed history whose state size does not grow with the sequence.

We test this in two stages. First, a complete factorial sweep chooses the recipe across attention type, regularization, distractor alignment, memory, and local training windows. Second, matched NoPE, RoPE, and Polar models are trained for 9.816B tokens and evaluated from their 2K training length through 256K.

2. Architecture

The matched attention models contain 378.16–378.22M parameters and share hidden size, heads, tokenizer, data order, optimizer, schedule, and token budget. Only the attention core changes. This keeps the main comparison narrow enough to interpret.

Polar Attention

Polar Attention decomposes its output into a normalized direction and a bounded magnitude. The direction aggregates values and removes radial scale. The magnitude is derived from an effective participation ratio, then passed through an extreme-value-aware null sink and a bounded map. In plain language: the model records what the matching values point toward separately from how convincing the match appears to be.

Polar read
oipolar = Woci + Wμμi
ciNormalized value directionwhat matched
μiBounded participation magnitudehow much matched

This is a channel decomposition, not an independence claim. Changing the match set can still rotate the direction. The design instead prevents the raw number of participating keys from directly controlling output norm.

Extreme-value calibration diagram showing the null floor rising with context length while a fixed threshold is overtaken by the maximum noise score.
Figure 2. The null floor follows the extreme-value scale of irrelevant scores. A fixed threshold is eventually overtaken as context grows; the adaptive sink absorbs diffuse noise while leaving real-key weights available to the direction and magnitude channels.

Gated-delta compression memory

Each global layer also updates a recurrent key-value state. A learned sigmoid retention gate controls what remains; a delta update writes new information; a zero-initialized projection adds the retrieved memory back to the attention output. Unit-normalized keys control the update geometry. The sigmoid keeps each gate below one, but does not guarantee a useful fixed margin from one—an important distinction exposed by the checkpoint audit below.

3. Experimental design

The experiment is deliberately divided into recipe selection and matched comparison. Mixing these two stages would overstate what the ablation proves.

Stage I

120-cell factorial

All 3 × 5 × 2 × 2 × 2 combinations receive roughly 1B FineWeb-Edu tokens at length 2K. These are distinct recipe cells, not seed replicates.

Stage II

Matched pretraining

NoPE, RoPE, and Polar receive 9.816B tokens at length 2K in the same L40S environment and are evaluated through 256K.

The evaluation contains 24,000 paired retrieval trials over synthetic and FinePDFs haystacks, eight context lengths, three needle depths, and 50 trials per cell. We additionally measure BABILong after adaptation, fixed-target bits per byte, eight short-context tasks, and single-sequence serving on one L40S.

4. Results

Memory consistently helps Polar in the factorial

At 64K, adding memory improves Polar in all 20 matched combinations of regularizer, distractor setting, and window setting. The mean gain is 47.8 percentage points. The corresponding effect on NoPE is small and heterogeneous, while RoPE remains at zero.

+47.8mean 64K point gain from memory on Polar
20 / 20matched Polar cells improved with memory
−25.5mean points from adding a local window
92.5%selected Stage I cell at 64K

A local training window reduces Polar with memory by 25.5 points on average. Distractor alignment also has a smaller, nonuniform negative effect. We therefore promote full-context Polar with memory, without a local window or distractor alignment.

Polar retains more target signal at 256K

After matched training, NoPE and Polar both approach perfect teacher-forced target-token accuracy at 2K. Their extrapolation is different. At 256K, Polar retains 34.4% averaged across tasks, haystack suites, and depths; NoPE retains 0.6% and RoPE 0.0%.

PolarNoPERoPERaven NativeAtma-Raven-Titans
Teacher-forced target-token accuracy from 2K through 256K Polar declines to 34.4 percent at 256K, NoPE to 0.6 percent, RoPE to zero, Raven Native to 20.3 percent, and Atma-Raven-Titans to 10.0 percent. 10075502502K4K8K16K32K64K128K256K
Figure 3. Teacher-forced target-token retrieval accuracy for all five promoted checkpoints. Values average tasks, suites, and needle depths. Raven Native and Atma-Raven-Titans are separately optimized recurrent-family references, not matched attention ablations.
ComparisonModelToken @2KToken @256KExact @256KBABILong @256KBPB @256K
MatchedNoPE99.2%0.6%0.0%0%8.097
MatchedPolar98.9%34.4%9.0%28%1.825
MatchedRoPE88.2%0.0%0.0%14%2.512
Separately optimized recurrent family
Raven / AdamWAtma-Raven-Titans43.1%10.0%0.0%38%1.551
Raven / AdamWRaven Native41.1%20.3%0.0%46%1.597

Where retrieval fails

The aggregate masks the most important boundary in the result. At 256K, Polar retains 68.4% target-token accuracy on synthetic haystacks, but only 0.3% on FinePDFs. Exact five-token accuracy is 18.0% on synthetic contexts and zero on FinePDFs.

Synthetic · 256K68.4%

target-token accuracy

18.0% exact
FinePDFs · 256K0.3%

target-token accuracy

0.0% exact
Figure 4. The synthetic-to-natural retrieval gap is large enough that the aggregate should never be read as successful real-text retrieval.

5. The multi-objective frontier

Polar improves retrieval and long-document likelihood among the matched attention models, but it pays elsewhere. Its mean accuracy over eight 2K controls is 43.29%, compared with 45.15% for NoPE. At 128K, Polar attention decodes at 16.3 ms/token on one L40S; Atma-Raven-Titans records 2.27 ms/token with fixed recurrent state.

Raven Native reaches 46% BABILong at 256K and keeps likelihood nearly flat. Because Raven changes both model family and optimizer, it is not an attention ablation. It represents another practical point on the frontier: stronger adapted reasoning and cheaper decode, with lower direct retrieval.

Bubble plot of 256K retrieval accuracy against 128K decode latency, with bubble size representing BABILong performance.
Figure 5. A practical long-context frontier at 256K. Polar offers the strongest target-token retrieval among the matched attention variants; Raven occupies the low-latency, higher-BABILong region. Bubble area represents adapted BABILong performance.
There is no single “long-context score.” Retrieval, likelihood, adapted reasoning, short-context quality, memory growth, and latency answer different questions.

6. From checkpoint variability to a retention mechanism

The audit began with a mismatch: three NoPE checkpoints ended at almost the same 2K validation loss, yet differed by 6.70 nats at 256K. The runs were not seed-paired or randomized across devices, so this establishes checkpoint variability—not a hardware effect.

Parameter inspection found isolated near-unit gates

For every recurrent layer and memory head, we evaluated the learned zero-input gate γ0 and converted it to a half-life. The memory branch has eight independently learned head rows, even though attention uses two KV heads. One NoPE head implied a 21.01-million-token half-life and one Polar head 3.07 million. The earlier L4 NoPE control peaked at 185 tokens; Atma-Raven-Titans peaked at 41.

CheckpointLargest headZero-input half-lifeRole
NoPE · L4 mbs4block 2 / head 7185Earlier control
NoPE · L40S mbs4block 2 / head 21.38MMicrobatch control
NoPE · L40S mbs16block 2 / head 521.01MPromoted checkpoint
Polar · L40S mbs16block 2 / head 63.07MPromoted checkpoint
RoPE · L40S mbs16block 2 / head 1682Negative control
Atma-Raven-Titansblock 2 / head 341Recurrent reference

This is a parameter-only operating point, not a runtime trace: the nonzero input weights make γ activation-dependent. But the same extreme heads survive BABILong fine-tuning almost unchanged, which made them concrete intervention targets.

A one-head runtime cap tests the mechanism

We capped only the final runtime gate logit of the largest head so its half-life could not exceed 256 tokens (γ ≤ 0.997296). The hook changes no checkpoint tensor, leaves attention untouched, and is removed after each condition. In the paired pilot, baseline and cap use the same loaded model, documents, needle examples, seeds, and attention backend. At 256K, NoPE clean NLL falls from 12.003 to 1.138 and Polar from 1.252 to 1.057. Polar needle cross-entropy falls from 2.39 to 1.71; RoPE changes only from 6.16 to 6.02 and loses short-range retrieval.

Full re-evaluation confirms selective recovery

We then ran all eight 2K downstream tasks, synthetic and FinePDFs retrieval, fixed-target BPB, and BABILong for NoPE, Polar, and RoPE. The clamped runs below are compared with pinned archived baselines; the paired pilot above supplies the controlled comparison. All 15 jobs completed without OOM.

Three-panel length curves compare untouched and one-head-capped NoPE, Polar, and RoPE on retrieval, BABILong, and long-document bits per byte.
Figure 6. The complete length-wise re-evaluation. Dashed open and solid curves are the untouched/capped matched attention variants; dotted filled curves retain Raven Native and Atma-Raven-Titans as untouched recurrent-family references. NoPE’s BABILong recovery begins at 8K and persists through 256K.
ModelDownstream meanBPB @256KRetrieval @256K
token / exact
BABILong @256K
NoPE45.15 → 45.108.097 → 1.5950.60 / 0.00 → 0.93 / 0.000 → 39
Polar43.29 → 43.251.825 → 1.50134.37 / 9.00 → 47.07 / 16.3328 → 42
RoPE44.60 → 44.662.512 → 2.4600.00 / 0.00 → 0.00 / 0.0014 → 11

NoPE’s recovery is not confined to the endpoint. Its untouched BABILong curve falls from 21% at 16K to 6%, 0%, 0%, and 0% at 32K, 64K, 128K, and 256K; the capped checkpoint scores 54%, 45%, 37%, 35%, and 39%. Mean BPB changes from 3.374/5.527/5.885/6.369/8.097 to 1.484/1.504/1.506/1.530/1.595 over the same lengths. Exact retrieval still remains zero at 256K, so restored recurrent usability is not equivalent to restored direct lookup.

Polar gains 12.70 points in 256K target-token retrieval, 7.33 points in exact retrieval, and 14 points on BABILong; exact FinePDFs retrieval still remains zero. RoPE does not recover retrieval and loses three BABILong points at 256K. Ordinary downstream means move by at most 0.06 points. The paper appendix and diagnostic README report every task, dataset, depth, and length cell.

7. Limitations

  • The study uses one model scale and one 2K pretraining regime.
  • Stage I demonstrates robustness across nuisance-factor settings, not across random seeds.
  • Polar has zero exact FinePDFs retrieval at 64K and 256K.
  • Teacher-forced retrieval is not autoregressive generation.
  • Raven is a separately optimized family comparison, not an optimizer-matched ablation.
  • Serving measurements are single-sequence measurements on one L40S and should be treated as descriptive.
  • The retention cap diagnoses existing checkpoints. It neither identifies the outlier’s training origin nor validates a bounded-gate training formulation.
  • The broad clamped re-evaluation uses pinned archived baselines; strict same-process causality comes from the smaller paired sweep.

Conclusion

ATMA establishes a reproducible operating point for bounded full-context attention plus recurrent memory. Polar materially extends target-token signal, preserves exact synthetic retrieval, and stabilizes long-document likelihood. The result does not solve natural-text retrieval at extreme length, and it does not dominate recurrent alternatives on reasoning or serving.

The retention audit sharpens that lesson: a model can look converged at its training length while one near-unit recurrent gate silently creates a million-token timescale. A selective one-head intervention recovers NoPE likelihood and BABILong and improves Polar across likelihood, retrieval, and reasoning, but leaves other failures intact.

That mixed result is the point. Long-context systems should be compared as trade-offs, with metrics kept distinct, learned timescales audited, and failure boundaries made visible.

Inspect the evidence

The dashboard exposes all 120 recipe cells, validation trajectories, grouped contrasts, Stage II endpoints, and the retention-horizon re-evaluation. The repository contains the complete parameter scan, paired sweep, clamp specifications, and per-suite logs.

Open the ablation dashboard ↗ Browse the repository ↗