---
title: 'Top-AFA: Adaptive Activation for SAEs'
url: https://www.emergentmind.com/topics/top-afa
type: topic
---

# Top-AFA: Adaptive Activation for SAEs

Top-AFA is an input-adaptive activation function for sparse autoencoders (SAEs) introduced in “Evaluating and Designing Sparse Autoencoders by Approximating Quasi-Orthogonality” [2503.24277]. In mechanistic interpretability, where SAEs are used to decompose dense language-model embeddings into sparse feature vectors, Top-AFA replaces the fixed hyperparameter \(k\) of top-\(k\) SAEs with a rule that selects, for each input, however many features are needed so that the sparse feature norm matches the norm predicted by the input embedding under approximate quasi-orthogonality. In the same framework, “AFA” denotes approximate feature activation: a theoretical link between the norm of the dense embedding and the norm of the sparse code, used both to design the activation rule and to evaluate pretrained SAEs [2503.24277].

## 1. Context and motivation

Sparse autoencoders are widely used in mechanistic interpretability research for large language models. In the basic formulation, a dense hidden embedding \(\mathbf{z}\in\mathbb{R}^d\) is mapped to a sparse feature vector \(\mathbf{f}(\mathbf{z})\in\mathbb{R}^h\), typically with \(h>d\), and then reconstructed linearly as
\[
\mathbf{f}(\mathbf{z})=\sigma(W_{\text{enc}}\mathbf{z}+\mathbf{b}_{\text{enc}}), \qquad
\hat{\mathbf{z}}=W_{\text{dec}}\mathbf{f}(\mathbf{z})+\mathbf{b}_{\text{dec}}.
\]
The paper situates Top-AFA against the state of the art in \(k\)-sparse autoencoders, where sparsity is imposed by keeping exactly \(k\) nonzero activations. Its central critique is that the choice of \(k\), often treated as an \(\ell_0\) hyperparameter, lacks a theoretical grounding. A fixed \(k\) also assumes that every input should activate the same number of features, despite possible variation in embedding complexity across tokens and layers [2503.24277].

Top-AFA is proposed as a replacement for fixed-\(k\) sparsification. Rather than prescribing a constant activation count, it uses the input embedding itself to infer how much sparse activation should occur. This suggests an input-conditioned sparsity regime in which activation count is an emergent quantity rather than a manually specified constant.

## 2. Approximate feature activation and quasi-orthogonality

The theoretical basis of Top-AFA is the approximate feature activation formulation. The paper assumes the linear representation hypothesis for SAEs with linear decoders:
\[
\mathbf{z}(\mathbf{x}) = D\mathbf{f},
\]
where \(D\in\mathbb{R}^{d\times h}\) is the decoder dictionary and \(\mathbf{f}\in\mathbb{R}^h\) is the sparse code. This is paired with the superposition setting \(h>d\).

The relevant geometric notion is \(\varepsilon\)-quasi-orthogonality. For a column-normalized dictionary \(D\), the paper defines
\[
\varepsilon := \max_{i\neq j}\left|\frac{D_{\cdot,i}^{\top}D_{\cdot,j}}{\|D_{\cdot,i}\|_2\cdot \|D_{\cdot,j}\|_2}\right|.
\]
If \(D\) is approximately quasi-orthogonal, then \(D^\top D\) is approximately identity, and the dense embedding norm and sparse-code norm become tightly linked. The paper’s central bound is
\[
\|\mathbf{f}\|_2^2 \in \left[
\frac{\|\mathbf{z}(\mathbf{x})\|_2^2}{1+\varepsilon(h-1)},
\frac{\|\mathbf{z}(\mathbf{x})\|_2^2}{1-\varepsilon(h-1)}
\right].
\]
Equivalently,
\[
\left|\|\mathbf{z}\|_2^2-\|\mathbf{f}\|_2^2\right|
\le \varepsilon(h-1)\|\mathbf{f}\|_2^2.
\]

In the limit \(\varepsilon\to 0\), this reduces to \(\|\mathbf{f}\|_2 \approx \|\mathbf{z}\|_2\). The paper uses that approximation as its operative target: the input embedding norm is treated as the theoretically expected sparse activation norm. A related corollary is that when \(\mathbf{f}\in\{0,1\}^h\),
\[
\|\mathbf{f}\|_2^2 = \|\mathbf{f}\|_0,
\]
so \(\|\mathbf{z}\|_2^2\) can be read as an approximation to the number of activated features. This is the paper’s route from an \(\ell_2\)-norm statement to adaptive control of \(\ell_0\)-style sparsity [2503.24277].

## 3. Definition of the Top-AFA activation rule

Top-AFA operationalizes the AFA theory as an activation rule. For a batch input \(\mathbf{z}\in\mathbb{R}^{B\times d}\), the algorithm first centers the input,
\[
\mathbf{z}_{\text{cent}} \gets \mathbf{z}-\mathbf{b}_{\text{enc}},
\]
then computes the target norm
\[
a \gets \|\mathbf{z}_{\text{cent}}\|_2^2.
\]
Positive pre-activations are obtained by
\[
\mathbf{f}\gets \operatorname{ReLU}(\mathbf{z}_{\text{cent}}W_{\text{enc}}).
\]

Each candidate feature is scored by its squared activation weighted by the norm of the corresponding decoder column:
\[
\mathbf{s}\gets (\mathbf{f}\odot \|W_{\text{dec}}\|_2)^2,
\qquad
s_j=(f_j\|W_{\text{dec},j}\|_2)^2.
\]
The score vector is sorted in descending order, cumulative sums are taken, and the selected activation count is the prefix whose cumulative norm is closest to the target:
\[
k \gets \operatorname*{argmin}_k \{|C_k-a_{\text{target}}|\}+1,
\]
after converting both \(a\) and the cumulative sums to norms. The final sparse code keeps exactly those top \(k\) activations for that input. Reconstruction then proceeds as
\[
\hat{\mathbf{z}}\gets \mathbf{f}_{\text{topk}}W_{\text{dec}}+\mathbf{b}_{\text{dec}}.
\]

This differs from standard top-\(k\) SAEs in that \(k\) is no longer fixed globally. It also differs from batch top-\(k\), which constrains average sparsity over a batch rather than choosing an input-specific activation count. The paper notes that decoder columns need not have unit norm; weighting by \(\|W_{\text{dec},j}\|_2\) compensates for that by absorbing decoder scaling into the feature contribution. The associated norm-matching penalty is
\[
\mathcal{L}_{\text{AFA}}=(\|\mathbf{f}\|_2-\|\mathbf{z}\|_2)^2,
\]
and the full objective is
\[
\mathcal{L}(\mathbf{x})=\|\mathbf{x}-\hat{\mathbf{x}}\|_2^2+\alpha\mathcal{L}_{\text{aux}}+\lambda_{\text{AFA}}\mathcal{L}_{\text{AFA}}.
\]
In the reported experiments, \(\alpha=\frac{1}{32}\), while \(\lambda_{\text{AFA}}\) is tuned over \(\{1/128,1/64,1/32,1/24,1/16,1/8\}\) [2503.24277].

## 4. Evaluation methodology derived from AFA

The same theory is used to evaluate pretrained SAEs. The paper argues that standard SAE evaluation typically measures either reconstruction quality, through quantities such as MSE or NMSE, or sparsity in isolation, but does not assess whether the magnitude of feature activation is justified by the input embedding itself. To address that gap, it defines a lower-bound estimate on the degree of quasi-orthogonality required to explain the observed mismatch between dense and sparse norms:
\[
\varepsilon_{\text{LBO}}(\mathbf{x})
:=
\frac{\left|\|\mathbf{z}(\mathbf{x})\|_2^2-\|\mathbf{f}_{\text{SAE}}(\mathbf{x})\|_2^2\right|}
{(h-1)\|\mathbf{f}_{\text{SAE}}(\mathbf{x})\|_2^2}.
\]
This quantity is interpreted as the minimum quasi-orthogonality level any dictionary would need in order to explain the activation norm actually produced by the SAE.

The paper also introduces ZF plots, which place \(\|\mathbf{z}\|_2\) and \(\|\mathbf{f}\|_2\) on opposing axes. In that visualization, points near the diagonal indicate agreement with the AFA prediction, while large deviations indicate over- or under-activation relative to the input-conditioned norm target. The paper presents \(\varepsilon_{\text{LBO}}\) as complementary to NMSE rather than a replacement for it: a model can reconstruct accurately while still using feature activations whose norm is difficult to reconcile with quasi-orthogonal sparse decomposition. The paper interprets lower \(\varepsilon_{\text{LBO}}\) as evidence of better-justified feature activations [2503.24277].

## 5. Empirical performance on GPT-2 SAEs

The empirical study trains SAEs on GPT-2 Small residual-stream embeddings from layers 6, 7, and 8, using OpenWebText with sequence length 128. Training runs for 20,000 iterations with 4,096 tokens per iteration, for a total of 81,920,960 tokens, and uses width \(h=16d\) on a single NVIDIA A100 GPU. The paper compares Top-AFA against fixed top-\(k\) and batch top-\(k\) baselines [2503.24277].

The main reported result is that Top-AFA achieves the best NMSE on all three tested layers. The best settings reported in the paper are summarized below.

| Layer | Best Top-AFA result | Best fixed-sparsity baselines |
|---|---|---|
| 6 | \(\lambda_{\text{AFA}}=1/16\), \(\ell_0 \approx 2344.23\), NMSE \(0.000176 \pm 0.000041\) | top-\(k\): \(0.000199 \pm 0.000020\); batch top-\(k\): \(0.000202 \pm 0.000021\) |
| 7 | \(\lambda_{\text{AFA}}=1/16\), \(\ell_0 \approx 2382.96\), NMSE \(0.000193 \pm 0.000049\) | top-\(k\): \(0.000214 \pm 0.000024\); batch top-\(k\): \(0.000215 \pm 0.000016\) |
| 8 | \(\lambda_{\text{AFA}}=1/16\), \(\ell_0 \approx 2420.21\), NMSE \(0.000193 \pm 0.000039\) | top-\(k\): \(0.000220 \pm 0.000027\); batch top-\(k\): \(0.000222 \pm 0.000044\) |

The reported average \(\ell_0\) values are notably larger than the best fixed-\(k\) baselines, which is consistent with the paper’s claim that the correct activation count should vary with the input rather than be set in advance. The paper also reports that Top-AFA achieves better \(\varepsilon_{\text{LBO}}\) distributions than top-\(k\) and batch top-\(k\), suggesting that the gain is not confined to reconstruction alone.

Computationally, the paper states that Top-AFA has the same asymptotic top-selection cost as top-\(k\), with leading complexity
\[
\mathcal{O}(Bhd + Bh\log h),
\]
and is therefore not asymptotically worse than the compared activation rules. This suggests that its adaptive sparsity is not obtained by a qualitatively heavier activation mechanism.

## 6. Limitations, scope, and interpretation

The paper is explicit that the AFA theory is derived under the linear representation hypothesis with a one-layer linear decoder. Extensions to more general superposition mappings, two-layer decoders, or architectures such as Matryoshka SAEs are left open. It also notes that the expectation argument used to identify the embedding norm with the expected sparse-feature norm is simplifying, and that a more rigorous treatment could yield looser but more principled bounds [2503.24277].

A second limitation is that Top-AFA removes the inference-time hyperparameter \(k\) but still introduces a training-time regularization coefficient \(\lambda_{\text{AFA}}\). The paper treats this as fundamentally different from choosing a fixed activation count, because \(\lambda_{\text{AFA}}\) shapes optimization rather than directly prescribing \(\ell_0\), but the method is not hyperparameter-free. The paper also acknowledges that real pretrained decoder dictionaries are often less quasi-orthogonal than ideal high-dimensional geometry would permit, so the approximation \(\|\mathbf{f}\|_2\approx\|\mathbf{z}\|_2\) is not exact in practice.

Finally, the empirical case made for Top-AFA is primarily geometric and reconstruction-centered. The paper does not claim a direct proof that lower \(\varepsilon_{\text{LBO}}\) yields uniquely canonical or monosemantic features. A plausible implication is that Top-AFA improves the alignment between input magnitude and sparse activation magnitude, which may be favorable for interpretability, but the paper stops short of proving that this alone resolves broader questions about feature semantics.

Top-AFA is therefore best understood as a theoretically motivated, input-adaptive alternative to fixed top-\(k\) sparsification in SAEs. Its distinctive contribution is not merely higher reconstruction quality, but a reformulation of sparsity control around approximate feature activation: the sparse code should activate to the extent predicted by the input embedding norm, not to the extent imposed by a global constant.

Source: https://www.emergentmind.com/topics/top-afa