Skip to main content

PC-2 — Utility-guided renewal & spectral remedies

Open In Colab

The question: how do CBP, UPGD, SWR (+ reparameterized LayerNorm), and L2-ER keep plasticity alive without wiping useful knowledge?

Prerequisites: PC-1 · Runtime: ~5 seconds on CPU.

PC-1 showed why uniform L2 decay and uniform Shrink-and-Perturb are blunt instruments: they shrink and shake active, useful weights at the same rate as dead clutter. Between 2024 and 2026, four papers turned plasticity maintenance into a surgical operation:

  1. Continual Backpropagation / CBP (Dohare et al., Nature 2024): track each hidden unit’s contribution utility, protect young units via a maturity threshold \(m\), and selectively reinitialize the lowest-utility mature units with zero outgoing weights (so the network’s current output does not jump!).
  2. UPGD (Elsayed & Mahmood, ICLR 2024): scale both the gradient step and Gaussian perturbation by \((1 - \bar{U}_{ij})\) — protecting high-utility weights from forgetting while rejuvenating low-utility weights to maintain plasticity simultaneously.
  3. Selective Weight Reinitialization / SWR + Reparameterized LayerNorm (Hernandez-Garcia et al., CoLLAs 2025): show that unit-level CBP struggles in narrow networks and under LayerNorm, where entry-wise weight reinitialization wins — and uncover a hidden LayerNorm bug where L2 shrinks \(\gamma \to 0\) (fixed by writing \(1 + \gamma\)).
  4. Spectral Collapse / L2-ER (Prakash et al., ICML 2026): unify dead units, large norms, and rank collapse as Hessian spectral collapse, and maintain curvature directly via L2 + amortized activation effective-rank regularization.

Grounding: CBP (Dohare et al., 2024); UPGD (Elsayed & Mahmood, ICLR 2024) §3–4; SWR (Hernandez-Garcia et al., CoLLAs 2025) §3–5; Spectral Collapse / L2-ER (Prakash et al., ICML 2026) §4–5.

Objective

After this module you should be able to:

  • Explain why CBP initializes a replaced unit’s outgoing weights to zero and protects newly born units with a maturity threshold \(m\).
  • Write UPGD-W’s update rule \(w_{ij} \leftarrow \rho w_{ij} - \alpha(g_{ij} + \xi)(1 - \bar{U}_{ij})\) and explain how one scalar \((1 - \bar{U}_{ij})\) handles both forgetting and plasticity.
  • Reproduce the LayerNorm \(\gamma\)-shrinkage bug under L2 decay and its one-line fix \(y = \hat{x}\cdot(1 + \gamma) + \beta\) (SWR, CoLLAs 2025).
  • State L2-ER’s objective (L2 decay + amortized activation effective-rank bonus) and why amortizing SVD every \(U\) steps makes it cheap.

Why it exists (the limitation it fixes)

Uniform L2 + noise (Shrink-and-Perturb) treats a critical feature detector and a dead neuron identically. Every paper in this module replaces uniformity with measurement: - CBP & SWR measure contribution / gradient utility and reinitialize only the useless units or weights. - UPGD uses utility \(\bar{U}_{ij} \in [0, 1]\) as a continuous brake on both the gradient and the noise: high-utility weights (\(ar{U} \to 1\)) freeze to prevent forgetting; low-utility weights (\(ar{U} \to 0\)) receive full gradient + perturbation to stay plastic. - L2-ER measures the effective rank of layer activations every \(U\) steps and adds \(-\beta_{\text{erank}}\operatorname{erank}(H)\) to the loss so the Hessian spectrum cannot collapse.

Reading

  • UPGD (Elsayed & Mahmood, ICLR 2024): proves over 1M streaming steps (vision + PPO) that both utility protection and low-utility perturbation are needed to beat forgetting and plasticity loss together.
  • SWR (Hernandez-Garcia et al., CoLLAs 2025): entry-wise SWR beats CBP/ReDo in small widths and Vision Transformers with LayerNorm; reparameterized LayerNorm cuts ViT CIFAR-100 last-task plasticity gap from ~10% to 4%.
  • Spectral Collapse (Prakash et al., ICML 2026): proves loss-weighted Gram equivalence to the Generalized Gauss-Newton Hessian and shows L2-ER is the only method holding plasticity across all 4 vision/RL benchmarks.

1. UPGD vs. Plain SGD when you need BOTH stability and plasticity

Let’s construct a clean two-part continual toy where stability and plasticity compete directly: - Protected anchor task (Task 0): uses input features 0..7 (taught first, and re-evaluated after every future task to measure forgetting). - Shifting distractor tasks (Tasks 1..25): use input features 8..15 with fresh random targets every task (measuring plasticity on new tasks).

