Privileged Windows: Post-Training Attention-Boosted Persistent Token Memory for Large Language Models
2026-11-22
<pw_write> / <pw_keep/>), and adds a positive attention logit boost () to queries attending to privileged-window keys only during post-training. Using decoupled GRPO—assigning future-task transfer reward and zero KL regularization () to privileged-window content tokens—we test whether models distill generalizable, potentially non-English symbolic knowledge into the window while filtering task-specific distractors. Across 27 A100-80GB runs on Qwen2.5-3B and 7B spanning two benchmarks and a 7-condition causal battery controlling for attention-sink/register confounds, we find: (1) Episodic rule transfer (RuleTransfer-Bench): self-edited windows reach vs. No-PW and Random-PW (), compress prose while stripping distractors, and beat human Oracle windows across all five 3B arms (); on explicit named rules matches up to 3.2k tokens, with helping most under tight budgets (: pp; OOD when disabled). (2) Real-world multi-task transfer (RealMultiTask-Bench, 3 seeds 320 test tasks): zero-KL models spontaneously invent compact non-English codes (SymbVerifLKNTLKTrd, SOLVEUNIDIST, perf|prove|ltt|...|eqtn|stats, and <M><L><C><V><K><N> at 7B). Adding creates asymmetric causal coupling (penalizing random/shuffled tokens by up to pp un-gated and pp ID gated) and cuts 3-seed variance ( vs. ); at 7B, upper-layer boosting attains the highest overall ( vs. ) and unseen OOD ( vs. ) accuracy, whereas across 960 pooled 3B evaluations, a 32-token static window yields only modest mean lift over LoRA GRPO ( vs. ). (3) Failure modes: we diagnose 7B cold-start keep-collapse, high- edit lock-in, and un-gated pollution, yielding concrete design rules for self-editing attention-privileged memory.Introduction
Large language models (LLMs) solve tasks within an ephemeral context window that resets between problems (Vaswani et al., 2017). While external agentic memory systems persist natural-language notes across tasks (Packer et al., 2023; Shinn et al., 2023; Suzgun et al., 2025), they inject retrieved text as ordinary context tokens that compete for softmax attention against long, noisy task prompts (Liu et al., 2024) and keep model weights frozen. Conversely, parameter-efficient soft-prompt and context-compression methods optimize continuous latent prefixes via gradient descent (Li & Liang, 2021; Lester et al., 2021; Mu et al., 2023; Chevalier et al., 2023), but do not let the model dynamically edit discrete cross-task symbols at will during inference or post-training.
In this paper, we formulate and rigorously test an alternative hypothesis: Privileged Window Post-Training (PW-PT). We give a pretrained LLM a dedicated, compact discrete token buffer of at most tokens (e.g., tokens) distinct from the normal task context, persist its token IDs across tasks, allow the model to overwrite or retain it at will, and inject an additive attention logit boost from normal task/reasoning queries to privileged-window keys exclusively during post-training. Crucially, we remove the KL divergence penalty on tokens generated inside the privileged window (), freeing the model to evolve arbitrary compressed or non-English conceptual symbols whenever doing so improves downstream cross-task performance.

Why might a post-training attention boost create a useful inductive bias? Because softmax reweighting makes a double-edged selection pressure: every query in every subsequent task is forced to allocate substantial probability mass to the privileged window. If the window holds generalizable, cross-task abstractions, every task benefits; if it holds narrow, task-specific clutter or noise, the forced boost actively distracts future tasks.
Testing this idea honestly requires isolating several confounds that easily produce false positives in LLM memory studies: (i) attention-sink / register-token confounds (Xiao et al., 2024; Darcet et al., 2024; Sun et al., 2024), where extra prefix tokens help purely as computation sinks regardless of semantic content; (ii) weight memorization, where RL updates memorize a fixed benchmark into weights rather than relying on persistent memory; and (iii) attribution of the attention boost, where gains might stem from persistent text memory alone () rather than the post-training boost (). We therefore organize our two-stage evaluation around four falsifiable questions:
- RQ1 (Content Causality): Can a pretrained LLM adapt to a post-training-only boost while preserving BOS sinks and KV-cache exactness, and learn via RL to store genuine cross-task knowledge rather than register-token noise?
- RQ2 (Boost vs. ): In which regimes does outperform an identical self-edited window with or standard RL without a window?
- RQ3 (Symbolic Emergence): Does removing KL regularization on PW content under tight token caps induce non-English or compressed symbolic representations?
- RQ4 (Scale & Failure Modes): What optimization bottlenecks arise across 3B vs. 7B scales and layerwise boost placements?
Across 27 A100-80GB runs (10 pilot/Stage 1/Stage 2 v1 runs plus a 17-run multi-seed + 7B suite), we deliver rigorous, nuanced answers to all four questions.
Related Work
Soft Prompts, Context Compression, and Memory Tokens. Prefix-Tuning (Li & Liang, 2021) and Prompt Tuning (Lester et al., 2021) prepend continuous task-specific vectors optimized via backpropagation with frozen LM weights. Memory Transformers (Burtsev et al., 2020), Recurrent Memory Transformers (Bulatov et al., 2022), Gist Tokens (Mu et al., 2023), and AutoCompressors (Chevalier et al., 2023) train models via language modeling or instruction tuning to compress context segments into continuous summary vectors or cached KV states, following earlier differentiable memory architectures (Graves et al., 2014). Unlike these methods, PW-PT stores discrete vocabulary tokens edited at will by the model across tasks via reinforcement learning, and introduces a post-training attention logit boost without modifying pretraining.
Attention Steering, Sinks, and Auxiliary Workspace Tokens. PASTA (Zhang et al., 2024) applies inference-time attention reweighting on selected heads to emphasize user-highlighted spans without weight updates or cross-task persistence. StreamingLLM (Xiao et al., 2024) and Sun et al. (2024) demonstrate that pretrained LLMs place massive attention onto initial tokens (“attention sinks”); similarly, register tokens (Darcet et al., 2024) and pause tokens (Goyal et al., 2024) provide auxiliary compute workspace. Because boosted prefix tokens could inadvertently act as free registers, we explicitly protect position 0 from boosting and introduce a length- and boost-matched Random-PW causal control in every evaluation. Long-context degradation and attention dilution motivate our distraction-scaling stress test (Liu et al., 2024).
Agentic Self-Editing Memory and RL Post-Training. MemGPT (Packer et al., 2023), Reflexion (Shinn et al., 2023), and Dynamic Cheatsheet (Suzgun et al., 2025) equip LLMs with persistent natural-language memory updated across tasks at inference time, without modifying attention mechanics or co-training the model’s weights. On the optimization side, Group Relative Policy Optimization (GRPO) (Shao et al., 2024; DeepSeek-AI, 2025) enables critic-free RL post-training of reasoning models (Qwen Team, 2024) over objective verifiers (Cobbe et al., 2021) with parameter-efficient LoRA adapters (Hu et al., 2022). PW-PT bridges these lines by jointly RL-training discrete memory editing and attention-boosted memory utilization end-to-end.
Method: Privileged Window Post-Training (PW-PT)
Sequence Layout and Post-Training Attention Boost
Let denote the discrete token IDs currently stored in the Privileged Window, hard-capped at . For any task prompt and generated response , we form the sequence (Eq. 1):
where begins with the model’s pretrained position-0 chat delimiter (<|im_start|>system\n<privileged_window>\n) and closes the slot (\n</privileged_window>\n) before the system/user messages.[Preliminary diagnostics (Appendix A) showed that prepending a novel <|im_start|>memory role before <|im_start|>system caused zero-shot Qwen2.5 to ignore the block, whereas keeping <|im_start|>system at position 0 preserved both attention sinks and immediate readability while boosting strictly the raw PW content tokens .]
In each targeted transformer layer and attention head , we modify scaled dot-product attention (SDPA) purely through an additive logit bias added onto the standard causal mask (Eq. 2):
Notice three structural safeguards in Eq. (2): (i) position 0 () is never boosted, preserving pretrained attention sinks; (ii) PW tokens attending to each other () are unboosted, keeping PW internal encoding well-conditioned; and (iii) padding/future causal entries () are strictly untouched. We study three parameterizations of : fixed uniform ( across all layers), fixed upper-layer ( for and below), and unconstrained learnable per-head ( optimized jointly with LoRA parameters via exact SDPA backward gradients).
Exact KV-Cache and Gradient-Checkpointing Consistency.
On-policy RL generates rollouts with left-padded KV caching (use_cache=True) and computes policy log-probabilities via a full forward pass (use_cache=False) with gradient checkpointing. By indexing via absolute cache_position and storing per-example masks and start offsets inside a context manager wrapping both forward() and backward(), our implementation guarantees exact equivalence between cached decoding and full-sequence log-probabilities (verified to in FP32 on Qwen2.5-3B, matching vanilla 's ; Appendix A).
Verbatim Token-ID Editing and Decoupled GRPO
On every editable turn, the model generates reasoning, a final answer inside <answer>...</answer>, and a memory directive: either <pw_keep/> (retaining ) or <pw_write>...</pw_write>. Rather than decoding and re-tokenizing the text—which corrupts non-English subwords or unusual BPE combinations—we slice the exact generated token IDs strictly inside the <pw_write> span (handling boundary BPE tokens that straddle > or </) and truncate to tokens to form .
Each generated response partitions cleanly into three disjoint token-index masks: task-solving tokens (reasoning + <answer>), memory-directive tokens (<pw_keep/> or <pw_write>...</pw_write>), and the interior content subset strictly inside <pw_write>...</pw_write>. For a group of rollouts facing the identical task/world, we compute decoupled group-normalized advantages (Eq. 3):
where is immediate task accuracy (plus a small format bonus) and is strictly downstream performance on future unseen tasks using the resulting persisted window . We minimize the decoupled on-policy GRPO objective (Eq. 4):
where if else , is Schulman’s non-negative KL estimator against the adapter-disabled reference model at initial , and critically (Eq. 5):
Setting on ensures zero fluency penalty against non-English or compressed symbolic codes inside the privileged window, while keeps normal reasoning coherent.

Qwen2.5-1.5B, mean attention mass directed from task queries to PW keys rises smoothly from () to () and (), while next-token KL perturbation stays modest ( nats) in the operating band. (b) In Stage 1 (Qwen2.5-3B, 36 layers), unconstrained learnable per-head initialized at drifts down across early/middle syntactic layers () and up across upper reasoning layers ().Stage 1: Episodic Multi-Task Rule Transfer (RuleTransfer-Bench)
Benchmark Design and Causal Controls
To test RQ1–RQ3 without any possibility of weight memorization, we build RuleTransfer-Bench: each episode procedurally samples a brand-new world with three orthogonal small-integer latent rules using randomized nonce operator names (24 binary names, 24 unary names): (1) a binary operator (linear, -shift, or -shift), (2) a unary conditional operator (parity or threshold branch), and (3) a global output convention applied to final results. Verbose prose definitions require tokens—far exceeding our tight window caps ( and ).
Each episode consists of 4 sequential observation turns (where the model sees only its persisted PW and the current noisy task prompt, never prior turns) followed by 4 held-out transfer tasks with zero rule definitions in the prompt buried inside noisy operational logs:
- Obs 1–3: Sequentially introduce Rules 1, 2, and 3 amid decoy ticket logs; Obs 2–3 require combining the new rule with earlier rules stored only in PW.
- Obs 4 (Trap Turn): Introduces no new global rule—only a tempting one-time local rush fee. Blindly overwriting PW destroys stored rules; the optimal action is
<pw_keep/>. - Transfer T1–T4: T1 tests Rule 1; T2 tests Rule 2; T3 tests full composition ; T4 is an unseen OOD format testing reverse-order composition .
We train six arms on Qwen2.5-3B-Instruct (up to 100 GRPO steps, worlds rollouts/step, LoRA , , ) and two scale-check arms on Qwen2.5-7B-Instruct (60 steps): No-PW (floor), PW (key no-boost ablation), PW , PW , PW Learn (init , unconstrained), and PW (extreme compression). Every best checkpoint undergoes a 7-condition causal battery on 40 brand-new unseen test worlds ( transfer tasks).
Stage 1 Results
| Arm | Learned PW () | Boost OFF () | Random PW () | Shuffled PW () | Wrong-W () | Empty PW | Oracle PW () | PW Attn (%) | OOD T4 (L / Off) |
|---|---|---|---|---|---|---|---|---|---|
3B No-PW (floor) | 0.037 | — | — | — | — | — | — | 0.0 | 0.03 / — |
3B PW | 0.388 | 0.388 | 0.019 | 0.044 | 0.044 | 0.044 | 0.263 | 3.8 | 0.00 / 0.00 |
3B PW | 0.281 | 0.269 | 0.050 | 0.013 | 0.037 | 0.019 | 0.163 | 10.7 | 0.03 / 0.00 |
3B PW | 0.319 | 0.319 | 0.013 | 0.037 | 0.019 | 0.031 | 0.081 | 26.1 | 0.05 / 0.03 |
3B PW Learn | 0.388 | 0.388 | 0.025 | 0.037 | 0.019 | 0.037 | 0.231 | 11.6 | 0.03 / 0.00 |
3B PW | 0.312 | 0.256 | 0.019 | 0.062 | 0.037 | 0.037 | 0.056 | 12.9 | 0.12 / 0.05 |
7B PW | 0.056 | 0.056 | 0.056 | 0.056 | 0.056 | 0.056 | 0.294 | 0.0 | 0.00 / 0.00 |
7B PW Up | 0.031 | 0.031 | 0.031 | 0.031 | 0.031 | 0.031 | 0.194 | 0.0 | 0.00 / 0.00 |

s1_pw_beta3.5 peaks at ). (b) Causal interventions on 40 unseen test worlds (): replacing learned PWs with random or shuffled tokens collapses accuracy back to the no-memory floor across all 3B PW arms, and self-written PWs beat hand-crafted Oracle PWs.Table 1 and Figure 3 establish four clean findings on RuleTransfer-Bench:
1. Self-edited PWs store genuine cross-task knowledge and beat Oracle PWs.
All five 3B PW arms jump from (No-PW) to unseen transfer accuracy (reaching and on PW and Learn ). Replacing the learned PW with length- and boost-matched Random, Shuffled, or Wrong-World tokens collapses accuracy to (), ruling out register-token or attention-sink confounds. Remarkably, across all five 3B arms, the model’s self-written PW significantly outperforms our human-authored compact Oracle PW (e.g., vs. , for ; vs. , for ), demonstrating end-to-end writer–reader co-adaptation. Qualitatively, Step-0 PWs were polluted by local noise (+4 rush fee), whereas trained PWs discarded 100% of distractors and compressed -token prose by (e.g., relk(a, b) = a - b + 3 ; wrim(x) = x + 3, dropping multiplication symbols under tight caps).
2. Explicit rule lookup works at up to 3.2k tokens—until tight compression ().
To test whether prevents attention dilution when normal context grows long and noisy, we appended 0, 12, or 30 blocks of distracting archive logs containing deprecated decoy formulas ( prompt tokens) to and across all five 3B checkpoints (Figure 4). While preserved higher PW attention mass at tokens ( vs. for ), explicit named-rule recall remained virtually flat for both PW () and Learn (). Because Stage 1 prompts explicitly name the target operator (compute relk(5,3)), pretrained induction heads locate readable formulas even at mean attention mass. Crucially, however, under the tightest budget (PW ), disabling at test time caused the sharpest drop in Stage 1: pp overall (), pp on OOD (, the highest OOD score of any Stage 1 arm), and pp at tokens ().

