[Feature] Add LFM2, LFM2-MoE, and LFM2-VL support - #1317
Draft
alay2shah wants to merge 1 commit into
Draft
Conversation
alay2shah
force-pushed
the
feat/lfm2-support
branch
2 times, most recently
from
July 24, 2026 20:26
ae1d42f to
1774035
Compare
alay2shah
force-pushed
the
feat/lfm2-support
branch
from
July 31, 2026 17:14
bee8bb9 to
de8993f
Compare
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
Adds Liger Kernel support for the Liquid AI LFM2 model family in Hugging Face Transformers:
LFM2ForCausalLMLFM2MoeForCausalLMLfm2VlForConditionalGenerationThe integration adds custom Triton kernels for the gated short convolution and MoE router, integrates LFM2-MoE expert tensors with the Liger fused MoE path, patches the SigLIP2 vision tower where a Liger implementation is beneficial, and supports fused linear cross entropy. It is exposed through the normal
AutoLigerKernelForCausalLMand monkey-patch APIs, so downstream trainers only need the correct Liger version anduse_liger_kernel=True.Kernel changes
Gated short convolution
MoE router and experts
cache_results, while remaining compatible with older Triton releases.LIGER_FUSED_MOE_AUTOTUNE=0; CUDA retains the existing fixed configurations.ROCm fused linear cross entropy
H >= 1024guard preserves upstream numerical behavior for mini models.LFM2-VL / SigLIP2
Kernel benchmarks
Post-H100-update AMD rerun on exact commit
de8993f82af07e7fb9025ae6e506f2db14851266. Hardware: AMD Instinct MI325X, BF16. Values are median full forward+backward latency.The expert table compares the two production paths selected by the workload-aware dispatch, not the generic Python expert loop. H100 kernel benchmark rows are committed in
benchmark/data/all_benchmark_data.csv; this table is the independent MI325X rerun after the H100 changes landed.End-to-end training
Post-H100-update rerun through leap-finetune on MI325X with BF16. Each workload used counterbalanced baseline/Liger/Liger/baseline runs on an exclusive node. Throughput is the mean of each pair's inverse median synchronized optimizer-step time after five warmup steps. Memory is the Trainer transient per-rank peak allocation delta; for two GPUs the maximum rank is reported.
Dense SFT and DPO benefit most because the optimized language-model path is a large fraction of total step time. MoE memory remains nearly flat because expert parameters and optimizer/FSDP state dominate the full-model footprint. VL and GRPO include vision, generation, reward, and communication work that Liger does not optimize, so their gains are smaller. The VL 2-GPU throughput result is effectively neutral within run-to-run variance while retaining a 27.4% transient peak-memory reduction.
Cold Triton compilation is excluded by the synchronized warmup/median methodology; short ephemeral jobs still need to account for cache fill.
Testing done
make test: 3,931 passed, 1,184 skipped, 14 xfailed on the LFM2 feature branchgit diff --checkpass for the final changed files