feat: add native LFM2 and PhiMoE bridge support#1419
Closed
randommm wants to merge 1 commit into
Closed
Conversation
TL;DR: add TransformerBridge support for LiquidAI LFM2 MoE and Microsoft PhiMoE, including registry wiring, config passthrough, unit coverage, native PhiMoE loading, and correct chat EOS stopping. Adds native architecture adapters for Lfm2MoeForCausalLM and PhiMoEForCausalLM. LFM2 is exposed conservatively as a residual-probing adapter over the HF decoder layers, avoiding fake attention/MLP internals for the hybrid conv/full-attention architecture. PhiMoE targets the native Transformers implementation with trust_remote_code=False rather than the archived remote implementation, which is incompatible with current generation/cache semantics. Registers both architectures across the TransformerBridge adapter factory, supported-architecture exports, model-registry architecture lists, report metadata, and supported_models.json. Adds explicit registry entries for LiquidAI/LFM2.5-8B-A1B and microsoft/Phi-mini-MoE-instruct. Extends HF config passthrough for hybrid/MoE and tokenizer-related attributes used by these adapters, including LFM2 layer/norm/MoE metadata, PhiMoE routing/bias metadata, and eos_token_id. TransformerBridge generation now prefers cfg.eos_token_id when present, allowing architecture adapters to provide multiple default stop tokens. Handles PhiMoE chat generation correctly by stopping on both the tokenizer EOS (<|endoftext|>) and the chat-template turn terminator (<|end|>). This prevents generation from continuing into another assistant turn after the model has ended its answer. Adds unit tests covering both adapters' config flags, component mappings, weight conversions, and PhiMoE EOS defaults.
Author
|
ops, wrong branch. Created another one pointing to dev branch |
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 TransformerBridge support for LiquidAI LFM2 MoE and Microsoft PhiMoE, including registry wiring, config passthrough, unit coverage, native PhiMoE loading with correct chat EOS stopping (a small change on
transformer_lens/model_bridge/bridge.pywas needed for that).Type of change
Checklist: