Add option to normalize dataset, track thresholds for TopK SAEs, Fix Standard SAE #31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
1. Activation Normalization (Optional)
The scaling factors are applied to SAE thresholds and biases during model saving, eliminating the need for normalization at inference time. This approach significantly improves hyperparameter transfer across different layers and models. In particular, Jump ReLU requires significant hyperparameter tuning without this.
2. Global Threshold Implementation for BatchTopK SAE
I also track this global threshold for the TopK SAE during training, but I don't use it by default in the encode method. Using a global threshold provides several benefits: it achieves better loss recovery compared to standard TopK, eliminates feature dependencies within inputs, and enables forward pass on a limited subset of SAE latents (useful for steering, autointerp, etc).
3. Standard SAE Improvements
With the standard SAE, W_dec is now W_enc.T. I also used the correct reconstruction loss for standard and p anneal, which was already used in all other trainers. The initialization provided a major benefit and the reconstruction loss provided a minor benefit.