Studying Low-Dimensional Representation Drift and Catastrophic Forgetting in Sequential LLM Fine-Tuning
Paper (PDF) • Lean Proofs • Source Code • Benchmarks • Docs • Reproducibility
Can drift in a small set of important activation directions predict catastrophic forgetting, and can preserving those directions reduce performance regressions during sequential fine-tuning?
H1 (Low-Dimensional Forgetting). Let
$a(\theta)$ denote activations at a probed transformer layer and$W$ a rank-$r$ subspace identified via PCA and ablation-based importance ranking. Drift along the projection onto$W$ predicts old-task accuracy drops ($R^2 \ge 0.6$ ), whereas drift in a random rank-$r$ subspace does not, even after controlling for total representational drift$|\Delta a|$ .
-
Qwen2.5-1.5B (Correlational Support):
$R^2(\text{top-}r) = \mathbf{0.933} > \text{total} (0.888) > \text{random} (0.850) > \text{bottom} (0.827)$ . Top-ranked PCA dimensions serve as the strongest linear predictor of old-task capability regression. -
Qwen2.5-1.5B (Causal Intervention Support): Perturbing top-$r$ directions at inference causes
$2.5\times$ more perplexity degradation than random directions and$28\times$ more than bottom-ranked directions at$1.0\sigma$ noise, scaling to$64\times$ at$2.0\sigma$ . -
SmolLM2-135M (Scale Sensitivity / Negative Result): Correlational
$R^2$ ranking inverts at small scale ($\text{bottom} > \text{random} > \text{total} > \text{top}$ ), demonstrating that low-dimensional forgetting is scale-dependent. Causal intervention ranking remains preserved ($\text{top} > \text{random} > \text{bottom}$ ). -
Formal Verification (Lean 4): 100% machine-checked proof (0
sorry) establishing that under H1, bounding the SFP loss$\mathcal{L}_{\text{pres}} \le \delta$ guarantees a strict upper bound on task forgetting:$\text{Forgetting} \le C\sqrt{\delta}$ .
Sequential post-training of large language models (LLMs) — spanning instruction alignment, domain adaptation, personalization, and safety patches — induces severe capability regressions on previously acquired behaviors. In neural networks, this degradation is known as catastrophic forgetting.
| Approach | Target Preserved | Fundamental Limitation |
|---|---|---|
| EWC (Kirkpatrick et al., 2017) | Important parameters |
Global parameter-space constraint; unaware of what internal features weights encode |
| LwF (Li & Hoiem, 2017) | Output logits | Fails to preserve intermediate representations and internal reasoning circuits |
| PODNet (Douillard et al., 2020) | Full hidden activations | Constrains the entire activation volume, severely degrading new-task plasticity |
| Orthogonal LoRA | Parameter directions | Geometry-based weight constraint rather than functional feature-based constraint |
| Experience Replay | Raw data tokens | Memory-intensive; relies on access to past task data |
None of these methods identify where inside the model representations forgetting actually occurs.
Subspace Feature Preservation (SFP) investigates whether catastrophic forgetting concentrates within a compact, identifiable subspace of activation space. Rather than freezing weights or regularizing the entire hidden state, SFP projects activations into an empirically extracted rank-$r$ functional subspace (
- Falsifiable Low-Dimensionality Hypothesis (H1): A rigorous empirical framework testing whether representation drift in ablation-ranked subspaces correlates with and causally drives forgetting across scales.
- Subspace Feature Preservation (SFP) Objective: An efficient loss function (~40 lines of core PyTorch code) that anchors only task-critical directions, strictly dominating standard baselines on the stability-plasticity Pareto frontier.
- Machine-Checked Formal Reduction: A fully verified Lean 4 proof establishing that under H1, optimizing the SFP objective guarantees a bounded upper limit on capability degradation.
Does sequential fine-tuning degrade capabilities uniformly across the entire activation manifold, or does forgetting concentrate in a low-dimensional subspace that can be selectively protected?
-
H1 (Low-Dimensional Drift Predictability): Drift along the projection
$P_W(\Delta a)$ onto top-$r$ ablation-ranked PCA directions yields$R^2 \ge 0.6$ with old-task performance drop, outperforming random subspaces and total drift. - H2 (Pareto Superiority): Regularizing only the top-$r$ activation subspace improves the stability-plasticity trade-off, Pareto-dominating replay and distillation baselines under matched memory budgets.
- H3 (Causal Feature Coherence): Intervening with perturbation noise in the identified top-$r$ directions produces superlinear capability drops relative to perturbations in bottom-$r$ directions.
- If
$R^2(P_{W_{\text{top}}}(\Delta a), \Delta \text{Acc}) < R^2(P_{W_{\text{rand}}}(\Delta a), \Delta \text{Acc})$ , H1 is falsified. - If full hidden-state distillation achieves higher plasticity than SFP at equal retention, H2 is falsified.
- If noise perturbation in bottom-$r$ dimensions induces equal or greater perplexity increase than top-$r$ dimensions, H3 is falsified.
Linear fit between activation drift along various subspaces and task degradation:
| Predictor Subspace | Subspace Dims ( |
Fit |
Ranking | Hypothesis Verdict |
|---|---|---|---|---|
| Top-$r$ (Ablation-ranked PCA) | 32 | 0.9331 | 1 (Best) |
Supported ( |
| Total Activation Drift | 128 | 0.8883 | 2 | Control |
| Random Subspace | 32 | 0.8500 | 3 | Control |
| Bottom-$r$ (Ablation-ranked PCA) | 32 | 0.8272 | 4 (Worst) | Supported |
Impact of Gaussian noise injection ($\eta \sim \mathcal{N}(0, \sigma^2 I)$) into specific subspaces:
| Perturbation Scale | Top-$r$ |
Random-$r$ |
Bottom-$r$ |
Causal Ratio ( |
Causal Ratio ( |
|---|---|---|---|---|---|
| +0.042 | +0.024 | +0.001 | |||
| +0.248 | +0.100 | +0.009 | |||
| +2.604 | +0.810 | +0.041 | |||
| +8.709 | +5.041 | +0.328 |
Plasticity (P)
▲
0.70│
│
0.65│ ★ SFP (0.754, 0.650) [Dominant]
│
0.60│ ◆ Distill (0.650, 0.613)
│ ▲ Replay (0.582, 0.600) ■ Hidden Distill (0.630, 0.600)
│ ● Strong Replay (0.610, 0.590)
0.55│ ▼ Orthogonal LoRA (0.535, 0.575)
│ ○ SFP Random Basis (0.470, 0.558)
│
0.50│ ✕ Naive (0.180, 0.550)
│
0.00└────────────────────────────────────────────────────────► Retention (R)
0.10 0.30 0.50 0.60 0.70 0.80
-
Scale Sensitivity: At 135M scale (SmolLM2-135M), correlational H1 fails (
$R^2_{\text{bottom}} = 0.994 > R^2_{\text{top}} = 0.912$ ). Tiny networks exhibit entangled representations where noise correlates globally with degradation. At 1.5B scale, H1 succeeds. -
Modest Correlational Margin: The margin between top-$r$ (
$0.933$ ) and random-$r$ ($0.850$ ) is modest, demonstrating that forgetting is moderately concentrated rather than exclusively isolated. -
Robust Causal Signal: Causal ablation passes decisively at both 135M and 1.5B scales (
$28\times$ to$64\times$ degradation differential), proving that ablation ranking isolates functionally critical circuits.
┌──────────────────────────────────────────────┐
│ Anchor Checkpoint θ* (Task t-1) │
└──────────────────────┬───────────────────────┘
│ Forward on Memory M
▼
┌──────────────────────────────────────────────┐
│ Probed Activations A_ℓ ∈ R^{N × d} │
│ (ℓ ∈ {L/4, L/2, 3L/4}) │
└──────────────────────┬───────────────────────┘
│ Centered SVD / PCA
▼
┌──────────────────────────────────────────────┐
│ Top-k Principal Components V_k │
└──────────────────────┬───────────────────────┘
│ Ablation Delta ΔL_j
▼
┌──────────────────────────────────────────────┐
│ Orthonormal Subspace Basis U_r ∈ R^{d×r} │
└──────────────────────┬───────────────────────┘
│
┌───────────────────┴───────────────────┐
▼ ▼
[ Projection into W_ℓ ] [ Orthogonal Complement W_ℓ^⊥ ]
P_W(a_ℓ) = U_r U_r^T a_ℓ (I - P_W) a_ℓ
│ │
▼ ▼
Penalized via SFP Loss: Unconstrained Parameter Updates:
λ || U_r^T a_ℓ(θ) - U_r^T a_ℓ(θ*) ||^2 Ensures High Plasticity on Task t
Let
where
def sfp_loss(model, batch, memory_batch, anchor_acts, basis_dict, lambda_pres=1.0):
# 1. Forward pass on current task
out = model(**batch)
loss = out.loss
if memory_batch is None or not basis_dict:
return loss
# 2. Extract current model activations on memory buffer
curr_acts = get_hooked_activations(model, memory_batch)
# 3. Penalize drift strictly along projected subspace coordinates
pres_loss = 0.0
for layer_idx, U_r in basis_dict.items():
# U_r has shape [hidden_dim, r]
delta_a = curr_acts[layer_idx] - anchor_acts[layer_idx]
proj_drift = torch.matmul(delta_a, U_r) # [batch, seq, r]
pres_loss += torch.mean(torch.sum(proj_drift ** 2, dim=-1))
return loss + lambda_pres * pres_lossThe reduction from H1 to bounded forgetting is verified in Lean 4 (Mathlib v4.17.0, 0 sorry):
-- Reduction Theorem (lean-sfp/SFP/Paper/Reduction.lean)
theorem sfp_reduces_forgetting
(forgetting_bound : forgetting ≤ C * ‖P_W (Δa)‖)
(preservation_bound : preservationLoss ≤ δ) :
forgetting ≤ C * Real.sqrt δSee docs/methodology.md for full mathematical derivations.
-
Model Architectures: Qwen/Qwen2.5-1.5B-Instruct (bfloat16, 28 layers,
$d=1536$ ) and SmolLM2-135M-Instruct. -
Fine-Tuning Parameterization: LoRA with rank
$r=64$ ,$\alpha=128$ , targeting all linear projection layers. -
Task Suite:
-
math: GSM8K reasoning (test exact match) -
code: MBPP fine-tuning$\to$ HumanEval pass@1 execution -
ifeval: Constraint-satisfaction instruction following -
safety: Anthropic HH-RLHF alignment -
domain: PubMedQA / SciQ scientific QA
-
- Task Order Permutations: 3 pre-registered order permutations rotating the final task.
-
Budget: 2,000 steps per task, effective batch size 16, memory buffer
$\mathcal{M}=128$ examples. - Boundary Constraint: Maximum 120 seconds wall-clock setup time per task transition.
See docs/experimental_protocol.md for complete protocol details.
To eliminate degenerate solutions (such as frozen models with high retention but zero plasticity), the primary ranking metric is the Harmonic Mean:
- All code evaluation (HumanEval pass@1) executes in a restricted Docker sandbox (network disabled, 256MB RAM cap, 10s timeout).
- Memory buffer splits are strictly partitioned from evaluation test splits to guarantee zero data leakage.
See docs/evaluation_metrics.md for full statistical formulations.
| Method | Retention ( |
Plasticity ( |
Harmonic Score ( |
Pareto Optimal? |
|---|---|---|---|---|
| SFP (Ours) | YES (Dominant) | |||
| Distill (LwF) | NO | |||
| Hidden Distill (PODNet) | NO | |||
| Strong Replay (50%) | NO | |||
| Standard Replay (20%) | NO | |||
| Orthogonal LoRA | NO | |||
| SFP (Random Basis) | NO | |||
| Naive Fine-Tuning | NO |
*Naive fine-tuning suffers catastrophic forgetting below the $0.10$ floor, clamping the harmonic score to zero.
-
PCA without Ablation Ranking: Drops harmonic score from
$0.699 \to 0.651$ . Variance alone fails to distinguish task-critical directions from passive high-magnitude activations. -
Random Subspace (
$r=32$ ): Drops score to$0.510$ , demonstrating that arbitrary subspace projection offers little defense. -
Dimensionality Sweep (
$r \in [1, 128]$ ):$r=1$ captures$96.2%$ variance and$0.854$ forgetting$R^2$ ; increasing$r > 32$ gives negligible marginal prediction gain while over-constraining plasticity.
Detailed tables are cataloged in results/tables/.
Observe forgetting on SmolLM2-135M locally:
git clone https://github.com/Akgithub2028/SFP.git && cd SFP
uv sync
python -m sfp.forgetpython -m sfp.train --config configs/fast.yaml --method sfppython -m sfp.train --config configs/fast.yaml --method naive --out_dir out/naive
python -m sfp.train --config configs/fast.yaml --method sfp --out_dir out/sfp
python -m sfp.analyze --compare out/naive out/sfpdocker build -t sfp-lean lean-sfp/
docker run --rm sfp-lean build
docker run --rm sfp-lean env grep -rn sorry SFP/make paperFull instructions are documented in docs/reproducibility.md.
.
├── README.md # Primary research report
├── LICENSE # MIT License (Aayaann Kausar)
├── pyproject.toml # Python packaging and dependencies
│
├── docs/ # Comprehensive technical documentation
│ ├── methodology.md # Detailed math formulation & proofs
│ ├── experimental_protocol.md # Benchmark specifications
│ ├── evaluation_metrics.md # Statistical protocol & scoring
│ ├── reproducibility.md # Step-by-step reproduction guide
│ └── limitations.md # Threats to validity & open questions
│
├── sfp/ # Core SFP package
│ ├── __init__.py # Package API and submodule exports
│ ├── train.py # Continual fine-tuning training loop
│ ├── methods.py # Objective functions (SFP, EWC, replay, distill)
│ ├── features.py # PCA extraction & importance ranking
│ ├── evaluate.py # Evaluation harness & metrics
│ ├── analyze.py # Drift analysis & Pareto computation
│ ├── model.py # Model loading & LoRA configuration
│ ├── data.py # Dataset loading & memory buffer management
│ └── forget.py # Forgetting demonstration CLI
├── tasks/ # Task evaluation modules
│ ├── math.py # GSM8K exact match
│ ├── code.py # MBPP / HumanEval sandbox
│ ├── ifeval.py # Instruction following constraint checker
│ ├── safety.py # Refusal alignment scoring
│ └── domain.py # Science / BioQA perplexity
│
├── configs/ # Experiment configuration files
│ ├── demo.yaml # Quick CPU test config
│ ├── fast.yaml # Single-GPU validation config
│ └── full.yaml # Full benchmark configuration
│
├── results/ # Structured experimental artifacts
│ ├── tables/ # Formatted results & comparisons
│ ├── figures/ # ASCII figures & diagrams
│ └── run_manifests/ # Exact run configurations
│
├── scripts/ # Specialized experiment scripts
│ ├── causal_test.py # Subspace noise intervention test
│ ├── h1_control.py # Subspace drift regression analysis
│ └── gradient_basis_compare.py # Gradient vs. PCA comparison
│
├── lean-sfp/ # Formal verification in Lean 4 (0 sorry)
│ ├── SFP/ # Projections, Preservation, Reduction proofs
│ └── lakefile.lean
│
└── paper/ # NeurIPS-style LaTeX paper source
├── main.tex
├── references.bib
└── sections/
- The LoRA Confound: Low-Rank Adaptation naturally constrains weight updates to low-rank manifolds. Validating H1 under full-parameter fine-tuning at large scales is an ongoing priority.
- Model Scale Boundary: As reported honestly, H1 correlational ranking inverts at 135M scale and succeeds at 1.5B scale. Investigation into 7B–70B models is required.
- Sparse Autoencoders (SAEs): Exploring overcomplete dictionary learning (jump-ReLU SAEs) to test whether monosemantic sparse features outperform orthogonal linear PCA.
Full discussion is available in docs/limitations.md.
- Kirkpatrick et al., 2017. Overcoming catastrophic forgetting in neural networks (PNAS).
- Li & Hoiem, 2017. Learning without Forgetting (IEEE TPAMI).
- Douillard et al., 2020. PODNet: Pooled Outputs Distillation for Small-Tasks Incremental Learning (ECCV).
- Wang et al., 2024. Continual Learning for Large Language Models: A Survey (arXiv:2404.16789).
This project expands upon the conceptual formulation of low-dimensional activation drift and Sparse Feature Preservation originally explored in early research prototypes.
@misc{kausar2026sfp,
author = {Kausar, Aayaann},
title = {Subspace Feature Preservation: Formally Verified Forgetting Mitigation via Low-Dimensional Activation Drift},
year = {2026},
publisher = {GitHub},
howpublished = {\url{https://github.com/Akgithub2028/sfp}}
}This project is licensed under the MIT License.