Add GPT-OSS-20B model support#1195
Open
CarlG0123 wants to merge 6 commits intoTransformerLensOrg:devfrom
Open
Conversation
Adds support for loading and running OpenAI's GPT-OSS-20B model, which uses a unique MoE architecture with 32 experts, custom GLU activation, and MXFP4 quantized weights on HuggingFace. New files: - gpt_oss_moe.py: GptOssExpert (custom activation) and GptOssMoE (routing) - openai.py: Weight converter for HF model -> TransformerLens state dict - run_gpt_oss.py: Direct safetensors loader that dequantizes MXFP4 on CPU, enabling the model to run on machines with <40GB RAM via swap Modified files: - loading_from_pretrained.py: Register model, config extraction, weight dispatch - mlp_factory.py: Route GptOssForCausalLM to GptOssMoE - weight_conversions/__init__.py: Export convert_gpt_oss_weights Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Register the new model in the incompatible_models list (too large for Colab) and update the model count from 231 to 232. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c12d182 to
9d72d1b
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3 tasks
Convert the standalone script to a Jupyter notebook to match the existing demo format. Adds sections for inference, caching, expert routing analysis, logit lens, attention patterns, and activation patching. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Key architecture differences from Mixtral
gate.clamp(max=7) * sigmoid(gate * 1.702) * (up.clamp(-7, 7) + 1)(not standard SiLU)Files changed
transformer_lens/components/mlps/gpt_oss_moe.pyGptOssExpertandGptOssMoEclassestransformer_lens/pretrained/weight_conversions/openai.pytransformer_lens/loading_from_pretrained.pytransformer_lens/factories/mlp_factory.pytransformer_lens/pretrained/weight_conversions/__init__.pyconvert_gpt_oss_weightsrun_gpt_oss.pyUsage
Test plan
🤖 Generated with Claude Code