Skip to content

Studio: route lfm2_moe (LFM2-8B-A1B) to transformers 5.3.0 - #7040

Merged
danielhanchen merged 1 commit into
mainfrom
studio-route-lfm2-moe
Jul 11, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
studio-route-lfm2-moe

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

Training or loading LiquidAI/LFM2-8B-A1B (or any lfm2_moe checkpoint) in Studio fails at model load with:

`LiquidAI/LFM2-8B-A1B` is not supported yet in `transformers==4.57.6`.

Root cause

studio/backend/utils/transformers_version.py maps a model to the transformers sidecar it needs. The lfm2_moe model type and its Lfm2MoeForCausalLM architecture were not listed in any tier, so the resolver fell through to the default 4.57.x sidecar. The MoE variant was simply never added; only lfm2_vl was present. lfm2_moe is registered in transformers 5.3.0, which we already ship as the .venv_t5_530 sidecar.

Fix

Add Lfm2MoeForCausalLM to _TRANSFORMERS_530_ARCHITECTURES and lfm2_moe to _TRANSFORMERS_530_MODEL_TYPES, so LFM2 MoE checkpoints route to the 5.3.0 sidecar like the other MoE families already do.

Verification

get_transformers_tier now returns 530 for the model:

Transformers tier 530 selected for LFM2-8B-A1B (local config.json check)
get_transformers_tier('LFM2-8B-A1B') -> '530'

With the 5.3.0 sidecar active, the full QLoRA path works end to end: 4-bit load with the experts quantized (about 4.5 GB resident), LoRA attaches to the MoE expert projections, a short train run produces a finite loss, and merge to 16-bit reloads in stock transformers and generates coherent text.

No behavior change for any other model: this only adds two entries to the 5.3.0 tier sets.

LFM2-8B-A1B and any other lfm2_moe checkpoint were missing from the
transformers tier tables, so they fell through to the default 4.57.x
sidecar, which does not register lfm2_moe and errors with
"not supported yet in transformers==4.57.6". Only lfm2_vl was listed.

Add Lfm2MoeForCausalLM / lfm2_moe to the 5.3.0 tier (lfm2_moe is
registered in transformers 5.3.0). get_transformers_tier now returns
530 for LFM2-8B-A1B and the model loads and trains as expected.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for the 'Lfm2MoeForCausalLM' model type and its corresponding 'lfm2_moe' identifier to the transformers version utility. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@danielhanchen

Copy link
Copy Markdown
Member Author

Superseded by #7043, which routes lfm2_moe (and any new architecture) by reading CONFIG_MAPPING_NAMES instead of a table edit. This can be closed once that lands.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 567dedd3d6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit c3feac6 into main Jul 11, 2026
39 checks passed
@danielhanchen
danielhanchen deleted the studio-route-lfm2-moe branch July 11, 2026 12:08
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.

1 participant