Skip to content

Add llava onevision adapter tests#1384

Open
chandrudp29 wants to merge 11 commits into
TransformerLensOrg:mainfrom
chandrudp29:add-llava-onevision-adapter-tests
Open

Add llava onevision adapter tests#1384
chandrudp29 wants to merge 11 commits into
TransformerLensOrg:mainfrom
chandrudp29:add-llava-onevision-adapter-tests

Conversation

@chandrudp29

Copy link
Copy Markdown

Description

Adds unit tests for LlavaOnevisionArchitectureAdapter as part of the test backfill effort in #1302.

All 35 tests pass locally.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

danra and others added 11 commits June 8, 2026 09:14
…ensOrg#1316)

* Add Direct Logit Attribution tool for TransformerBridge

* Resolve review feedback and add Direct Logit Attribution tests

Resolved review feedback from @jlarson4, added tests covering
reconstruction invariants on a distilgpt2 bridge in compatibility mode,
arguments, asserting sum(scores) == logit_diff - (b_U[correct] -
b_U[wrong]) against the model's real logits, plus labels/shape and
batch-averaging checks.

Added additional hardening:
- Fix a latent direction-shape bug: replace the fragile
  answer_tokens.numel()==1 branch with a robust reshape so single-prompt,
  single-token inputs are handled correctly
- Detect hybrid blocks via bridge.layer_types() instead of substring
  matching named_modules(), the codebase's own semantic mechanism
- Import get_act_name from transformer_lens.utilities to avoid the
  transformer_lens.utils DeprecationWarning; drop the invalid
  return_type kwarg to run_with_cache
- Register the analysis subpackage in tools/__init__.py

Closes TransformerLensOrg#1263.
…merLensOrg#1369)

* Add Direct Logit Attribution tool (TransformerLensOrg#1263)

Add transformer_lens/tools/analysis/direct_logit_attribution.py, a single-call
DLA analysis that decomposes a logit (or logit difference) into per-component,
per-layer (logit-lens), or per-head contributions. Wraps the existing
ActivationCache primitives (decompose_resid / accumulated_resid /
stack_head_results / logit_attrs) and works with both HookedTransformer and
TransformerBridge, since they share the cache API.

Returns a DirectLogitAttribution dataclass (attribution tensor + aligned
labels, plus a top(k) helper). Adds integration tests asserting the exact DLA
correctness invariant on both systems: the complete decomposition reconstructs
the model's real logit up to the unembedding bias b_U.

Closes TransformerLensOrg#1263

* Resolving conflicts between 1316 and 1369

* format fixes

---------

Co-authored-by: Azra Bano <azrabano23@gmail.com>
Co-authored-by: Jonah Larson <jonahalarson@comcast.net>
* Add Phi adapter tests

* Add comment about setup component test

* Delete redundant config literal tests
* Fixed SVD interpreter test

* Format SVD interpreter fixture test
The Restricted Loss section called loss_fn(all_logits, labels), but
all_logits had been rearranged earlier into a (p, p, d_vocab) grid for
the logit periodicity analysis. loss_fn's 3-D branch assumes
(batch, pos, d_vocab) and takes logits[:, -1], producing a (p, p)
tensor that crashes the gather against the p*p labels (TransformerLensOrg#543).

Use original_logits instead, which is recomputed just above and is the
same full-dataset loss the cell intends to print. Also clear the stored
RuntimeError output from the cell.
Breaking: removes the public eps_attr constructor argument and the config.eps_attr attribute. The field was never read (its consumer was deleted when NormalizationBridge moved to direct HF delegation), so no model behavior changes, but it is an API removal.
@chandrudp29 chandrudp29 force-pushed the add-llava-onevision-adapter-tests branch from 1982274 to e811765 Compare June 15, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants