Trained as one half of a controlled cross-paradigm comparison against
legible-weights/sae-gpt2-small-l6-v0.1
— a matched-scale SAE on GPT-2 small trained on the same corpus. The two
SAEs differ only in the base model's training objective (causal
autoregressive vs. discrete masked diffusion).
MSE differs from the GPT-2 counterpart (0.85) because MDLM activations have
~2× the magnitude. EV is scale-normalized and comparable.
55 % of these features have a GPT-2 SAE counterpart at activation
correlation r > 0.30 (median 0.33, max 0.99), despite median decoder cosine
of −0.002. Top-correlated pairs are closed-class function-word features
(
which,
the,
but, …) that fire on identical contexts across both
models. Full writeup, methodology, and reproducible pipeline:
github.com/legibleweights/diffusion-vs-ar-saes
1import torch
2from huggingface_hub import hf_hub_download
3from safetensors.torch import load_file
4
5class TopKSAE(torch.nn.Module):
6 def __init__(self, d_in=768, d_hidden=12288, k=32):
7 super().__init__()
8 self.k = k
9 self.encoder = torch.nn.Linear(d_in, d_hidden, bias=True)
10 self.decoder = torch.nn.Linear(d_hidden, d_in, bias=False)
11 self.pre_bias = torch.nn.Parameter(torch.zeros(d_in))
12
13 def forward(self, x):
14 pre = self.encoder(x - self.pre_bias)
15 vals, idx = pre.topk(self.k, dim=-1)
16 vals = torch.relu(vals)
17 acts = torch.zeros_like(pre)
18 acts.scatter_(-1, idx, vals)
19 return self.decoder(acts) + self.pre_bias, acts
20
21path = hf_hub_download("legible-weights/sae-mdlm-owt-l6-v0.1", "sae.safetensors")
22sae = TopKSAE()
23sae.load_state_dict(load_file(path))
Hook point: output of
model.backbone.blocks[6]. The MDLM modeling file in
the upstream repo depends on
flash-attn. The
diffusion-vs-ar-saes
repo ships a patched version that uses standard PyTorch SDPA instead, so
anyone can load and use this SAE without that build dependency.
MIT.