Repository navigation
feat(qwen3-next): add pipeline-parallel stage support (StageModel + stage executor) #510
Copy link
Copy link
Closed
Labels
area:modelsModel architectures, weights, loading, metadataModel architectures, weights, loading, metadatapriority:mediumMedium priorityMedium prioritystatus:doneCompletedCompletedtype:enhancementNew features, capabilities, or significant additionsNew features, capabilities, or significant additions
Description
Summary
mlxcel supports pipeline-parallel (PP) layer-range sharding across stages for many families, but qwen3_next is missing it. The closely related qwen3_5 family already has full PP stage support, so qwen3_next is the odd one out among the Qwen3-Next-style hybrid (gated-delta + attention) models.
Current state in mlxcel
- PP infrastructure exists:
StageFamilyenum and per-model dispatch insrc/distributed/pipeline/stage_executor/mod.rs(families listed atmod.rs:241-244,ModelType -> StageFamilymatch atmod.rs:331-354), with per-family executors undersrc/distributed/pipeline/stage_executor/(e.g.qwen35.rs,deepseek_v3.rs,gemma4.rs,gpt_oss.rs,llama.rs, ...). qwen3_5is fully PP-shardable:Qwen35StageModel(src/models/qwen3_5.rs:2079-2156) withstage_index/filter.layer_range/ hidden-state and token-ID stage I/O, plus the dedicated executorsrc/distributed/pipeline/stage_executor/qwen35.rs.qwen3_nexthas no stage support:src/models/qwen3_next.rsimplements noStageModel/LayerFilter/StageExecutionOutput, and there is nostage_executor/qwen3_next.rs. So aqwen3_nextcheckpoint cannot be served across PP stages.
This matters because qwen3_5 itself reuses qwen3_next's building blocks (Qwen3NextAttention, Qwen3NextMLP, Qwen3NextRMSNormGated, gated_delta_update), so the PP work for qwen3_next is structurally very close to the existing qwen3_5 stage implementation.
What needs to be built
Qwen3NextStageModelinsrc/models/qwen3_next.rs, mirroringQwen35StageModel: load only the layers infilter.layer_range, accept/produce hidden states (intermediate stages) or token IDs / final logits (first/last stage), tie embeddings on the final stage.- Hybrid cache across stage boundaries.
qwen3_nextmixes linear (gated-delta,ArraysCache) and attention (KVCache) layers; the stage model must build and advance the correct cache type per local layer, exactly as the single-process path does, and the SSM/attention masks must be derived from the layers actually present in the stage. Qwen3NextStageExecutorundersrc/distributed/pipeline/stage_executor/qwen3_next.rs, modeled onqwen35.rs.- Registration: add the
StageFamilyvariant(s) instage_executor/mod.rs(enum, name mapping, PP-capable set, and theModelType::Qwen3Next* -> StageFamilymatch arms), covering the MoE/VLM variants if applicable.
Acceptance criteria
-
qwen3_nextshards across >= 2 PP stages and completes generation. - Multi-stage decode output matches single-process decode for the same checkpoint/prompt/seed (jitter-aware parity, consistent with how other hybrid families are gated).
- Hybrid cache (gated-delta
ArraysCache+ attentionKVCache) is constructed and advanced correctly per stage; masks derived from stage-local layers. -
qwen3_nextappears in the PP-capable family set and is dispatched to the new executor. - Validated on a real
qwen3_nextcheckpoint across stages.
Files
src/models/qwen3_next.rs(newQwen3NextStageModel)src/distributed/pipeline/stage_executor/qwen3_next.rs(new executor)src/distributed/pipeline/stage_executor/mod.rs(StageFamily variant + dispatch + PP-capable set)- tests mirroring the
qwen3_5stage tests
Context
Discovered while auditing pipeline-parallel coverage during an upstream-sync review: qwen3_5 gained model-level pipelining but qwen3_next was never given the equivalent stage plumbing in mlxcel.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:modelsModel architectures, weights, loading, metadataModel architectures, weights, loading, metadatapriority:mediumMedium priorityMedium prioritystatus:doneCompletedCompletedtype:enhancementNew features, capabilities, or significant additionsNew features, capabilities, or significant additions
Activity