Repository navigation
Analysis Tools Review & Re-contextualization - #1907
Merged
Merged
Conversation
5 of 7 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.
Description
After a thorough review of all the Analysis Tools that have been built over the last several months, it was determined that we need to refocus some of these efforts. We are building tools with too narrow a scope, or tools that can be recreated using base-bridge functionalities.
This is the resulting size-reduction pass over
transformer_lens.tools.analysis: two tools are removed or redesigned to better fit the library, two other tools are demoted to demos, one tool is rebuilt as part of the existingpatchinglibrary, shared helpers are consolidated, and the public surface shrinks substantially. All changes tested bit-indentical on real models.RelevanceLens,_relevance_rulesand the rule hooks inNormalizationBridge,GatedMLPBridgeandJointGateUpMLPBridgehave been removed, due to forward costs.Backward_Lens_Demo.ipynbandSVD_Circuits_Demo.ipynbare rewritten to use self-contained on bridge hooks,FactoredMatrix.svdandlogit_readout. They successfully reproduce the previous outputs without the need for an expansive analysis toolscripts/– benchmark and CLI are one script with unchanged logic; it regenerates the frozen demo artifact byte for byte.success_rate_cinow lives intransformer_lens.utilitiesand the old package path forwards with aDeprecationWarning.transformer_lens.patching– the clean-minus-corrupted source-head write is added to the destination head's pre-norm fork input (split-QKV enabled for the sweep and restored), so LayerNorm recomputes. It matches the attribution module's edge ablation to fp64 precision; the frozen-scale approximation and its unfolded-LN warning are gone, so numbers change. Sources without a fork (boot_native, GPT-J, GPT-Neo, OPT, BERT) and post-norm, scaled-residual or parallel-mixer source blocks are refused before any forward; K/V on grouped-query attention stays refused. The old module path forwards with aFutureWarning.hybrid_block_types,compute_dtype,require_intandto_token_idsin_model_state.pyreplace inlined copies across the logit lens, DLA, projection kernel, sparse probing and the Jacobian lens; attribution patching shares one clean/corrupt pair check.logit_readout(bit-identical, now subject to its guards),swap_clamp_hooksfolds intoswap_hooks(clamp_to=)with a deprecated forward,coordinate_patch_hooksuses the shared intervention hook, occupancy controls are drawn on the CPU so every device agrees (slower on accelerators; documented), and registry lenses load at the registry's pinned revision.tools.analysis.__all__now only exports 35 items; result dataclasses stay importable from their modules.alphainswap_hooks(clamp_to=)is the fraction of the way to the clamped coordinates; a few validation messages are reworded.Verified with the unit, docstring, acceptance and integration tiers,
mypy ., formatting, nbval on the four touched notebooks and the docs build; per-test regression checked against the base run.Fixes #1832 (Backward Lens leaves the package, so #1833 will not be merged).
Type of change
Checklist: