ArXiv: 2411.13476

🎯 Pitch

RoPE’s promise of relative positional encoding silently breaks under BFloat16, with the first token absorbing most of the corruption—and the error explodes as sequences get longer. The authors fix this with AnchorAttention, a plug-in trick that not only restores long-context fidelity but also cuts training time by over 50%.


1. Executive Summary

This paper identifies and analyzes a critical numerical breakdown that occurs when Rotary Positional Embedding (RoPE) runs under BFloat16 precision during long-context training, revealing that the first token in a sequence contributes most significantly to deviations from RoPE’s intended relative positional encoding — a deviation that accumulates as context length grows. To address this, the authors propose AnchorAttention, a plug-and-play attention mechanism that treats the first token as a shared anchor with a consistent position ID visible to all documents within the training context while masking cross-document attention (e.g., using the <bos> token as a common starting point for all documents, eliminating positional inconsistencies across document boundaries). On the RULER long-context benchmark with LLaMA-2-7B, AnchorAttention reduces training time by over 50% compared to standard full attention while consistently outperforming both full attention and intra-document attention methods across context lengths from 8K to 128K tokens, establishing that long-context performance improvements can be achieved through attention-pattern redesign without sacrificing general capabilities on MMLU and HellaSwag — but only when the numerical precision issues inherent to BFloat16 are explicitly mitigated rather than ignored.

2. Context and Motivation

The Core Problem: BFloat16 Corrupts RoPE's Relative Encoding in Long-Context Training

The fundamental problem this paper addresses is one that most practitioners of long-context LLM training have likely encountered without recognizing its root cause: Rotary Positional Embedding (RoPE) does not actually preserve its theoretically promised relative positional encoding properties when computations are performed under BFloat16 precision, and this breakdown becomes increasingly severe as sequence length grows. This is not a minor numerical nuisance — it is a structural failure in the positional encoding mechanism that undermines the very advantages RoPE is supposed to provide for long-context adaptation.

To understand why this matters, we need to be precise about what RoPE guarantees in theory versus what happens in practice. RoPE's key theoretical property, derived in Appendix A (Equation 7), is that the attention logit between positions ii and jj depends only on their relative distance m=jim = j-i, not on their absolute positions:

Aij=(Ri,θqi)(Rj,θkj)=qiRji,θkjA_{ij} = (R_{i,\theta} q_i)^\top (R_{j,\theta} k_j) = q_i^\top R_{j-i,\theta} k_j

This means that if we add a constant positional shift Δ\Delta to every token in a sequence — moving the entire sequence forward in position space — the attention computation should be completely unchanged (Equation 3). This property is what enables RoPE-based models to generalize to sequence lengths beyond their training context: if the model has learned to attend to tokens at relative distance mm, it should recognize that same relative relationship regardless of where in the extended sequence those tokens appear.

The paper demonstrates that this property breaks under BFloat16. Figure 1 (left) shows the evidence: when applying different positional shifts Δ1\Delta_1 and Δ2\Delta_2 to the same input sequence, a pretrained LLaMA-2-7B model under BFloat16 produces different attention patterns — the blue line deviates substantially from zero as the shift gap increases. Under Float32 precision (yellow line), this discrepancy vanishes, confirming that the theoretical property holds when numerical precision is adequate. Under random initialization (green line), the discrepancy is also much smaller, indicating that pretraining amplifies this breakdown — the model learns to rely on the corrupted positional signal during training.

The implications are severe for long-context training and inference:

  • Cumulative error with length: Figure 1 (right) shows that the attention logit discrepancy for the first token grows with sequence length. At 8,192 tokens, the discrepancy is substantially larger than at 64 tokens. This means that as practitioners push context windows to 128K, 256K, or beyond, the positional encoding degradation compounds, potentially explaining why models exhibit performance drop-offs at extreme lengths even when the theoretical maximum context is large enough.

  • The first token is the primary culprit: Figure 1 (middle) reveals a striking pattern: when measuring per-token attention differences caused by positional shifts, the first token accounts for most of the total difference. Tokens beyond the first largely preserve the relative positional property. This is a non-obvious finding with direct mechanistic implications — it means the breakdown is not a uniform degradation across all positions but is concentrated at a single structurally significant token.

  • Training reinforces bad behavior: The fact that pretrained parameters show larger discrepancies than randomly initialized ones (blue vs. green lines in Figure 1, left) indicates that during training, the model internalizes the corrupted positional signal. The weights adapt to the BFloat16-induced distortions, making the problem deeply embedded in the trained model rather than a superficial runtime artifact.

This problem is particularly insidious because it is invisible to standard evaluation pipelines. Models are typically trained, fine-tuned, and evaluated under the same BFloat16 regime, so the positional corruption is baked into both the training objective and the evaluation metric. It only becomes visible through controlled experiments that isolate precision effects, as the paper does in Section 2.2. Most practitioners would never think to compare Float32 and BFloat16 attention computations on the same model, because BFloat16 is assumed to be a faithful approximation — an assumption this paper definitively disproves for RoPE's rotational operations.

Why This Problem Matters: The Convergence of Precision Constraints and Long-Context Ambitions

The significance of this finding spans theoretical understanding, practical deployment, and the future trajectory of LLM development.

Theoretical significance: challenging the foundation of RoPE-based long-context scaling. RoPE has become the dominant positional encoding scheme in modern LLMs — adopted by LLaMA (Touvron et al., 2023), LLaMA-2, LLaMA-3 (Dubey et al., 2024), Mistral (Jiang et al., 2023), Qwen (Yang et al., 2024), and many others — precisely because of its relative positional encoding properties. The entire paradigm of "train short, extend long" through techniques like NTK-aware scaling (LocalLLaMA, 2023), YaRN (Peng et al., 2023), and position interpolation (Chen et al., 2023a) is premised on the assumption that RoPE's rotational structure faithfully encodes relative distance. If that structure is corrupted under the very precision format universally used for training these models, then the theoretical foundation for these extension methods is compromised. The paper's finding does not mean these methods don't work — they clearly do, empirically — but it suggests they may work for reasons different from their stated theoretical justifications, and their failure modes may be predictable from the precision-induced breakdown rather than from the mathematical properties they claim to leverage.

Practical significance: wasted compute and suboptimal performance. The practical stakes are high. Long-context training is extraordinarily expensive — attention computation scales quadratically with sequence length, and organizations invest enormous GPU-hours to extend models from 4K or 8K context windows to 128K, 256K, or even 1M tokens. If a significant fraction of that training budget is being spent on overcoming BFloat16-induced positional distortions rather than genuinely learning long-range dependencies, then the field is systematically wasting compute on a fixable numerical issue. The paper's proposed AnchorAttention reduces training time by over 50% (Figure 6) while improving long-context performance, suggesting that the status quo approach of full attention under BFloat16 is achieving suboptimal results at inflated computational cost — a doubly inefficient outcome.

Deployment significance: on-device and edge scenarios. The paper's focus on BFloat16 is not arbitrary. BFloat16 is the default precision for training because it reduces memory bandwidth requirements by half compared to Float32 while preserving sufficient dynamic range for gradient-based optimization (Kalamkar et al., 2019). For long-context training — where memory is the primary bottleneck — switching to Float32 would be prohibitively expensive. The problem creates a tension: use BFloat16 and accept corrupted positional encoding, or use Float32 and accept drastically reduced context lengths or batch sizes. AnchorAttention resolves this tension by redesigning the attention pattern to sidestep the precision issue entirely, operating within BFloat16 constraints.

The hidden cost of cross-document attention. The paper also identifies a subtler waste: standard intra-document attention (Figure 2, left) as used in LLaMA-3 and verified by Gao et al. (2024) masks cross-document attention but assigns continuous position IDs across document boundaries. This means the first token of each document — which the paper shows is the primary source of positional corruption — receives a different absolute position ID depending on where that document falls in the packed sequence. The model must then learn to disentangle document boundaries from positional encoding, a task made harder by the BFloat16-induced distortion at those critical first-token positions. The paper shows that simply resetting position IDs to 1 at each document boundary (Figure 2, middle) consistently improves long-context performance (Figure 3), confirming that inconsistent first-token positioning is a real source of error. But this creates a new problem: the model never sees positions beyond the longest single document, limiting its ability to learn high rotational frequencies needed for long-distance attention.

Where Prior Approaches Fall Short

The paper identifies limitations across several axes of existing work:

Precision-agnostic RoPE research. The extensive literature on RoPE-based context extension (Chen et al., 2023a; LocalLLaMA, 2023; Peng et al., 2023; Men et al., 2024; Liu et al., 2023b; Wang et al., 2024b) treats RoPE as a mathematical abstraction operating in infinite precision. The theoretical derivations of NTK-aware scaling, YaRN, and position interpolation all assume that the rotational operations preserve exact relative distances. None of these works consider whether the actual hardware implementation — which inevitably uses reduced precision — delivers the theoretical guarantees. The paper's experiments in Table 2 confirm that vanilla RoPE with an appropriate base frequency outperforms these theoretically motivated methods within the training context length, but the reasons for this superiority may be more about precision dynamics than about the relative merits of the interpolation schemes themselves. This gap — treating software-level algorithms as if they operate independently of hardware-level precision constraints — is a blind spot across the position encoding literature.

Intra-document attention without positional consistency. Recent work by Zhao et al. (2024b) and Gao et al. (2024) demonstrates that intra-document attention — masking cross-document attention during training — improves both short and long-context performance while reducing computational cost. This approach is adopted in production models like LLaMA-3. However, these works apply intra-document attention with continuous position IDs across the entire packed sequence (Figure 2, left), implicitly assuming that the cross-document mask is sufficient and that position ID assignment is irrelevant. The paper shows this assumption is false — the position ID of each document's first token matters substantially, and the inconsistency introduced by continuous numbering degrades performance compared to resetting position IDs per document (Figure 3). The prior work's failure to recognize this issue stems from the same root cause: not accounting for how BFloat16 distorts the positional signal at those critical boundary tokens.

Perplexity as a long-context metric. The paper directly challenges the widespread use of perplexity (PPL) for evaluating long-context models, citing Hu et al. (2024) and Fang et al. (2024) who show PPL poorly correlates with actual long-range dependency comprehension. Figure 4 provides direct evidence: during long-context training, PPL plateaus after just a few steps while RULER benchmark performance continues to improve. This means papers that optimize for and report PPL improvements on long-context data may be measuring — and reinforcing — the wrong signal. The paper's recommendation to evaluate on synthetic long-context tasks like RULER that specifically probe retrieval, tracing, and aggregation over long distances is a methodological contribution that addresses a real weakness in the evaluation literature.

Training-free context extension underdelivers. While methods like LM-Infinite (Han et al., 2023) and StreamingLLM (Xiao et al., 2023) can extend inference context without additional training, the paper notes that dedicated long-context training yields significantly better results (Fu et al., 2024; Xiong et al., 2023; Gao et al., 2024). The problem is that training-based approaches inherit the BFloat16 precision issue, making them less effective than they could be if the positional encoding were functioning correctly. AnchorAttention bridges this gap: it is a training-based method that explicitly avoids the precision pitfall, achieving the benefits of continued training without the accumulated positional error.

Sparse and efficient attention without precision awareness. Many methods reduce attention complexity through sparsity patterns (Lou et al., 2024; Ge et al., 2024), group query attention (Ainslie et al., 2023), or sequence parallelism (Li et al., 2021; Liu et al., 2023a; Jacobs et al., 2023). These approaches optimize for computational or memory efficiency but make the same implicit assumption: that the attention mechanism's mathematical formulation translates faithfully to the precision-limited hardware implementation. The paper's contribution is orthogonal — it designs an attention pattern specifically to mitigate BFloat16-induced errors while also achieving efficiency gains — but the insight that precision issues should inform attention design is new and broadly applicable.

How This Paper Positions Itself

The paper frames its contribution not as a fundamentally new attention mechanism but as a precision-aware redesign of existing attention patterns that addresses a specific, previously undiagnosed failure mode. The intellectual lineage is clear: the paper builds on intra-document attention (Zhao et al., 2024b; Gao et al., 2024) and the observation that the first token is structurally significant in transformer attention — a phenomenon that has been independently observed in the "attention sink" literature (Xiao et al., 2023; Han et al., 2023; Gu et al., 2024). But the paper's unification of these threads is novel: the first token's significance is not merely a statistical property of trained models but is mechanistically linked to BFloat16 precision interacting with RoPE's rotational operations, and this interaction explains why attention sinks may be more than an empirical curiosity.

The paper positions AnchorAttention as a minimally invasive modification — a "plug-and-play" method that requires changing only the attention mask and position ID assignment, not the model architecture, training pipeline, or optimization procedure. This is strategically important: the adoption barrier for long-context training methods is high because the training runs are expensive and infrastructure-specific. A method that works within existing FlashAttention2 (Dao, 2024) and Hugging Face Transformers (Wolf et al., 2020) frameworks, as AnchorContext does (Section 5.5), has practical relevance that more invasive proposals lack.

The paper also positions itself against a specific form of practitioner complacency: the assumption that BFloat16 is "accurate enough" for all training computations. By isolating the precision issue to RoPE's rotational operations — where small trigonometric errors at each position accumulate into systematic biases — the paper provides a concrete counterexample to the general claim that reduced-precision training is lossless. This has implications beyond RoPE: other positional encoding schemes with similar rotational or multiplicative structures may experience analogous degradation, and the methodology of comparing Float32 and BFloat16 attention on the same model provides a template for auditing such effects.

Finally, the paper implicitly argues for a shift in how we think about positional encoding in precision-limited environments. Rather than treating RoPE as a mathematical function that produces correct relative positions, the paper suggests we should think of it as a function that produces approximately correct relative positions with an error term that is concentrated at the sequence boundary and grows with length. AnchorAttention is then a way to periodically reset this error accumulation by treating the first token as an absolute reference — essentially converting the problem from "maintain accurate relative positions across the entire sequence" to "maintain accurate relative positions within each document, with a shared absolute reference point." This reframing of RoPE's failure mode into an engineerable property is the paper's deepest conceptual contribution.

3. Technical Approach

3.1 Reader Orientation

This paper develops AnchorAttention, a precision-aware attention mechanism for long-context training of large language models. The system solves the problem that BFloat16 precision corrupts RoPE's relative positional encoding — particularly at the first token of each sequence — by redesigning the attention pattern to use a shared anchor token visible to all documents while masking cross-document attention, thereby maintaining positional consistency, reducing numerical error accumulation, and cutting training time by over 50%.

3.2 Big-Picture Architecture (Diagram in Words)

The system has four major components that work together to enable numerically stable long-context training:

  1. Base LLM with RoPE — a pretrained transformer (e.g., LLaMA-2-7B, LLaMA-3-8B) that uses Rotary Positional Embedding for position encoding. This model receives training sequences packed with multiple documents.

  2. AnchorAttention Mask Generator — a component that constructs the causal attention mask such that: (a) each token within a document can attend to all previous tokens in the same document, (b) the shared anchor token (the <bos> token at position 0) is visible to all tokens across all documents in the packed sequence, and (c) tokens from different documents cannot attend to each other (cross-document masking). The position IDs are assigned continuously from 0 to the sequence length, with the anchor always receiving position ID 0.

  3. FlashAttention2 / FlexAttention Backend — the efficient attention implementation that executes the actual forward pass. The rotation matrices Ri,θR_{i,\theta} are applied to queries and keys outside FlashAttention2 using Float32 precision, then the rotated vectors are cast to BFloat16 before entering the attention kernel where the inner product qkq^\top k is computed.

  4. Training Loop with Sequence Packing — the data pipeline packs multiple documents into a single training sequence of length TT (e.g., 64K or 128K tokens), with the <bos> token prepended once at the start. The loss is computed only on document tokens (not the anchor), and training proceeds with standard autoregressive language modeling.

Information flows as follows: packed documents enter the training pipeline → the anchor token <bos> is prepended once → position IDs are assigned continuously starting from 0 → the AnchorAttention mask is constructed specifying which token pairs can interact → RoPE rotation matrices are applied in Float32 → rotated queries and keys are cast to BFloat16 → FlashAttention2 computes the attention in BFloat16 with the custom mask → the output is used for the standard next-token prediction loss.

