[Bug Report] `get_caching_hooks` fires for alias names in `names_filter` but caches only under the canonical key
Los mantenedores suelen responder en 1 día
@Mudassiruddin7 ya está trabajando en esto.
Desde el 6/10/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Describe the bug
TransformerBridge.get_caching_hooks(names_filter=<alias name>) matches the alias entry in hook_dict and the hook fires, but save_hook keys the cache by hook.name, which is the canonical name. The returned cache therefore has no entry under the name the caller asked for: names_filter="blocks.0.hook_resid_pre" produces a cache whose only key is blocks.0.hook_in, and cache["blocks.0.hook_resid_pre"] raises KeyError. Because the hook did fire and the cache is non-empty, nothing warns.
run_with_cache with the same filter returns both the canonical key and the alias key (it copies alias entries into the cache after the forward), so the two caching APIs disagree for the same input.
Code example
import torch
from transformer_lens.config import TransformerBridgeConfig
from transformer_lens.model_bridge import TransformerBridge
cfg = TransformerBridgeConfig(
d_model=32, d_head=16, n_heads=2, n_layers=1, n_ctx=8, d_vocab=16,
d_mlp=64, act_fn="gelu", normalization_type="LN", seed=0,
)
bridge = TransformerBridge.boot_native(cfg)
tokens = torch.randint(0, cfg.d_vocab, (1, 6))
alias = "blocks.0.hook_resid_pre"
with torch.no_grad():
_, ref = bridge.run_with_cache(tokens, names_filter=alias)
print(sorted(ref.cache_dict))
cache, fwd_hooks, _ = bridge.get_caching_hooks(names_filter=alias)
with torch.no_grad(), bridge.hooks(fwd_hooks=fwd_hooks):
bridge.forward(tokens)
print(sorted(cache))
cache[alias] # KeyError
Output on dev (1012730f):
['blocks.0.hook_in', 'blocks.0.hook_resid_pre']
['blocks.0.hook_in']
KeyError: 'blocks.0.hook_resid_pre'
System Info
- Source checkout installed with
uv sync,devat1012730f. - macOS (Apple Silicon), CPU only; Python 3.12.12; torch 2.11.0; transformers 5.13.0.
- No model downloads needed: reproduced with a random-init
TransformerBridge.boot_nativemodel.
Additional context
Found while verifying #1856. Note the fix cannot be a post-forward alias pass like run_with_cache's, because get_caching_hooks hands back the live cache dict before the model runs, it needs alias awareness inside save_hook (e.g. also store under the hook point's alias names, or under the filter name that matched).
Checklist
- I have checked that there is no similar issue in the repo (required)
- Lenguaje dominante
- Python
- Estrellas
- 3.9k
- Forks
- 708
- Merge medio
- 1 d 17 h
- PR fusionados (30 d)
- 70
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TransformerLensOrg/TransformerLens
-
[Proposal] RoBERTa masked-LM adapter for TransformerBridgePosiblemente ocupada @Canonik la tomó hoy. Abiertocomplexity-moderate new-architecture TransformerBridge
TransformerLensOrg/TransformerLens#1870 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[Proposal] Backward Lens: support gated MLP gate/ up/ down gradient factorsPosiblemente ocupada @janmenjayap la tomó hace 7 días. Abiertocomplexity-moderate enhancement TransformerBridge
TransformerLensOrg/TransformerLens#1832 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[Proposal] Sparse probing: optional groups argument so rows from one prompt can't straddle the splitPosiblemente ocupada @lorenzozanee la tomó hace 13 días. Abiertocomplexity-simple enhancement help wanted TransformerBridge
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
TransformerLensOrg/TransformerLens#1813 ·
Los mantenedores suelen responder en 1 día
-
[Bug Report] _BLOCK_LIST_ATTRS hardcoded name list silently drops Raven's blocks from composition-score / head-label analysisPosiblemente ocupada @LightWork666 la tomó hace 17 días. Abiertobug complexity-moderate TransformerBridge
TransformerLensOrg/TransformerLens#1791 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[Proposal] SVD Circuits: singular-vector decomposition of a head's QK/ OV into causally-validated subfunctionsPosiblemente ocupada @janmenjayap la tomó hace 28 días. Abiertocomplexity-high enhancement TransformerBridge
TransformerLensOrg/TransformerLens#1767 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de TransformerLensOrg/TransformerLens
Issues similares
-
HTML: <template> content is extracted as document textPosiblemente ocupada @ryanmeowy la tomó hoy. Abiertobug html
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
docling-project/docling#4714 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[BUG] Qdrant RAG client applies score_threshold to raw cosine similarity, not the 0-1 score it returnsPosiblemente ocupada @roydonsequeira la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Host test failure in core/direct_io.zig on Linux kernel 6.17: O_DIRECT open succeeds on procfs, so the test's 'plain' fd is not plainPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
ashhart/TensorFold#536 ·
Los mantenedores suelen responder en 1 día
-
area/install-update comp/cli duplicate P2 python:uv sweeper:risk-compatibility type/bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
NousResearch/hermes-agent#135440 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Deepak3699/Ai_Mentor#244 ·
Los mantenedores suelen responder en 1 día