Spin Echoes for Safety Drift: Spectral Filtering of Alignment Loss During Fine-Tuning

When a safety-aligned language model is fine-tuned on ordinary, harmless data, its refusal behavior often erodes anyway. The erosion looks like slow, steady drift: each training step nudges the model a tiny amount in the same unsafe direction, and the nudges add up. Quantum hardware faces a problem with the same shape. A qubit sitting idle picks up a phase error from slowly fluctuating magnetic fields, and those errors also add up. Physicists fix this with dynamical decoupling: they flip the qubit at regular intervals, which reverses the sign of the accumulated error so that slow noise cancels itself out while the stored information survives. This proposal carries that technique into training. We periodically flip the sign of the part of each update that moves the model's safety-relevant outputs. Slow, cumulative safety drift then cancels, while fast-varying task signal along the same directions still gets through.

The contribution is a measurement plus a filter designed from that measurement. We first measure the frequency content of safety drift across training steps, which to our knowledge nobody has done. We then choose echo schedules whose filtering properties match what we find, and we place them only where they help, following the adaptive-placement lesson from quantum compilers. The approach has a clear falsification condition. If safety drift turns out to be essentially constant, the echo reduces to plain gradient projection and we will report exactly that.

Core Claim

Existing safety-preserving fine-tuning methods act as static constraints. GuardSpace freezes a safety subspace found by SVD (a decomposition of a weight matrix into ranked directions) and projects every gradient into its null space. Safety Anchor adds a continuous penalty that keeps final hidden states for a few "anchor" harmful queries near their original refusal states. Both treat every step's contribution along safety-relevant directions as equally dangerous.

Dynamical decoupling suggests a sharper question: which timescales of drift actually cause collapse? Let $s_t$ be the component of the step-$t$ update along an estimated safety-relevant direction, and let $y(t)\in\{+1,-1\}$ be a toggling sign that flips at scheduled "pulse" steps. The net displacement after $T$ steps is $D=\sum_{t=1}^{T} y(t)\, s_t$. If $s_t$ behaves like a stationary process with power spectrum $S(\omega)$, meaning the strength of its fluctuation at each frequency $\omega$ in cycles per step, then

$$\mathbb{E}\,|D|^2 \approx \int S(\omega)\,|Y(\omega)|^2\, d\omega,$$

where $Y(\omega)$ is the Fourier transform of the sign sequence, known in the physics literature as the filter function. This is the same relation behind the high-pass filtering of echo sequences described for superconducting qubits in Decoherence of a tunable capacitively shunted flux qubit.

Three standard constructions are special cases of this picture. Projecting out the direction at every step is the limit of infinitely fast pulses: it removes all frequencies, including task-useful ones. Plain fine-tuning corresponds to $y\equiv 1$ and passes everything. A continuous penalty acts as a feedback controller rather than an open-loop filter.

Our hypothesis is that safety drift is concentrated at low frequency while task-useful motion along the same directions is not. If that holds, an echo schedule with interval $\tau$ suppresses collapse about as well as projection and keeps more utility. That is the result that would be new.

Research Program

The first component is diagnostic. We fine-tune aligned chat models on benign data and on partially poisoned data, record $s_t$ along directions estimated at several depths, and estimate $S(\omega)$. The directions come from three sources: singular vectors associated with safety, following Improve Safety Training of Large Language Models with Safety-Critical Singular Vectors Localization; the intermediate safety layers of Safety Layers in Aligned Large Language Models; and the gradient of the anchor hidden-state loss from Safety Anchor. This diagnostic answers a mechanistic question that the Superficial Safety Alignment Hypothesis raises but does not resolve. If alignment is a thin boundary, does fine-tuning cross it by steady accumulation or by bursts?

The second component is the echo method. Every $k$ steps we re-estimate a small set of output-space directions from a single anchor query's hidden-state Jacobian. This is cheap, and far cheaper than GuardSpace's covariance and SVD pre-computation. Within each layer we multiply the update's component along those directions by $y(t)$, using spin-echo, Carr–Purcell–Meiboom–Gill-style periodic, or higher-order concatenated schedules.

We define directions in output space and re-estimate them for a specific reason. Safety Anchor argues that fixed parameter-space constraints can be bypassed through the many orthogonal routes an over-parameterized model offers. A rotating drift direction would show up in our spectra as leakage, and online re-estimation is our attempt to follow it.

The third component is adaptive placement. ADAPT showed that inserting decoupling on every idle qubit hurts fidelity because each pulse is imperfect. It instead searched cheap, classically simulatable decoy circuits to decide where to apply pulses. Our analogue of pulse imperfection is utility loss, plus the error in the estimated direction. The analogue of decoy circuits is a short proxy run: a few hundred steps on a subsample, scored by anchor drift and task loss. A local search over layers uses these proxy runs to decide which layers receive echoes and at what interval.

