sae-lens 6.17.0__tar.gz → 6.18.0__tar.gz
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.
Potentially problematic release.
This version of sae-lens might be problematic. Click here for more details.
- {sae_lens-6.17.0 → sae_lens-6.18.0}/PKG-INFO +1 -1
- {sae_lens-6.17.0 → sae_lens-6.18.0}/pyproject.toml +1 -1
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/__init__.py +1 -1
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/config.py +37 -2
- {sae_lens-6.17.0 → sae_lens-6.18.0}/LICENSE +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/README.md +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/analysis/__init__.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/analysis/hooked_sae_transformer.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/analysis/neuronpedia_integration.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/cache_activations_runner.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/constants.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/evals.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/llm_sae_training_runner.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/load_model.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/loading/__init__.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/loading/pretrained_sae_loaders.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/loading/pretrained_saes_directory.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/pretokenize_runner.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/pretrained_saes.yaml +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/registry.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/saes/__init__.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/saes/batchtopk_sae.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/saes/gated_sae.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/saes/jumprelu_sae.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/saes/matryoshka_batchtopk_sae.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/saes/sae.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/saes/standard_sae.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/saes/topk_sae.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/saes/transcoder.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/tokenization_and_batching.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/training/__init__.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/training/activation_scaler.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/training/activations_store.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/training/mixing_buffer.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/training/optim.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/training/sae_trainer.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/training/types.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/training/upload_saes_to_huggingface.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/tutorial/tsea.py +0 -0
- {sae_lens-6.17.0 → sae_lens-6.18.0}/sae_lens/util.py +0 -0
|
@@ -18,6 +18,7 @@ from datasets import (
|
|
|
18
18
|
|
|
19
19
|
from sae_lens import __version__, logger
|
|
20
20
|
from sae_lens.constants import DTYPE_MAP
|
|
21
|
+
from sae_lens.registry import get_sae_training_class
|
|
21
22
|
from sae_lens.saes.sae import TrainingSAEConfig
|
|
22
23
|
|
|
23
24
|
if TYPE_CHECKING:
|
|
@@ -387,8 +388,11 @@ class LanguageModelSAERunnerConfig(Generic[T_TRAINING_SAE_CONFIG]):
|
|
|
387
388
|
return self.sae.to_dict()
|
|
388
389
|
|
|
389
390
|
def to_dict(self) -> dict[str, Any]:
|
|
390
|
-
|
|
391
|
-
|
|
391
|
+
"""
|
|
392
|
+
Convert the config to a dictionary.
|
|
393
|
+
"""
|
|
394
|
+
|
|
395
|
+
d = asdict(self)
|
|
392
396
|
|
|
393
397
|
d["logger"] = asdict(self.logger)
|
|
394
398
|
d["sae"] = self.sae.to_dict()
|
|
@@ -398,6 +402,37 @@ class LanguageModelSAERunnerConfig(Generic[T_TRAINING_SAE_CONFIG]):
|
|
|
398
402
|
d["act_store_device"] = str(self.act_store_device)
|
|
399
403
|
return d
|
|
400
404
|
|
|
405
|
+
@classmethod
|
|
406
|
+
def from_dict(cls, cfg_dict: dict[str, Any]) -> "LanguageModelSAERunnerConfig[Any]":
|
|
407
|
+
"""
|
|
408
|
+
Load a LanguageModelSAERunnerConfig from a dictionary given by `to_dict`.
|
|
409
|
+
|
|
410
|
+
Args:
|
|
411
|
+
cfg_dict (dict[str, Any]): The dictionary to load the config from.
|
|
412
|
+
|
|
413
|
+
Returns:
|
|
414
|
+
LanguageModelSAERunnerConfig: The loaded config.
|
|
415
|
+
"""
|
|
416
|
+
if "sae" not in cfg_dict:
|
|
417
|
+
raise ValueError("sae field is required in the config dictionary")
|
|
418
|
+
if "architecture" not in cfg_dict["sae"]:
|
|
419
|
+
raise ValueError("architecture field is required in the sae dictionary")
|
|
420
|
+
if "logger" not in cfg_dict:
|
|
421
|
+
raise ValueError("logger field is required in the config dictionary")
|
|
422
|
+
sae_config_class = get_sae_training_class(cfg_dict["sae"]["architecture"])[1]
|
|
423
|
+
sae_cfg = sae_config_class.from_dict(cfg_dict["sae"])
|
|
424
|
+
logger_cfg = LoggingConfig(**cfg_dict["logger"])
|
|
425
|
+
updated_cfg_dict: dict[str, Any] = {
|
|
426
|
+
**cfg_dict,
|
|
427
|
+
"sae": sae_cfg,
|
|
428
|
+
"logger": logger_cfg,
|
|
429
|
+
}
|
|
430
|
+
output = cls(**updated_cfg_dict)
|
|
431
|
+
# the post_init always appends to checkpoint path, so we need to set it explicitly here.
|
|
432
|
+
if "checkpoint_path" in cfg_dict:
|
|
433
|
+
output.checkpoint_path = cfg_dict["checkpoint_path"]
|
|
434
|
+
return output
|
|
435
|
+
|
|
401
436
|
def to_sae_trainer_config(self) -> "SAETrainerConfig":
|
|
402
437
|
return SAETrainerConfig(
|
|
403
438
|
n_checkpoints=self.n_checkpoints,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|