[Bug Report] NormMatchedPlacebo silently loses norm matching and produces float16 NaNs
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 75/100
Línea de trabajo
Start in transformer_lens/tools/analysis/interchange.py at NormMatchedPlacebo.__call__. Reproduce with the provided torch script to see float16 NaNs and zero-projection silence. Edit to preserve zero-reference rows, normalize at safe precision, and raise on zero placebo projection with nonzero reference. Run the focused regression tests (8 failing) until they pass and new identity/error cases hold.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
NormMatchedPlacebo promises to match the reference intervention's displacement in a different subspace, but a zero projection silently produces no displacement in float32 even when the reference moves. In float16, the 1e-8 denominator clamp rounds to zero and produces NaNs, including when source and base are identical. This can occur with the documented random-neuron control excluding the reference neurons, not just a degenerate dense random basis.
Code example
import torch
from transformer_lens.tools.analysis.interchange import (
NormMatchedPlacebo, SubspaceInterchange, neuron_basis, random_neuron_basis,
)
for dtype in (torch.float32, torch.float16):
base = torch.zeros(2, 4, dtype=dtype)
source = base.clone()
source[0, 0] = 2
reference = SubspaceInterchange(neuron_basis(4, [0]))
control_basis = random_neuron_basis(4, 1, seed=0, exclude=[0])
result = NormMatchedPlacebo(reference, control_basis)(base, source)
print(dtype, (reference(base, source) - base).norm(dim=-1), result)
The reference displacement norms are [2, 0]. Float32 returns two unchanged rows, so the first row is not norm-matched. Float16 returns NaNs in both rows; the second row should simply be an identity control. The current implementation also forms a potentially overflowing low-precision scale factor before multiplying by the direction.
Expected behavior: safely preserve rows with zero reference displacement, normalize nonzero projected directions at safe precision, and explicitly reject a zero placebo projection when the reference displacement is nonzero rather than silently returning an unmatched control. This keeps the existing projected-direction definition without inventing a fallback direction.
System Info
Source checkout at dev commit a7b3213a, Windows, Python 3.12, existing uv project environment, CPU. No model loading or downloads are required. Focused regression tests on this base: 8 failed, 14 passed, 38 deselected, covering float16, bfloat16, float32 and float64. Four failures assert the proposed explicit-error contract; the other four expose current float16 NaNs.
Additional context
The affected implementation is transformer_lens/tools/analysis/interchange.py, NormMatchedPlacebo.__call__. Existing random dense float32 tests cover ordinary nonzero projections, but not the zero-projection or float16 identity cases. This concerns the numerical validity of the control; no pretrained-model accuracy claim is involved.
Checklist
- I have checked that there is no similar issue in the repo.
- Lenguaje dominante
- Python
- Estrellas
- 3.9k
- Forks
- 708
- Merge medio
- 1 d 4 h
- PR fusionados (30 d)
- 87
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
-
[Bug Report] test_faithfulness_recovery_is_graded_not_binary passes or fails on the sign of float32 roundingPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
TransformerLensOrg/TransformerLens#1993 ·
Los mantenedores suelen responder en 1 día
-
[Bug Report] `TransformerBridge.boot_*` methods are invisible to static type checkersPosiblemente ocupada @koriyoshi2041 la tomó hace 2 días. Abiertobug complexity-simple TransformerBridge
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
TransformerLensOrg/TransformerLens#1980 ·
Los mantenedores suelen responder en 1 día
-
[Bug Report] detect_head fails with a list of sequences and a custom tensor detection patternPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobug complexity-moderate TransformerBridge
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
TransformerLensOrg/TransformerLens#1979 ·
Los mantenedores suelen responder en 1 día
-
[Proposal] MiniCPM adapter (MiniCPMForCausalLM) — I'm working on itPosiblemente ocupada @pablocs116 la tomó hoy. Abierto
TransformerLensOrg/TransformerLens#1992 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[Proposal] Pretrained J++ lenses through JacobianLens: artifact provenance and filtered readoutsAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 45/100
TransformerLensOrg/TransformerLens#1991 ·
Los mantenedores suelen responder en 1 día
Todos los issues de TransformerLensOrg/TransformerLens
Issues similares
-
bug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
graphql-python/graphql-core#304 ·
Los mantenedores suelen responder en 1 día
-
docs size:S
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
Gathin23/cleanyourtv#3464 ·
Los mantenedores suelen responder en 1 día
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día