3. Layerwise boost preference and two optimization failure modes.
Unconstrained Learn (Figure 2b) revealed a structured depth profile: early/middle syntactic layers () drifted below initialization () while upper semantic layers () drifted above (). Stage 1 also exposed two concrete RL failure modes: (i) Conservative keep-lock: 3B PW learned to write Rule 1 perfectly () and then emit <pw_keep/> on of Turns 2–4 () because overwriting a boosted window carried high immediate downside; and (ii) Cold-start write collapse at 7B: Qwen2.5-7B-Instruct emitted <pw_keep/> on of Turn-1 steps at Step 0, starving GRPO of non-empty trajectories and collapsing to () despite reading Oracle PWs at .
Stage 2: Real-World Cross-Domain Persistent PW (RealMultiTask-Bench)
Benchmark Design, Validation Gating, and v1 v2 Diagnosis
Unlike Stage 1—where task prompts explicitly name operators defined in PW—real-world reasoning tasks never mention tokens stored in a global persistent window. We construct RealMultiTask-Bench spanning four objectively verified training domains: (1) Math (GSM8K word problems (Cobbe et al., 2021), disjoint train , val-gate , and official test split), (2) Countdown (4-number combinatorial target search verified by safe AST evaluation), (3) Knights & Knaves (3-agent formal logic verified for unique SAT assignments), and (4) Python Execution Tracing (6–10 line stateful programs with loops, branches, and list mutations). After training, the single evolved global PW () is evaluated frozen on 160 held-out in-distribution tasks (40/domain) and 160 completely unseen OOD tasks across two novel domains: (5) Symbolic Sequence Pattern Extrapolation (80 tasks) and (6) Multi-Constraint Scheduling CSP (80 tasks, unique permutation verified).
In each GRPO round, the model views the current global PW, generates candidate PW revisions (<pw_keep/> or <pw_write>) at temperature , and evaluates every candidate across the exact same stratified 8-task batch (2 tasks/domain). Policy updates train both the PW-editor (group-normalized cross-domain accuracy, ) and the task solver ().
Diagnostic Discovery from Pilot Stage 2 v1 (Un-Gated Persistence).
In an initial single-seed pilot ( ID OOD, Appendix C), feeding raw accuracy percentages into the reflection prompt and committing the best mini-batch candidate without validation gating caused noisy failure-log strings (e.g., math=0%, logic_knk=0%) to pollute PW in PW (collapsing overall accuracy to , math ) and Learn (). Strikingly, PW escaped collapse, achieved the highest pilot score ( overall vs. No-PW; vs. OOD, peaking at OOD at Step 45 with the alien shorthand perf|prove|ltt|ltts|lt|cntdwn|ltt|stats|lt|rst|scrn|eqtn|stats), and exhibited strong causal coupling ( Learned vs. Boost-Off, Empty, Random [], Shuffled []), whereas PW showed zero content dependence ( Learned Empty Shuffled).
Stage 2 v2 (Rigorous Multi-Seed Protocol).
To eliminate pollution and properly power OOD testing, Stage 2 v2 introduces two clean fixes: (i) removing raw accuracy percentages from the reflection prompt, and (ii) validation-gated persistence, committing a candidate rewrite only if its greedy accuracy on a disjoint 24-task cross-domain gate buffer satisfies . We run 3 independent seeds () across four 3B arms—No-PW GRPO, PW , PW (All), and PW (Upper-Half ) (directly testing our Stage 1 layerwise hypothesis)—yielding 960 pooled test evaluations (480 ID + 480 OOD) per arm, plus a 3-arm 7B scale generalization check (Qwen2.5-7B-Instruct).
Stage 2 v2 Multi-Seed and 7B Scale Results
| Model / Arm | Intervention | In-Dist (160) | Unseen OOD (160) | Overall (320) | Math | OOD Pat | PW Attn |
|---|---|---|---|---|---|---|---|
3B No-PW GRPO (3s) | Standard RL | 79.2 | 33.3 | 0.0% | |||
3B PW (3s) | Evolved PW | 79.2 | 35.4 | 1.2% | |||
3B PW (3s) | Empty PW | — | — | 0.0% | |||
3B PW (3s) | Random PW | — | — | 1.3% | |||
3B PW (3s) | Shuffled PW | — | — | 1.3% | |||
3B PW All (3s) | Evolved PW () | 81.7 | 34.2 | 6.5% | |||
3B PW All (3s) | Boost OFF () | — | — | 1.5% | |||
3B PW All (3s) | Empty PW | — | — | 0.0% | |||
3B PW All (3s) | Random PW () | — | — | 8.6% | |||
3B PW All (3s) | Shuffled PW () | — | — | 6.1% | |||
3B PW Upper (3s) | Evolved PW () | 68.3 | 35.4 | 1.4% | |||
3B PW Upper (3s) | Boost OFF () | — | — | 0.4% | |||
3B PW Upper (3s) | Random / Shuffled | / | / | / | — | — | 1.5% |
7B No-PW GRPO (s42) | Standard RL | 35.0 | 37.5 | 36.2 | 90.0 | 51.3 | 0.0% |
7B PW (s42) | Evolved PW (K<Kn><V>) | 28.1 | 40.0 | 34.1 | 80.0 | 50.0 | 1.2% |
7B PW (s42) | Empty / Random | 32.5 / 27.5 | 37.5 / 34.4 | 35.0 / 30.9 | — | — | 0.0 / 1.7% |
7B PW Up (s42) | Evolved PW (<M><L><C><V><K><N>) | 34.4 | 41.2 | 37.8 | 87.5 | 45.0 | 4.5% |
7B PW Up (s42) | Boost OFF () | 32.5 | 42.5 | 37.5 | 85.0 | 50.0 | 1.5% |
7B PW Up (s42) | Empty PW | 34.4 | 40.6 | 37.5 | 87.5 | 52.5 | 0.0% |
7B PW Up (s42) | Random PW () | 31.9 | 35.6 | 33.8 | 87.5 | 47.5 | 7.2% |
7B PW Up (s42) | Shuffled PW () | 33.1 | 36.2 | 34.7 | 82.5 | 48.8 | 5.6% |

