Repository navigation
Add pipeline parallelism for Qwen3 MoE - #1801
Merged
Merged
Conversation
Collaborator
|
Thank you for your contribution, will test it as soon as possible. |
nastya236
approved these changes
Sep 1, 2026
nastya236
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me! Tested on 4 m5 ultra mesh.
azamamirza
added a commit
to azamamirza/mlx-lm
that referenced
this pull request
Sep 1, 2026
Regenerated from upstream/main e93eaf7. Both qwen3_moe patches are now upstream (ml-explore#1774 tensor parallel, merged 2026-08-22; ml-explore#1801 pipeline, merged 2026-08-29 - the base commit itself), so this branch carries ZERO code patches: upstream + this document + the version marker. Zero functional divergence for the first time since the fork was created.
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.
Problem
qwen3_moehas no pipeline support, so Qwen3 MoE checkpoints cannot besplit layer-wise across machines the way
glm4_moe,deepseek_v3, andother MoE models already can via
PipelineMixin. (Companion to thetensor-parallel
shard()added in #1774; this adds the pipeline axis.)Change
Follows the established
glm4_moe/deepseek_v3pattern exactly:Qwen3MoeModelmixes inPipelineMixinand its__call__gains thestandard pipeline plumbing:
recv_likefrom the previous rank, runpipeline_layers,sendto the next rank with themx.dependstie onthe last cache, and the final
all_gatherbroadcast. Withpipeline_size == 1(the default) every branch is skipped and behavioris unchanged.
Model.layersreturnsself.model.pipeline_layers(as inglm4_moe).tests/model_parallel_tests.py::test_pipeline, a structural testin the style of the existing
test_shard: a tinyqwen3_moeconfig ispipelined on a size-1 group and must match the un-pipelined output.
Verification
Rebased onto current
main(which already includes #1774 and #1787):tests/model_parallel_tests.py: 2 passed, 5 subtests passed.tests/test_models.py -k qwen3: 3 passed.JACCL ring, Thunderbolt 5),
Qwen3-235B-A22B4-bit, greedy, identicalprompt: 2-node pipeline 28.41 tok/s decode, TTFT 7.23 s vs 2-node
tensor-parallel sharding 24.56 tok/s / TTFT 11.91 s (+16% decode,
-39% TTFT); generated text checked coherent and consistent between the
two modes.
black/isort --profile=blackclean.