fix(bridge): remove dead _enable_ht_attention and its exclusive helpers - #1604
Merged
jlarson4 merged 1 commit intoAug 4, 2026
Merged
Conversation
_enable_ht_attention dispatched on three attention layouts, but two of the three branches called methods that no longer exist: _extract_linear_ht_format (split Q/K/V - Llama, Mistral, Qwen, Gemma) and _extract_qkv_neox_style (fused query_key_value - GPT-NeoX, Falcon). 3efbd6e ("Cleanup (TransformerLensOrg#1129)") deleted both definitions while keeping the call sites, so only the GPT-2 branch could run; the other two raised AttributeError on entry. Four # type: ignore[attr-defined] comments kept mypy quiet about it. The same commit removed both callers (architecture_adapter.py:1249 and bridge.py:1144 as of 3efbd6e^), leaving the method unreachable - no user impact, but it reads as a finished "architecture-agnostic" helper to anyone wiring it into component testing. Its three remaining helpers are called only from it, so they go too: _extract_qkv_gpt2_style, _extract_output_proj, and _disable_hook_conversions (whose body was already `pass`). einops becomes unused and is dropped. setup_component_testing and _wire_rotary_for_testing are untouched. Follow-up to TransformerLensOrg#1601/TransformerLensOrg#1602, which fixed the same pattern in the nanogpt adapter; separate PR per maintainer request.
Collaborator
|
Looks great, thank you @sohv! |
Author
|
Great @jlarson4 , happy to contribute! |
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
Follow-up to #1602, as agreed in #1601 - same defect pattern, same origin commit, separate PR.
ArchitectureAdapter._enable_ht_attentiondispatched on three attention layouts, but two of the three branches called methods that do not exist anywhere in the tree:c_attn_extract_qkv_gpt2_styleq_proj/k_proj/v_proj_extract_linear_ht_formatquery_key_value_extract_qkv_neox_style3efbd6e("Cleanup (#1129)", 2025-11-15) deleted both helper definitions while keeping their call sites:Four
# type: ignore[attr-defined]comments suppressed the resulting mypy errors, so CI stayed green. Only the GPT-2 branch could run; the other two raisedAttributeErroron entry.No user was affected. The same commit also removed both callers (
architecture_adapter.py:1249andbridge.py:1144as of3efbd6e^), leaving the method unreachable — verified by searching*.py/*.ipynb/*.mdand checking for dynamicgetattrdispatch. The risk was latent: the method advertises itself as "architecture-agnostic" in its docstring, so the next person wiring it into component testing would have hit an immediate crash on every architecture except GPT-2.What is removed
The whole unreachable cluster — 98 lines, the tail of the file:
_enable_ht_attention_extract_qkv_gpt2_style,_extract_output_proj,_disable_hook_conversions— each called only from_enable_ht_attention, so they die with it._disable_hook_conversionswas already a no-op (pass, with a docstring saying it "currently does nothing in no_processing mode").# type: ignore[attr-defined]commentsimport einops, now unused (pruned bymake format)setup_component_testingand_wire_rotary_for_testingare untouched — they were never part of this path.If you would rather keep the capability
The opposite fix is equally available: restore
_extract_linear_ht_formatand_extract_qkv_neox_stylefrom3efbd6e^and re-wire a caller. That is a feature with its own design questions (which call path owns it, how it relates tosetup_component_testing), so I have not assumed it — happy to send that version instead if you prefer.Type of change
Checklist:
# type: ignorecomments leaves the CItype-checkjob as the guard against reintroduction.