SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2405.12241 · 2024

Identifying Functionally Important Features with End-to-End Sparse Dictionary Learning

arXiv · PDF · Open in the Atlas

Code that ran

8 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 6 failures of our instrument; 3 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2405.12241.json · badge: /api/ran/2405.12241.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
apolloresearch/e2e_sae canonical (classifier label)
classifier basis: census
8 ran · 3 no recorded run
FunctionStatusWhere it lives
calc_explained_variance Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
apolloresearch/e2e_sae/e2e_sae/losses.py
code served (permissive licence) · get_code("4240424af18cec3a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create small tensors with distinct dimensions for batch and sequence
# batch_size=2, seq_len=3, dim=4
pred = torch.randn(2, 3, 4)
target = torch.randn(2, 3, 4)

ARGS = {
    "pred": pred,
    "target": target,
    "layer_norm": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jaxtyping, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_config Ran
ran; our contract draft was wrong, not the code
apolloresearch/e2e_sae/e2e_sae/utils.py
code served (permissive licence) · get_code("c965ff7e1ebc030d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned MyConfig. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tempfile
from pathlib import Path
from pydantic import BaseModel
import yaml

# Define a simple config model
class MyConfig(BaseModel):
    learning_rate: float = 0.001
    batch_size: int = 32
    num_epochs: int = 10

# Create a temporary YAML file for testing
temp_dir = tempfile.TemporaryDirectory()
config_yaml_path = Path(temp_dir.name) / "config.yaml"

config_data = {
    "learning_rate": 0.001,
    "batch_size": 32,
    "num_epochs": 10
}

with open(config_yaml_path, 'w') as f:
    yaml.dump(config_data, f)

# Create an instance of the config model
existing_config = MyConfig(learning_rate=0.002, batch_size=64, num_epochs=5)

# Define ARGS with all possible parameter combinations
ARGS = [
    # Test 1: Pass a string path to YAML file
    {
        "config_path_or_obj": str(config_yaml_path),
        "config_model": MyConfig,
    },
    # Test 2: Pass a Path object
    {
        "config_path_or_obj": config_yaml_path,
        "config_model": MyConfig,
    },
    # Test 3: Pass an existing config object (instance of config_model)
    {
        "config_path_or_obj": existing_config,
        "config_model": MyConfig,
    },
]

# For single execution, use the first test case
ARGS = {
    "config_path_or_obj": str(config_yaml_path),
    "config_model": MyConfig,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pydantic, yaml — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MyConfig — a MyConfig output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MyConfig output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
setup_logger Ran
ran; our contract draft was wrong, not the code
apolloresearch/e2e_sae/e2e_sae/log.py
code served (permissive licence) · get_code("d8a05e02085eeb90")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned RootLogger. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import logging
from logging.config import dictConfig
from pathlib import Path
import tempfile

# Create a temporary directory for logs
temp_dir = tempfile.mkdtemp()
logfile = Path(temp_dir) / 'logs' / 'logs.log'

ARGS = {
    'logfile': logfile
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type RootLogger — a RootLogger output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a RootLogger output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
statistical_distance Ran
ran; our contract draft was wrong, not the code
apolloresearch/e2e_sae/e2e_sae/metrics.py
code served (permissive licence) · get_code("940eb3f8703e24c9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn.functional as F

torch.manual_seed(0)

# Create small logit tensors
# Shape: (batch_size=2, vocab_size=4)
orig_logits = torch.randn(2, 4)
new_logits = torch.randn(2, 4)

ARGS = {
    "orig_logits": orig_logits,
    "new_logits": new_logits,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jaxtyping, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
to_numpy Ran
ran, honoured the contract we drafted
apolloresearch/e2e_sae/e2e_sae/utils.py
code served (permissive licence) · get_code("10dfdb7059057d01")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Test various input types that the function accepts
ARGS = {
    "tensor": torch.tensor([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]])
}

# Additional test cases to verify all branches work
test_cases = [
    np.array([[1, 2, 3, 4], [5, 6, 7, 8]]),
    [1, 2, 3, 4],
    (1.0, 2.0, 3.0, 4.0),
    torch.tensor([1, 2, 3, 4]),
    torch.nn.parameter.Parameter(torch.tensor([[1.0, 2.0], [3.0, 4.0]])),
    42,
    3.14,
    True,
    "test_string"
]

# Verify each can be converted
for test in test_cases:
    pass  # Function will handle conversion

ARGS = {
    "tensor": torch.tensor([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]])
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
tokenize_and_concatenate Ran
ran on a synthesized input
apolloresearch/e2e_sae/e2e_sae/data.py
code served (permissive licence) · get_code("785cf677e1de98f6")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Dataset. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
from datasets import Dataset
from transformers import AutoTokenizer

# Create a minimal tokenizer stand-in
class MinimalTokenizer:
    def __init__(self):
        self.pad_token_id = 0
        self.pad_token = '<PAD>'
        self.bos_token_id = 1
        self.eos_token_id = 2
        self.eos_token = '</s>'
    
    def __call__(self, text, return_tensors=None, padding=False):
        # Simple mock tokenization: convert text to token ids
        if isinstance(text, str):
            text = [text]
        
        token_lists = []
        max_len = 0
        for t in text:
            tokens = [ord(c) % 100 + 3 for c in t]  # Simple token generation
            token_lists.append(tokens)
            max_len = max(max_len, len(tokens))
        
        if padding:
            for token_list in token_lists:
                while len(token_list) < max_len:
                    token_list.append(self.pad_token_id)
        
        if return_tensors == 'np':
            return {'input_ids': np.array(token_lists, dtype=np.int32)}
        return {'input_ids': token_lists}
    
    def add_special_tokens(self, special_tokens_dict):
        pass

# Create a small dataset
data_dict = {
    'text': [
        'hello world this is a test',
        'another sample text for tokenization',
        'more test data here',
        'final example text',
    ]
}
dataset = Dataset.from_dict(data_dict)

# Create tokenizer
tokenizer = MinimalTokenizer()

ARGS = {
    'dataset': dataset,
    'tokenizer': tokenizer,
    'max_length': 16,
    'column_name': 'text',
    'add_bos_token': False,
    'num_proc': 2,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
datasets, einops, numpy, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Dataset — a Dataset output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Dataset output the recorded ndim 1 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
top1_consistency Ran
ran; our contract draft was wrong, not the code
apolloresearch/e2e_sae/e2e_sae/metrics.py
code served (permissive licence) · get_code("fd3eafcb040f48d9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from jaxtyping import Float
from torch import Tensor

torch.manual_seed(0)

# Create two logit tensors with shape (batch_size, vocab_size)
# batch_size = 2, vocab_size = 4
orig_logits = torch.randn(2, 4)
new_logits = torch.randn(2, 4)

# Define all arguments for the function
ARGS = {
    "orig_logits": orig_logits,
    "new_logits": new_logits,
    "per_token": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jaxtyping, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
topk_accuracy Ran
ran; our contract draft was wrong, not the code
apolloresearch/e2e_sae/e2e_sae/metrics.py
code served (permissive licence) · get_code("328f50c831db8d0f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from einops import repeat

torch.manual_seed(0)

# Create logits tensor with shape (batch, pos, vocab)
# batch=2, pos=5, vocab=4
logits = torch.randn(2, 5, 4)

# Create tokens tensor with shape (batch, pos)
# batch=2, pos=5
tokens = torch.randint(0, 4, (2, 5))

# k parameter for top-k accuracy
k = 2

# per_token parameter
per_token = False

ARGS = {
    "logits": logits,
    "tokens": tokens,
    "k": k,
    "per_token": per_token,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, jaxtyping, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
convert_str_to_torch_dtype Not yet run
unverified (harvested, no recorded run)
apolloresearch/e2e_sae/e2e_sae/types.py
code served (permissive licence) · get_code("495a63f69d38d772")
How it ran

no invocation recorded.

load_pretrained_saes Not yet run
unverified (harvested, no recorded run)
apolloresearch/e2e_sae/e2e_sae/loader.py
code served (permissive licence) · get_code("0b6d19ab9443ea4e")
How it ran

no invocation recorded.

serialize_torch_dtype_to_str Not yet run
unverified (harvested, no recorded run)
apolloresearch/e2e_sae/e2e_sae/types.py
code served (permissive licence) · get_code("0c353f5afddae0f1")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 0 later) and 10 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
setup_logger 1 other paper
1 dated earlier
2305.07759 (2023-05)
TinyStories: How Small Can Language Models Be and Still Speak Coherent English?

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Identifying the features learned by neural networks is a core challenge in mechanistic interpretability. Sparse autoencoders (SAEs), which learn a sparse, overcomplete dictionary that reconstructs a network's internal activations, have been used to identify these features. However, SAEs may learn more about the structure of the datatset than the computational structure of the network. There is therefore only indirect reason to believe that the directions found in these dictionaries are functionally important to the network. We propose end-to-end (e2e) sparse dictionary learning, a method for training SAEs that ensures the features learned are functionally important by minimizing the KL divergence between the output distributions of the original model and the model with SAE activations inserted. Compared to standard SAEs, e2e SAEs offer a Pareto improvement: They explain more network performance, require fewer total features, and require fewer simultaneously active features per datapoint, all with no cost to interpretability. We explore geometric and qualitative differences between e2e SAE features and standard SAE features. E2e dictionary learning brings us closer to methods that can explain network behavior concisely and accurately. We release our library for training e2e SAEs and reproducing our analysis at https://github.com/ApolloResearch/e2e_sae

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2405.12241")
get_code_for_paper("2405.12241")
have("2405.12241")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2405.12241.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2405.12241.svg)](https://syntology.ai/paper/2405.12241)

Connect an agent — have() is free.