3.3 Roadmap for the Deep Dive

  • First, the formal definition of RoPE and its theoretical relative positional encoding property (Equation 3), because understanding what should happen under infinite precision is necessary to explain what does happen under BFloat16.

  • Second, the diagnostic methodology (Equations 4 and 5) that the paper uses to isolate and measure the BFloat16-induced breakdown — this is the empirical foundation for the entire paper, and understanding the metrics clarifies what "breakdown" means operationally.

  • Third, the analysis of why the first token is the primary source of positional corruption, which then motivates the anchor design — this connects the diagnostic findings to the architectural solution.

  • Fourth, the AnchorAttention mechanism itself — the mask construction, position ID assignment, and how it resolves both the precision issue and the position-inconsistency issue identified in intra-document attention.

  • Fifth, the training protocol for long-context extension using AnchorAttention — including data preparation (SlimPajama, upsampling), RoPE base frequency selection, and the specific hyperparameter choices.

  • Sixth, the AnchorContext implementation infrastructure and how it achieves numerical accuracy, speed, and ease of integration with existing frameworks.

3.4 Detailed, Sentence-Based Technical Breakdown

This is primarily an empirical diagnosis paper with a practical architectural fix. The core idea is that BFloat16 precision interacts destructively with RoPE's rotational operations at the first sequence position, and that treating this first token as a shared anchor with consistent positioning across documents both repairs the positional encoding breakdown and improves training efficiency.


Rotary Positional Embedding (RoPE): The Theoretical Promise

The paper begins from the well-known formulation of RoPE (Su et al., 2021) as used in modern transformer-based LLMs. Understanding the intended behavior is necessary to understand what breaks.

Standard attention (without positional encoding). The attention mechanism in a transformer computes:

Aij=qikjA_{ij} = q_i^\top k_j

where AijA_{ij} is the attention logit between the ii-th query and jj-th key, qi=WQxiq_i = W_Q x_i is the query vector obtained by applying the learned query matrix WQRd×dW_Q \in \mathbb{R}^{d \times d} to the ii-th token embedding xix_i, and kj=WKxjk_j = W_K x_j is the key vector obtained by applying the learned key matrix WKRd×dW_K \in \mathbb{R}^{d \times d} to the jj-th token embedding xjx_j. The complete attention output is:

ATTN(X)=softmax(A+M)\text{ATTN}(X) = \text{softmax}(A + M_{-\infty})

where MRT×TM_{-\infty} \in \mathbb{R}^{T \times T} is the causal mask: M,ij=M_{-\infty, ij} = -\infty if i<ji < j (the ii-th token cannot attend to future tokens) and M,ij=0M_{-\infty, ij} = 0 otherwise. The softmax then converts these masked logits into attention weights that sum to 1 across attended positions.

What this computes: for each query position ii, the model computes a compatibility score with every key position jij \leq i (including itself), then uses the softmax to produce a probability distribution over previous positions. The scaling factor 1/d1/\sqrt{d} introduced by Vaswani et al. (2017) is omitted from the paper's notation for simplicity.

Why this form: the dot-product attention allows each position to gather information from all previous positions, with the learnable WQW_Q and WKW_K matrices determining which features matter for relevance scoring. The causal mask enforces the autoregressive property needed for language modeling.

RoPE: injecting relative position through rotation. Rather than adding positional embeddings to the token representations (as in original transformer absolute position encoding), RoPE rotates the query and key vectors by position-dependent angles. The core operation is:

Aij=(Ri,θqi)(Rj,θkj)A_{ij} = (R_{i,\theta} q_i)^\top (R_{j,\theta} k_j)

where Ri,θR_{i,\theta} is a block-diagonal rotation matrix applied to the ii-th position's query, and Rj,θR_{j,\theta} is the corresponding rotation applied to the jj-th position's key. The rotation matrix Ri,θR_{i,\theta} has the structure shown in Equation 6 (Appendix A):

\cos(i\theta_0) & -\sin(i\theta_0) & 0 & 0 & \cdots & 0 & 0 \\ \sin(i\theta_0) & \cos(i\theta_0) & 0 & 0 & \cdots & 0 & 0 \\ 0 & 0 & \cos(i\theta_1) & -\sin(i\theta_1) & \cdots & 0 & 0 \\ 0 & 0 & \sin(i\theta_1) & \cos(i\theta_1) & \cdots & 0 & 0 \\ \vdots & \vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\ 0 & 0 & 0 & 0 & \cdots & \cos(i\theta_{d/2-1}) & -\sin(i\theta_{d/2-1}) \\ 0 & 0 & 0 & 0 & \cdots & \sin(i\theta_{d/2-1}) & \cos(i\theta_{d/2-1}) \end{bmatrix}$$ where $\theta_p = \text{base}^{-2p/d}$ for $p = 0, 1, \ldots, d/2-1$, with base typically set to 10,000, and $d$ is the per-head dimension (e.g., 128 for LLaMA-2-7B). Each $2 \times 2$ block rotates a pair of dimensions by an angle $i \cdot \theta_p$, with different frequencies $\theta_p$ for different dimension pairs. **What this computes:** the query and key vectors are split into $d/2$ pairs of coordinates, and each pair is rotated by a position-dependent angle in its own 2D plane. The rotation matrix applied to position $i$ uses the absolute position index $i$ multiplied by the frequency $\theta_p$ for each dimension pair. **The critical property: reduction to relative position.** Because rotation matrices are orthogonal, $R_{i,\theta}^\top R_{j,\theta} = R_{j-i,\theta}$ (shown in Appendix A.3 using trigonometric identities). This means: $$A_{ij} = (R_{i,\theta} q_i)^\top (R_{j,\theta} k_j) = q_i^\top R_{i,\theta}^\top R_{j,\theta} k_j = q_i^\top R_{j-i,\theta} k_j$$ Let $m = j - i$ be the relative distance. Then $A_{ij} = q_i^\top R_{m,\theta} k_j$. The attention logit depends **only on the relative distance $m$**, not on the absolute positions $i$ and $j$. **Why this form matters:** this relative encoding property is the theoretical foundation for RoPE's long-context generalization. If the model has learned to attend at certain relative distances during pretraining (e.g., distances up to 4K), then when sequences are extended to 64K, the same relative distances exist — tokens separated by 2000 positions in a 64K sequence use the same rotation angle as tokens separated by 2000 positions in a 4K sequence. The model does not need to learn new positional relationships; it just needs to encounter new absolute positions that map to familiar relative distances. **Invariance under positional shifts.** A direct consequence of the relative encoding property is that adding a constant shift $\Delta$ to all position indices should leave attention unchanged: $$A_{(i+\Delta)(j+\Delta)} = (R_{i+\Delta,\theta} q_i)^\top (R_{j+\Delta,\theta} k_j) = q_i^\top R_{(j+\Delta)-(i+\Delta),\theta} k_j = q_i^\top R_{j-i,\theta} k_j = A_{ij}$$ Equation 3 in the paper formalizes this: the attention between tokens at shifted positions $(i+\Delta, j+\Delta)$ is identical to the attention at the original positions $(i, j)$, because the $\Delta$ cancels in the relative distance computation. This invariance is what the paper tests — and finds broken — under BFloat16. **Implementation detail: where precision matters.** The paper notes a crucial implementation split (Section 2.1). The rotation matrices are applied to queries and keys *outside* the FlashAttention2 module in Float32 precision: $R_{i,\theta} q_i$ and $R_{j,\theta} k_j$ are computed using Float32 arithmetic. However, the inner product $q_i^\top R_{j-i,\theta} k_j$ is computed *within* the FlashAttention2 module, which requires BFloat16. This means the rotation itself is exact, but the dot product that determines attention weights is approximate. The paper's finding is that this approximation is not uniform — it produces systematic biases that grow with the magnitude of the position indices. --- #### Diagnostic Methodology: Measuring the Breakdown The paper introduces two quantitative metrics to isolate and measure the BFloat16-induced distortion of RoPE's relative property. **Attention difference metric (Equation 4).** To detect whether positional shifts affect attention patterns: $$D(X, \Delta_1, \Delta_2) = \sum_{l,h} \sum_{j=1}^{L} \left( \mathbf{n} \odot \sum_{i=1}^{L} \left| \text{ATTN}_{i,j}^{l,h}(X, \Delta_1) - \text{ATTN}_{i,j}^{l,h}(X, \Delta_2) \right| \right)$$ where $l$ indexes transformer layers (e.g., 32 for LLaMA-2-7B), $h$ indexes attention heads within each layer, $L$ is the sequence length, $\text{ATTN}_{i,j}^{l,h}(X, \Delta)$ is the attention weight (after softmax) that the $i$-th token assigns to the $j$-th token in the $h$-th head of the $l$-th layer when the entire sequence is shifted by $\Delta$ positions, and $\mathbf{n} = [1/L, 1/(L-1), \ldots, 1, 0, \ldots, 0]$ is a normalization vector that accounts for the varying number of valid (non-masked) elements in each row due to causal masking — row $j$ has $L-j+1$ valid elements, so dividing by $L-j+1$ prevents later rows (which have fewer valid comparisons) from dominating the sum. The operator $\odot$ denotes element-wise multiplication. **What it computes:** for a fixed input $X$ and two positional shifts $\Delta_1$ and $\Delta_2$, the metric measures the total absolute difference in attention weights across all layers, all heads, and all token pairs, normalized per row. If RoPE's relative property holds, $D = 0$ exactly — shifting the sequence does not change attention. Any non-zero $D$ indicates a violation. **Why this form:** summing across all layers and heads captures cumulative effects throughout the network depth, not just at a single layer where the distortion might be hidden. The per-row normalization ensures that the metric is not artificially inflated by earlier tokens (which can attend to more previous tokens under causal masking). Using absolute differences rather than squared differences keeps the metric in probability units, making it interpretable as "how much the attention distribution shifts." **Attention logit difference for the first token (Equation 5).** To isolate the first token's contribution and study length dependence: $$D_{\text{logit}} = \frac{1}{T} \sum_{l,h} \sum_{i=1}^{T} \left| A_{i,j=1}^{l,h}(\Delta_1) - A_{i,j=1}^{l,h}(\Delta_2) \right|$$ where $T$ is the sequence length, $A_{i,j}^{l,h}(\Delta)$ is the attention logit (pre-softmax) from token $i$ attending to token $j$ with positional shift $\Delta$, and the sum is over all tokens $i$ attending specifically to the first token ($j=1$). The division by $T$ normalizes for sequence length. **What it computes:** the average absolute difference in logits when any token attends to the first token under two different positional shifts. By measuring logits rather than post-softmax attention weights, the metric avoids the distortion introduced by softmax over varying sequence lengths — with more tokens, the softmax denominator changes, making attention weights for the first token incomparable across lengths. The metric focuses exclusively on $j=1$ to quantify how much the first token's positional signal is corrupted. **Why this form:** using logits bypasses the softmax normalization issue, enabling fair comparison across different sequence lengths. Focusing on $j=1$ isolates the effect at the first token, which the per-token analysis (Figure 1, middle) identifies as the primary locus of the breakdown. **Experimental protocol for Figure 1.** The paper fixes a text corpus and samples 50 sequences of length 4096. For Figure 1 (left), $\Delta_2 = 16$ is held constant while $\Delta_1$ varies over [0, 2, 4, 6, 8, 10, 12, 14, 15, 17, 18, 20, 22, 50, 100, 200, 500, 1000, 2000]. Three configurations are compared: - **Blue line:** pretrained LLaMA-2-7B parameters, BFloat16 precision - **Yellow line:** same pretrained parameters, Float32 precision - **Green line:** random initialization (Kaiming uniform, PyTorch default), BFloat16 precision For each $(\Delta_1, \Delta_2)$ pair, $D$ is computed and averaged over the 50 sequences. The point $\Delta_1 = 16$ (where $D$ would be zero by definition since $\Delta_1 = \Delta_2$) is excluded from the plot for visualization clarity. For Figure 1 (middle), the per-token breakdown of $D$ is visualized for a fixed $(\Delta_1=0, \Delta_2=16)$ pair, showing the contribution of each token position to the total difference. For Figure 1 (right), the sequence length is varied over [64, 128, 256, 512, 1024, 2048, 4096, 8192] while keeping $\Delta_1=0$ and $\Delta_2=16$ fixed, and $D_{\text{logit}}$ is computed for the first token ($j=1$) at each length. **Key findings from the diagnostics:** 1. The blue line deviates substantially from zero, while the yellow line stays near zero — BFloat16 specifically corrupts RoPE's relative property, and Float32 restores it. 2. The green line (random initialization) shows much smaller deviations than the blue line — pretraining amplifies the distortion, meaning the model's learned weights adapt to and reinforce the corrupted positional signal. 3. Figure 1 (middle) shows the first token accounts for the vast majority of the attention difference; excluding it makes the difference near-zero. 4. Figure 1 (right) shows $D_{\text{logit}}$ grows with sequence length — longer sequences suffer more severe positional corruption at the first token. --- #### Why the First Token: Mechanistic Hypothesis The paper does not provide a full theoretical proof for why the first token is specifically affected, but it offers a well-motivated mechanistic hypothesis grounded in the interaction between BFloat16 precision and the magnitude of position indices. **The role of absolute position magnitude.** Under RoPE, the rotation angle applied to a token at position $i$ is $i \cdot \theta_p$, where $\theta_p = \text{base}^{-2p/d}$ is a frequency that varies across dimension pairs. When the sequence is shifted by $\Delta$, the first token's position changes from 0 to $\Delta$, and its rotation angles change by $\Delta \cdot \theta_p$ for each frequency. For large $\Delta$, the angles become large (potentially many multiples of $2\pi$), and representing $\cos(\Delta \cdot \theta_p)$ and $\sin(\Delta \cdot \theta_p)$ precisely under BFloat16 becomes challenging because BFloat16 has only 7 bits of mantissa (compared to 23 bits for Float32). **The BFloat16 rounding mechanism.** BFloat16 represents numbers as $\text{sign} \times 2^{\text{exponent}} \times (1.\text{mantissa})$, with 8 exponent bits and 7 mantissa bits. When computing $\cos(\theta)$ and $\sin(\theta)$ for large $\theta$, the function values oscillate between -1 and 1, requiring accurate representation of the argument modulo $2\pi$ to determine which cycle the angle falls in. With only 7 mantissa bits, the granularity of representable numbers near 1 is approximately $2^{-7} \approx 0.008$, meaning the cosine of a large angle could be off by this order of magnitude even before the dot-product computation. When the dot product $q_i^\top (R_{\Delta,\theta} k_j)$ is then computed in BFloat16, these per-coordinate errors accumulate differently for different $\Delta$ values, producing the systematic differences observed in Figure 1. **Why the first token is special.** The first token's key vector $k_1$ has its rotation applied using position index $\Delta$ (after shifting), while the $i$-th query is rotated with position index $i + \Delta$. Their relative distance is $(i + \Delta) - \Delta = i$, which is independent of $\Delta$ in theory. However, the *absolute* magnitude of the rotation applied to $k_1$ is $\Delta \cdot \theta_p$, which grows with $\Delta$. For large $\Delta$, the trigonometric functions at these large angles have reduced precision, and this loss of precision propagates into the dot product. For tokens further into the sequence, the relative distance calculation involves subtracting two large numbers ($i + \Delta$ and $j + \Delta$) that are close to each other, so the cancellation reduces the dependence on absolute position magnitude. But the first token's key rotation uses $\Delta$ directly without any cancellation, making it maximally exposed to large-angle precision loss. **Connection to attention sinks.** The paper speculates (Section 8) that this first-token precision issue may be related to the "attention sink" phenomenon observed by Xiao et al. (2023) and others, where the first token consistently receives disproportionately high attention weights. The hypothesis is that the BFloat16-induced positional corruption at the first token causes the model's attention distribution to be quantitatively different from what it would be under exact arithmetic, and the model may learn to compensate by adjusting how it allocates attention to the first token — potentially contributing to the emergence of attention sinks as a learned adaptation to this numerical imperfection. This connection is flagged as future work and is not empirically tested in the paper. --- #### Document Token Indexing When training long-context models, it is standard practice to pack multiple documents into a single training sequence to maximize GPU utilization. Each document is a self-contained text unit (e.g., a Wikipedia article, a GitHub file), and during autoregressive training, a document boundary should not leak information — the model should not be able to attend from one document to the next, because in real deployment these documents would be processed independently. The paper studies and refines how position IDs are assigned across these document boundaries. **Standard intra-document attention with continuous position IDs (Figure 2, left).** This is the approach used in LLaMA-3 and studied by Zhao et al. (2024b) and Gao et al. (2024). Documents $d_1, d_2, d_3$ are concatenated into one sequence, and an attention mask prevents tokens in $d_2$ from attending to tokens in $d_1$ or $d_3$, and vice versa. However, the position IDs are assigned continuously: the first token of $d_1$ gets position 0, the last token of $d_1$ gets some position $p_1$, the first token of $d_2$ gets $p_1+1$, and so on. This means the "first token" of each document receives a *different* absolute position ID depending on how many tokens came before it in the packed sequence. **What this computes:** the attention within each document uses valid relative distances, but the absolute position of the first token varies across documents. For a document starting at position $p_1+1$, its first token's rotation is $R_{p_1+1,\theta}$, which uses a completely different set of rotation angles than the first token of a document starting at position 0. **Why this matters:** under exact arithmetic (Float32), this variation would be irrelevant — RoPE's relative property ensures that only relative distances within each document matter, and the absolute starting position cancels out. But under BFloat16, the paper has shown that the *absolute* position of the first token affects attention because of precision loss at large position indices. So a document that happens to start at position 50,000 will have its first token's positional encoding more corrupted than a document starting at position 1,000. The model sees inconsistent positional signals for what should be equivalent "first token" roles. **Intra-document attention with position ID reset (Figure 2, middle).** This is the paper's improved version. The position IDs are reset to 1 (or 0) at the start of each document, so every document's first token receives position ID 1, its second token receives position ID 2, and so on. The attention mask still prevents cross-document attention. **What this computes:** within each document, the position IDs are a clean consecutive sequence starting from 1, regardless of where the document falls in the packed training sequence. The first token of every document receives the same rotation $R_{1,\theta}$, avoiding the absolute-position-variation problem. **Why this helps:** Figure 3 shows that resetting position IDs consistently improves RULER performance compared to continuous IDs at all context lengths. At 128K context, the reset version achieves approximately 65.75 vs. 64.31 with continuous IDs, and at 64K, 73.34 vs. 70.87. This confirms that position ID inconsistency at document boundaries is a real source of error, and that the BFloat16-induced distortion at the first token is what makes the inconsistency matter (under Float32, the two schemes would be equivalent). **The trade-off:** resetting position IDs means the model never sees position IDs larger than the longest single document in the training corpus. If no document exceeds, say, 32K tokens, the model's RoPE rotations are only ever evaluated at angles up to $32,000 \cdot \theta_p$, even though the intended context length is 128K. The model cannot learn the rotational frequencies corresponding to large relative distances because it never encounters the necessary absolute positions. This limits its ability to attend over long distances — the rotational angles for a relative distance of 100K have never been seen during training. --- #### AnchorAttention: The Shared Anchor Design AnchorAttention resolves the trade-off between positional consistency and full-spectrum rotational angle coverage by introducing a single shared anchor token that serves as the common starting point for all documents. **Core design (Figure 2, right).** The mechanism has three components: 1. **A shared anchor token $A$:** the `<bos>` token at position ID 0, which is visible to every token in every document. 2. **Continuous position IDs:** all document tokens receive continuously increasing position IDs, starting from 1 for the first token of $d_1$, continuing through all tokens of $d_1$, then into $d_2$, $d_3$, etc. Unlike the "reset" approach, position IDs are *not* restarted at document boundaries. 3. **Cross-document masking:** tokens from different documents cannot attend to each other, with the sole exception that all tokens can attend to the anchor $A$ at position 0. **Mask construction.** For a packed sequence with $K$ documents and $N_k$ tokens in document $k$, the attention mask $M$ is an $(1 + \sum_k N_k) \times (1 + \sum_k N_k)$ matrix (including the anchor at position 0) where: - $M_{i,0} = 0$ for all $i$ (all tokens can attend to the anchor) - $M_{i,j} = 0$ if tokens $i$ and $j$ belong to the same document and $j \leq i$ (intra-document causal attention) - $M_{i,j} = -\infty$ if tokens $i$ and $j$ belong to different documents (cross-document masking) - $M_{i,j} = -\infty$ if $j > i$ (causal mask) **What this computes:** within each document, attention proceeds normally with causal masking. Across documents, attention is blocked. But every token in every document can attend to the shared anchor token $A$ at position 0. The anchor's key vector is rotated by $R_{0,\theta}$ (which is the identity matrix, since $\cos(0)=1$ and $\sin(0)=0$), while the query vectors use their absolute position IDs — which can be as large as the total sequence length. **Why this design resolves the first-token precision issue:** the critical insight is that by making the anchor token visible everywhere with a fixed position ID of 0, we provide a consistent positional reference point. The precision loss that occurs when tokens attend to the anchor (their query is at position $i$, the anchor key is at position 0) is consistent across documents because the relative distance to the anchor is always just $i$. There is no shifting of the anchor's position — it is always 0. This eliminates the inconsistency that plagued continuous-ID intra-document attention, where different documents' first tokens had different absolute positions and thus different precision losses when attending to their respective first tokens. **Why this design allows full rotational spectrum learning:** because position IDs are continuous across the entire packed sequence, the model regularly encounters large absolute position IDs (up to the training window size, e.g., 128K). When a token at position 100,000 attends to another token at position 50,000 within the same document, their relative distance is 50,000, and the rotation involves angles up to $50,000 \cdot \theta_p$. This allows the model to learn the full range of rotational frequencies needed for long-distance attention, unlike the position-reset approach which caps absolute positions at the maximum document length. **Why the `<bos>` token as anchor:** the beginning-of-sequence token has no semantic content — it is a special token added at the start of every sequence purely for structural purposes. Any precision errors concentrated on this token's attention scores have minimal impact on the model's ability to extract meaning from document content, because the model does not need to "understand" the bos token. The anchor absorbs the positional corruption that would otherwise affect the first token of each document, and since the bos token is semantically vacuous, the corruption is harmless. **Reduction in attention computations.** In standard full attention, every token attends to all previous tokens across all documents, resulting in $\mathcal{O}(T^2)$ operations for a packed sequence of length $T$. In AnchorAttention, each token attends only to tokens within its own document plus the anchor. If the packed sequence contains $K$ documents of roughly equal length $T/K$, the total attention operations are approximately $K \cdot (T/K)^2 + T \cdot 1 = T^2/K + T$, a substantial reduction. This is the source of the over 50% training time reduction shown in Figure 6 — fewer attention edges mean fewer FLOPs, and the anchor adds only $T$ additional edges, which is negligible compared to the $T^2$ cross-document edges that are eliminated. **Design choices and alternatives considered:** - **Why not just use Float32 for everything?** Float32 would eliminate the precision issue (as shown in Figure 1, yellow line) but would double the memory requirements for all attention computations. Long-context training is already memory-bound, so this is not practical. - **Why not use the first token of each document as its own anchor?** This is exactly what happens in standard intra-document attention, and the paper shows it causes inconsistency because different documents' first tokens have different position IDs. The shared anchor eliminates this inconsistency. - **Why anchor at position 0 rather than position 1?** Position 0 is convenient because it naturally maps to the bos token, and $R_{0,\theta} = I$ (the identity matrix) simplifies computation — no rotation is needed for the anchor key. Position 1 would require non-trivial rotation and add a small constant offset to all relative distances without benefit. - **Why not allow all-to-all attention on the anchor?** The design allows all tokens to attend to the anchor (causal mask permits this since the anchor is at position 0, the earliest position), but the anchor does not attend to any token except itself. This is the natural causal structure for a prefix token. --- #### AnchorAttention with Domain Tagging (Optional Extension) The paper explores adding domain tags to the anchor to provide explicit domain-type information (Figure 5, left). A domain tag is a text string prepended to each document, such as "Wikipedia" or "CommonCrawl," that identifies the source domain. The tags are included in the input but masked from the loss computation, so the model sees them during attention but is not trained to predict them. **What this computes:** the domain tag becomes part of the prefix visible to all subsequent tokens in that document. When the model attends to the tag tokens (which appear at the start of the document), it can learn domain-specific features that may help it contextualize the document content — for example, knowing a document is from GitHub might prime the model to expect code syntax, while knowing it is from Wikipedia might prime it for encyclopedic style. **Why this is explored:** prior work by Allen-Zhu & Li (2024) and Zhang et al. (2024b) suggests domain tagging can optimize knowledge storage and aid in selective learning. The paper hypothesizes that combining domain tags with AnchorAttention could provide an additional signal that helps the model organize information from different sources. **Results:** domain tagging (AnchorAttention + Tag) does not consistently improve upon base AnchorAttention. On SlimPajama-64K, it achieves 73.88 vs. 73.25 at 64K but performs slightly worse at 32K. On SlimPajama-128K, it achieves 65.46 vs. 66.15 at 128K. The paper concludes that the base AnchorAttention generally performs better overall, and domain tagging provides marginal and inconsistent benefits. The tags may introduce additional trainable parameters or optimization complexity without solving a clear information bottleneck. --- #### AnchorAttention with Interleaved Chunks (Investigated and Discouraged) The paper also explores interleaved chunking (Figure 5, middle and right), a data augmentation technique from Zhao et al. (2024a) where documents are split into multiple chunks at random split points, the chunks are shuffled, and then recombined into new sequences while preserving the original order within each document. For example, if document $d$ is split into chunks $[c_1, c_2, c_3]$, the shuffled sequence might be $d_1^A, d_2^A, d_1^B, d_3^A, d_2^B, \ldots$, where each $d_k^X$ is a chunk of document $k$. **What this computes:** the model must track information across discontiguous chunks of the same document that are separated by chunks of other documents. This forces the model to learn to maintain document-level coherence over longer effective distances than exist in any single contiguous document. **Why it is explored:** Zhao et al. (2024a) showed that interleaved chunks combined with full attention can generate synthetic long-context training data that improves long-context performance. The paper tests whether this strategy is compatible with the cross-document masking used in AnchorAttention. **Results:** interleaved chunks consistently degrade performance when combined with any cross-document masking approach. AnchorAttention + Interleaved Chunks achieves 66.77 at 64K on SlimPajama-64K, compared to 73.25 for base AnchorAttention. Intra-Document Attention + Interleaved Chunks achieves 60.59 at 64K, worse than baseline Full Attention at 66.40. The paper hypothesizes that cross-document attention masking is fundamentally incompatible with interleaved chunks because when chunks of different documents are interleaved, the model cannot use attention to connect chunks of the same document that are separated by chunks of other documents — the cross-document mask blocks this connection. The strategy that works for full attention (allowing cross-chunk connections across the entire sequence) is defeated when those cross-chunk connections are masked out. --- #### Long-Context Training Protocol The paper follows and refines established protocols for continued pretraining on long-context data, with specific attention to RoPE base frequency selection and evaluation methodology. **Base model initialization.** The primary experiments use LLaMA-2-7B as the pretrained starting point. Cross-model experiments also use LLaMA-3-8B, Mistral-7B-v0.3, and Qwen-1.5-1.8B. All models are loaded with their original pretrained weights, which were trained with a context length of 4,096 tokens. **Dataset: SlimPajama with optional upsampling.** The SlimPajama dataset (Soboleva et al., 2023) is an open-source replication of the LLaMA pretraining data mixture. The paper samples 2 billion tokens and constructs three variants: - **SlimPajama-64K:** sequences chunked to 64K tokens, with the original domain mixture preserved. - **SlimPajama-128K:** sequences chunked to 128K tokens, original mixture preserved. - **UpSampledMix-128K:** sequences chunked to 128K tokens, with long sequences within each domain upsampled following the method of Fu et al. (2024), which increases the proportion of naturally long documents while maintaining the overall domain distribution. The upsampled mixture ratios are: 58% CommonCrawl, 20% C4, 7% GitHub, 6% ArXiv, 5% Books, 4% Wikipedia, 2% StackExchange (Table 1). **RoPE base frequency selection.** The paper conducts a systematic sweep of RoPE base values to determine the optimal setting per context length. The base value appears in the frequency formula $\theta_p = \text{base}^{-2p/d}$. Table 3 shows the sweep for 32K context length: base values of 500, 10K, 200K, 600K, 900K, 5M, and 1B. The average RULER score across context lengths [32K, 16K, 8K, 4K] peaks at 600K (82.70) and begins declining at 1B (78.47). The final recommended values (Table 1) are: 1M for 16K context, 5M for 64K context, 10M for 128K context, and 50M for 256K context. These are significantly larger than the default 10K used in pretraining, consistent with the finding that larger base values (which produce slower-varying rotations) help extend context length (Men et al., 2024; Liu et al., 2023b). **Vanilla RoPE vs. NTK vs. YaRN.** Table 2 compares three positional encoding strategies for 64K training: - **Vanilla RoPE** with base values 1M, 5M, 10M - **NTK-aware scaling** (LocalLLaMA, 2023) with base values 10K, 1M, 5M, 10M - **YaRN** (Peng et al., 2023) with base values 10K, 1M, 5M, 10M Within the training context length (64K), vanilla RoPE with base 10M achieves the highest score (69.43), outperforming the best NTK (62.47) and best YaRN (64.22). However, Table 4 shows that when evaluated *beyond* the training length (128K), YaRN with base 1M achieves 57.07 — the best generalization — while vanilla RoPE with base 1M drops to 35.93. This confirms that vanilla RoPE is best for in-distribution lengths, but specialized interpolation methods like YaRN provide better out-of-distribution length generalization. **Training hyperparameters (Table 1).** All long-context training runs use: - **Optimizer:** AdamW with weight decay = 0.1, $\beta_1 = 0.9$, $\beta_2 = 0.95$ - **Learning rate:** $2 \times 10^{-5}$, constant (no schedule mentioned) - **Training steps:** 2000 steps, corresponding to approximately 1 epoch over the 2 billion token dataset - **Batch size:** 8 sequences per GPU batch, equating to 0.5M tokens per batch for 64K context and 1M tokens for 128K context - **Hardware:** 8 NVIDIA A100 GPUs - **RoPE theta:** 1M (32K), 5M (64K), 10M (128K), 50M (256K) **Why 2000 steps and 2B tokens:** prior work by Fu et al. (2024) suggests that approximately 1B tokens suffices for learning long-context abilities. The paper uses 2B tokens to provide a margin, and 2000 steps is the resulting number of iterations at the specified batch size. This is intentionally a small amount of continued training — the goal is to extend context length without degrading pretrained capabilities, and over-training on long-context data can harm short-context performance (as the paper notes in Section 5.4). --- #### Evaluation Protocol and the Case Against Perplexity The paper argues strongly against using perplexity (PPL) as the primary metric for long-context evaluation, and proposes specific benchmarks and averaging procedures. **Why PPL is insufficient.** Perplexity measures how well the model predicts the next token in a sequence. The paper cites three lines of evidence: 1. Hu et al. (2024) show PPL poorly correlates with a model's ability to comprehend long-range dependencies because it primarily measures local information capture — a model can achieve low PPL by accurately predicting the next word based on the immediately preceding context, without understanding how distant parts of the document relate. 2. Fang et al. (2024) provide empirical evidence that PPL overlooks key tokens crucial for understanding long-context inputs, leading to unreliable assessments of true long-context ability. 3. Figure 4 in the paper directly demonstrates that during long-context training, PPL plateaus after the first several hundred steps, while RULER performance continues to improve through the full 2000 steps. If one were to select checkpoints or tune hyperparameters based on PPL, one would stop training far too early and leave substantial long-context performance on the table. **RULER benchmark (Hsieh et al., 2024).** The paper uses RULER as the primary long-context evaluation because it is specifically designed for extended context lengths and tests capabilities that require genuine long-range processing: - **Needle-in-a-Haystack (NIAH):** locating specific information within vast content. Variants include NIAH Single (single needle), NIAH Multikey (multiple keys to retrieve), NIAH Multivalue (multiple values for a single key), and NIAH Multiquery (multiple queries on a single context). - **Variable Tracing (VT):** tracing relationships and dependencies across broad contexts, such as tracking a chain of variable assignments. - **Aggregation tasks:** Common Word Extraction (CWE) and Frequent Word Extraction (FWE), which require counting and quantifying dispersed information across the full context. - **Question Answering (QA):** answering comprehension questions based on long documents. **Task filtering for LLaMA-2-7B.** The paper excludes two tasks — NIAH Multikey 3 and Common Word Extraction — from the LLaMA-2-7B evaluation. The rationale is that LLaMA-2-7B cannot perform these tasks even within its original 4K context window (as shown in Table 10), so expecting it to acquire these capabilities during long-context training is unreasonable. The paper argues that long-context training primarily extends a model's existing abilities to longer sequences rather than teaching entirely new skills. For more advanced models (LLaMA-3-8B, Mistral-7B-v0.3, Qwen-1.5-1.8B) in Section 5.3, all 13 RULER tasks are used. **Averaging over checkpoints to reduce variance.** The paper observes that RULER performance exhibits non-trivial fluctuations during training (Figure 4). To avoid cherry-picking favorable checkpoints, the paper recommends reporting the average RULER score across five checkpoints, saving a checkpoint every 10 steps over the last 50 training steps. This is more practical than retraining with five different random seeds (which would multiply the experimental cost by 5) and provides a more robust estimate of model performance than reporting only the final checkpoint or the best checkpoint. **Short-context capability preservation.** To verify that continued long-context training does not degrade the model's original capabilities, the paper evaluates on: - **MMLU** (Hendrycks et al., 2021): 57 subjects spanning STEM, humanities, social sciences, and other domains, testing factual knowledge and reasoning. - **HellaSwag** (Zellers et al., 2019): commonsense reasoning through choosing the most plausible continuation of a scenario. - **LongBench ICL** (Bai et al., 2023): few-shot in-context learning on real-world long-context tasks including multi-document QA, single-document QA, summarization, code completion, and synthetic tasks. The paper notes that LongBench tasks can be adequately addressed with 16K context and thus does not fully challenge models trained for 64K-128K contexts, but includes it because its few-shot ICL tasks are appropriate for evaluating base models without instruction tuning. --- #### AnchorContext: Implementation Infrastructure Section 5.5 describes the engineering behind AnchorAttention, which is released as the AnchorContext codebase. The key design goals are numerical accuracy, computational speed, and ease of integration. **Two computational backends.** AnchorContext supports two attention engine options: - **FlexAttention:** a new PyTorch 2.5.0 feature that allows custom attention masks with kernel fusion. This provides flexibility for researchers who want to experiment with novel attention patterns beyond those supported by FlashAttention2. - **FlashAttention2** (Dao, 2024): the standard high-performance attention implementation used in most LLM training pipelines. Support for FlashAttention2 ensures compatibility with existing training infrastructure. **Numerical accuracy under distributed training.** When training with sequence parallelism (distributing a single long sequence across multiple GPUs), different parallelization strategies can introduce numerical errors due to the order of floating-point operations. The paper tests this by comparing logits from: 1. FlashAttention2 on a single GPU (the baseline, no distributed computation) 2. Zigzag-Ring attention (used in EasyContext, Zhang, 2023) across 8 GPUs 3. AnchorContext based on sequence parallelism with DeepSpeed-Ulysses (Jacobs et al., 2023) across 8 GPUs Table 8 shows the results for a 32K sequence: Zigzag-Ring attention exhibits a maximum logit difference of 0.75 compared to the single-GPU baseline, while AnchorContext achieves a logit difference of **exactly 0** — the distributed computation is numerically identical to the non-distributed baseline. This zero-discrepancy result is significant because it means researchers can scale to longer sequences using multiple GPUs without introducing numerical artifacts that could confound experimental results. **Training speed.** Figure 6 estimates the number of days required to process 1 billion tokens at various context lengths. AnchorAttention with DeepSpeed-Ulysses sequence parallelism substantially reduces training time compared to full attention at the same level of parallelism. The paper claims "more than 50% reduction" — at 64K context, AnchorAttention takes roughly 2 days per billion tokens compared to approximately 4.5 days for full attention, and at 128K, the gap is similarly large. This speed-up comes from eliminating cross-document attention computations, which reduces the total number of attention edges from $\mathcal{O}(T^2)$ to approximately $\mathcal{O}(T^2/K + T)$ for $K$ documents per sequence. **Model compatibility.** AnchorContext supports LLaMA series, Mistral series, and Qwen2 series models. For Qwen models, which do not use a `<bos>` token, the `<eos>` token is used as the shared anchor instead. The implementation is designed to work within existing Hugging Face Transformers (Wolf et al., 2020) pipelines, requiring only changes to the attention mask and position ID assignment — no modifications to model architecture, optimizer, or data loading. **Support for interleaved chunks.** The FlexAttention backend can handle the non-contiguous attention masks required by interleaved chunking (where chunks of the same document are separated by chunks of other documents in the sequence). While the paper's experimental results discourage the use of interleaved chunks with cross-document masking, the infrastructure supports it for researchers who want to explore related ideas. ## 4. Key Insights and Innovations ### Innovation 1: Precision Is Not a Neutral Implementation Detail — It Can Break Algorithmic Guarantees The paper's most intellectually distinctive contribution is not a new architecture or training technique, but a **diagnostic finding that reframes how the field should think about the relationship between numerical precision and algorithmic design in deep learning systems**. The dominant assumption in the LLM literature — and in deep learning more broadly — is that reduced-precision formats like BFloat16 are sufficiently accurate approximations of Float32 that they can be treated as transparent: algorithms designed and analyzed in infinite-precision mathematics will behave essentially the same when executed in BFloat16. This assumption underlies the entire RoPE context-extension literature, from position interpolation (Chen et al., 2023a) to NTK-aware scaling (LocalLLaMA, 2023) to YaRN (Peng et al., 2023), all of which derive theoretical guarantees from trigonometric identities that assume exact arithmetic. The paper demonstrates that this assumption is **false in a non-obvious, structurally significant way**. The breakdown is not random noise or a uniform degradation — it is concentrated at a specific structural position (the first token), amplifies with sequence length, and is reinforced by pretraining. This transforms precision from a "backend concern" that hardware and systems engineers handle into a **first-class constraint on algorithmic design** — one that should inform which positional encoding schemes are chosen, how attention patterns are structured, and how training data is organized. What makes this finding fundamental rather than incremental is that it identifies a failure mode that was **invisible to the standard evaluation toolkit**. Models are trained and evaluated under the same BFloat16 regime, so the corruption is baked into both training and testing. It required a controlled cross-precision comparison (Figure 1, blue vs. yellow lines) — varying only the precision format while holding model parameters constant — to isolate the effect. Prior work that compared different positional encoding schemes (e.g., RoPE vs. ALiBi vs. learned absolute encodings) did so entirely within a single precision regime, making it impossible to detect that the apparent performance of RoPE was partly a function of the precision format, not just the mathematical design. This insight has broad implications beyond RoPE. Any component of a neural network whose theoretical properties rely on exact mathematical identities — rotational invariance, relative distance preservation, conservation of probability mass — should be audited for precision-induced violations. The methodology the paper develops (comparing Float32 and BFloat16 attention on the same model parameters, measuring cumulative difference across layers and heads) provides a template for such audits. The finding that pretraining amplifies the distortion (blue vs. green lines in Figure 1, left) is particularly significant because it means **precision errors are not just propagation artifacts — they become embedded in the learned representations**, making them harder to detect and correct through simple post-hoc fixes. ### Innovation 2: The First Token's Role in RoPE Is Mechanistically Distinct — and That Matters Prior work on attention sinks (Xiao et al., 2023; Han et al., 2023) and massive activations (Sun et al., 2024; Gu et al., 2024) had observed that the first token in a sequence often receives disproportionately high attention weights, but these observations were treated as empirical properties of trained transformers — phenomena to be described and, in some cases, exploited (e.g., StreamingLLM's use of attention sinks to enable infinite-length inference). The underlying mechanism was not well understood; attention sinks were an "it happens" phenomenon. This paper provides a **mechanistic hypothesis** that potentially explains *why* the first token becomes structurally significant: **it is the token whose positional encoding is maximally exposed to BFloat16 precision loss**. Under RoPE with a positional shift $\Delta$, the first token's key vector is rotated by angles $\Delta \cdot \theta_p$, which grow linearly with the shift magnitude. For large $\Delta$ (as occurs when sequences are shifted in position space), these angles become large, and BFloat16's 7-bit mantissa cannot accurately represent the trigonometric functions at these large arguments. Tokens further into the sequence benefit from approximate cancellation in the relative distance calculation $(i+\Delta) - (j+\Delta) = i-j$, which subtracts two large numbers to recover a small relative distance. The first token has no such cancellation — its rotation uses $\Delta$ directly, making it the canary in the precision coal mine. Figure 1 (middle) provides the key evidence: when measuring per-token attention differences caused by positional shifts, the first token accounts for the vast majority of the total discrepancy. Excluding it makes the remaining tokens nearly shift-invariant, as RoPE theory predicts. This is not a gradual degradation spread across all positions — it is a **concentrated failure at a single structurally privileged token**. What makes this insight distinctive is that it **connects two previously separate research threads**: the empirical literature on attention sinks (which documented the phenomenon without explaining its origin) and the precision-analysis literature (which typically focuses on aggregate training dynamics, not per-position effects). The paper does not claim to have proven the causal link — it explicitly flags it as future work (Section 8) — but the evidence is highly suggestive. If the first token's positional encoding is systematically corrupted by BFloat16, the model may learn to compensate by adjusting how it allocates attention to that token, potentially giving rise to the attention sink pattern as a learned adaptation to this numerical imperfection. This reframing has practical consequences. If attention sinks are a response to precision-induced corruption rather than an inherent property of transformer attention, then **fixing the precision issue should change the attention sink pattern** — a testable prediction that the paper leaves for future work. It also suggests that attention sink-based methods for length generalization (like StreamingLLM) may be treating a symptom rather than the underlying cause, and that combining precision fixes with attention sink techniques could yield further improvements. ### Innovation 3: Positional Consistency at Document Boundaries Is a Previously Unrecognized Bottleneck The field has converged on intra-document attention — masking cross-document attention during training — as a practical strategy for long-context training, used in production models like LLaMA-3 and validated by Gao et al. (2024). The standard implementation assigns continuous position IDs across the entire packed sequence, meaning the first token of each document receives a different absolute position ID depending on where that document falls in the packing order. The implicit assumption behind this practice is that **position ID assignment is irrelevant as long as relative distances within each document are preserved** — an assumption that follows directly from RoPE's theoretical relative encoding property. Under exact arithmetic, the absolute starting position of a document cancels out in all within-document attention computations, so whether a document starts at position 0 or position 50,000 should make no difference. The paper demonstrates that this assumption fails under BFloat16. The experiment comparing continuous position IDs to reset position IDs (Figure 3, Table 5) shows a consistent performance advantage for the reset scheme — at 128K context, reset position IDs achieve 65.75 vs. 64.31 with continuous IDs on SlimPajama-128K. This is a small but consistent gap that appears across all context lengths. The finding is significant not because of the magnitude of the improvement (which is modest) but because it reveals a **qualitative error in the standard approach**: the model is being asked to learn positional relationships from inconsistent signals, where the "first token" of one document uses completely different rotation angles than the "first token" of another document. Under BFloat16, these different angles have different precision losses, so what should be a consistent "document start" signal is corrupted in a position-dependent way. This insight is conceptually elegant because it **reconciles the paper's precision findings with a practical training design choice**. The reason position ID assignment matters is precisely because BFloat16 corrupts the first token's positional encoding — if the first token were not special, the continuous-vs-reset distinction would be irrelevant. The paper thus provides a mechanistic explanation for an empirical observation that would otherwise seem like an inexplicable sensitivity to a trivial implementation detail. ### Innovation 4: A Shared Anchor Token Is a Principled Resolution of the Precision-Consistency Trade-off The reset-position-ID approach fixes the consistency problem but creates a new one: the model never sees absolute positions larger than the longest single document, limiting its exposure to the full range of rotational frequencies needed for long-distance attention. The shared anchor design of AnchorAttention resolves this trade-off through a single structural modification: treat one token (the `<bos>` token at position 0) as a shared reference point visible to all documents, while keeping continuous position IDs for all document tokens. This is a **conceptually minimal intervention** that achieves three goals simultaneously: (1) it provides a consistent first-token reference (the anchor is always at position 0, never shifted), eliminating the positional inconsistency that degraded continuous-ID intra-document attention; (2) it allows document tokens to use continuously increasing position IDs up to the full training window size, enabling the model to learn the full rotational spectrum; and (3) it reduces attention computation by eliminating cross-document edges (except the anchor), yielding the > 50% training speedup shown in Figure 6. What makes this design intellectually satisfying — beyond its empirical performance — is that it **directly operationalizes the paper's diagnostic findings**. The diagnosis revealed that (a) the first token is the locus of precision-induced corruption, and (b) positional inconsistency at document boundaries degrades performance. AnchorAttention addresses (a) by placing the unavoidable precision loss on a semantically vacuous token (the bos token has no content to corrupt) and addresses (b) by giving every document the same anchor with the same position ID. It is rare for a diagnostic analysis to suggest such a clean architectural fix; typically, the gap between "we found the problem" and "here's how to fix it" is large and filled with engineering compromises. The fact that the fix is simultaneously simpler (fewer attention edges) and more principled (consistent positional reference) than the baseline is a strong signal that the diagnosis identified the right causal mechanism. Notably, the anchor design was not arrived at through architecture search or hyperparameter tuning — it follows logically from the diagnostic findings. The paper found that the first token's positional encoding is corrupted, that this corruption grows with position magnitude, and that inconsistent first-token positions hurt performance. The natural solution is to fix the first token's position and make it consistent across documents, which is exactly what AnchorAttention does. This **diagnosis-driven design process** is methodologically distinctive and contrasts with much of the efficient-attention literature, which proposes sparsity patterns based on computational heuristics or empirical tuning rather than on an identified failure mode. ## 5. Experimental Analysis ### Evaluation Methodology - **Dataset.** The paper uses the SlimPajama dataset (Soboleva et al., 2023), an open-source replication of the LLaMA pretraining data mixture, for long-context continued pretraining. Three variants are constructed: SlimPajama-64K (sequences chunked to 64K tokens), SlimPajama-128K (chunked to 128K), and UpSampledMix-128K (128K chunks with long sequences upsample d following Fu et al. (2024), adjusting domain ratios to 58% CommonCrawl, 20% C4, 7% GitHub, 6% ArXiv, 5% Books, 4% Wikipedia, 2% StackExchange). Approximately 2 billion tokens are sampled from each variant, with 2000 training steps corresponding to roughly 1 epoch. Evaluation uses RULER (Hsieh et al., 2024) for long-context assessment, LongBench ICL (Bai et al., 2023) for medium-context in-context learning, and MMLU (Hendrycks et al., 2021) and HellaSwag (Zellers et al., 2019) for short-context general capability preservation. - **Base model(s).** The primary experiments use LLaMA-2-7B (Touvron et al., 2023) as the pretrained starting point, chosen because it represents a widely-used open-source model with established long-context extension baselines. Cross-model generalization experiments in Section 5.3 additionally use LLaMA-3-8B (Dubey et al., 2024), Mistral-7B-v0.3 (Jiang et al., 2023), and Qwen-1.5-1.8B (Yang et al., 2024), covering different model families, scales (1.8B to 8B parameters), and pretraining paradigms to test whether AnchorAttention's benefits transfer across architectures. - **Metrics.** The primary long-context metric is accuracy on the RULER benchmark, which tests needle-in-a-haystack retrieval, variable tracing, word frequency aggregation, and question answering across context lengths from 4K to 128K tokens. For LLaMA-2-7B, two of RULER's 13 tasks (NIAH Multikey 3 and Common Word Extraction) are excluded because the model cannot perform them even within its original 4K context window (Table 10); for other models, all 13 tasks are used. Secondary metrics include LongBench ICL accuracy (few-shot in-context learning on real-world long-context tasks), MMLU accuracy (57-subject knowledge and reasoning), and HellaSwag accuracy (commonsense reasoning). The paper recommends reporting RULER performance averaged over five checkpoints saved every 10 steps during the last 50 training steps to mitigate variance from training fluctuations (Figure 4). - **Baselines.** Four attention mechanisms are compared: (1) **Full Attention** — standard causal attention where every token attends to all previous tokens across the entire packed sequence (no cross-document masking); (2) **Intra-Document Attention** (Zhao et al., 2024b; Gao et al., 2024) — cross-document attention is masked but position IDs continue across document boundaries (Figure 2, left); (3) **Intra-Document Attention + Reset** — the paper's improved version where position IDs are reset to 1 at each document boundary (Figure 2, middle); (4) **Intra-Document Attention + Interleaved Chunks** — intra-document masking combined with the interleaved chunking data augmentation from Zhao et al. (2024a). Within the search for optimal positional embeddings (Table 2-4), additional baselines include **NTK-aware scaling** (LocalLLaMA, 2023) and **YaRN** (Peng et al., 2023), each tested with multiple RoPE base values. - **Generation budget / compute accounting.** All training runs use a fixed budget of 2 billion tokens and 2000 optimization steps at batch size 8, equating to 0.5M tokens per batch for 64K context and 1M tokens for 128K context on 8 NVIDIA A100 GPUs. Compute efficiency comparisons (Section 5.5, Figure 6) measure estimated days required to process 1 billion tokens at various context lengths, accounting for the reduced attention FLOPs from cross-document masking. Numerical accuracy under distributed training (Table 8) is measured by comparing logits from multi-GPU implementations against a single-GPU FlashAttention2 baseline on 32K-length sequences. - **Cross-validation / statistical protocol.** To avoid cherry-picking favorable checkpoints, all RULER results are reported as the average across five checkpoints saved every 10 steps over the last 50 training steps (2000 total steps). The paper argues this is more practical than retraining with multiple random seeds while still providing robustness against training variance. No k-fold cross-validation over data splits is reported, as all comparisons use fixed dataset variants (SlimPajama-64K, SlimPajama-128K, UpSampledMix-128K). ### Main Quantitative Results #### RoPE Base Frequency and Positional Encoding Selection The paper first establishes the optimal positional encoding configuration before evaluating attention mechanisms, ensuring a fair baseline for subsequent comparisons. **Vanilla RoPE with appropriate base frequency outperforms NTK and YaRN within the training length.** Table 2 shows results for models trained on SlimPajama-64K with 1B tokens. At the 64K evaluation length (within the training context), vanilla RoPE with base 10M achieves 69.43, compared to the best NTK variant at 62.47 (base 1M) and the best YaRN variant at 64.22 (base 1M). The gap is substantial: vanilla RoPE outperforms YaRN by 5.21 points and NTK by 6.96 points. This pattern holds across all context lengths from 8K to 64K, with vanilla RoPE at base 10M achieving 71.01 at 32K, 81.01 at 16K, 85.28 at 8K, and 88.13 at 4K. The untrained baseline (Free⋆, RoPE 10K) achieves 85.29 at 4K, showing that long-context training with appropriate base values does not degrade short-context performance. **But YaRN generalizes better beyond the training length.** Table 4 evaluates the same models at 128K context (double the training length). Vanilla RoPE at base 1M drops from 66.88 at 64K to 35.93 at 128K — a decrease of 30.95 points. Vanilla RoPE at base 5M drops from 68.81 to 53.98 (a 14.83 point decrease). In contrast, YaRN at base 1M achieves 57.07 at 128K (only 7.15 points below its 64K score of 64.22), and YaRN at base 10K achieves 27.25 at 128K (22.84 points below its 64K score of 50.09). The best out-of-distribution performance belongs to YaRN, confirming that specialized interpolation methods provide better length generalization even though vanilla RoPE is superior within the trained range. **The optimal base value is context-length dependent and has a sweet spot.** Table 3 sweeps RoPE base values from 500 to 1B for models trained at 32K context. The average RULER score across [32K, 16K, 8K, 4K] peaks at 600K (82.70), with 900K close behind at 82.64. Performance degrades on both sides: base 500 achieves only 20.80 average, while base 1B drops to 78.47. The default base 10K (used in pretraining) achieves only 42.66, dramatically underperforming larger values. Based on this sweep and additional experiments at other lengths, the paper settles on: base 1M for 16K, 5M for 64K, 10M for 128K, and 50M for 256K (Table 1). The non-monotonic relationship — larger is better up to a point, then performance declines — aligns with observations from Men et al. (2024) and Liu et al. (2023b). #### Resetting Position IDs Improves Long-Context Performance Having established the optimal RoPE configuration, the paper tests whether the BFloat16-induced positional inconsistency identified in Section 2 actually affects long-context capabilities. **Position ID reset consistently outperforms continuous assignment in intra-document attention.** Figure 3 shows RULER results for LLaMA-2-7B trained on SlimPajama-128K with intra-document attention, comparing continuous position IDs (standard practice) against reset position IDs. The advantage is visible across all context lengths: at 128K, reset achieves ~65.75 vs. ~64.31 for continuous; at 64K, ~73.34 vs. ~70.87; at 32K, ~73.30 vs. ~72.07. The gap is moderate but consistent, and the paper interprets this as evidence that the BFloat16-induced deviation in RoPE's relative encoding — concentrated at document-first tokens — has measurable downstream consequences for long-context task performance, not just attention pattern differences. **The finding contradicts the theoretical prediction that position ID assignment should be irrelevant.** Under exact arithmetic, RoPE's relative property guarantees that continuous and reset position IDs produce identical attention within each document. The empirical difference therefore directly supports the paper's central claim that BFloat16 breaks this theoretical guarantee. Moreover, it validates that the breakdown is not merely an academic curiosity — it degrades performance on a practical long-context benchmark. #### AnchorAttention Performance on RULER: Main Results The core experimental results compare AnchorAttention against all baselines across three dataset variants and context lengths from 4K to 128K, presented in Table 5. **AnchorAttention consistently achieves the highest scores across all datasets and context lengths.** On SlimPajama-64K, AnchorAttention achieves 73.25 at 64K (vs. 66.40 for Full Attention and 69.97 for Intra-Document Attention), 75.97 at 32K (vs. 71.78 and 74.70), 82.91 at 16K (vs. 77.63 and 79.15), 85.48 at 8K (vs. 83.86 and 83.50), and 90.69 at 4K (vs. 89.84 and 89.62). The advantage grows with context length: at 4K the gap between AnchorAttention and Full Attention is only 0.85 points, but at 64K it expands to 6.85 points. **AnchorAttention reduces dependence on upsampled data.** On UpSampledMix-128K — which deliberately upsamples long sequences to improve long-context adaptation — Full Attention achieves 71.45 at 64K and 63.70 at 128K. AnchorAttention on the same data achieves 76.11 at 64K and 65.24 at 128K. Crucially, AnchorAttention on SlimPajama-128K (without upsampling) achieves 77.69 at 64K and 66.15 at 128K — numerically *better* than AnchorAttention on the upsampled data. This suggests AnchorAttention's architectural benefits reduce or eliminate the need for careful data upsampling, which is a labor-intensive data engineering step in standard long-context training pipelines. **Intra-Document Attention + Reset is the strongest non-Anchor baseline.** Across SlimPajama-128K, Intra-Document Attention + Reset achieves 65.75 at 128K, 73.34 at 64K, 73.30 at 32K, 82.82 at 16K, 84.43 at 8K, and 90.01 at 4K. This consistently outperforms standard Intra-Document Attention and occasionally approaches AnchorAttention at shorter lengths (90.01 vs. 90.60 at 4K), but the gap widens at longer contexts (65.75 vs. 66.15 at 128K). The reset mechanism addresses the positional inconsistency problem but creates the new limitation of not exposing the model to high position indices, which AnchorAttention avoids through the shared anchor design. **Interleaved chunks degrade performance when combined with cross-document masking.** On SlimPajama-128K, Intra-Document Attention + Interleaved Chunks achieves 53.74 at 128K (vs. 64.31 for Intra-Document Attention without interleaving), 61.08 at 64K (vs. 70.87), and underperforms at all context lengths. AnchorAttention + Interleaved Chunks on SlimPajama-64K achieves 66.77 at 64K (vs. 73.25 for base AnchorAttention). The paper hypothesizes that interleaved chunking, which works with full attention (Zhao et al., 2024a), is incompatible with cross-document masking because chunks of the same document separated by chunks of other documents cannot attend to each other — the cross-document mask blocks these connections, defeating the purpose of interleaving. **Domain tagging provides marginal and inconsistent benefits.** On SlimPajama-64K, AnchorAttention + Tag achieves 73.88 at 64K (vs. 73.25 for base AnchorAttention) but 74.21 at 32K (vs. 75.97). On SlimPajama-128K, AnchorAttention + Tag achieves 65.46 at 128K (vs. 66.15). The paper concludes that while domain tagging sometimes helps, the base AnchorAttention generally performs better overall, and the tagging does not provide a consistent improvement worth the additional complexity. #### Cross-Model Generalization Table 6 extends the evaluation to three additional model families to test whether AnchorAttention's benefits are specific to LLaMA-2 or generalize across architectures. **AnchorAttention substantially outperforms Full Attention on LLaMA-3-8B, especially at long contexts.** At 128K, AnchorAttention achieves 51.49 vs. 34.02 for Full Attention — a 17.47 point advantage. At 64K, the gap is 70.99 vs. 61.80 (9.19 points). The advantage narrows at shorter contexts: 88.72 vs. 83.68 at 4K. Adding domain tags (AnchorAttention + Tag) achieves 49.67 at 128K and 88.97 at 4K, trailing base AnchorAttention at 128K but slightly ahead at 4K. The large gap at 128K on LLaMA-3-8B is particularly notable because it suggests that even with a stronger base model, the BFloat16-induced positional corruption remains a significant bottleneck that AnchorAttention effectively addresses. **Mistral-7B-v0.3 shows consistent but smaller gains.** At 128K, AnchorAttention achieves 47.46 vs. 45.64 for Full Attention (a 1.82 point gap). The advantage grows at intermediate lengths: 61.26 vs. 49.05 at 64K (12.21 points), 68.53 vs. 54.49 at 32K (14.04 points). AnchorAttention + Tag achieves 49.61 at 128K, slightly ahead of the base AnchorAttention. The pattern differs from LLaMA-3 — on Mistral, the gains are more pronounced at medium lengths (32K-64K) than at the maximum length, possibly reflecting differences in how Mistral's attention heads distribute positional information. **Qwen-1.5-1.8B shows the smallest improvements but the direction is consistent.** At 128K, AnchorAttention achieves 34.32 vs. 33.56 for Full Attention (0.76 points). At 64K, 44.31 vs. 41.77 (2.54 points). At 4K, 68.61 vs. 67.26 (1.35 points). The Qwen series does not use a `<bos>` token, so the `<eos>` token is used as the shared anchor — this substitution may reduce the anchor's effectiveness because the eos token may carry semantic content that the bos token does not. AnchorAttention + Tag achieves 35.84 at 128K, modestly ahead of base AnchorAttention. The smaller overall improvements on Qwen-1.5-1.8B may reflect the model's smaller capacity (1.8B parameters) limiting its ability to benefit from improved positional encoding, or differences in how Qwen's pretraining incorporated RoPE. **The cross-model results confirm generality but reveal model-specific sensitivity.** Across all four model families tested (LLaMA-2-7B, LLaMA-3-8B, Mistral-7B-v0.3, Qwen-1.5-1.8B), AnchorAttention never underperforms Full Attention at any context length — the direction is uniformly positive. However, the magnitude of improvement varies from dramatic (LLaMA-3-8B at 128K) to modest (Qwen-1.5-1.8B at 128K), suggesting that model architecture, pretraining data, and scale modulate the severity of the BFloat16-induced positional corruption and thus the benefit from AnchorAttention. #### Medium- and Short-Context Performance Preservation Table 7 evaluates whether long-context training with AnchorAttention degrades the model's capabilities on tasks unrelated to long contexts — a critical practical concern since long-context adaptation is often performed as continued pretraining on existing models that already possess strong general capabilities. **AnchorAttention better preserves general capabilities than Full Attention or Intra-Document Attention.** On MMLU, the original LLaMA-2-7B achieves 46.66. After long-context training on SlimPajama-64K, Full Attention drops to 33.93 (a 12.73 point degradation), Intra-Document Attention achieves 36.94, Intra-Document Attention + Reset achieves 37.92, and AnchorAttention achieves 40.32 — the least degradation among all methods. On SlimPajama-128K, AnchorAttention achieves 41.63 vs. 37.93 for Full Attention. On UpSampledMix-128K, AnchorAttention achieves 41.15 vs. 40.58 for Full Attention (a smaller gap, but Full Attention benefits more from upsampled data on this metric). **AnchorAttention + Tag provides the best MMLU preservation on the 128K datasets.** On SlimPajama-128K, AnchorAttention + Tag achieves 42.85, and on UpSampledMix-128K, 42.03 — the highest MMLU scores among all attention mechanisms on those datasets. This is notable because domain tagging did not consistently improve long-context performance (Table 5), but it appears to help preserve factual knowledge and reasoning capabilities. The tags may provide a stable domain signal that helps the model maintain its pretrained knowledge organization during the continued training phase. **On HellaSwag, AnchorAttention remains competitive with the original model.** The original LLaMA-2-7B achieves 71.39 on HellaSwag. AnchorAttention on SlimPajama-64K achieves 70.78 (only 0.61 points below the original), compared to 68.50 for Full Attention. On SlimPajama-128K, AnchorAttention achieves 70.51 vs. 69.46 for Full Attention. On UpSampledMix-128K, AnchorAttention achieves 70.11 vs. 67.64 for Full Attention. Across all datasets, AnchorAttention consistently achieves HellaSwag scores within ~1 point of the original model, while Full Attention loses 2-4 points. Intra-Document Attention variants also preserve HellaSwag well (e.g., 71.01 on SlimPajama-64K), suggesting that cross-document masking itself — not specifically the anchor design — helps preserve commonsense reasoning. **On LongBench ICL, AnchorAttention shows the best in-context learning performance.** LongBench ICL evaluates few-shot learning on real-world long-context tasks. On SlimPajama-64K, AnchorAttention achieves 65.38, compared to 62.51 for Full Attention, 62.79 for Intra-Document Attention, and 63.76 for Intra-Document Attention + Reset. AnchorAttention + Tag achieves 66.02, the highest score. On SlimPajama-128K, AnchorAttention achieves 51.85 vs. 50.72 for Full Attention. On UpSampledMix-128K, AnchorAttention achieves 50.17 vs. 48.96. The unusually high LongBench ICL scores on SlimPajama-64K (all methods above 62, compared to ~50 on the 128K datasets) likely reflect that the 64K training data has a different domain mixture with more documents that match the LongBench task distribution, or that 128K training disproportionately emphasizes extremely long documents at the expense of the medium-length documents that LongBench tasks target. The original LLaMA-2-7B achieves only 6.22 on LongBench ICL before any long-context training, highlighting that continued pretraining on long-context data substantially improves in-context learning even though the specific LongBench ICL tasks do not require context lengths beyond 16K. **The trade-off between long-context and short-context performance is real but AnchorAttention minimizes it.** Across all three datasets and all three short/medium-context benchmarks, AnchorAttention (with or without tags) achieves the best or near-best preservation of pretrained capabilities. The paper's results confirm that long-context training inevitably causes some degradation on out-of-distribution short-context tasks, but the degradation is substantially smaller with AnchorAttention than with Full Attention — the mechanism that improves long-context performance (reducing BFloat16-induced positional error) also helps preserve general capabilities, suggesting that the positional corruption affects both long and short contexts, just more severely at long lengths. #### Training Efficiency: Speed and Numerical Accuracy Section 5.5 presents the engineering results for the AnchorContext implementation. **AnchorAttention reduces training time by more than 50% compared to Full Attention.** Figure 6 shows estimated training days per billion tokens at various context lengths. At 64K context, Full Attention with DeepSpeed-Ulysses sequence parallelism requires approximately 4.5 days per billion tokens, while AnchorAttention requires roughly 2 days — a 55% reduction. At 128K context, the gap is similarly large. The speedup comes from eliminating cross-document attention edges: in a packed sequence with K documents, Full Attention computes approximately $\mathcal{O}(T^2)$ attention edges while AnchorAttention computes approximately $\mathcal{O}(T^2/K + T)$ edges. For sequences with many documents (typical in training), this is a substantial reduction in FLOPs. **AnchorContext achieves zero logit difference compared to single-GPU FlashAttention2.** Table 8 compares distributed training implementations: Zigzag-Ring attention (used in EasyContext, Zhang, 2023) exhibits a maximum logit difference of 0.75 compared to a single-GPU FlashAttention2 baseline on a 32K sequence, while AnchorContext's distributed implementation achieves a maximum logit difference of 0.00 — the distributed computation is numerically identical to the non-distributed baseline. This zero-discrepancy result is significant because it means multi-GPU training with AnchorAttention does not introduce numerical artifacts that could confound the precision-related findings. The logit difference of 0.75 for Zigzag-Ring attention indicates that different sequence parallelism strategies can introduce substantial numerical variation, which could interact with the BFloat16 precision issues the paper identifies. ### Ablation Studies and Robustness Checks The paper's ablation studies are integrated into the main experimental sections rather than presented in a separate ablation subsection. Here we consolidate the key controlled comparisons. - **RoPE base frequency sweep across three orders of magnitude (Table 3):** Training at 32K context with base values from 500 to 1B reveals a non-monotonic optimal range. Base 500 (near the original pretraining value) achieves only 20.80 average RULER score. Performance rises sharply: base 200K achieves 79.81, base 600K reaches 82.70 (peak), base 900K achieves 82.64, and base 1B drops to 78.47. The decline beyond ~900K confirms that arbitrarily large bases are not beneficial — there is a finite optimal range. At base 5M, the score is 81.48, still strong but below the peak. This ablation establishes that base frequency selection is critical (the range from worst to best is 20.80 to 82.70) and that the optimal value depends on context length. - **NTK-aware and YaRN as alternatives to vanilla RoPE (Tables 2, 4):** Across three base values (1M, 5M, 10M), vanilla RoPE outperforms NTK and YaRN within the training context length at every length from 8K to 64K (Table 2). For example, at 64K with base 1M: vanilla RoPE 66.89, YaRN 64.22, NTK 62.47. However, the ablation on out-of-distribution generalization (Table 4, evaluating 64K-trained models at 128K) reveals the opposite pattern: YaRN at base 1M achieves 57.07 (only -7.15 from its 64K score), while vanilla RoPE at base 1M drops to 35.93 (-30.95). This ablation clarifies that RoPE selection involves a trade-off between in-distribution performance and length generalization, and that the paper's choice of vanilla RoPE is correct for its evaluation protocol (which tests within the training length) but would need reconsideration for applications requiring out-of-distribution length generalization. - **Position ID assignment: continuous vs. reset (Figure 3, Table 5):** Comparing Intra-Document Attention with and without position ID reset across multiple datasets and context lengths consistently shows a performance advantage for reset. On SlimPajama-128K: reset achieves 65.75 at 128K vs. 64.31 without reset, and at 16K, 82.82 vs. 82.60. The gap is consistent in direction but modest in magnitude (typically 1-3 points at longer contexts), suggesting that positional inconsistency is a real but not dominant source of error — AnchorAttention addresses it along with other issues, yielding larger gains than reset alone. - **Domain tagging added to AnchorAttention (Tables 5, 6, 7):** Across all datasets and models, AnchorAttention + Tag sometimes improves and sometimes degrades long-context RULER performance relative to base AnchorAttention, with no consistent pattern. On SlimPajama-64K: +Tag achieves 73.88 vs. 73.25 at 64K but 74.21 vs. 75.97 at 32K. On SlimPajama-128K: 65.46 vs. 66.15 at 128K. On UpSampledMix-128K: 66.85 vs. 65.24 at 128K but 73.52 vs. 76.11 at 64K. However, on MMLU preservation, +Tag consistently improves scores: 40.67 vs. 40.32 on SlimPajama-64K, 42.85 vs. 41.63 on SlimPajama-128K, 42.03 vs. 41.15 on UpSampledMix-128K. This ablation reveals an unexpected dissociation: domain tags help preserve general knowledge but do not reliably improve long-context processing, suggesting that the mechanisms for factual recall and long-range attention are at least partially independent. - **Interleaved chunks with cross-document attention masking (Table 5):** Adding interleaved chunks consistently and substantially degrades performance for both Intra-Document Attention and AnchorAttention. On SlimPajama-64K: Intra-Document + Interleaved achieves 60.59 at 64K (vs. 69.97 without), AnchorAttention + Interleaved achieves 66.77 (vs. 73.25). On SlimPajama-128K: Intra-Document + Interleaved achieves 53.74 at 128K (vs. 64.31). This ablation provides a clear negative result: the interleaved chunking strategy that works with full attention (as shown in Zhao et al., 2024a) is incompatible with cross-document attention masking. The ablation also indirectly validates the paper's choice to use document-coherent data sequences rather than pursuing synthetic data augmentation for length extension. - **Cross-model generalizability (Table 6):** Testing AnchorAttention on LLaMA-3-8B, Mistral-7B-v0.3, and Qwen-1.5-1.8B confirms that the benefits transfer across architectures, scales, and pretraining paradigms. The results are universally positive (AnchorAttention never underperforms Full Attention) but the magnitude varies: the gain at 128K is 17.47 points on LLaMA-3-8B, 1.82 on Mistral-7B-v0.3, and 0.76 on Qwen-1.5-1.8B. This ablation establishes that AnchorAttention is not exploiting LLaMA-2-specific properties but does not explain the source of cross-model variation in benefit magnitude. - **RULER performance averaging protocol (Figure 4):** The ablation comparing single-checkpoint evaluation to multi-checkpoint averaging on LLaMA-2-7B trained with Full Attention on SlimPajama-16K shows that RULER performance fluctuates during training while PPL plateaus early. This ablation justifies the paper's methodological recommendation to average over checkpoints rather than reporting final or best-checkpoint scores, and provides direct evidence that PPL is a misleading metric for long-context training progress. ### Critical Assessment The paper makes several central claims: (1) BFloat16 breaks RoPE's relative positional encoding, especially for the first token and at long contexts; (2) this breakdown measurably degrades long-context performance; (3) AnchorAttention — a shared anchor token with cross-document masking — fixes this problem while also reducing training time; (4) the method transfers across model architectures; and (5) it preserves short-context capabilities while improving long-context performance. Here we assess the experimental support for each. **Claim 1 (BFloat16 breaks RoPE's relative encoding): Strongly supported, but with scope limitations.** The diagnostic evidence in Figure 1 is clean and convincing: the attention difference metric $D$ (Equation 4) is zero under Float32 and non-zero under BFloat16, the first token dominates the discrepancy, and the logit difference grows with sequence length. The methodology of comparing Float32 and BFloat16 on identical model parameters is the right controlled experiment for isolating precision effects. The 50-sequence averaging with length 4096 inputs provides reasonable statistical stability for the diagnostic purpose. However, the claim applies specifically to LLaMA-2-7B pretrained parameters — no other models are tested in the diagnostic analysis (Section 2.2). Given that the cross-model results (Section 5.3) show varying magnitudes of AnchorAttention benefit, it is plausible that different model families experience different degrees of BFloat16-induced RoPE breakdown, potentially related to differences in pretraining data, architecture, or scale. The paper also does not test whether the breakdown varies with the number of attention heads or with specific frequency bands within RoPE — the analysis aggregates over all heads and all frequency components, which could mask head-specific or frequency-specific effects. The mechanistic hypothesis about why the first token is affected (large absolute rotation angles with reduced trigonometric precision) is plausible but not directly tested — for instance, by measuring cosine/sine computation error at varying position indices or by ablating specific frequency bands. **Claim 2 (the breakdown degrades long-context performance): Supported, with the key evidence being indirect.** The direct evidence that the BFloat16-induced attention differences *cause* downstream performance degradation comes from the position-ID reset experiment (Figure 3, Table 5). The logic is: if position-ID assignment shouldn't matter under exact arithmetic (per RoPE theory) but does matter empirically, then the difference must be attributable to BFloat16 precision loss. This is a valid inference, but it is correlational rather than causal — the paper does not, for example, compare the same model trained under Float32 vs. BFloat16 (which would be prohibitively expensive) or isolate the first-token BFloat16 error and measure its impact on task performance in a controlled simulation. The magnitude of the reset-vs-continuous gap (1-3 RULER points at longer contexts) is modest relative to the total performance variation across methods. The larger gains from AnchorAttention over Intra-Document Attention (e.g., 73.25 vs. 69.97 at 64K on SlimPajama-64K) may reflect benefits beyond just fixing positional inconsistency — the reduction in attention FLOPs and the consistent anchor reference could provide additional advantages not directly attributable to BFloat16 precision. The paper does not attempt to decompose AnchorAttention's total benefit into "precision-related" vs. "other architectural" components. A stronger causal test — not performed — would be to implement AnchorAttention under Float32 and measure whether the advantage over Full Attention diminishes or disappears. If AnchorAttention's benefit is primarily from fixing BFloat16 precision issues, it should matter less under Float32 where those issues don't exist. The paper does not run this experiment, likely due to the computational cost of Float32 long-context training. **Claim 3 (AnchorAttention fixes the problem and reduces training time): Strongly supported for performance; training time reduction is estimated, not wall-clock measured.** The RULER results in Table 5 consistently show AnchorAttention outperforming all baselines across datasets and context lengths, with particularly large gains at longer contexts. The cross-model results in Table 6 extend this finding. The training time reduction claim (Figure 6) is presented as an estimation based on FLOPs counting, not as measured wall-clock time across equivalent training runs. The paper states estimated "days required to process 1 billion tokens" — this is a theoretical efficiency metric that assumes perfect scaling and does not account for implementation overhead, communication costs in distributed training, or memory access patterns that affect real GPU utilization. The zero-logit-difference result in distributed training (Table 8) is a strong engineering validation, but it applies to a specific sequence parallelism configuration (DeepSpeed-Ulysses) and may not generalize to all distributed training setups. The claim that AnchorAttention requires "minimal modifications to existing training pipelines" (stated in the abstract and Section 5.5) is supported by the implementation details — it works with FlashAttention2 and HuggingFace Transformers — but practical adoption may face challenges: the attention mask construction must correctly handle variable-length documents within packed sequences, the position ID assignment must be coordinated with the mask, and the anchor token must be distinguished from document content for loss masking. These are manageable engineering tasks but may not be trivial for all training frameworks. **Claim 4 (transfer across architectures): Supported, but with important variation.** Table 6 demonstrates that AnchorAttention never hurts and usually helps across four model families. The variation in benefit magnitude is substantial but not explained — LLaMA-3-8B gains ~17 points at 128K while Qwen-1.5-1.8B gains less than 1 point. The paper notes that Qwen lacks a bos token and uses eos as anchor instead, which may degrade effectiveness, but this hypothesis is not tested by, for instance, adding a bos token to Qwen or testing whether the eos token's semantic content interferes with the anchor function. The paper also does not test models larger than 8B parameters — it is unknown whether AnchorAttention's benefits scale with model size, whether very large models (70B+) experience the same BFloat16 precision issues, or whether the optimal anchor configuration changes with model depth and width. **Claim 5 (preserves short-context capabilities): Supported, with evidence that AnchorAttention is better than alternatives but still causes some degradation.** Table 7 shows that all long-context training methods degrade MMLU performance relative to the original LLaMA-2-7B (46.66): the best AnchorAttention variant reaches 42.85 (SlimPajama-128K + Tag), still 3.81 points below the original. This is substantially better than Full Attention's 33.93 (SlimPajama-64K), but it is not "preservation" in the sense of no degradation. The HellaSwag results are more encouraging — AnchorAttention on SlimPajama-64K achieves 70.78 vs. 71.39 for the original, a 0.61 point gap — suggesting that commonsense reasoning is largely preserved. The LongBench ICL results show massive improvements over the original (from 6.22 to ~50-65), confirming that continued pretraining on long data teaches new capabilities that the original model lacked. An important caveat: all short-context evaluations use the models after 2000 steps of long-context training on 2 billion tokens. The paper does not explore whether a shorter training duration or a smaller long-context data budget could achieve similar long-context gains with less short-context degradation — there is no "Pareto frontier" analysis trading off long-context improvement against short-context preservation. The 2000-step, 2B-token protocol is inherited from prior work (Fu et al., 2024) rather than optimized for the AnchorAttention setting. **Overall strengths of the experimental design:** (1) The RULER benchmark provides granular, length-stratified evaluation that directly tests the long-range capabilities the paper claims to improve, in contrast to PPL-based evaluation that the paper persuasively critiques. (2) The multi-checkpoint averaging protocol addresses training variance, a practical concern that many papers ignore. (3) Testing across three dataset variants (64K, 128K without upsampling, 128K with upsampling) controls for data composition effects. (4) The cross-model evaluation in Table 6 is a genuine strength — it tests the central claim of generality rather than assuming it. (5) The negative results on interleaved chunks and the inconsistent results on domain tagging are reported transparently, building credibility. **Notable gaps and weaknesses:** (1) **Single task domain.** All long-context evaluation uses RULER, which is a synthetic benchmark. While RULER is well-designed for probing specific long-context capabilities, it does not represent the diversity of real-world long-context use cases. The LongBench ICL results provide some real-world validation but only up to ~16K effective context. Evaluation on longer real-world tasks (document-level translation, repository-level code understanding, book-length summarization) is absent. (2) **No comparison to training with Float32.** The paper argues that Float32 is impractical, which is true, but a small-scale comparison (e.g., training a smaller model or using a shorter context length) would directly test whether AnchorAttention's benefits are attributable to precision mitigation or to the attention pattern itself. Without this ablation, the causal link between the diagnostic findings (Section 2) and the solution (Section 3) remains correlational. (3) **Fixed training budget.** All experiments use exactly 2000 steps and 2 billion tokens. The paper does not explore whether AnchorAttention's benefits are robust to training duration — whether the advantage appears early in training, whether it grows or shrinks with more steps, or whether AnchorAttention converges faster to a given performance level. (4) **No systematic study of document packing density.** The number of documents per sequence affects the reduction in attention FLOPs and the fraction of tokens that are "first tokens" of documents. The paper does not report how document boundaries are distributed in the training data or how sensitive AnchorAttention is to the average document length within packed sequences. (5) **No comparison to alternative precision formats.** The paper focuses exclusively on BFloat16 vs. Float32. Other formats like FP8 (increasingly used in inference and training) or TensorFloat-32 (available on A100 GPUs) are not tested. It is possible that these formats experience different precision-loss characteristics that would alter the optimal attention design. (6) **The RULER averaging protocol is not validated across methods.** Figure 4 shows training variance for Full Attention only. It is unknown whether AnchorAttention exhibits similar or different variance patterns — if AnchorAttention training is more stable, the benefit of multi-checkpoint averaging might be smaller, and if it is less stable, the reported average might understate the advantage. **What would strengthen the paper:** A direct causal experiment isolating BFloat16's effect on long-context performance — for instance, comparing a small model trained with AnchorAttention under BFloat16 vs. the same model trained with Full Attention under Float32 at a modest context length where Float32 training is feasible. If Full Attention under Float32 matches AnchorAttention under BFloat16, it would confirm that AnchorAttention's benefit is primarily from precision mitigation. If AnchorAttention under BFloat16 still outperforms, it would indicate that the attention pattern provides architectural benefits beyond precision fixing. The paper does not run this experiment, leaving the central mechanistic claim — that AnchorAttention works because it mitigates BFloat16 precision issues — supported by diagnostic evidence but not by a controlled training comparison. ## 6. Limitations and Trade-offs ### Difficulty Estimation Cost Is Unaccounted For in the Headline Efficiency Numbers **The assumption or constraint:** The paper's entire analysis of BFloat16-induced RoPE corruption and the subsequent AnchorAttention design is performed on LLaMA-2-7B pretrained parameters, but the diagnostic methodology itself requires generating 50 sequences of length 4096 and computing attention differences across multiple positional shifts under *both* BFloat16 and Float32 precision (Figure 1). This is feasible for a one-time analysis on a 7B model but does not constitute a deployment-time cost. However, a subtler and more consequential assumption underlies the practical deployment of AnchorAttention: that the training data can be packed into sequences where document boundaries are known and where a suitable shared anchor token (bos or eos) exists. The paper explicitly acknowledges in Section 5.3 that the Qwen series "does not utilize a bos token" and requires using the eos token as the shared anchor instead, but does not systematically study how anchor token choice — including adding a synthetic anchor token to models that lack one — affects performance or whether some model families lack any suitable semantically-vacuous token to serve as anchor. **The consequence:** A practitioner deploying AnchorAttention on a model without a natural bos-like token may experience degraded benefits, as the Qwen-1.5-1.8B results suggest (Table 6: the improvement at 128K is only 0.76 RULER points vs. 17.47 for LLaMA-3-8B). The eos token typically carries semantic content (it signals sequence termination), and using it as an anchor that all tokens attend to could inject spurious signals that partially counteract the precision-mitigation benefit. More broadly, the paper does not characterize what properties make a token suitable as an anchor — semantic vacuity, consistent position across all training examples, absence from document content — leaving practitioners to guess when applying AnchorAttention to new model families or training pipelines. If the anchor is suboptimally chosen, the method's benefits may shrink substantially, but the paper provides no diagnostic for detecting this failure mode. **What evidence exists in the paper:** The Qwen-1.5-1.8B results (Table 6) provide indirect evidence of anchor sensitivity. AnchorAttention achieves 34.32 at 128K vs. 33.56 for Full Attention (a 0.76 point gap), compared to 51.49 vs. 34.02 for LLaMA-3-8B (a 17.47 point gap). The paper notes the bos/eos substitution but does not ablate it — for instance, by testing whether adding a synthetic bos token to Qwen recovers the larger gains seen on LLaMA models, or by testing whether the eos token's semantic content in Qwen's training data makes it a worse anchor than the bos token. **Mitigation status:** The paper acknowledges the issue ("the Qwen series does not utilize a bos token, we use the eos token as the shared anchor in our implementation") but treats it as an implementation detail rather than a limitation requiring systematic study. There is no ablation on anchor token choice, no recommendation for practitioners facing models without bos tokens, and no analysis of what makes a token "anchor-suitable." The paper does not address this in the future work section either, focusing instead on connections to attention sinks and massive activations. --- ### Single Synthetic Benchmark for Long-Context Evaluation **The assumption or constraint:** All long-context performance claims are validated on exactly one benchmark: RULER (Hsieh et al., 2024). The paper explicitly justifies this choice in Section 4.2, arguing that RULER is "specifically designed for extensive context lengths" and that alternatives like LongBench (Bai et al., 2023) "can be adequately addressed with a context length of 16K tokens" and "heavily rely on instruction-following abilities." The paper also excludes two of RULER's 13 tasks for LLaMA-2-7B evaluation because the model "struggled with these two tasks even within its original 4K context window." This filtering means the reported RULER scores are on an 11-task subset for LLaMA-2-7B experiments (the primary model) but on all 13 tasks for the cross-model experiments in Section 5.3. **The consequence:** The single-benchmark evaluation leaves open the possibility that AnchorAttention's benefits are specific to the types of synthetic retrieval, tracing, and aggregation tasks that RULER tests, rather than reflecting genuine improvements in general long-context processing. Real-world long-context use cases — document-grounded dialogue, multi-document summarization, repository-level code understanding, book-length translation — require capabilities (coherence maintenance, cross-document synthesis, hierarchical reasoning) that RULER's needle-in-a-haystack and word-counting tasks do not probe. A model could achieve high RULER scores by learning to attend precisely to the anchor when searching for scattered information, without developing the ability to integrate information across long contexts for complex reasoning — RULER's structure may inadvertently reward exactly the attention pattern that AnchorAttention creates. Furthermore, the task filtering for LLaMA-2-7B makes cross-model comparisons in Table 6 potentially misleading. The LLaMA-3-8B, Mistral-7B-v0.3, and Qwen-1.5-1.8B results use all 13 RULER tasks, while the LLaMA-2-7B results in Table 5 use 11 tasks. The excluded tasks (NIAH Multikey 3 and Common Word Extraction) are among the hardest in RULER, so their inclusion would likely lower absolute scores. The relative ranking of methods might be preserved, but the absolute performance levels and gap magnitudes are not comparable across Tables 5 and 6. **What evidence exists in the paper:** The LongBench ICL results (Table 7) provide partial real-world validation but only at medium context lengths (~16K effective). AnchorAttention achieves better ICL scores than baselines (e.g., 65.38 vs. 62.51 for Full Attention on SlimPajama-64K), suggesting the benefit transfers to some real-world tasks, but LongBench ICL is few-shot in-context learning, not long-context retrieval or reasoning at 64K-128K lengths. The paper does not evaluate on other long-context benchmarks like InfiniteBench (Zhang et al., 2024c), which includes tasks at 100K+ tokens, or on document-level tasks from HELMET (Yen et al., 2024). The RULER averaging protocol (Figure 4) is validated only for Full Attention on SlimPajama-16K; the paper does not show whether AnchorAttention training exhibits similar or different variance patterns. **Mitigation status:** The paper acknowledges that LongBench tasks "can be adequately addressed with a context length of 16K tokens" and therefore "does not fully challenge models like ours that can handle 64K or even 128K tokens," but treats this as a limitation of the benchmark rather than a gap in their own evaluation. The paper does not propose or use any real-world benchmark at the 64K-128K scale, leaving the practical value of AnchorAttention's RULER improvements unvalidated for realistic deployment scenarios. The future work section does not mention expanding the evaluation suite. --- ### All Experiments Use a Single Training Budget and Data Recipe **The assumption or constraint:** Every long-context training run in the paper uses exactly 2000 steps on 2 billion tokens from SlimPajama variants at batch size 8 on 8 NVIDIA A100 GPUs (Table 1). This protocol is inherited from prior work — the paper cites Fu et al. (2024) as finding that "1B tokens suffices for learning long-context abilities" and doubles it to 2B for margin. The RoPE base frequency is tuned per context length (1M for 32K, 5M for 64K, 10M for 128K) based on the sweep in Table 3, but all other hyperparameters — learning rate, optimizer settings, number of steps, data mixture — are held fixed across all attention mechanism comparisons. **The consequence:** The paper cannot distinguish between "AnchorAttention is genuinely better than Full Attention" and "AnchorAttention converges faster or requires different hyperparameters than Full Attention." If Full Attention benefits from a different learning rate, warmup schedule, or training duration at long context lengths — which is plausible given that Full Attention processes more attention edges and may have different optimization dynamics — the fixed-protocol comparison may understate Full Attention's achievable performance. Conversely, if AnchorAttention's efficiency enables training on more tokens within the same wall-clock budget, the paper does not explore whether additional training steps would further widen the gap or whether the advantage saturates. The fixed data budget also means the paper cannot characterize how AnchorAttention's benefits scale with training duration. Figure 4 shows that RULER performance for Full Attention fluctuates during training and continues improving at 2000 steps, but the paper does not show a learning curve for AnchorAttention. It is possible that AnchorAttention reaches its peak RULER performance earlier (in which case the 2000-step comparison is fair but the method is even more efficient than reported) or later (in which case the comparison understates the potential benefit with more training). The paper's recommendation to average over the last 50 steps (5 checkpoints) partially addresses training variance at the endpoint but does not replace a learning curve analysis. **What evidence exists in the paper:** The RoPE base frequency sweep (Tables 3-4) is the only hyperparameter that receives systematic optimization. The learning rate ($2 \times 10^{-5}$) and optimizer settings (AdamW with weight decay 0.1, $\beta_1 = 0.9$, $\beta_2 = 0.95$) are stated but their selection is not justified beyond reference to prior work (Zhang, 2023). There is no learning rate sweep, no comparison of training durations, and no experiment varying the total token budget. The paper does explore data mixture effects (SlimPajama-64K vs. SlimPajama-128K vs. UpSampledMix-128K), which provides some robustness, but all mixtures are instances of the SlimPajama distribution — the paper does not test whether AnchorAttention's benefits transfer to substantially different data distributions (e.g., code-heavy, multilingual, or domain-specific corpora). **Mitigation status:** The paper makes no claim to have optimized the training protocol for AnchorAttention and does not frame the fixed-budget comparison as a limitation. The consistent advantage across three dataset variants provides some robustness, but the lack of hyperparameter optimization for baselines leaves open the possibility that the reported gap is partly attributable to suboptimal baseline tuning. The future work section mentions "optimization hyperparameters and additional data mixtures" as limitations due to resource constraints but does not specify which hyperparameters are most likely to matter or how future work should address them. --- ### No Causal Evidence Linking BFloat16 Precision to Downstream Performance Degradation **The assumption or constraint:** The paper's central narrative is that BFloat16 precision breaks RoPE's relative positional encoding (Section 2) and that this breakdown degrades long-context training performance, motivating AnchorAttention as a fix (Section 3). However, the evidence for the second step — that the precision-induced attention differences *cause* performance degradation — is entirely correlational. The diagnostic experiments (Figure 1) measure attention pattern differences between Float32 and BFloat16 on pretrained LLaMA-2-7B, and the positional-ID reset experiment (Figure 3) shows that position ID assignment affects RULER performance, which is consistent with BFloat16 causing problems but does not isolate BFloat16 as the cause. **The consequence:** Without a controlled experiment that isolates BFloat16's effect on training outcomes, the paper cannot rule out alternative explanations for AnchorAttention's benefits. It is possible that AnchorAttention improves long-context performance primarily because it reduces the number of attention edges (producing a sparser gradient signal that regularizes training) or because the shared anchor provides a useful architectural inductive bias (a dedicated global information channel), rather than because it specifically mitigates BFloat16 precision errors. If the primary mechanism is sparsity or the anchor inductive bias rather than precision mitigation, then the paper's diagnostic analysis — while interesting — is not the mechanistic explanation for the performance gains, and practitioners could potentially achieve similar benefits through other sparse attention patterns or global token designs that do not require the BFloat16 precision motivation. The strongest test of the precision-mitigation hypothesis would be to compare AnchorAttention against Full Attention when both are trained under Float32 — where the precision issues are absent per Figure 1 (yellow line). If AnchorAttention's advantage largely disappears under Float32, it would confirm that precision mitigation is the primary mechanism. If the advantage persists, it would indicate that AnchorAttention provides benefits independent of BFloat16 precision. The paper does not run this experiment (likely due to the prohibitive memory cost of Float32 training at 64K-128K context lengths), leaving the causal claim unvalidated by a direct training comparison. **What evidence exists in the paper:** The correlational evidence is strong but incomplete. Figure 1 establishes that BFloat16 causes attention differences, and Figure 3 establishes that position ID assignment matters empirically. The logic connecting them — BFloat16 corrupts the first token's positional signal, inconsistent position IDs exacerbate this, AnchorAttention fixes it — is coherent and plausible. However, the paper acknowledges in Section 3.2 that the analysis "is based on the hypothesis that RoPE functions in some way as an absolute positional encoding mechanism under BFloat16 precision" and that "further research is necessary to rigorously validate this assumption." This is an honest admission but also a recognition that the causal chain is hypothetical rather than proven. The magnitude of AnchorAttention's advantage also raises questions about parsimony. At 128K on LLaMA-3-8B, AnchorAttention outperforms Full Attention by 17.47 RULER points (Table 6). If this entire gap were attributable to BFloat16 precision errors at the first token, it would imply that first-token positional corruption is the dominant bottleneck in long-context performance for a well-trained 8B model — a claim that seems mechanically plausible but deserves more direct verification than the paper provides. **Mitigation status:** The paper is transparent about the hypothetical nature of the precision explanation (the "further research is necessary" statement in Section 3.2, the speculation about attention sinks in Section 8), but does not propose specific experiments to test the causal claim. A small-scale Float32 training comparison (perhaps at 8K or 16K context where Float32 is feasible) would be the most direct test and is not suggested. The paper's central contribution — AnchorAttention as an effective attention mechanism — does not depend on the precision explanation being correct, but the paper's framing and the field's understanding of *why* the method works do depend on it. --- ### Short-Context Capability Degradation Is Real and Not Eliminated **The assumption or constraint:** The paper claims that AnchorAttention "largely preserv[es] the original LLM's capabilities on general tasks" (abstract) and that it "better preserve[s] general abilities from the pretraining stage compared to those using full attention or intra-document attention" (Section 5.4). This relative claim — better than alternatives — is well-supported by Table 7. However, the absolute claim of "preservation" warrants scrutiny: **every long-context training method, including AnchorAttention, degrades MMLU performance relative to the original LLaMA-2-7B**. The original model achieves 46.66 on MMLU; the best AnchorAttention variant (SlimPajama-128K + Tag) achieves 42.85, a loss of 3.81 points (8.2% relative degradation). On SlimPajama-64K, AnchorAttention achieves 40.32, a loss of 6.34 points (13.6% relative degradation). **The consequence:** A practitioner deploying AnchorAttention for long-context adaptation must accept a non-trivial degradation in factual knowledge and reasoning capabilities as measured by MMLU. The degradation is substantially smaller than with Full Attention (which drops to 33.93 on SlimPajama-64K, a 12.73-point loss), but it is not negligible. For applications where the model must maintain strong performance across both long-context and knowledge-intensive tasks (e.g., a research assistant that needs to both process long documents and answer factual questions accurately), this trade-off may be unacceptable, regardless of how much better AnchorAttention is than alternatives. The paper does not explore whether this degradation is reversible or avoidable. Could a shorter training duration achieve most of the long-context benefit with less MMLU loss? Could a data mixture that includes short-context factual data during long-context training prevent the degradation? Could learning rate schedules or regularization techniques preserve pretrained knowledge better? The paper provides no guidance on navigating this trade-off, only the empirical observation that AnchorAttention sits at a more favorable point on the trade-off curve than baselines. **What evidence exists in the paper:** Table 7 provides the raw numbers. HellaSwag is better preserved (70.78 on SlimPajama-64K vs. 71.39 original, a 0.61-point loss), suggesting that commonsense reasoning is more robust to long-context training than factual knowledge. LongBench ICL improves dramatically (from 6.22 to 50-65), confirming that continued pretraining on long data teaches new capabilities. But MMLU — the most comprehensive knowledge benchmark used — consistently degrades. The paper does not plot or discuss the trade-off curve between long-context improvement and short-context preservation, nor does it propose strategies for shifting the curve. **Mitigation status:** The paper presents the MMLU degradation transparently (Table 7 includes all numbers) and accurately characterizes AnchorAttention as "better preserving" rather than "perfectly preserving." The domain tagging variant (+Tag) provides the best MMLU preservation on 128K datasets, suggesting a partial mitigation, but the mechanism is not explained — the paper notes the observation without analyzing why tags help knowledge retention. The future work section does not address the capability preservation trade-off, focusing instead on connections to attention sinks and pretraining-scale experiments. For practitioners, this means deploying AnchorAttention requires accepting an ill-characterized knowledge degradation whose severity may vary with model family, training data, and domain — the paper provides only a single point estimate on LLaMA-2-7B with SlimPajama data. --- ### Method Evaluation Is Limited to Sub-10B Models and 2B Training Tokens **The assumption or constraint:** All experiments are conducted with models at the 1.8B to 8B parameter scale (LLaMA-2-7B, LLaMA-3-8B, Mistral-7B-v0.3, Qwen-1.5-1.8B) trained on 2 billion tokens for 2000 steps. The paper explicitly acknowledges this limitation: "We also limit ourselves to the 10B-scale model size regime with 2B tokens, which may limit the generalizability of our findings" (Limitations section). The 2B token budget is small relative to the pretraining corpora of these models (trillions of tokens), and the 2000-step duration means the models undergo relatively few parameter updates during long-context adaptation. **The consequence:** Several aspects of the findings may not transfer to larger models or longer training regimes. First, the BFloat16 precision breakdown documented in Section 2 might behave differently at larger model scales — deeper networks could accumulate positional errors differently across layers, wider networks could distribute the corrupted signal across more attention heads (potentially diluting or amplifying the effect), and models pretrained on more data might have learned different compensatory strategies. Second, the optimal AnchorAttention configuration (anchor placement, mask pattern, position ID assignment) might change with model depth and width — a 70B model with 80 layers and 64 heads per layer has substantially different attention dynamics than a 7B model with 32 layers and 32 heads. Third, the 2000-step training duration may be insufficient to observe convergence behavior or late-training effects — if AnchorAttention enables faster initial learning but Full Attention eventually catches up with more steps, the fixed-budget comparison would overstate AnchorAttention's advantage. Fourth, the data efficiency claim — that AnchorAttention "reduces dependency on carefully upsampled data" (Section 5.1) — is based on comparing SlimPajama-128K (no upsampling) against UpSampledMix-128K (with upsampling) at the 2B token scale. With larger data budgets (e.g., tens of billions of tokens), the gap between upsampled and non-upsampled data might narrow or change character, altering the practical value of AnchorAttention's reduced data dependency. **What evidence exists in the paper:** The cross-model evaluation (Table 6) provides some evidence of generalization across model families at similar scales, but the results are variable — the benefit magnitude ranges from 0.76 to 17.47 RULER points at 128K. This variability itself suggests that model-specific factors (architecture, pretraining data, scale) modulate AnchorAttention's effectiveness, but the paper does not attempt to explain the variation or predict how it would extrapolate to larger models. The 2B token budget is acknowledged as a limitation but no sensitivity analysis is provided — for instance, training curves showing RULER performance as a function of tokens processed for each attention mechanism, which would indicate whether the relative ranking is stable or changes with more training. **Mitigation status:** The paper explicitly flags this limitation: "we cannot exhaust all aspects, such as study its effectiveness for pretraining, optimization hyperparameters and additional data mixtures. We also limit ourselves to the 10B-scale model size regime with 2B tokens" (Limitations section). This honest acknowledgment is appropriate but does not reduce the uncertainty for practitioners working at larger scales. The paper does not propose scaling laws or theoretical arguments for why the findings should transfer, nor does it suggest a research program for validating AnchorAttention at larger scales. For a production team considering adopting this method for a 70B+ model trained on hundreds of billions of long-context tokens, the paper provides suggestive but insufficient evidence that the benefits would persist at that scale, and the cost of running the confirmatory experiment would be substantial. ## 7. Implications and Future Directions ### How This Work Changes the Landscape This paper causes a **methodological shift in how the field should think about numerical precision** — it elevates precision from a backend implementation detail to a first-class architectural constraint that can break algorithmic guarantees and degrade task performance. This is not a paradigm shift in positional encoding theory (RoPE's mathematical properties remain unchanged) nor in attention mechanism design (AnchorAttention is a refinement of intra-document attention), but it is a **diagnostic reframing** with substantial practical consequences. The core insight — that BFloat16's 7-bit mantissa interacts destructively with RoPE's rotational operations at the first sequence position, and that this interaction grows with context length and is amplified by pretraining — introduces a new category of failure mode that the long-context training literature had not previously recognized or addressed. **What changes conceptually:** Before this paper, the implicit model in the RoPE-based context extension literature was that numerical precision is a transparent substrate. Theoretical analyses of NTK-aware scaling (LocalLLaMA, 2023), YaRN (Peng et al., 2023), and position interpolation (Chen et al., 2023a) derive guarantees from trigonometric identities assuming exact arithmetic, and the empirical validation of these methods uses BFloat16 throughout — so any precision-induced deviations are baked into both the theory's assumptions and the experiments that appear to confirm them. The paper demonstrates that this creates a **self-consistent but potentially suboptimal equilibrium**: the field converges on methods that work under BFloat16 not because they are theoretically optimal, but because they implicitly compensate for BFloat16-induced distortions that were never separately diagnosed. The finding that vanilla RoPE with an appropriate base frequency outperforms NTK and YaRN *within* the training context length (Table 2, 69.43 vs. 64.22 vs. 62.47 at 64K) while YaRN generalizes better *beyond* the training length (Table 4, 57.07 vs. 35.93 at 128K) takes on new meaning in light of the precision analysis: these methods may differ partly in how they interact with BFloat16's error characteristics, not just in their mathematical interpolation properties. This reframing suggests a broader principle: **any component whose theoretical guarantees rely on exact mathematical identities should be audited for precision-induced violations before those guarantees are assumed to hold in deployed systems.** The paper's diagnostic methodology — comparing Float32 and BFloat16 attention on identical model parameters, measuring cumulative differences across layers and heads — provides a template for such audits. Future work on positional encoding, normalization, or attention variants that make invariance claims (translation invariance, rotation invariance, scale invariance) should include precision-aware validation, not just infinite-precision mathematical derivations. **Resolving prior contradictions:** The paper provides a unifying explanation for several previously disconnected observations. The attention sink phenomenon (Xiao et al., 2023; Han et al., 2023) — where the first token receives disproportionately high attention — had been documented as an empirical regularity without a clear mechanistic origin. The paper hypothesizes (Section 8) that attention sinks may emerge as a learned adaptation to BFloat16-induced positional corruption at the first token, providing a potential causal mechanism for what had been a descriptive observation. Similarly, the finding that intra-document attention with continuous position IDs underperforms the same attention pattern with reset position IDs (Figure 3) contradicts the theoretical prediction that position ID assignment is irrelevant under RoPE — but becomes coherent once BFloat16's distortion of the first token's positional encoding is recognized. The paper thus converts a set of "this shouldn't matter but it does" anomalies into a coherent picture where the common cause is BFloat16 precision loss concentrated at sequence boundaries. **Research directions that become more attractive:** The paper makes **precision-aware architecture design** a viable research direction — not just for positional encoding but for any component where reduced precision could introduce systematic biases. The methodology of isolating precision effects through cross-precision comparisons on frozen model parameters is transferable to other components (layer normalization, attention softmax, gating mechanisms). The paper also makes **first-token-aware attention design** a principled rather than heuristic endeavor — rather than treating the first token's special status as an empirical nuisance to be worked around (as in StreamingLLM), researchers can now design attention patterns that explicitly account for the first token's precision vulnerability. Finally, the paper shifts attention from developing *new* positional encoding schemes to understanding how existing schemes interact with hardware precision constraints — a more engineering-focused but potentially higher-impact direction than incremental RoPE variants. **Research directions that become less attractive:** The paper's negative results on interleaved chunks with cross-document masking (Table 5, consistent degradation of 6-12 RULER points) suggest that data augmentation strategies designed for full attention do not transfer to sparse attention patterns, and that pursuing synthetic data generation for long-context training without considering attention-pattern compatibility is likely unfruitful. The inconsistent results on domain tagging (Table 5, sometimes helps by ~0.5 points, sometimes hurts by ~1 point) suggest that naive prepending of domain information is not a reliable strategy for improving long-context performance, even though prior work (Allen-Zhu & Li, 2024; Zhang et al., 2024b) found benefits for knowledge storage in other contexts. The paper also makes purely theoretical analyses of RoPE variants that ignore precision constraints seem incomplete — any future positional encoding proposal should include at minimum a BFloat16-vs-Float32 attention comparison on a pretrained model as a basic sanity check. ### Follow-Up Research This Work Enables **1. Direct causal test: Float32 long-context training at modest scale.** The paper's central claim — that AnchorAttention improves long-context performance primarily by mitigating BFloat16 precision errors — remains correlational. The cleanest test would be to train a small model (e.g., LLaMA-2-1B or a randomly initialized transformer) at a modest context length (e.g., 8K or 16K) where Float32 training is computationally feasible. Compare three conditions: (a) Full Attention under BFloat16 (baseline), (b) Full Attention under Float32 (precision fix only), (c) AnchorAttention under BFloat16 (architectural fix only). If condition (b) matches condition (c), it confirms that precision mitigation is the primary mechanism. If condition (c) substantially outperforms condition (b), AnchorAttention provides benefits beyond precision fixing (e.g., architectural inductive bias from the shared anchor). If condition (b) is close to condition (a), then the BFloat16 precision issues are not the dominant bottleneck at this scale and context length, suggesting the issue may be specific to larger models or longer contexts. The paper does not run this experiment due to resource constraints, but a follow-up at 1B-3B scale with 8K-16K context is feasible on a modest GPU budget (4-8 A100s) and would substantially strengthen or refine the mechanistic claims. **2. Anchor token ablation: what makes a token "anchor-suitable"?** The Qwen-1.5-1.8B results (Table 6) show substantially smaller AnchorAttention benefits (0.76 RULER points at 128K) compared to LLaMA-3-8B (17.47 points). The paper attributes this to Qwen's lack of a bos token, requiring the semantically-loaded eos token as anchor. A systematic ablation would test this hypothesis: take a model that has a natural bos token (LLaMA-2-7B) and compare AnchorAttention performance using (a) the bos token as anchor (standard), (b) the eos token as anchor, (c) a randomly initialized learnable embedding as anchor, (d) a mid-sequence punctuation token (e.g., period) as anchor, and (e) no anchor (standard intra-document attention with reset position IDs). Measure RULER performance and attention pattern differences across conditions. If semantic vacuity matters, conditions (a) and (c) should outperform (b) and (d). If consistent position ID (always 0) matters more than semantic content, condition (b) should perform similarly to (a). This ablation would characterize the anchor design space and provide guidance for applying AnchorAttention to models without bos tokens — potentially including a recommendation to add a synthetic anchor token during continued pretraining. **3. Scaling behavior of BFloat16-induced positional corruption.** The paper demonstrates that first-token attention logit differences grow with sequence length from 64 to 8192 tokens (Figure 1, right), but does not characterize the functional form of this growth (linear? sublinear? thresholded?) or project to the 64K-128K training lengths used in later experiments. A measurement study on LLaMA-2-7B at context lengths from 1K to 128K (using the same $D_{\text{logit}}$ metric, Equation 5) would establish the scaling law for positional corruption. Key questions: Does the logit difference saturate at some length, or continue growing? Is the growth dominated by the lowest RoPE frequencies (which have the largest effective rotation angles and thus the worst trigonometric precision) or distributed across frequencies? Does the growth pattern differ across attention heads — do some heads learn to be robust to positional corruption while others amplify it? If the corruption follows a predictable scaling law, it may be possible to estimate a "maximum reliable context length" under BFloat16 for a given RoPE configuration, providing practical guidance for when AnchorAttention or Float32 becomes necessary. **4. Interaction between AnchorAttention and existing context extension methods at deployment scale.** The paper shows AnchorAttention outperforms Full Attention when training from a 4K pretrained model to 64K-128K context over 2000 steps (Table 5). Real-world deployments often combine *multiple* context extension techniques: a model pretrained at 4K or 8K might first undergo position interpolation (Chen et al., 2023a) or YaRN (Peng et al., 2023) to initialize for longer context, then continued pretraining on long data, then supervised fine-tuning, then deployment with techniques like StreamingLLM or LM-Infinite for further length generalization. Where in this pipeline does AnchorAttention provide the most value? A follow-up could test AnchorAttention applied at different stages: (a) during the initial long-context continued pretraining (as in the paper), (b) during supervised fine-tuning on long-context task data, (c) as an inference-time attention mask modification on an already-trained long-context model. If AnchorAttention is beneficial primarily during continued pretraining (when the model is learning to use new position indices), it may be a training-only technique. If it also helps at inference, it could be applied to existing long-context models without retraining. A negative result at inference would not diminish the paper's contribution but would clarify the scope of applicability. **5. Precision-aware RoPE frequency allocation.** The paper's RoPE base frequency sweep (Table 3) treats the base as a single global hyperparameter, but the BFloat16 precision analysis suggests that different RoPE frequencies experience different degrees of corruption: low frequencies (small $\theta_p$, large rotation periods) use small rotation angles even at large position indices and should be relatively robust, while high frequencies (large $\theta_p$, small rotation periods) cycle rapidly and may be more severely affected by mantissa limitations. A follow-up could design a **frequency-dependent precision allocation**: use Float32 for the highest-frequency RoPE dimensions (where BFloat16 errors are largest) while keeping BFloat16 for lower frequencies (where errors are negligible). This hybrid approach could achieve most of the precision benefit of full Float32 at a fraction of the memory cost. The experiment would measure the attention logit difference for each RoPE frequency band separately and identify which bands contribute most to the first-token discrepancy, then implement selective Float32 rotation for those bands and measure RULER performance. **6. Connection to attention sinks: causal intervention experiment.** The paper speculates (Section 8) that attention sinks may emerge as a learned response to BFloat16-induced positional corruption at the first token. A causal test: take a pretrained model that exhibits strong attention sinks (high attention weight on the first token), measure the attention sink strength, then fine-tune the model with AnchorAttention (which provides a clean, consistent anchor signal). If attention sinks are a compensatory mechanism, AnchorAttention training should reduce the model's reliance on the first token for non-anchor functions — the attention sink pattern should weaken or redistribute. Conversely, if attention sinks are an inherent property of transformer attention dynamics independent of precision, AnchorAttention training should not change the pattern. Measure the attention weight distribution before and after AnchorAttention continued pretraining, specifically testing whether non-anchor first tokens (e.g., the first content token of each document) receive less attention after training with a shared anchor. A positive result would link the precision analysis to the attention sink literature and suggest that some attention sink phenomena are artifacts of numerical precision rather than fundamental architectural properties — with implications for methods like StreamingLLM that exploit attention sinks for length generalization. ### Practical Applications and Downstream Use Cases **1. Cost-efficient long-context continued pretraining of open-source LLMs.** A research lab or company that wants to extend an existing open-source model (LLaMA-2, LLaMA-3, Mistral) from its original 4K-8K context to 64K-128K for document processing applications can adopt AnchorAttention immediately. The concrete benefit: training time reduced by more than 50% compared to standard full attention (Figure 6, approximately 2 vs. 4.5 days per billion tokens at 64K context on 8 A100s), with simultaneous improvements in long-context benchmark performance (Table 5, AnchorAttention achieves 73.25 vs. 66.40 for Full Attention at 64K on SlimPajama-64K) and better preservation of pretrained capabilities (Table 7, MMLU 40.32 vs. 33.93; HellaSwag 70.78 vs. 68.50). The integration cost is low — AnchorContext provides FlashAttention2-compatible implementations for LLaMA, Mistral, and Qwen families (Section 5.5) — and the method requires only changes to attention masking and position ID assignment, not model architecture or training infrastructure. The primary risk is that AnchorAttention's benefits are validated at the 7-8B scale and 2B token training budget; a team extending a 70B model may see different benefit magnitudes, but the direction of effect is consistently positive across four model families (Table 6), making a negative result unlikely. **2. On-device or edge deployment with limited-precision hardware.** Edge devices (phones, laptops, embedded systems) increasingly run quantized or reduced-precision LLMs for local inference, often using even lower precision than BFloat16 (e.g., INT8, INT4). While the paper studies BFloat16 specifically, the underlying mechanism — reduced mantissa bits causing systematic errors in trigonometric functions at large arguments — applies to any precision format where the representable granularity is insufficient for the rotation angles induced by long context lengths. A deployment team building an on-device long-context application could use AnchorAttention as an inference-time attention mask on a quantized model to mitigate precision-induced positional degradation without increasing the model's memory footprint. The concrete benefit: a model quantized to 4-bit that uses AnchorAttention may achieve better long-context retrieval accuracy than the same model using full attention, because the anchor provides a consistent positional reference that is less sensitive to quantization error than variable first-token positions. The paper's zero-logit-difference distributed training result (Table 8) suggests the mask itself is numerically stable across implementations, and the inference-time cost of applying the AnchorAttention mask (a sparse attention pattern with fewer edges than full attention) is lower than full attention, providing a latency benefit on top of the accuracy benefit. **3. Data curation pipeline simplification for long-context training.** The paper's finding that AnchorAttention on non-upsampled SlimPajama-128K achieves comparable or better performance than on carefully upsampled UpSampledMix-128K (Table 5, 66.15 vs. 65.24 at 128K for AnchorAttention; Full Attention achieves 63.70 on upsampled data vs. 62.75 on non-upsampled) suggests that AnchorAttention reduces or eliminates the need for the labor-intensive data upsampling step that prior work identified as critical for long-context adaptation (Fu et al., 2024). Upsampling long sequences requires identifying documents that naturally fill the training context window, which is expensive for web-scale corpora and may introduce domain biases (e.g., upsampling favors sources with long documents like books and ArXiv papers over sources with short documents like StackExchange or code files). A team building a long-context training pipeline could adopt AnchorAttention and skip the upsampling step entirely, reducing data engineering complexity while achieving equivalent or better performance. The specific claim that should be validated in a new deployment: train AnchorAttention on raw (non-upsampled) data and compare against Full Attention on upsampled data; if AnchorAttention matches or exceeds the upsampled baseline as it does in Table 5, the upsampling step can be removed from the pipeline, saving data processing compute and simplifying maintenance. **4. Long-document question answering and retrieval systems.** A production RAG (retrieval-augmented generation) or long-document QA system that processes documents of 32K-128K tokens could use an AnchorAttention-trained model to improve retrieval accuracy for information located far from the document start. The RULER benchmark's Needle-in-a-Haystack tasks directly measure this capability: locating a specific piece of information ("needle") embedded at varying positions within a long context ("haystack"). AnchorAttention's consistent improvements at 64K and 128K on RULER (Table 5, e.g., 66.15 vs. 62.75 for Full Attention at 128K on SlimPajama-128K) indicate that the model more reliably retrieves information regardless of its position in the document, which is precisely the requirement for long-document QA. The concrete benefit: a system that processes 128K-token legal contracts, scientific papers, or code repositories could use an AnchorAttention-fine-tuned model and expect more uniform retrieval accuracy across the document rather than degraded performance for information in the middle-to-late sections (a known failure mode of full-attention long-context models). The reduced inference latency from the sparse attention pattern (eliminating cross-document attention at training time, though inference on a single document would not benefit from this sparsity in the same way) is secondary to the accuracy improvement. A team deploying such a system should validate on their specific document distribution, as the RULER needle-in-haystack tasks use synthetic needles rather than natural queries.