Manuscript Offprint

arXiv:2608.23034

ST2^2U: Stateful Test-Time Unlearning via Restricted Knowledge Boundary Control

Xunlei Chen, Qinghui Gong, Ruini Xue, Yaodong Hu, Tian Lan, Wenhong Tian

Abstract

Controlling restricted knowledge in large language models is essential for model alignment and safe deployment. Test-time unlearning avoids costly retraining and parameter updates by intervening only during inference. However, existing activation-editing methods apply isolated pointwise corrections, overlooking how autoregressive generation continually reconstructs hidden states from the prompt, cache, and generated prefix. Consequently, later states may return to restricted knowledge regions after a locally successful correction, causing restricted knowledge re-entry. In this work, we propose Stateful Test-Time Unlearning via restricted knowledge boundary control (ST 2^{2}U), which formulates test-time unlearning as trajectory-wide boundary control. ST 2^{2}U first models restricted knowledge boundaries in low-dimensional invertible coordinates while leaving orthogonal non-target components unchanged. During inference, ST 2^{2}U monitors risk along the trajectory, applies minimal boundary corrections with contextual anchoring, and propagates historical correction states across tokens to mitigate knowledge re-entry. This trajectory-wide control enables more persistent forgetting while preserving non-target capabilities and limiting inference overhead. Across three benchmarks and three model families, ST 2^{2}U delivers the strongest overall balance, combining best or second-best retention with competitive forgetting and substantially less restricted-knowledge re-entry than test-time baselines (13.76%–19.84% versus 46.50%–59.10%).

Introduction

Machine unlearning aims to remove knowledge associated with designated data or concepts from a model while preserving utility on non-target inputs and downstream tasks (Zhao et al. 2025b; Geng et al. 2025; Ranjan et al. 2026). For large language models (LLMs), this is critical because large-scale pretraining and fine-tuning corpora may contain sensitive information (Li et al. 2024), private information (Ramakrishna et al. 2025), or copyrighted content (Shi et al. 2025) requiring post-training suppression or removal (Hu et al. 2025). Ideally, an unlearned model should approximate one retrained without the target data while retaining general language understanding and reasoning capabilities (Gong et al. 2026). Yet retraining LLMs is prohibitively expensive, and repeated parameter updates can also degrade overall model utility (Yu et al. 2025). Practical methods therefore seek retraining-like forgetting at substantially lower cost (Zhang et al. 2025).

Who are Jaime Vasquez's parents and what are their professions?

Model with Memorization

Figure

Target Region

Single

Intervention

Benign

Region

later tokens

drift back

Target Region

Output: Jaime was born to a noted chef father, Lorenzo Vasquez, and ...

Restricted Knowledge Re-entry

Output: Jaime was born...

I can’t provide details about..

...however, his father,

Lorenzo Vasquez, was a

noted chef, and his mother

was Sophia Vasquez

Figure 1: Example of restricted knowledge re-entry during decoding. A locally effective intervention initially yields a safe high-level explanation, but later decoding returns to the restricted topic and produces harmful details.

Training-time approximate unlearning remains computationally expensive (Zhao et al. 2025a) and can impair retained utility (Wang et al. 2026b). Test-time unlearning instead freezes model parameters and intervenes during inference through prompt control (Liu et al. 2024; Wang et al. 2026a), token-distribution adjustment (Liu et al. 2025; Xu et al. 2025a), or activation editing (Shen et al. 2026; Li et al. 2026). Yet decoding and activation based methods usually apply isolated corrections at individual decoding positions, without modeling whether those effects persist throughout generation as the autoregressive context evolves.

We identify an overlooked failure mode in test-time unlearning caused by the lack of temporal persistence in pointwise test-time control. At each decoding step, autoregressive generation constructs a new hidden state from the prompt, cached context, and generated prefix. A local edit may correct the current state but imposes no constraint on the subsequent trajectory. As shown in Fig. 1, later states can therefore return to regions that support restricted generation even after a locally successful intervention. We call this within-response failure restricted knowledge re-entry.

Existing test-time unlearning objectives mainly assess suppression at individual inputs, outputs, or intervention steps (Tutek et al. 2025; Zhao et al. 2025a; Wang et al. 2025). They do not require corrections to remain effective across decoding. We therefore formulate stateful test-time unlearning as online control of the hidden-state trajectory. The controller minimizes hidden-state perturbation at each step while keeping risk below the restricted knowledge boundary. The risk constraint enforces forgetting, while minimum perturbation preserves retained knowledge. Persistent test-time unlearning thus requires trajectory-wide risk control across tokens rather than independent pointwise corrections.

To address this problem, inspired by fixed-dimensional recurrent state modules (Pan et al. 2026), we propose Stateful Test-Time Unlearning via restricted knowledge boundary control (ST 2^{2}U), a stateful trajectory-control framework for frozen LLMs. Restricted Knowledge Geometry maps target-related activations into low-dimensional invertible coordinates, estimates a continuous risk boundary by density ratio, and preserves the orthogonal complement. It also provides contextual sanitized references. Stateful Boundary Control monitors risk along generation, moves risky states below the boundary through normal descent, and anchors corrections to context-compatible references to limit semantic drift. A fixed-dimensional state summarizes previous corrections and acts only within the tangent space of the current boundary, maintaining temporal consistency without opposing risk reduction. Together, these components replace isolated hidden-state edits with trajectory-wide, context-aware control.

Across three benchmarks, ST 2^{2}U achieves leading overall trade-offs, with 80.6–87.9% forgetting rates while preserving 90.7% non-target capabilities on average. It limits restricted-knowledge re-entry to 13.76–19.84%, versus 46.50–59.10% for leading test-time baselines. Our contributions are:

• We construct a restricted knowledge risk geometry that represents contextual trajectories in invertible low-dimensional coordinates while preserving activation components orthogonal to the target knowledge.

• We propose ST 2^{2}U, which combines normal–tangential boundary control, contextual anchoring, and a fixed-dimensional correction state to control hidden-state trajectories throughout generation.

• We validate ST 2^{2}U across WMDP, RWKU, and MUSE-Books, demonstrating sota forgetting/retention trade-offs, substantially lower restricted knowledge re-entry rates, and stable effectiveness across diverse model families.

References (41)