dusterbloom: perf(models): fused MoE gate+up — 3→2 expert matmuls per layer#12
Open
dusterbloom wants to merge 3 commits intomainfrom
Open
dusterbloom: perf(models): fused MoE gate+up — 3→2 expert matmuls per layer#12dusterbloom wants to merge 3 commits intomainfrom
dusterbloom wants to merge 3 commits intomainfrom
Conversation
SwitchMlpWeights::forward_gather_fused() lazy-concatenates gate+up weights on first call, then dispatches a single gather_qmm instead of two separate calls. FfnBlock::forward() now routes through the fused path instead of forward_gather_global_sort(). Measured on 35B-A3B-3bit M4 base: - S=1 decode: 27ms → 17ms (−37%) - S=16 verify: 253ms → 112ms (−56%) - MoE/layer at K=1: 0.47ms (down from ~0.68ms) Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Reflow `let fw/fs/fb = ops::concatenate_axis(..)` from broken-line indentation back onto single lines so `cargo fmt --all -- --check` passes in CI.
2e9e083 to
18bf33f
Compare
Two errors flagged by `-D clippy::doc-markdown` and `-D clippy::cast-sign-loss`/`-D clippy::as-conversions`: - Backtick `MoE` and `gather_qmm` in the `fused_gate_up` doc comment. - Replace `top_k as u32` with the same `u32::try_from(top_k).map_err(...)` pattern already used by `forward_gather_global_sort`.
5 tasks
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
SwitchMlpWeights::forward_gather_fused()lazy-concatenates gate+up weights on first call, then dispatches a singlegather_qmminstead of two separate calls.FfnBlock::forward()now routes through the fused path instead offorward_gather_global_sort().Numbers (35B-A3B-3bit on M4 base)
Test plan
cargo check -p higgs-models— cleancargo test -p higgs-models --lib qwen3_next::— 71 passed, 0 failed (includes newtest_moe_gate_up_fusion_parity)cargo run -p higgs-bench --release --bin bench_decode -- --model <qwen3_5_moe-key>— A/B against main on a Qwen3.5-MoE checkpointcargo clippy -p higgs-models— cleanNotes
crates/higgs-models/src/qwen3_next.rs(+175 / −9)