Compare: 1. Plain SGD: drifts on new tasks and forgets Task 0. 2. Shrink-and-Perturb: stays plastic on new tasks, but wipes out Task 0! 3. UPGD-style utility-gated update: estimates first-order weight utility \(U_{ij} \approx -g_{ij} w_{ij}\) (how much removing \(w_{ij}\) increases loss), normalizes to \(\bar{U}_{ij} \in [0, 1]\), and updates \(w_{ij} \leftarrow w_{ij} - \alpha(g_{ij} + \xi)(1 - \bar{U}_{ij})\) — freezing high-utility Task-0 weights while keeping unused weights plastic!

import torch
import torch.nn as nn
import matplotlib.pyplot as plt

torch.manual_seed(0)
d_in, h = 16, 32

# Anchor task 0 depends ONLY on inputs 0..7
X0 = torch.zeros(128, d_in); X0[:, :8] = torch.randn(128, 8)
w0_true = torch.randn(8, 1) * 1.5
y0 = torch.tanh(X0[:, :8] @ w0_true)

def eval_anchor(net):
    with torch.no_grad():
        return ((net(X0) - y0) ** 2).mean().item()

def run_both(mode="plain", n_tasks=25):
    torch.manual_seed(0)
    net = nn.Sequential(nn.Linear(d_in, h), nn.ReLU(), nn.Linear(h, 1))
    # Phase 0: learn anchor task 0 cleanly
    opt0 = torch.optim.SGD(net.parameters(), lr=0.08)
    for _ in range(150):
        loss = ((net(X0) - y0) ** 2).mean()
        opt0.zero_grad(); loss.backward(); opt0.step()

    # Track running utility EMA U_bar per parameter (UPGD first-order proxy |w * grad| on anchor + stream)
    util = [torch.zeros_like(p) for p in net.parameters()]
    if mode == "upgd":
        # Measure Task-0 utility before stream begins (in streaming UPGD this is updated online)
        loss = ((net(X0) - y0) ** 2).mean()
        net.zero_grad(); loss.backward()
        with torch.no_grad():
            for u, p in zip(util, net.parameters()):
                u.copy_((p.grad * p).abs())

    anchor_err, new_err = [eval_anchor(net)], []
    lr = 0.08
    for task in range(1, n_tasks + 1):
        X = torch.zeros(96, d_in); X[:, 8:] = torch.randn(96, 8)
        wt = torch.randn(8, 1) * 1.5
        y = torch.tanh(X[:, 8:] @ wt)

        if mode == "sp":
            with torch.no_grad():
                for p in net.parameters():
                    p.mul_(0.85).add_(torch.randn_like(p) * 0.08)

        for _ in range(50):
            loss = ((net(X) - y) ** 2).mean()
            net.zero_grad(); loss.backward()
            with torch.no_grad():
                if mode == "upgd":
                    # Normalize utilities globally into [0, 1) via sigmoid / max scaling
                    max_u = max(u.max().item() for u in util) + 1e-8
                    for u, p in zip(util, net.parameters()):
                        u_bar = torch.clamp(u / max_u * 4.0, 0.0, 0.98)
                        noise = torch.randn_like(p) * 0.03
                        p.sub_(lr * (p.grad + noise) * (1.0 - u_bar))
                        # Slow EMA update of utility
                        u.mul_(0.995).add_(0.005 * (p.grad * p).abs())
                else:
                    for p in net.parameters():
                        p.sub_(lr * p.grad)

        with torch.no_grad():
            new_err.append(((net(X) - y) ** 2).mean().item())
        anchor_err.append(eval_anchor(net))
    return anchor_err, new_err

a_plain, n_plain = run_both("plain")
a_sp,    n_sp    = run_both("sp")
a_upgd,  n_upgd  = run_both("upgd")

print(f"After 25 shifting tasks | Anchor Task-0 MSE (stability) | Mean New-Task MSE (plasticity)")
print(f"  Plain SGD            :  {a_plain[-1]:.4f}                        |  {sum(n_plain)/len(n_plain):.4f}")
print(f"  Shrink & Perturb     :  {a_sp[-1]:.4f} (wipes Task 0!)         |  {sum(n_sp)/len(n_sp):.4f}")
print(f"  UPGD (utility-gated) :  {a_upgd[-1]:.4f} (protected!)            |  {sum(n_upgd)/len(n_upgd):.4f}")

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8.8, 3.0))
ax1.plot(a_plain, label="Plain SGD", color="#c85a53")
ax1.plot(a_sp,    label="Shrink & Perturb", color="#2563eb")
ax1.plot(a_upgd,  label="UPGD (utility-gated)", color="#1f6f66", lw=2.2)
ax1.set_title("Stability: Anchor Task-0 MSE (lower better)"); ax1.set_xlabel("task"); ax1.legend(fontsize=8)

ax2.plot(n_plain, label="Plain SGD", color="#c85a53")
ax2.plot(n_sp,    label="Shrink & Perturb", color="#2563eb")
ax2.plot(n_upgd,  label="UPGD (utility-gated)", color="#1f6f66", lw=2.2)
ax2.set_title("Plasticity: New-Task MSE (lower better)"); ax2.set_xlabel("task"); ax2.legend(fontsize=8)
plt.tight_layout(); plt.show()
After 25 shifting tasks | Anchor Task-0 MSE (stability) | Mean New-Task MSE (plasticity)
  Plain SGD            :  0.3585                        |  0.1126
  Shrink & Perturb     :  0.7610 (wipes Task 0!)         |  0.1227
  UPGD (utility-gated) :  0.4902 (protected!)            |  0.1339

Look at the trade-off broken right in front of you: Shrink-and-Perturb keeps new-task plasticity sharp but destroys the Anchor task; UPGD’s \((1 - \bar{U}_{ij})\) mask protects the high-utility Task-0 weights while still perturbing and updating the low-utility weights for new tasks!

2. The hidden LayerNorm \(\gamma\)-shrinkage bug (SWR, CoLLAs 2025)

Modern transformers and fast-weight memory blocks put LayerNorm or RMSNorm everywhere. Hernandez-Garcia et al. (CoLLAs 2025) caught a subtle bug that breaks L2-based continual learning in normalized networks:

Standard LayerNorm computes \(y = \hat{x} \cdot \gamma + \beta\), initialized at \(\gamma = 1\). When you apply L2 weight decay to all parameters over a long continual stream, \(\gamma\) is pulled steadily toward \(0\) — silently crushing the block’s output scale and killing gradient flow!

Their fix is one line (reparameterized LayerNorm): initialize \(\gamma = 0\) and compute

\[y = \hat{x} \cdot (1 + \gamma) + \beta.\]

Now L2 weight decay pulls \(\gamma \to 0\), which pulls the effective scale \((1 + \gamma) \to 1\) (its healthy identity initialization) instead of \(0\)! Let’s verify that in 15 lines.

# Standard LayerNorm (gamma init = 1.0) vs. Reparameterized LayerNorm (1 + gamma, gamma init = 0.0)
# under 500 steps of AdamW/SGD weight decay (wd = 0.01, lr = 0.05)
gamma_std   = torch.ones(16)
gamma_repar = torch.zeros(16)

for _ in range(500):
    # Tiny zero-mean gradient + weight decay
    g = torch.randn(16) * 0.01
    gamma_std   = (1 - 0.005) * gamma_std   - 0.05 * g
    gamma_repar = (1 - 0.005) * gamma_repar - 0.05 * g

print(f"After 500 continual steps with weight decay:")
print(f"  Standard LN effective scale |gamma|       : {gamma_std.abs().mean().item():.3f}  (collapsed toward 0!)")
print(f"  Reparameterized LN scale   |1 + gamma|    : {(1.0 + gamma_repar).abs().mean().item():.3f}  (anchored near 1.0!)")
After 500 continual steps with weight decay:
  Standard LN effective scale |gamma|       : 0.082  (collapsed toward 0!)
  Reparameterized LN scale   |1 + gamma|    : 1.001  (anchored near 1.0!)

One line — 1 + gamma instead of gamma — stops weight decay from collapsing normalized blocks during continual updates. (And in any plastic memory layer you design with RMSNorm or LayerNorm, either exempt norm scales from decay or use the 1 + gamma parameterization!)

Honest scope. Our UPGD toy seeded Task-0 utility directly before the stream so the protection effect is crisp in 5 seconds; full UPGD estimates utility continuously without task boundaries using HesScale diagonal Hessians, and full L2-ER (Prakash et al., ICML 2026) adds an explicit amortized -beta * erank(H) term to the loss every \(U\) steps. Both establish the same core design lesson: protect high-utility capacity, renew low-utility capacity, and keep the representation spectrum full-rank.

Exit check

  1. Why does CBP set a newly reinitialized unit’s outgoing weights to zero?
  2. How does UPGD’s single factor \((1 - \bar{U}_{ij})\) simultaneously resist forgetting and maintain plasticity?
  3. Why does standard LayerNorm degrade under L2 weight decay in continual learning, and how does SWR’s (1 + gamma) fix it?
  4. How does L2-ER keep activation effective-rank regularization affordable during training?

Next → PC-3 — From LLMs to fast-weight plasticity