feat(moe): add MoE inference and expert parallel support#444
Open
qinyiqun wants to merge 1 commit into
Open
Conversation
- add reusable MoE router, dispatcher, runner, and expert abstractions - enable Qwen3 MoE fused inference with TP-local expert parallel routing - add graph-safe MoE workspace handling and EP backend selection through engine config - preserve legacy MoE path for existing DeepSeek V2 code
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
csrc/layers/moe.SparseMoeBlock,TopKRouter,FusedMoeExperts, andFusedMoErunner.local_allreduceandallgather_reducescatter.deepepbackend interface for future integration.MoeMLPintocsrc/layers/moe/legacyand keep DeepSeek-V2 on the legacy path.num_key_value_heads < tp_size.Motivation
Closes #
InfiniLM needs a reusable MoE inference path that can support Qwen3-MoE models and provide a clear abstraction boundary for future high-performance EP backends such as DeepEP.
The current implementation focuses on correctness and data-flow alignment first:
local_allreduceas the preferred current path.allgather_reducescatteris available as a correctness-oriented backend.Type of Change
feat— new feature / new modelrefactor— code restructuring without behavior changeperf— performance improvement (no behavioral change)fix— bug fixtest— adding or fixing tests onlydocs— documentation onlybuild/ci— build system or CI configurationchore— tooling, formatting, or other non-code changesTest Results of Involved Models on Supported Platforms (Please attach screenshots)
Please attach screenshots for the final tested commands.
Suggested coverage:
local_allreduceallgather_reducescatterlocal_allreduceBenchmark / Performance Impact
Initial measured examples on A100:
local_allreduce, graph enabled:local_allreduce, graph enabled:This PR does not claim final high-performance MoE EP parity with vLLM/SGLang. It establishes the correct abstraction and execution path for later DeepEP/fused MoE work.
Notes for Reviewers
local_allreduceis the recommended current EP backend for DP=1.allgather_reducescatteris correctness-oriented and expected to be slower.deepepis intentionally a placeholder interface.prepare_moe_input-style CUTLASS grouped GEMM flow is not used by the current InfiniLM MoE runner.layers/moe/legacyand is not migrated to the new fused Qwen3-MoE path.MoE EP backend: disabled.Checklist
Title, Branch, and Commits
<type>/xxx-yyyy-zzzz.main.fixup!/squash!/wipcommits remain.Scope and Design
C++ Specific
scripts/format.py.Python Specific
scripts/format.py.Testing