test(integration): add oracle parity test for JacobianLens (#1539 Tier-1)#1543
Open
mukund1985 wants to merge 4 commits into
Open
test(integration): add oracle parity test for JacobianLens (#1539 Tier-1)#1543mukund1985 wants to merge 4 commits into
mukund1985 wants to merge 4 commits into
Conversation
…erLensOrg#1539 Tier-1) Compares TransformerBridge JacobianLens.readout() against the reference anthropics/jacobian-lens oracle (pinned to 581d398) on google/gemma-2-2b-it across 75 layer x prompt cells (5 prompts x 15 sampled layers). Pass criteria per the TransformerLensOrg#1539 spec (matching TransformerLensOrg#1505 spike numbers): - Worst-case top-8 token overlap >= 7/8 in every cell - Spearman rank-correlation >= 0.95 on the top-64 logit union per cell The oracle is installed at test time via pip from the pinned commit so the threshold is reproducible independent of upstream drift. Reuses the bridge's original_model + tokenizer to avoid a second model copy in RAM.
Contributor
Author
Collaborator
|
Awesome, thanks @mukund1985! I will make a look at this first thing Monday. |
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1539 Tier-1 item 1.
What
Adds
tests/integration/test_jacobian_lens_oracle_parity.py— a@pytest.mark.slowintegration test that comparesTransformerBridgeJacobianLens.readout()against the referenceanthropics/jacobian-lensoracle across 75 layer×prompt cells.Why
#1539 Tier-1 items require a test asserting numerical parity between the TL implementation and the oracle. The oracle is pinned to commit
581d398(Apache-2.0, frozen) so the threshold is reproducible independent of upstream drift.How it works
The oracle (
jlens.lens.JacobianLens) and TL'sJacobianLensboth load the same published checkpoint fromneuronpedia/jacobian-lens. The oracle is installed at test time via pip from the pinned commit:Both lenses run on
google/gemma-2-2b-it. The oracle wrapsbridge.original_modelandbridge.tokenizerviajlens.hf.from_hf()— no second model copy is loaded.Pass criteria (per #1539 spec, matching #1505 spike numbers)
75 cells = 5 prompts × 15 sampled layers (0–24 plus final)
Final layer (identity transport) is verified against oracle's
model_logitsrather than lens output, since the oracle raises if passed a layer not insource_layers.Test structure
Spearman is computed inline with numpy (no scipy dependency).