Repository navigation
perf(moe): wire lfm2 to the fused decode-MoE kernel - #309
Merged
Merged
Conversation
LFM2-MoE uses the shared SwitchGLU which already exposes forward_fused_kernel. Add the standard fused-gated branch to Lfm2MoeSparseMoeBlock::forward, mirroring the dots1 / qwen3_moe pattern. The existing scores tensor (sigmoid-routed, with norm_topk_prob and routed_scaling_factor already applied) is passed directly to forward_fused_kernel. The dense fallback path is unchanged. Update the fused-moe-decode-kernel-design doc to list lfm2 among the wired models.
This was referenced Jun 16, 2026
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
Wire
lfm2(LFM2-MoE) to the fused single-token decode-MoE kernel. TheLfm2MoeSparseMoeBlockalready uses the sharedSwitchGLU, which exposesforward_fused_kernel, so no struct migration was needed.What changed
src/models/lfm2.rs: replaced the two-statementswitch_mlp.forward+moe_weighted_sumsequence with the standard fused-gated branch, mirroring the dots1 / qwen3_moe pattern. The dense fallback path and all routing logic (sigmoid gating, expert_bias selection, norm_topk_prob, routed_scaling_factor) are unchanged.docs/benchmark_results/fused-moe-decode-kernel-design.md: moved lfm2 from the unwired list to the wired list; count updated from five to six model paths.Test plan
cargo check --lib --tests --features metal,accelerate- cleancargo clippy --lib --tests --features metal,accelerate -- -D warnings- cleanmodels/lfm2-8b-a1b-4bitpending orchestrator (chain 2/6 under epic epic(moe): wire the remaining unwired MoE families to the fused decode-MoE kernel #307)Closes #305