Add MTP support for Step 3.5 Flash#901
Open
janhilgard wants to merge 1 commit intoml-explore:mainfrom
Open
Conversation
Add MTP speculative decoding support to the existing Step 3.5 Flash model: - Step3p5SharedHead: per-layer prediction head (norm + output projection) - Step3p5MTPLayer: hnorm + enorm → eh_proj → attention + dense MLP → shared_head - Step3p5MTP: container for multiple prediction layers - Model: return_hidden, mtp_forward, make_mtp_cache - sanitize: handle MTP weight loading - quant_predicate: exclude MTP norm layers from quantization Tested with mlx-community/Step-3.5-Flash-4bit (196B MoE, 3 MTP layers). Backward compatible — MTP is only instantiated when num_nextn_predict_layers > 0. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4644f8f to
ac83f11
Compare
janhilgard
added a commit
to janhilgard/vllm-mlx
that referenced
this pull request
Feb 16, 2026
Step 3.5 Flash is a 196B MoE model (288 experts, top-8 routing, ~11B active params) with 3 MTP prediction layers. The MLX community 4-bit conversion strips MTP weights and lacks MTP-aware modeling code. This adds: - scripts/add_mtp_weights_step3p5.py: Downloads BF16 MTP shards from the original model, extracts layers 45-47, remaps to mtp.layers.*, quantizes to 4-bit, and installs the MTP modeling file - scripts/modeling_step3p5_mtp.py: Full MLX-native model implementation with MTP support (Step3p5MTP, Step3p5MTPLayer, Step3p5SharedHead) - Reasoning parser alias "step3p5" (reuses deepseek_r1 <think> parser) - Documentation updates in README.md and docs/reference/models.md Note: The custom modeling file is a workaround until ml-explore/mlx-lm#901 is merged upstream. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4 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
num_nextn_predict_layers > 0Changes
Step3p5SharedHeadStep3p5MTPLayerStep3p5MTPModel.__call__return_hiddenparameter for MTP integrationModel.mtp_forwardModel.make_mtp_cachesanitizequant_predicateAlso fixes two pre-existing
ruffE741 lint warnings (l→layerin generator expressions).MTP Architecture
Each MTP layer uses sliding attention with dense SwiGLU MLP (not MoE), matching the original StepFun architecture.
Test plan
return_hidden=Truereturns prenorm hidden statesmtp_forward()produces correct-shaped logitsmake_mtp_cache()returns KVCache list matching MTP layer countruff formatandruff checkpass cleanlymlx-community/Step-3.5-Flash-4bit(111 GB, requires Apple Silicon)🤖 Generated with Claude Code