Add fine-grained MoE experts: decouple expert FFN hidden dim from dense FFN#118
Open
amazloumi wants to merge 1 commit into
Open
Add fine-grained MoE experts: decouple expert FFN hidden dim from dense FFN#118amazloumi wants to merge 1 commit into
amazloumi wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
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
ModelConfig.moe_expert_ffn_multiplier(default1.0) + acomputed_expert_ffn_hidden_dimproperty: expert FFN hidden =computed_ffn_hidden_dim × multiplier, rounded to a multiple of 16.transformer.py(standardbuild_moe),mot.py(MoT per-modalitybuild_moe),moma.py(ExpertChoiceMoE).num_params_estimateto count experts at the (possibly smaller) expert hidden dim.k, setmultiplier = 1/ksok × (F/k) = F(e.g. top-2 +0.5→ MoE activates the same FFN compute as dense). Verified: 70M backbone, top-2/0.5→ 1536 activated = dense (1.0×).Default
1.0reproduces current behavior exactly (expert hidden == dense FFN); dense and existing MoE configs are unchanged.Testing
uv run ruff check kempnerforge/ tests/passesuv run ruff format --check kempnerforge/ tests/ scripts/passesuv run pyright kempnerforge/passes (0 errors; parity withmain)uv run pytest tests/unit/ -v --timeout=60passes (1377 passed, 2 skipped; +9 new tests in test_config / test_moe / test_mot / test_moma)tests/e2e --e2eanyway: 25 passed, 5 pre-existing failures (checkpoint-resume / pipeline-parallel / SIGTERM), identical onmain.Closes #116