SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2605.20296 · 2026

Spectral Unforgetting: Post-Hoc Recovery of Damaged Capabilities Without Retraining

Aarash Abro, Muhammad Tahir

arXiv · PDF · Open in the Atlas

Code that ran

9 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 3 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 6 failures of our instrument; 1 no recorded run), measured 2026-11-22; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2605.20296.json · badge: /api/ran/2605.20296.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
BrickleRex/dghard community
Papers with Code archive
9 ran · 1 no recorded run
FunctionStatusWhere it lives
_compute_deltas Ran
ran; our contract draft was wrong, not the code
BrickleRex/dghard/dghard/repair/dg_hard.py
code served (permissive licence) · get_code("0dc3919b12724614")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create two state dicts with tensors
# base_sd: the baseline model weights
base_sd = {
    "layer1.weight": torch.randn(4, 3),
    "layer1.bias": torch.randn(4),
    "layer2.weight": torch.randn(5, 4),
}

# ft_sd: fine-tuned model weights
ft_sd = {
    "layer1.weight": torch.randn(4, 3),
    "layer1.bias": torch.randn(4),
    "layer2.weight": torch.randn(5, 4),
}

# eps: threshold for skipping near-zero deltas
eps = 1e-08

ARGS = {
    "base_sd": base_sd,
    "ft_sd": ft_sd,
    "eps": eps,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
_dg_hard_shrink_batch Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
BrickleRex/dghard/dghard/repair/dg_hard.py
code served (permissive licence) · get_code("e3e0a7657eb33954")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import math

torch.manual_seed(0)

# Create test tensors
# S: singular values tensor, shape (batch, n_features)
# sigma_eff: effective noise level tensor, shape (batch,)
S = torch.randn(2, 4)  # batch=2, n_features=4
sigma_eff = torch.abs(torch.randn(2)) + 0.1  # batch=2, ensure positive

m = 5  # number of rows (larger dimension)
n = 3  # number of columns (smaller dimension)
scale = 1.5

ARGS = {
    'S': S,
    'sigma_eff': sigma_eff,
    'm': m,
    'n': n,
    'scale': scale
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
_sigma_hat_dg_batch Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
BrickleRex/dghard/dghard/repair/dg_hard.py
code served (permissive licence) · get_code("be03b9b860271a8c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 1, dtype family float, shape (2,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import math

torch.manual_seed(0)

# Small singular values tensor: batch_size=2, n_features=4
# We need S to be a 2D tensor where we can take median along dim=-1
S = torch.tensor([
    [3.5, 2.8, 1.9, 0.5],
    [4.2, 3.1, 2.3, 0.7]
], dtype=torch.float32)

# m and n for the aspect ratio calculation
m = 3
n = 5

ARGS = {
    'S': S,
    'm': m,
    'n': n
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 1, dtype family float, shape (2,) — shape (2,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
_sigma_hat_ours_batch Ran
ran, honoured the contract we drafted
BrickleRex/dghard/dghard/repair/dg_hard.py
code served (permissive licence) · get_code("a28002a12a235b53")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 1, dtype family float, shape (2,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# S is a tensor that will be indexed and have operations performed on it
# The function accesses S.shape[-1], indexes S[..., -n_tail:], calls .mean(dim=-1)
# So S needs to be at least 1D, and should have a meaningful last dimension
# Let's make a 2D tensor (batch, features) with small sizes
S = torch.randn(2, 4)

ARGS = {
    "S": S
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 1, dtype family float, shape (2,) — shape (2,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
dg_hard_shrink Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
BrickleRex/dghard/dghard/repair/dg_hard.py
code served (permissive licence) · get_code("9ced83614bd103c8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 1, dtype family float, shape (4,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import math

torch.manual_seed(0)

# S is a torch.Tensor of singular values
# The function uses it with torch.where and torch.zeros_like
# Create a small tensor of singular values
S = torch.tensor([5.0, 3.0, 1.5, 0.8], dtype=torch.float32)

# sigma_eff is a float representing effective noise level
sigma_eff = 0.5

# m is an int representing one dimension
m = 3

# n is an int representing another dimension
n = 4

# scale is an optional float parameter (defaults to 1.0)
scale = 1.0

ARGS = {
    "S": S,
    "sigma_eff": sigma_eff,
    "m": m,
    "n": n,
    "scale": scale
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 1, dtype family float, shape (4,) — shape (4,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
dg_omega Ran
ran, honoured the contract we drafted
BrickleRex/dghard/dghard/repair/dg_hard.py
code served (permissive licence) · get_code("31512bd50deec21d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import math

def dg_omega(beta: float) -> float:
    """DG hard-threshold aspect coefficient (Gavish-Donoho 2014, eq. 1.1).

    ``ω(β) = √(2(β+1) + 8β / ((β+1) + √(β² + 14β + 1)))``.
    At β=1 this reduces to ``4/√3 ≈ 2.309`` — the eponymous constant.
    """
    return math.sqrt(2.0 * (beta + 1.0) + 8.0 * beta / (beta + 1.0 + math.sqrt(beta * beta + 14.0 * beta + 1.0)))

ARGS = {
    "beta": 1.0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
mp_singular_median Ran
ran, honoured the contract we drafted
BrickleRex/dghard/dghard/repair/dg_hard.py
code served (permissive licence) · get_code("d59c7ded5c646650")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import math
from functools import lru_cache
import numpy as np

@lru_cache(maxsize=1024)
def mp_singular_median(beta: float, n_grid: int=200000) -> float:
    """Median of the Marchenko-Pastur singular-value distribution at aspect β.

    The MP eigenvalue density on ``[β_-, β_+]`` with ``β_± = (1 ∓ √β)²`` is

        f(λ) = √((β_+ − λ)(λ − β_-)) / (2π β λ).

    We compute the median ``λ_med`` of this density via fine-grid trapezoidal
    integration of the CDF + linear interpolation at CDF=0.5, then return
    ``√λ_med`` — the median in singular-value space, i.e. the ``μ_β`` that
    appears in the DG σ̂ formula. ``beta`` must be in (0, 1].
    """
    if not 0.0 < beta <= 1.0:
        raise ValueError(f'beta must be in (0, 1], got {beta}')
    sqrt_b = math.sqrt(beta)
    lam_minus = (1.0 - sqrt_b) ** 2
    lam_plus = (1.0 + sqrt_b) ** 2
    lam = np.linspace(lam_minus, lam_plus, n_grid + 1)
    radicand = np.maximum((lam_plus - lam) * (lam - lam_minus), 0.0)
    safe_lam = np.where(lam > 0, lam, 1.0)
    f = np.sqrt(radicand) / (2.0 * math.pi * beta * safe_lam)
    f[lam <= 0] = 0.0
    dx = (lam_plus - lam_minus) / n_grid
    cdf = np.concatenate([[0.0], np.cumsum(0.5 * (f[:-1] + f[1:]) * dx)])
    cdf = cdf / cdf[-1]
    idx = int(np.searchsorted(cdf, 0.5))
    if idx <= 0:
        med_eig = lam_minus
    elif idx >= len(cdf):
        med_eig = lam_plus
    else:
        c0, c1 = (float(cdf[idx - 1]), float(cdf[idx]))
        l0, l1 = (float(lam[idx - 1]), float(lam[idx]))
        med_eig = l0 + (0.5 - c0) * (l1 - l0) / max(c1 - c0, 1e-300)
    return math.sqrt(med_eig)


ARGS = {
    "beta": 0.5,
    "n_grid": 1000
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
sigma_hat_dg Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
BrickleRex/dghard/dghard/repair/dg_hard.py
code served (permissive licence) · get_code("22373b7862723a7f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import math

torch.manual_seed(0)

# Construct a small singular value tensor
# S is used with torch.median(S).item(), so it needs to be a 1D tensor of singular values
S = torch.tensor([0.5, 1.2, 1.8, 2.3], dtype=torch.float32)

# m and n are used to compute beta = min(m,n) / max(m,n)
# They represent matrix dimensions
m = 5
n = 10

ARGS = {
    "S": S,
    "m": m,
    "n": n,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
sigma_hat_ours Ran
ran; our contract draft was wrong, not the code
BrickleRex/dghard/dghard/repair/dg_hard.py
code served (permissive licence) · get_code("ba7eeb93bfb0e628")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# S is a torch.Tensor of singular values
# The function accesses len(S), indexes S[-n_tail:], calls .float(), .mean(), and .item()
# So S should be a 1D tensor of floats representing singular values in sorted order
S = torch.tensor([0.5, 0.4, 0.3, 0.2, 0.15, 0.1, 0.08, 0.05], dtype=torch.float32)

# n_tail_frac is a float between 0 and 1, default 0.25
n_tail_frac = 0.25

ARGS = {
    "S": S,
    "n_tail_frac": n_tail_frac,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
DgHardRepair Not yet run
unverified (harvested, no recorded run)
BrickleRex/dghard/dghard/repair/dg_hard.py
code served (permissive licence) · get_code("b2ed3fabfcfc87cf")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 10 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Fine-tuning a language model for a target task routinely degrades capabilities the training data never explicitly threatened. We study this phenomenon, known as catastrophic forgetting, and propose a post-hoc repair solution that uses only the pretrained checkpoint W base and its fine-tuned descendant W ft . The goal is not merely to revert the model toward the base checkpoint, but to recover capabilities damaged by fine-tuning while preserving both the target-task gains and any beneficial held-out improvements. We introduce DG-Hard, a checkpointonly spectral repair method for the fine-tuning update ∆ = W ft -W base . DG-Hard treats ∆ as a low-rank task-aligned signal embedded in an IID-like noise residual that gradient descent has no incentive to remove, and applies the Donoho-Gavish hard singular-value threshold to each weight-delta matrix, keeping the structured high-energy part of the update and removing the spectral bulk. This reduces repair to a closed-form SVD filtering step requiring no data-dependent tuning. A central difficulty is evaluation: average accuracy hides per-benchmark failures, while naive recovery scores reward models that simply revert toward the base. We therefore introduce a partition-conditional metric that separately tracks healing, preservation, non-damage, and target-task retention. Across 14 (model, task) settings and nine cross-domain held-out benchmarks, DG-Hard achieves the strongest balanced repair among post-hoc baselines. DG-Hard also restores safety alignment degraded by benign fine-tuning on three independent safety axes, despite using no alignment data. These results suggest that part of fine-tuninginduced capability loss is not an unavoidable consequence of specialization, but a removable spectral residue in the weight update itself. The code can be found at: https://github.com/BrickleRex/dghard.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2605.20296")
get_code_for_paper("2605.20296")
have("2605.20296")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2605.20296.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2605.20296.svg)](https://syntology.ai/paper/2605.20296)

Connect an agent — have() is free.