sae-lens 6.6.0__py3-none-any.whl → 6.6.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sae_lens/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  # ruff: noqa: E402
2
- __version__ = "6.6.0"
2
+ __version__ = "6.6.2"
3
3
 
4
4
  import logging
5
5
 
@@ -82,7 +82,7 @@ class CacheActivationsRunner:
82
82
  )
83
83
  for hook_name in [self.cfg.hook_name]
84
84
  }
85
- features_dict["token_ids"] = Sequence(
85
+ features_dict["token_ids"] = Sequence( # type: ignore
86
86
  Value(dtype="int32"), length=self.context_size
87
87
  )
88
88
  self.features = Features(features_dict)
sae_lens/evals.py CHANGED
@@ -459,14 +459,16 @@ def get_sparsity_and_variance_metrics(
459
459
  original_act = cache[hook_name]
460
460
 
461
461
  # normalise if necessary (necessary in training only, otherwise we should fold the scaling in)
462
- original_act = activation_scaler.scale(original_act)
462
+ original_act_scaled = activation_scaler.scale(original_act)
463
463
 
464
464
  # send the (maybe normalised) activations into the SAE
465
- sae_feature_activations = sae.encode(original_act.to(sae.device))
466
- sae_out = sae.decode(sae_feature_activations).to(original_act.device)
465
+ sae_feature_activations = sae.encode(original_act_scaled.to(sae.device))
466
+ sae_out_scaled = sae.decode(sae_feature_activations).to(
467
+ original_act_scaled.device
468
+ )
467
469
  del cache
468
470
 
469
- sae_out = activation_scaler.unscale(sae_out)
471
+ sae_out = activation_scaler.unscale(sae_out_scaled)
470
472
 
471
473
  flattened_sae_input = einops.rearrange(original_act, "b ctx d -> (b ctx) d")
472
474
  flattened_sae_feature_acts = einops.rearrange(
@@ -1245,9 +1245,15 @@ def get_mwhanna_transcoder_config_from_hf(
1245
1245
  # Extract layer from folder name
1246
1246
  layer = int(folder_name.replace(".safetensors", "").split("_")[-1])
1247
1247
 
1248
- wandb_config_path = hf_hub_download(
1249
- repo_id, "wanb-config.yaml", force_download=force_download
1250
- )
1248
+ try:
1249
+ # mwhanna transcoders sometimes have a typo in the config file name, so check for both
1250
+ wandb_config_path = hf_hub_download(
1251
+ repo_id, "wanb-config.yaml", force_download=force_download
1252
+ )
1253
+ except EntryNotFoundError:
1254
+ wandb_config_path = hf_hub_download(
1255
+ repo_id, "wandb-config.yaml", force_download=force_download
1256
+ )
1251
1257
  base_config_path = hf_hub_download(
1252
1258
  repo_id, "config.yaml", force_download=force_download
1253
1259
  )
@@ -289,7 +289,7 @@ class ActivationsStore:
289
289
  "Dataset must have a 'tokens', 'input_ids', 'text', or 'problem' column."
290
290
  )
291
291
  if self.is_dataset_tokenized:
292
- ds_context_size = len(dataset_sample[self.tokens_column])
292
+ ds_context_size = len(dataset_sample[self.tokens_column]) # type: ignore
293
293
  if ds_context_size < self.context_size:
294
294
  raise ValueError(
295
295
  f"""pretokenized dataset has context_size {ds_context_size}, but the provided context_size is {self.context_size}.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sae-lens
3
- Version: 6.6.0
3
+ Version: 6.6.2
4
4
  Summary: Training and Analyzing Sparse Autoencoders (SAEs)
5
5
  License: MIT
6
6
  Keywords: deep-learning,sparse-autoencoders,mechanistic-interpretability,PyTorch
@@ -16,24 +16,19 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
16
  Provides-Extra: mamba
17
17
  Requires-Dist: automated-interpretability (>=0.0.5,<1.0.0)
18
18
  Requires-Dist: babe (>=0.0.7,<0.0.8)
19
- Requires-Dist: datasets (>=3.1.0,<4.0.0)
19
+ Requires-Dist: datasets (>=3.1.0)
20
20
  Requires-Dist: mamba-lens (>=0.0.4,<0.0.5) ; extra == "mamba"
21
- Requires-Dist: matplotlib (>=3.8.3,<4.0.0)
22
- Requires-Dist: matplotlib-inline (>=0.1.6,<0.2.0)
23
21
  Requires-Dist: nltk (>=3.8.1,<4.0.0)
24
- Requires-Dist: plotly (>=5.19.0,<6.0.0)
25
- Requires-Dist: plotly-express (>=0.4.1,<0.5.0)
26
- Requires-Dist: pytest-profiling (>=1.7.0,<2.0.0)
27
- Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
22
+ Requires-Dist: plotly (>=5.19.0)
23
+ Requires-Dist: plotly-express (>=0.4.1)
24
+ Requires-Dist: python-dotenv (>=1.0.1)
28
25
  Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
29
- Requires-Dist: pyzmq (==26.0.0)
30
- Requires-Dist: safetensors (>=0.4.2,<0.5.0)
26
+ Requires-Dist: safetensors (>=0.4.2,<1.0.0)
31
27
  Requires-Dist: simple-parsing (>=0.1.6,<0.2.0)
28
+ Requires-Dist: tenacity (>=9.0.0)
32
29
  Requires-Dist: transformer-lens (>=2.16.1,<3.0.0)
33
30
  Requires-Dist: transformers (>=4.38.1,<5.0.0)
34
- Requires-Dist: typer (>=0.12.3,<0.13.0)
35
31
  Requires-Dist: typing-extensions (>=4.10.0,<5.0.0)
36
- Requires-Dist: zstandard (>=0.22.0,<0.23.0)
37
32
  Project-URL: Homepage, https://jbloomaus.github.io/SAELens
38
33
  Project-URL: Repository, https://github.com/jbloomAus/SAELens
39
34
  Description-Content-Type: text/markdown
@@ -1,15 +1,15 @@
1
- sae_lens/__init__.py,sha256=nZaNNPsvcyXtYBDQj-3dU5cZNmVynuc0d1gpeRUqQq8,3588
1
+ sae_lens/__init__.py,sha256=NChdhNs5Lv_JQ8vOEIDZMmDSmQepJhRE11G2EXRY7iQ,3588
2
2
  sae_lens/analysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  sae_lens/analysis/hooked_sae_transformer.py,sha256=vRu6JseH1lZaEeILD5bEkQEQ1wYHHDcxD-f2olKmE9Y,14275
4
4
  sae_lens/analysis/neuronpedia_integration.py,sha256=MrENqc81Mc2SMbxGjbwHzpkGUCAFKSf0i4EdaUF2Oj4,18707
5
- sae_lens/cache_activations_runner.py,sha256=L5hhuU2-zPQr2S3L64GMKKLeMQfqXxwDl8NbuOtrybI,12567
5
+ sae_lens/cache_activations_runner.py,sha256=cNeAtp2JQ_vKbeddZVM-tcPLYyyfTWL8NDna5KQpkLI,12583
6
6
  sae_lens/config.py,sha256=IrjbsKBbaZoFXYrsPJ5xBwIqi9uZJIIFXjV_uoErJaE,28176
7
7
  sae_lens/constants.py,sha256=CSjmiZ-bhjQeVLyRvWxAjBokCgkfM8mnvd7-vxLIWTY,639
8
- sae_lens/evals.py,sha256=rVmKqdSa4xlZw-78qpgdhDleJIO1EI1QHRiPsObW1Tc,39129
8
+ sae_lens/evals.py,sha256=2YHR_IBhXdjktpmoVtvvNrqUZIx5ok7yERuiFY40HHY,39186
9
9
  sae_lens/llm_sae_training_runner.py,sha256=exxNX_OEhdiUrlgmBP9bjX9DOf0HUcNQGO4unKeDjKM,13713
10
10
  sae_lens/load_model.py,sha256=C8AMykctj6H7tz_xRwB06-EXj6TfW64PtSJZR5Jxn1Y,8649
11
11
  sae_lens/loading/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- sae_lens/loading/pretrained_sae_loaders.py,sha256=hAWYByePjRiKdVBShmrdAZZVP4TZ01Nbg4eTAUbey-4,43601
12
+ sae_lens/loading/pretrained_sae_loaders.py,sha256=QsvovdlKF7zu6iLM0CK5UP6qBqS0N9wVml_u8ZFdcak,43875
13
13
  sae_lens/loading/pretrained_saes_directory.py,sha256=4Vn-Jex6SveD7EbxcSOBv8cx1gkPfUMLU1QOP-ww1ZE,3752
14
14
  sae_lens/pretokenize_runner.py,sha256=w0f6SfZLAxbp5eAAKnet8RqUB_DKofZ9RGsoJwFnYbA,7058
15
15
  sae_lens/pretrained_saes.yaml,sha256=O_FwoOe7fU9_WLEOnMk1IWXRxD4nwzf1tCfbof1r0D0,598578
@@ -25,7 +25,7 @@ sae_lens/saes/transcoder.py,sha256=BfLSbTYVNZh-ruGxseZiZJ_acEL6_7QyTdfqUr0lDOg,1
25
25
  sae_lens/tokenization_and_batching.py,sha256=now7caLbU3p-iGokNwmqZDyIvxYoXgnG1uklhgiLZN4,4656
26
26
  sae_lens/training/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  sae_lens/training/activation_scaler.py,sha256=seEE-2Qd2JMHxqgnsNWPt-DGtYGZxWPnOwCGuVNSOtI,1719
28
- sae_lens/training/activations_store.py,sha256=x2Fwt5QY7M83v6Vf1CSa821j2_WKMw9oPu1cdlLblvg,32887
28
+ sae_lens/training/activations_store.py,sha256=2EUY2abqpT5El3T95sypM_JRDgiKL3VeT73U9SQIFGY,32903
29
29
  sae_lens/training/mixing_buffer.py,sha256=vDpYG5ZE70szDvBsRKcNHEES3h_WTKJ16qDYk5jPOVA,2015
30
30
  sae_lens/training/optim.py,sha256=TiI9nbffzXNsI8WjcIsqa2uheW6suxqL_KDDmWXobWI,5312
31
31
  sae_lens/training/sae_trainer.py,sha256=6HPf5wtmY1wMUTkLFRg9DujNMMXJkVMPdAhB2svvlkk,15368
@@ -33,7 +33,7 @@ sae_lens/training/types.py,sha256=qSjmGzXf3MLalygG0psnVjmhX_mpLmL47MQtZfe7qxg,81
33
33
  sae_lens/training/upload_saes_to_huggingface.py,sha256=r_WzI1zLtGZ5TzAxuG3xa_8T09j3zXJrWd_vzPsPGkQ,4469
34
34
  sae_lens/tutorial/tsea.py,sha256=fd1am_XXsf2KMbByDapJo-2qlxduKaa62Z2qcQZ3QKU,18145
35
35
  sae_lens/util.py,sha256=mCwLAilGMVo8Scm7CIsCafU7GsfmBvCcjwmloI4Ly7Y,1718
36
- sae_lens-6.6.0.dist-info/LICENSE,sha256=DW6e-hDosiu4CfW0-imI57sV1I5f9UEslpviNQcOAKs,1069
37
- sae_lens-6.6.0.dist-info/METADATA,sha256=hAg3k2VOAwVSyF3KV54z3VBFk9neHz3EON504xMQl58,5555
38
- sae_lens-6.6.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
39
- sae_lens-6.6.0.dist-info/RECORD,,
36
+ sae_lens-6.6.2.dist-info/LICENSE,sha256=DW6e-hDosiu4CfW0-imI57sV1I5f9UEslpviNQcOAKs,1069
37
+ sae_lens-6.6.2.dist-info/METADATA,sha256=0fAahxc3s1QUC9_yCAsL5N_0q-2qU6s67Jj75BOKehg,5303
38
+ sae_lens-6.6.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
39
+ sae_lens-6.6.2.dist-info/RECORD,,