[Bug Report] test_faithfulness_recovery_is_graded_not_binary passes or fails on the sign of float32 rounding

Abierto Apto para principiantes
#1,993 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@pablocs116 ya está trabajando en esto.

Desde el 6/11/2026.

  • #1998 de @pablocs116 — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
77/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python, pytorch
Área
testing-qa

Línea de trabajo

Empieza con tests/unit/tools/test_attribution_patching.py::test_faithfulness_recovery_is_graded_not_binary e inspecciona cómo se selecciona el circuito parcial y cómo se calcula la fracción recuperada. Ejecuta la prueba con el comando del issue y luego comprueba la aserción frente a la ruta completa sugerida hasta logits. El objetivo es que la prueba sea determinista ante variaciones del comportamiento de coma flotante y siga verificando la recuperación gradual.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Describe the bug
tests/unit/tools/test_attribution_patching.py::test_faithfulness_recovery_is_graded_not_binary fails deterministically on my machine, both inside the full unit suite and on its own, while CI is green on the same commit.

The partial circuit is readout[: len(readout) // 2], the first 23 of the 46 edges into the last position. In enumeration order those are all edges into the layer-0 Q/K/V/MLP inputs and the layer-1 Q/K inputs. None of them feeds the logits reader. _EdgeScoringToyBridge is linear, so with every edge into logits ablated, no clean signal reaches the metric. The recovered fraction is therefore exactly 0 in exact arithmetic: building the toy in float64 gives 6.5e-17. In float32 the 0.0 < check comes down to the sign of the rounding error, which is positive on CI and negative here.

Code example
On dev at a1fe5d4d, with no local changes:

uv run pytest tests/unit/tools/test_attribution_patching.py -k faithfulness_recovery_is_graded_not_binary
>       assert 0.0 < report.recovered < 1.0
E       AssertionError: assert 0.0 < -1.3424525621271817e-08

System Info

  • Installed from source with uv
  • Linux under WSL2 on Windows, CPU only
  • Python 3.12, torch 2.11.0, transformers 5.13.0

Additional context
Suggestion: pick the partial circuit so it contains at least one complete path to logits (for example by including the embed→logits edge), so the "recovers part" claim holds structurally. Simply switching to the second half isn't enough on its own: it recovers 0.30 with the float32 toy, but 1.12 with the float64 toy (a different random draw), so the < 1.0 bound isn't guaranteed either.

Checklist
  • I have checked that there is no similar issue in the repo (required)

The checklist box is honest: I searched issues and PRs and found nothing about this test.

Lenguaje dominante
Python
Estrellas
3.9k
Forks
708
Merge medio
1 d 4 h
PR fusionados (30 d)
87

Preparar el entorno

Abrir en Codespaces

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

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TransformerLensOrg/TransformerLens

Todos los issues de TransformerLensOrg/TransformerLens

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.