PW All achieves the tightest variance ( ALL, OOD) and highest 3B mean OOD (), though mean accuracy over No-PW GRPO is statistically modest (). (b) Causal interventions demonstrate that is invariant to window content, whereas couples performance to window tokens.Table 2 and Figure 5 reveal four critical, nuanced findings that single-seed evaluation alone would have obscured:
1. Validation gating fixes pollution—and exposes the true headroom of static discrete PWs.
Removing raw percentage snapshots and adding the 24-task validation gate raised 3B PW from (v1) to (v2), tying No-PW GRPO (). Across 960 pooled 3B evaluations, 3B PW All achieved the highest mean overall accuracy (), highest mean OOD accuracy ( across all three seeds vs. No-PW and PW ), highest GSM8K accuracy ( vs. ), and lower cross-seed standard deviation ( vs. ). However, pooled two-proportion tests show the mean accuracy difference vs. No-PW GRPO is not statistically significant ( ALL; OOD), and Empty PW () matches Evolved PW () on average. When LoRA updates can directly adapt weights to stationary benchmarks whose underlying skills are already pretrained, a 32-token static prefix provides stabilization rather than a large mean ceiling jump.
2. Asymmetric (“double-edged”) causal coupling replicates across seeds and scales.
At (3B mean attention mass ), the model is completely invariant to window content: Evolved () Shuffled () Empty () Random (). At (attention mass , higher), causal sensitivity rises sharply: Random PW drops 3B ID accuracy by pp (), and in Seed 137 (SymbVerifLKNTLKTrd), Evolved PW () beats Boost-Off (), Random (), and Shuffled (). At 7B, PW reaches OOD (vs. No-PW, lifting Countdown ) while Random PW drops OOD to ( pp). Most notably, 7B PW Upper—which autonomously evolved the 13-token bracketed code <M><L><C><V><K><N>—achieves the highest overall ( vs. No-PW, ) and highest unseen OOD accuracy ( vs. No-PW) of any 7B arm, driven by a pp jump on unseen constraint scheduling (ood_csp: vs. No-PW, Empty, and under both Random and Shuffled PW, ).
3. Scale dependence of upper-layer boosting (, ). Interestingly, upper-layer boosting showed a clear scale split: at 3B, concentrating in significantly hurt Stage 2 v2 ( vs. , ) because two of three seeds stayed locked at empty PW () under the strict validation gate (while Seed 2026 still showed sharp causal coupling: Evolved vs. Boost-Off and Random/Shuffled). At 7B, however, the exact same upper-layer configuration () succeeded cleanly ( ALL, OOD), suggesting that larger models better exploit concentrated upper-layer attention boosts without destabilizing early parsing.
4. Spontaneous emergence of compressed non-English symbolic codes under .
Table 3 catalogs representative windows invented autonomously by the models across stages, seeds, and scales. Without any supervision on window syntax, zero-KL RL consistently compressed verbose strategies into ultra-dense symbolic shorthand: stripped-vowel pipe tokens (perf|prove|ltt|...|eqtn|stats), camel-case composite codes (SymbVerifLKNTLKTrd, SOLVEUNIDIST), and—at 7B scale—abstract bracketed single-letter tags (<M><L><C><V><K><N> and K<Kn><V>).
| Stage / Run | Model | Toks | Verbatim Evolved Privileged Window (pw_text) |
|---|---|---|---|
Stage 1 beta0 (Step 0) | 3B | 16 | +4 rush fee / kral(x,y): x+y+3; rush_fee(+3) (noisy) |
Stage 1 learnable_head | 3B | 23 | relk(a, b) = a - b + 3; wrim(x) = x + 3 ( compressed) |
Stage 1 beta2_k18 | 3B | 13 | miv(a, b) = 2a - 2b + 2 (drops * and all distractors) |
Stage 2 v1 beta2 (Step 45) | 3B | 32 | perf|prove|ltt|ltts|lt|cntdwn|ltt|stats|lt|rst|scrn|eqtn|stats |
Stage 2 v2 beta0 (s42) | 3B | 9 | verify logic steps, generalize patterns, reuse templates |
Stage 2 v2 beta2_all (s137) | 3B | 9 | SymbVerifLKNTLKTrd |
Stage 2 v2 beta2_all (s2026) | 3B | 5 | SOLVEUNIDIST |
Stage 2 v2 beta0 (s42) | 7B | 6 | K<Kn><V> |
Stage 2 v2 beta2.5_up (Step 25) | 7B | 16 | <CK><TK><PK><V><CK><TK><PK><V><W><C><T><P><N><S><CK><TK |
Stage 2 v2 beta2.5_up (Step 50) | 7B | 13 | <M><L><C><V><K><N> |
Discussion, Design Rules, and Limitations
Operating Taxonomy: When Privileged Windows and Work. Our two-stage study establishes a clear taxonomy of operating regimes. (1) Novel, non-memorizable cross-task invariants (Stage 1): when tasks share persistent latent structure absent from pretraining, RL-edited discrete PW yields transfer gains, strips distractors, and beats human-written prompts via writer–reader co-adaptation. (2) Explicit lookup vs. implicit priors: standard attention () already retrieves explicitly named rules up to 3.2k tokens, so adds lift there primarily under tight compression (, pp). On implicit, abstract cross-domain priors (Stage 2), allocates only attention mass and ignores the window, whereas forces higher attention, creating genuine causal coupling, cutting 3B cross-seed variance , and achieving top 7B ID/OOD accuracy (). (3) Weight-absorption limit: on stationary benchmarks where pretrained weights already encode core skills and LoRA adapters are trainable, weight adaptation absorbs most headroom ( vs. across 960 pooled 3B evals). We therefore predict the largest real-world wins for PW-PT in continual test-time adaptation with frozen weights (e.g., per-user/codebase memory) and very long contexts ( tokens) where softmax dilution is harsher.
Engineering Rules and Limitations.
Four design rules emerge directly from our ablations: (1) bootstrap write exploration (SFT warm-start or write-entropy bonus) to prevent 7B’s 92% <pw_keep/> cold-start collapse; (2) use slot-level additive edits (<pw_set slot=i>) rather than full-window overwrites to prevent high- keep-lock; (3) validation-gate persistent commits whenever , since forced attention magnifies pollution penalties; and (4) match boost placement to scale (moderate uniform at 3B; upper-layer at 7B). Key limitations include restricting evaluation to Qwen2.5 (1.5B/3B/7B) with LoRA () over 50–100 GRPO steps and contexts; cross-family transfer (Llama/Gemma), RoPE-decoupled memory keys, ultra-long horizons, and continuous-vs-discrete PW comparisons remain promising future directions.
Reproducibility and Ethics.
All code, procedural environment generators, exact random seeds, unit tests verifying KV-cache and gradient-checkpointing equivalence, and raw JSON logs for all 27 training runs are reproducible from open-weight models (Qwen2.5) and synthetic or public academic benchmarks (GSM8K); no human subjects or private data are involved.
References
- Bulatov, Aydar and Kuratov, Yuri and Burtsev, Mikhail S. (2022). Recurrent Memory Transformer. Advances in Neural Information Processing Systems (NeurIPS).
- Burtsev, Mikhail S. and Kuratov, Yuri and Peganov, Anton and Sapunov, Grigory V. (2020). Memory Transformer. arXiv preprint arXiv:2006.11527.
- Chevalier, Alexis and Wettig, Alexander and Ajith, Anirudh and Chen, Danqi (2023). Adapting Language Models to Compress Contexts. Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing (EMNLP).
- Cobbe, Karl and Kosaraju, Vineet and Bavarian, Mohammad and Chen, Mark and Jun, Heewoo and Kaiser, Łukasz and Plappert, Matthias and Tworek, Jerry and Hilton, Jacob and Nakano, Reiichiro and Hesse, Christopher and Schulman, John (2021). Training Verifiers to Solve Math Word Problems. arXiv preprint arXiv:2110.14168.
- Darcet, Timothée and Oquab, Maxime and Mairal, Julien and Bojanowski, Piotr (2024). Vision Transformers Need Registers. International Conference on Learning Representations (ICLR).
- DeepSeek-AI (2025). DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning. arXiv preprint arXiv:2501.12948.
- Goyal, Sachin and Ji, Ziwei and Rawat, Ankit Singh and Menon, Aditya Krishna and Kumar, Sanjiv and Nagarajan, Vaishnavh (2024). Think Before You Speak: Training Language Models With Pause Tokens. International Conference on Learning Representations (ICLR).
- Graves, Alex and Wayne, Greg and Danihelka, Ivo (2014). Neural Turing Machines. arXiv preprint arXiv:1410.5401.
- Hu, Edward J. and Shen, Yelong and Wallis, Phillip and Allen-Zhu, Zeyuan and Li, Yuanzhi and Wang, Shean and Wang, Lu and Chen, Weizhu (2022). LoRA: Low-Rank Adaptation of Large Language Models. International Conference on Learning Representations (ICLR).
- Lester, Brian and Al-Rfou, Rami and Constant, Noah (2021). The Power of Scale for Parameter-Efficient Prompt Tuning. Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing (EMNLP).
- Li, Xiang Lisa and Liang, Percy (2021). Prefix-Tuning: Optimizing Continuous Prompts for Generation. Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics (ACL).
- Liu, Nelson F. and Lin, Kevin and Hewitt, John and Paranjape, Ashwin and Bevilacqua, Michele and Petroni, Fabio and Liang, Percy (2024). Lost in the Middle: How Language Models Use Long Contexts. Transactions of the Association for Computational Linguistics (TACL).
- Mu, Jesse and Li, Xiang Lisa and Goodman, Noah (2023). Learning to Compress Prompts with Gist Tokens. Advances in Neural Information Processing Systems (NeurIPS).
- Packer, Charles and Wooders, Sarah and Lin, Kevin and Fang, Vivian and Patil, Shishir G. and Stoica, Ion and Gonzalez, Joseph E. (2023). MemGPT: Towards LLMs as Operating Systems. arXiv preprint arXiv:2310.08560.
- Qwen Team (2024). Qwen2.5 Technical Report. arXiv preprint arXiv:2412.15115.
- Shao, Zhihong and Wang, Peiyi and Zhu, Qihao and Xu, Runxin and Song, Junxiao and Bi, Xiao and Zhang, Haowei and Zhang, Mingchuan and Li, Y. K. and Wu, Y. and Guo, Daya (2024). DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models. arXiv preprint arXiv:2402.03300.
- Shinn, Noah and Cassano, Federico and Berman, Edward and Gopinath, Ashwin and Narasimhan, Karthik and Yao, Shunyu (2023). Reflexion: Language Agents with Verbal Reinforcement Learning. Advances in Neural Information Processing Systems.
- Sun, Mingjie and Chen, Xinlei and Kolter, J. Zico and Liu, Zhuang (2024). Massive Activations in Large Language Models. Conference on Language Modeling (COLM).
- Suzgun, Mirac and Yuksekgonul, Mert and Bianchi, Federico and Jurafsky, Dan and Zou, James (2025). Dynamic Cheatsheet: Test-Time Learning with Adaptive Memory. arXiv preprint arXiv:2504.07952.
- Vaswani, Ashish and Shazeer, Noam and Parmar, Niki and Uszkoreit, Jakob and Jones, Llion and Gomez, Aidan N. and Kaiser, Łukasz and Polosukhin, Illia (2017). Attention Is All You Need. Advances in Neural Information Processing Systems (NeurIPS).
- Xiao, Guangxuan and Tian, Yuandong and Chen, Beidi and Han, Song and Lewis, Mike (2024). Efficient Streaming Language Models with Attention Sinks. International Conference on Learning Representations (ICLR).
- Zhang, Qingru and Singh, Chandan and Liu, Liyuan and Liu, Xiaodong and Yu, Bin and Gao, Jianfeng and Zhao, Tuo (2024). Tell Your Model Where to Attend: Post-hoc Attention Steering for LLMs. International Conference on Learning Representations (ICLR).
Appendix
A. Implementation, Stage 0 Diagnostics, and Training Loop
KV-Cache Exactness and Gradient Checkpointing.
Our PWAttentionController wraps each decoder layer’s self_attn.forward under PyTorch SDPA (attn_implementation="sdpa"). When requires gradients (learnable modes), we switch strictly to SDPBackend.MATH during gradient-enabled passes because fused CUDA SDPA kernels do not backpropagate into additive attn_mask tensors. Both forward() and backward() execute inside ctrl.pw_context(pw_key_mask, task_query_start) so non-reentrant gradient checkpointing recomputes the exact same boosted mask. On Qwen2.5-1.5B-Instruct in FP32 CUDA with left-padded heterogeneous batches (including empty sequences), cached step-by-step decoding matches full-sequence forward() within at versus at .
| 0.0 | 1.0 | 2.0 | 3.0 | 4.0 | 6.0 | |
|---|---|---|---|---|---|---|
| Mean PW Attention Mass (%) | 3.70 | 7.45 | 13.46 | 22.72 | 34.71 | 62.02 |
| Zero-Shot Next-Token KL vs. (nats) | 0.000 | 0.093 | 0.419 | 1.268 | 3.459 | 3.590 |
Chat-Template Layout Discovery (Stage 0b).
Prepending an unseen <|im_start|>memory\n[PW]<|im_end|>\n turn before <|im_start|>system caused zero-shot Qwen2.5-1.5B and 3B to ignore the window ( oracle accuracy, emitting bare guessed integers without CoT). Placing <privileged_window> immediately inside the opening <|im_start|>system block—while restricting the PW key boost mask strictly to the raw PW content token IDs—restored immediate zero-shot parsing and raised Step-0 format compliance from to on 3B.
Algorithm 1: Privileged Window Post-Training (PW-PT) via Decoupled GRPO. Given pretrained LLM , LoRA adapters , boost config , token cap , and KL weights , for each step :
- Sample a batch of worlds/tasks and roll out trajectories per group under
pw_context(). - Parse
<answer>and verbatim token IDs inside<pw_write>...</pw_write>(capped at ) or<pw_keep/>. - Persist across subsequent turns (Stage 1) or validation-gate global commits on 24 disjoint tasks (Stage 2 v2).
- Compute immediate task rewards and downstream future transfer rewards .
- Group-normalize per-segment advantages (Eq. 3).
- Compute reference log-probs via
disable_adapter()at fixed . - Update using Eq. (4) with on (inside
pw_contextfor gradient checkpointing).
B. Stage 1 Detailed Breakdown and Long-Context Table
| Arm | PW Len | Sym % | (OOD) | All | Boost OFF | Oracle | |||
|---|---|---|---|---|---|---|---|---|---|
3B No-PW | 0.0 | 0.0 | 0.05 | 0.00 | 0.07 | 0.03 | 0.037 | — | — |
3B PW | 27.9 | 61.0 | 0.93 | 0.62 | 0.00 | 0.00 | 0.388 | 0.388 | 0.263 |
3B PW | 16.3 | 60.0 | 1.00 | 0.05 | 0.05 | 0.03 | 0.281 | 0.269 | 0.163 |
3B PW | 25.1 | 58.6 | 0.85 | 0.38 | 0.00 | 0.05 | 0.319 | 0.319 | 0.081 |
3B PW Learn | 27.2 | 59.2 | 0.95 | 0.57 | 0.00 | 0.03 | 0.388 | 0.388 | 0.231 |
3B PW | 17.1 | 60.8 | 0.93 | 0.12 | 0.07 | 0.12 | 0.312 | 0.256 | 0.056 |
| Arm | Short (281t) Acc (ON / OFF) | Short Attn % | Med (1,452t) Acc (ON / OFF) | Med Attn % | Long (3,209t) Acc (ON / OFF) | Long Attn % |
|---|---|---|---|---|---|---|
3B PW | 0.734 / — | 3.63 | 0.750 / — | 1.95 | 0.750 / — | 1.57 |
3B PW | 0.516 / 0.469 | 10.76 | 0.469 / 0.469 | 6.26 | 0.469 / 0.484 | 5.26 |
3B PW | 0.594 / 0.609 | 25.50 | 0.562 / 0.562 | 16.46 | 0.578 / 0.578 | 14.25 |
3B PW Learn | 0.781 / 0.766 | 11.42 | 0.766 / 0.781 | 7.84 | 0.750 / 0.766 | 7.04 |
3B PW | 0.516 / 0.469 | 13.54 | 0.516 / 0.453 | 8.93 | 0.469 / 0.469 | 7.71 |
C. Stage 2 v1 Pilot vs. Stage 2 v2 Per-Seed Results
| Arm (v1 Pilot, 60 steps) | Intervention | ID (80) | OOD (40) | ALL (120) | Attn % | PW Len |
|---|---|---|---|---|---|---|
s2_no_pw | Standard GRPO | 0.300 | 0.125 | 0.242 | 0.0 | 0 |
s2_pw_beta0 | Evolved / Empty / Rand / Shuf | 0.113 / 0.125 / 0.100 / 0.113 | 0.275 / 0.250 / 0.225 / 0.300 | 0.167 / 0.167 / 0.142 / 0.175 | 2.2 | 11 |
s2_pw_beta2 | Evolved () | 0.287 | 0.275 | 0.283 | 9.8 | 19 |
s2_pw_beta2 | Boost OFF () | 0.263 | 0.150 | 0.225 | 2.5 | 19 |
s2_pw_beta2 | Empty / Random / Shuffled | 0.263 / 0.075 / 0.087 | 0.200 / 0.200 / 0.025 | 0.242 / 0.117 / 0.067 | 0 / 14.1 / 14.4 | 19 |
s2_pw_learnable_head | Step 60 Eval (polluted) | 0.062 | 0.250 | 0.125 | 7.3 | 30 |
| Run | ID | OOD | ALL | OFF | Empty | Rand | Shuf | Evolved PW |
|---|---|---|---|---|---|---|---|---|
no_pw_s42 | 0.219 | 0.181 | 0.200 | — | — | — | — | "" |
no_pw_s137 | 0.237 | 0.263 | 0.250 | — | — | — | — | "" |
no_pw_s2026 | 0.312 | 0.256 | 0.284 | — | — | — | — | "" |
beta0_s42 | 0.237 | 0.237 | 0.237 | 0.237 | 0.222 | 0.234 | 0.231 | verify logic steps, generalize... |
beta0_s137 | 0.331 | 0.200 | 0.266 | 0.266 | 0.256 | 0.284 | 0.272 | unsolved prob; |
beta0_s2026 | 0.269 | 0.194 | 0.231 | 0.231 | 0.237 | 0.241 | 0.231 | ... |
beta2_all_s42 | 0.256 | 0.244 | 0.250 | 0.250 | 0.259 | 0.287 | 0.263 | Consistency Verify Prove... |
beta2_all_s137 | 0.263 | 0.244 | 0.253 | 0.219 | 0.266 | 0.212 | 0.200 | SymbVerifLKNTLKTrd |
beta2_all_s2026 | 0.231 | 0.244 | 0.237 | 0.256 | 0.216 | 0.172 | 0.237 | SOLVEUNIDIST |
beta2.5_up_s42 | 0.163 | 0.188 | 0.175 | 0.175 | 0.175 | 0.175 | 0.175 | "" (gate kept empty) |
beta2.5_up_s137 | 0.163 | 0.188 | 0.175 | 0.175 | 0.175 | 0.175 | 0.175 | "" (gate kept empty) |
beta2.5_up_s2026 | 0.200 | 0.200 | 0.200 | 0.147 | 0.181 | 0.138 | 0.138 | logic_knk code_t |
D. Hyperparameters and Compute Budget
All training runs used NVIDIA A100-80GB GPUs on Modal with bfloat16 weights, LoRA ( on all attention and MLP projections q,k,v,o,gate,up,down), AdamW (, weight decay on LoRA and on ), gradient clipping (clipped separately for LoRA and in Stage 2), and non-reentrant gradient checkpointing. Stage 1 used (3B) / (7B), , , , worlds rollouts/step, . Stage 2 v2 used (3B) / (7B), , , candidates 8 stratified tasks/step, edit temperature , task temperature , 50 steps. Total compute across all 27 training runs plus diagnostics and causal stress tests was approximately 19 A100-80GB GPU-hours ($48 on Modal).