-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from chanind/activations_store_tests
chore: adding more tests to ActivationsStore + light refactoring
- Loading branch information
Showing
5 changed files
with
200 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import pytest | ||
from transformer_lens import HookedTransformer | ||
|
||
from tests.unit.helpers import TINYSTORIES_MODEL | ||
|
||
|
||
@pytest.fixture | ||
def ts_model(): | ||
return HookedTransformer.from_pretrained(TINYSTORIES_MODEL, device="cpu") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from typing import Any | ||
|
||
import torch | ||
|
||
from sae_training.config import LanguageModelSAERunnerConfig | ||
|
||
TINYSTORIES_MODEL = "tiny-stories-1M" | ||
TINYSTORIES_DATASET = "roneneldan/TinyStories" | ||
|
||
|
||
def build_sae_cfg(**kwargs: Any) -> LanguageModelSAERunnerConfig: | ||
""" | ||
Helper to create a mock instance of LanguageModelSAERunnerConfig. | ||
""" | ||
# Create a mock object with the necessary attributes | ||
mock_config = LanguageModelSAERunnerConfig( | ||
model_name=TINYSTORIES_MODEL, | ||
hook_point="blocks.0.hook_mlp_out", | ||
hook_point_layer=0, | ||
hook_point_head_index=None, | ||
dataset_path=TINYSTORIES_DATASET, | ||
is_dataset_tokenized=False, | ||
use_cached_activations=False, | ||
d_in=64, | ||
expansion_factor=2, | ||
d_sae=64 * 2, | ||
l1_coefficient=2e-3, | ||
lp_norm=1, | ||
lr=2e-4, | ||
train_batch_size=2048, | ||
context_size=64, | ||
feature_sampling_window=50, | ||
dead_feature_threshold=1e-7, | ||
n_batches_in_buffer=10, | ||
total_training_tokens=1_000_000, | ||
store_batch_size=32, | ||
log_to_wandb=False, | ||
wandb_project="test_project", | ||
wandb_entity="test_entity", | ||
wandb_log_frequency=10, | ||
device=torch.device("cpu"), | ||
seed=24, | ||
checkpoint_path="test/checkpoints", | ||
dtype=torch.float32, | ||
) | ||
|
||
for key, val in kwargs.items(): | ||
setattr(mock_config, key, val) | ||
|
||
return mock_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters