Skip to content

Adding adapter tests for Qwen2#1309

Merged
jlarson4 merged 9 commits into
TransformerLensOrg:devfrom
Rishik00:qwen-adapter-test
May 21, 2026
Merged

Adding adapter tests for Qwen2#1309
jlarson4 merged 9 commits into
TransformerLensOrg:devfrom
Rishik00:qwen-adapter-test

Conversation

@Rishik00
Copy link
Copy Markdown

Description

Adds unit coverage for the Qwen2 architecture adapter.

Changes

  • Tests Qwen2 config defaults, component mapping, and HF module paths.
  • Verifies Q/K/V/O weight conversions use the right head counts for GQA.
  • Adds download-free fake attention coverage for Qwen2 GQA hook shapes.
  • Checks factory registration for Qwen2ForCausalLM.

To run the test: uv run pytest tests\unit\model_bridge\supported_architectures\test_qwen2_adapter.py

Relevant to Issue #1302 @jlarson4

brendanlong and others added 6 commits April 20, 2026 14:50
* Fix type of HookedTransformerConfig.device

This is typed as `Optional[str]` but sometimes returns `torch.device`.
Updated the code to just return the `str` instead of wrapping with a
device.

I'm not confident that every function which takes a device will
always be passed a string, so I didn't change functions like
warn_if_mps.

Found while working on TransformerLensOrg#1219

* more cleanup

* 3.0 CI Bugs (TransformerLensOrg#1261)

* Fixing `utils` imports

* skip gated notebooks on PR from forks

* Updating notebooks

* Ensure LLaMA only runs when HF_TOKEN is available

---------

Co-authored-by: jlarson4 <jonahalarson@comcast.net>
Copy link
Copy Markdown
Collaborator

@jlarson4 jlarson4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Rishik00! This is an excellent test suite, I left one comment on the code and have one additional ask:

Can we get some testing for Qwen2's setup_component_testing override? That is the biggest feature that currently isn't getting tested. If you'd like a reference, another contributor has a great example of roughly what I'm looking for in #1311

return Qwen2ArchitectureAdapter(cfg)


class FakeQwen2Attention(nn.Module):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is excellent, and it would be great to write some tests that use it, but at present it does not appear wired into anything?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My apologies. Will wire it up and update the PR!

@jlarson4 jlarson4 changed the base branch from main to dev May 18, 2026 15:33
@Rishik00
Copy link
Copy Markdown
Author

Of course! I will get that added

@Rishik00
Copy link
Copy Markdown
Author

Apologies for the dummy files commit. I had those accidentally appear from elsewhere, will not let that happen again

@jlarson4
Copy link
Copy Markdown
Collaborator

@Rishik00 no worries, as long as they're cleaned up they won't be in the final merge! I will review once CI completes

@Rishik00
Copy link
Copy Markdown
Author

Sure, thank you very much!

@jlarson4
Copy link
Copy Markdown
Collaborator

Hi @Rishik00! This is great work, I am going to squash merge this now. This will prevent those furunpod files from being introduced to main in the future

Make sure to invalidate any keys that may have been included in your initial commits, since they were committed to a public repository they are compromised.

@jlarson4 jlarson4 merged commit 4efd766 into TransformerLensOrg:dev May 21, 2026
24 checks passed
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.

3 participants