Skip to content

Conversation

@emharsha1812
Copy link

Granite 3.3 Model Support for TransformerLens
Description
This PR adds support for the IBM Granite 3.3 family of models to TransformerLens. These models use a specialized architecture with Grouped Query Attention (GQA) and SwiGLU activation with separate gate and up-projection weights.

Key implementation details:

Added weight conversion logic in granite.py to properly handle Granite's architecture
Correctly handled the transposition and reshaping of attention weights
Implemented support for GQA (Grouped Query Attention)
Configured the model to use the GatedMLP component with silu activation
Ensured all tensors are moved to the correct device during conversion
The implementation enables researchers to use IBM's Granite models with TransformerLens's interpretability tools, expanding the range of architectures available for study

Fixes # (issue)

Screenshots

Please attach before and after screenshots of the change if applicable.

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

Additional Notes
The implementation specifically handles the unique aspects of Granite 3.3's architecture:

It properly separates gate and up-projection weights for the GatedMLP component
It correctly handles the Grouped Query Attention mechanism
It ensures all tensors are moved to the model's configured device
This PR builds on TransformerLens's existing infrastructure for supporting various model architectures, making minimal changes to accommodate Granite 3.3's specific requirements

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.

2 participants