Registry / ai-ml / sae-lens

sae-lens

JSON →
library6.44.3pypypi✓ verified 84d ago

SAE Lens is a library for training, loading, and analyzing sparse autoencoders (SAEs) on transformer language models. Current version is 6.43.0, with frequent releases (multiple versions per month).

pip install sae-lens
INSTALL
IMPORT
SIG · SAE-LENS
S
sae-lens
ai-mlpythonv6.44.3
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
timeout
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SAE
from sae_lens import SAE
Standard import for loading a pretrained SAE.
SAEConfig
from sae_lens.config import SAEConfig
from sae_lens import SAEConfig
SAEConfig is in sae_lens.config, not top-level.
HookedSAETransformer
from sae_lens import HookedSAETransformer
Wraps a HookedTransformer to cache activations.

Load a pretrained SAE and compute feature activations for a prompt.

from sae_lens import SAE from transformer_lens import HookedTransformer model = HookedTransformer.from_pretrained("gpt2-small", device="cpu") sae, cfg_dict, sparsity = SAE.from_pretrained(release="gpt2-small-res-jb", sae_id="blocks.0.hook_resid_pre", device="cpu") sae.to("cpu") # Example: get SAE feature activations for a prompt prompt = "Hello, world!" _, cache = model.run_with_cache(prompt, names_filter=[sae.cfg.hook_name]) act = cache[sae.cfg.hook_name] sae_acts = sae.encode(act) print(sae_acts.shape)
Debug
Known issues
breakingIn v6.x, the `SAE.from_pretrained` signature changed: the `release` argument is now the first positional argument and required. Old code using `SAE.from_pretrained(sae_id=...)` without `release` will break.
fix
Update to: SAE.from_pretrained(release=..., sae_id=...)
affects: <6.0
gotchaSAE expects activations on the same device as the SAE itself. Cross-device (e.g., model on GPU, SAE on CPU) can cause silent errors or crashes.
fix
Ensure model and SAE are on the same device (use sae.to(device) and model.to(device)).
affects: all
deprecatedThe `cache` parameter in `SAE.encode` is deprecated and will be removed in a future version. Use `HookedSAETransformer` or `model.run_with_cache` explicitly.
fix
Switch to using `model.run_with_cache` and pass the activations directly to `sae.encode`.
affects: >=6.30.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'sae_lens'
Package not installed.
fix
Run `pip install sae-lens`.
AssertionError: Expected activation shape (batch, seq_len, d_model) but got ...
Activations passed to SAE.encode have incorrect shape or are on wrong device.
fix
Check that activations are a 3D tensor on the same device as the SAE. Use `sae.encode(act)` where `act` is shape (batch, seq_len, d_model).
ValueError: Unknown release: ...
Provided release name does not exist in the SAE registry.
fix
Use a valid release name from `sae_lens.known_releases()` or check the docs.
Upgrade
Version history
6.44.3latest on PyPI · released Jun 16, 2026
Audit
Dependencies
torchrequiredCore dependency for tensor operations and model loading
transformer-lensrequiredUsed for model hooks and activation caching
datasetsrequiredFor loading activation datasets
wandboptionalOptional for experiment logging
Agent activity
27 hits · last 30 days
node
22
OpenAI (training)
1
Resources
sae-lens — pip install sae-lens · libregistry