Granite 3.3 Model Support for TransformerLens #965
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.
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:
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