Skip to content
Edit this page

What is verified

What the tests and the runs establish, and what they do not.

Verified

  • Losses and gradients of the sparse backward pass: against dense autograd and numerical differentiation.
  • Checkpoint resumption: bit-identical continuation on identical batches.
  • Export: identical outputs to the trained module, and to SAELens' own inference model for topk and batchtopk.
  • Content-token selection: against a manual forward pass, with fast and offset-less tokenizers.
  • Holdout split: disjoint, deterministic, independent of prompt and row.
  • Apple MPS and CUDA: losses, gradients and activations agree with the CPU, and the runs above completed. On CUDA, bfloat16 autocast gave the same result as float32 to three decimals.
  • Prompt exclusion with the ruri-v3 tokenizer: by hand, on three texts.
  • Text-level statistics, latent statistics and ranking metrics: against hand-built cases.
  • Leaving latents out of the probe: a masked latent is active in no vector, every other entry is unchanged, FLOPS falls by the latent's share, and the dense rankings stay the same.
  • The shared latents of two texts: their weights add up to the dot product of the pooled vectors, and each names the token with the largest activation.
  • Loading an SAE from a Hugging Face Hub repository: load_sae and build_sparse_encoder read the published SAE by its repository name, with weights equal to the local file. The tests use local directories.
  • The retrieval head: its vectors equal the probe's on the same texts; gradients equal a dense computation, for the token states and, when trainable, for the SAE's encoder; padded and unpadded batches agree; a saved model loads with the same head; three training steps on a tiny model update the transformer and leave the SAE unchanged.
  • The reranking probe and the loss recovered: an SAE that reconstructs exactly recovers 1; pooled vectors and replaced embeddings agree with a manual computation; the clean masked-language-model loss equals the model's own loss on the same masked batch.

Except for the runs above, all of this uses a randomly initialised two-layer BERT or synthetic activations. See Where it has run for the environments.

Not verified

  • SAE quality at full size beyond one run: 65,536 latents and one billion tokens were trained once, on modernbert-ja-310m with one seed (The published SAE). No other encoder, layer or seed.
  • That an SAE head gives a better retriever than a vocabulary head. The comparisons under Measurements are 2,000 steps on one benchmark.
  • The unpadded input layout of Sentence Transformers end to end. It needs flash attention; the head is tested on hand-built features in that layout.
  • The effect of AuxK on real activations. In the full-size run it was active in half of the logged steps, with at most 0.07% of the latents counted as dead; no run without it was made.
  • A run of the full length on a device other than one NVIDIA RTX 4090. The time estimates for other devices are extrapolations.
  • The pooled, per-text figures and the per-latent listing at full size. They have been measured only on 8,192 latents and ruri-v3-30m.
  • The reranking probe on all queries of the benchmark. At 65,536 latents and with titles in the documents it has run on 100 queries (The published SAE).
  • The masked-language-model loss recovered beyond 16,384 latents and 10 million tokens.
  • Separate encoders for queries and documents on real encoders: combine_encoders, the stitched SAE head and its ridge map have run on randomly initialised models only.
  • The cap on the share of texts an entry appears in beyond the runs reported above, and against penalties on document frequency.
  • The probability threshold of the vocabulary head beyond the runs reported above: on another benchmark, with longer training or distillation, on the 310M encoder with a temperature other than 1 or at an equal FLOPS, or against published sparsification methods other than the shift.

Where it has run

The runs on real encoders and on GPUs below were made before the package was reorganised into subpackages and its names were unified for 0.1.0. The tests, which check the numerics against independent references, pass on the reorganised code; the measurements were not repeated on it.

Environment What ran Result
GitHub Actions, Ubuntu 24.04 the locked mise run check on Python 3.12; the tests with the lowest supported versions on Python 3.11 (PyTorch 2.6, Transformers 4.48, Datasets 3.0, safetensors 0.4.4); the tests with the newest versions, SAELens and Sentence Transformers on Python 3.13 passed
macOS 26.6, Apple M5 Pro, Python 3.12, PyTorch 2.15 mise run check, including the hardware tests on MPS and Betterleaks passed
The same Mac, MPS runs of 5 to 30 million tokens on cl-nagoya/ruri-v3-30m with both trainers, their per-text and per-latent statistics, the reranking probe on 200 JQaRA queries, the retrieval head against the probe, small-scale retrieval training with the SAE head, and the step benchmark ran end to end; numbers under Measurements
Google Colab, NVIDIA L4, Python 3.13, PyTorch 2.14 the tests, including the hardware tests of the probe, the loss recovered and the retrieval head; loss and gradients on CUDA against the CPU; bfloat16 autocast; the step benchmark; a 5-million-token run in float32 and bfloat16; small-scale retrieval training of the SAE head and the vocabulary head on modernbert-ja-30m with three seeds, with and without distillation passed; numbers under Measurements
Rented NVIDIA GPUs; the SAE on one RTX 4090, with bfloat16 autocast in the encoder the 65,536-latent SAE on modernbert-ja-310m for one billion tokens (6.6 hours), its evaluation against the published SAE, and the retrieval comparisons on modernbert-ja-310m with three seeds ran end to end; numbers under The published SAE
Linux x86_64 CPU, Python 3.13, PyTorch 2.15 formatting, lint, mypy, tests, package build, public-content audit, step benchmark passed

Not run yet: retrieval training beyond 2,000 steps, and any recipe at the scale of its source. The decoder-model parts (inner layers, bidirectional attention and the adaptation to it, adapters, Qwen-Scope files) have run on randomly initialised models only. The automated tests use a randomly initialised two-layer BERT and a four-layer decoder, which check interfaces and numerics, not quality. The runs on ruri-v3-30m use a small dictionary and one seed each.

Limitations

  • One process, one device. No multi-GPU sharding.
  • --resume restores the SAE, optimizer and dead-latent state exactly. The data stream restarts after the texts already encoded with a new shuffle seed, so the activations that were waiting in the shuffle buffer at checkpoint time are skipped.
  • Datasets are loaded in map style and shuffled by row. Streaming datasets are not supported.
  • By default activations are used as they come out of the encoder. train-sae --normalize-inputs scales each activation to unit length first, which is the second half of the preprocessing of Gao et al. (the mean over the dimensions is not subtracted) and what LightOn's SlideOn does to its token embeddings. The setting is saved in sae_config.json and applied wherever the SAE is used: evaluation, inspection, the probe and the retrieval head. It has been run on the test model only; its effect on SAE quality or retrieval has not been measured here.
  • The SAELens backend cannot resume, and its auxiliary loss is not configurable from here.
  • probe-sae and --mlm-texts need an SAE trained on last_hidden_state.