Skip to content

Test llama architecture adapter#1311

Open
indrayani21 wants to merge 7 commits into
TransformerLensOrg:devfrom
indrayani21:test-llama-architecture-adapter
Open

Test llama architecture adapter#1311
indrayani21 wants to merge 7 commits into
TransformerLensOrg:devfrom
indrayani21:test-llama-architecture-adapter

Conversation

@indrayani21
Copy link
Copy Markdown

Description

Adds focused unit tests for the Llama architecture adapter in tests/unit/model_bridge/supported_architectures/test_llama_adapter.py.

This PR adds validation for:

  • Config attribute initialization
  • Component mapping structure
  • GQA (n_key_value_heads) support
  • Weight conversion registration
  • Rotary embedding setup logic
  • Factory registration

The tests were modeled after the existing CodeGen adapter test suite and adapted for Llama-specific behaviors such as:

  • RMSNorm
  • RoPE (rotary embeddings)
  • gated MLPs
  • grouped-query attention

Related to #1302

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • 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
  • I have not rewritten tests relating to key interfaces which would affect backward compatibility

-->

brendanlong and others added 7 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.

This PR is solid as well! Just one note on the rotary_emb assertion, and you'll need to clean up any formatting errors. Let me know if you have any questions @indrayani21

)

# Verify method exists and adapter remains usable
assert hasattr(attn_bridge, "set_rotary_emb")
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 assertion cannot fail due to the way the attention bridge constructs LLaMA's rotary_emb. It would be more valuable to assert assert attn_bridge._rotary_emb is rotary_emb

@jlarson4 jlarson4 changed the base branch from main to dev May 18, 2026 15:32
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