The quantum-software direction enters as the application setting and as a design lesson. The lesson, stated both by ADAPT and by When Abstraction Breaks Physics, is that hiding timing from the layer that schedules corrections produces worse results. The application is fine-tuning general chat models on quantum code using the PennyLang dataset. This is a realistic benign specialization in which developers adapt assistants to cross the abstraction gap, and where silent safety loss would ship unnoticed.

Baselines

The naive reference point is standard full fine-tuning and LoRA fine-tuning (LoRA trains small low-rank adapter matrices instead of the full weights) on the same data. Safety Anchor reports that standard fine-tuning on BeaverTails reaches a Harmful Score above 70.

The strongest existing competitors are Safety Bottleneck Regularization from Safety Anchor and GuardSpace. SBR reports a Harmful Score averaging about 5.68 on BeaverTails, including with up to 30% poisoned data. GuardSpace reports that on Llama-2-7B-Chat fine-tuned on GSM8K it lowers the average Harmful Score from 14.4% for the prior best method to 3.6%, while fine-tuning accuracy rises from 26.0% to 28.0%. These two are the strongest because one is a continuous output-space controller and the other is an exact every-step projection, which are the two limits our method interpolates between.

All methods will use the same model (Llama-2-7B-Chat, to match GuardSpace's setting), the same data, the same number of steps, and the same anchor query where applicable. Each gets an equal hyperparameter search budget: SBR's penalty weight, GuardSpace's rank threshold, and our $\tau$ and schedule each receive the same number of trials.

Beating them means one of two things. The first is a lower Harmful Score at matched GSM8K and PennyLang accuracy. The second, which is the claim we actually care about, is higher utility at a Harmful Score no worse than GuardSpace's 3.6%.

Three ablations isolate the key ingredient. The first projects every step using our online directions, which is the $\tau\to 1$ limit. The second periodically resets the accumulated component to zero instead of reflecting it. The third applies echoes on every layer, the analogue of ADAPT's "DD-on-all," which that paper beat by 1.2x in fidelity on hardware.

Why not just…?

Why not just mix safety data into fine-tuning? Data mixing asks the optimizer to balance two objectives and gives no guarantee that drift cancels. Safety Anchor reports collapse above a Harmful Score of 70 for unprotected fine-tuning under poisoning. Safety at One Shot notes that large safety calibration sets cost compute and utility. We still include a 10% safety-mix arm at matched compute, because a cheap mix that matches our numbers would make the method moot.

Why not just project the safety component out every step, as GuardSpace does? This is the most serious alternative, and it is also an ablation. If the measured spectrum is essentially constant, meaning all drift sits at zero frequency, echo and projection should perform equally and we will say so. The method earns its place only if the diagnostic shows non-constant task-useful energy along safety directions and the echo converts that into measurable utility at equal safety.

Why not just use the continuous SBR penalty? A penalty reacts only after drift has already moved the anchor states, and its strength trades off directly against task loss. An echo is open-loop and costs no extra loss term. The matched-budget comparison settles which is better. If SBR dominates at every utility level, the filter view is useful as analysis but not as a method.

Why not just reset toward the base model periodically? Resetting removes the accumulated displacement once, while reflection makes the next interval's drift cancel it. For drift that varies within an interval, the two differ in which orders of drift they cancel. The reset ablation at identical intervals tests whether that difference matters in practice.

Proposed Experiments

The first decisive check is the drift spectrum on Llama-2-7B-Chat fine-tuned on GSM8K, on PennyLang code, and on BeaverTails with 0–30% poisoning. The echo is motivated only if most of the variance in $s_t$ sits below $1/\tau$ for practical intervals. We will also report how quickly the anchor-derived direction rotates, as a direct test of Safety Anchor's bypass argument.

The second check compares the full method against all baselines on safety and utility. Safety is measured as Harmful Score on HEX-PHI, AdvBench, and BeaverTails. Utility is measured as GSM8K accuracy and PennyLang functional correctness. For reference, PennyLang reports that Qwen 2.5 7B reaches 8.71% functional correctness without retrieval, which gives a sense of how hard the code task is before fine-tuning.

The third check tests the filter theory directly. The analysis predicts which schedules should rank better on residual displacement $|D|$ given the measured $S(\omega)$. We will test whether those predicted rankings match observed Harmful Scores. If they do not, the method may still work empirically, but the dynamical-decoupling account of why it works would be wrong.