Merged
Conversation
Originally from TransformerLensOrg#718.
Fix to OLMo 2 normalization
This PR adds support for the OLMO 3/3.1 family of models from AllenAI, complementing the existing OLMO 1/2 and OLMoE implementations. Key improvements over existing OLMO weight conversion: - Proper GQA detection (n_key_value_heads < n_heads) with underscore prefix - Q/K normalization support (q_norm.w, k_norm.w) - Uses actual layer norm weights instead of torch.ones() - Device-consistent tensor creation (device=W.device) - Complete attention bias support (b_Q, b_K, b_V) Models added: - allenai/Olmo-3-7B-Think - allenai/Olmo-3-32B-Think - allenai/Olmo-3.1-32B-Think - allenai/Olmo-3-7B-Instruct - allenai/Olmo-3.1-32B-Instruct Test output: 11/11 OLMO 3 tests passed
# Conflicts: # demos/Attribution_Patching_Demo.ipynb # demos/BERT.ipynb # demos/Colab_Compatibility.ipynb # demos/Exploratory_Analysis_Demo.ipynb # demos/Head_Detector_Demo.ipynb # demos/Main_Demo.ipynb # demos/Othello_GPT.ipynb # poetry.lock # pyproject.toml # tests/integration/test_head_detector.py # tests/unit/test_svd_interpreter.py # transformer_lens/HookedEncoder.py # transformer_lens/HookedTransformer.py # transformer_lens/components/abstract_attention.py # transformer_lens/loading_from_pretrained.py # transformer_lens/pretrained/weight_conversions/__init__.py # transformer_lens/pretrained/weight_conversions/olmo.py # transformer_lens/pretrained/weight_conversions/olmo2.py # transformer_lens/pretrained/weight_conversions/olmoe.py # transformer_lens/utils.py
Collaborator
|
Hello @etomoscow! I mentioned this in PR #1081, the OLMo HookedTransformer implementation has been bumped to 3.x, in order to maintain Python 3.9 for version 2.x (#1081 included a deprecation of python 3.9 support). I have forward ported the this branch to 3.x, and these models will be included in HookedTransformer in the next 3.x release. |
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
Add support for OLMO 3/3.1 models, on top of the existing OLMO 1-2 and OLMoE.
OLMO 3/3.1 introduces several architectural improvements that required a new weight conversion implementation with the following enhancements over the existing OLMO weight conversion:
Description
This PR adds support for the OLMO 3/3.1 family of models from AllenAI, complementing the existing OLMO 1, OLMO 2, and OLMoE implementations.
OLMO 3/3.1 uses a different architecture from earlier OLMO models, so I added a new weight conversion function. It supports GQA, QK normalization, layer norm weights.
The config conversion uses
AutoConfigfrom the HuggingFace config. It also handles thelayer_typesattribute for models with mixed sliding window and full attention layers (convertingsliding_attention→local,full_attention→global).Models Added
allenai/Olmo-3-7B-Thinkallenai/Olmo-3-32B-Thinkallenai/Olmo-3.1-32B-Thinkallenai/Olmo-3-7B-Instructallenai/Olmo-3.1-32B-InstructType of change
Checklist: