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

Aperta Adatta ai principianti
#1,993 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@pablocs116 ci sta già lavorando.

Dal 6/11/2026.

  • #1998 di @pablocs116 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
77/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python, pytorch
Ambito
testing-qa

Direzione di ricerca

Inizia con tests/unit/tools/test_attribution_patching.py::test_faithfulness_recovery_is_graded_not_binary ed esamina come viene selezionato il circuito parziale e come viene calcolata la frazione recuperata. Esegui il test con il comando indicato nell’issue, poi verifica l’asserzione rispetto al percorso completo suggerito fino a logits. Il risultato atteso è che il test sia deterministico rispetto alle variazioni del comportamento in virgola mobile e continui a verificare il recupero graduale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
3.9k
Fork
708
Merge medio
1g 4h
PR unite (30g)
87

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TransformerLensOrg/TransformerLens

Tutte le issue di TransformerLensOrg/TransformerLens

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.