Conversation
This commit updates the MLX_LM class to include support for draft models, allowing for speculative decoding. A new method, _load_draft_model, is introduced to load the draft model and its tokenizer, with validation to ensure compatibility. The constructor is modified to accept draft model parameters, and the create_prompt_cache method is updated to incorporate caches from both the main and draft models. Additionally, logging is added to warn about potential tokenizer mismatches.
…onfiguration This commit introduces new CLI options for specifying a draft model and the number of draft tokens for speculative decoding. The MLXServerConfig class is updated to handle these new parameters, including validation for model type compatibility. Additionally, the MLXLMHandler is modified to accept draft model parameters, enhancing the model's capabilities for speculative decoding. This change improves flexibility in model usage and aligns with recent enhancements in the MLX_LM class.
…tions for draft models
|
I wrote a shortlist of possible testing for speculative decoding, including Qwen3, Nemotron, and GPT-OSS-20B. waybarrios/vllm-mlx#45 (comment) |
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.
feat: add speculative decoding support for lm models
Adds speculative decoding for text-only (
lm) models: a smaller draft model proposes tokens and the main model verifies them, speeding up generation.Changes
--draft-model <path>and--num-draft-tokens <n>(default: 2). Only applied when--model-type lm; other model types ignore them and log a warning.MLXServerConfiggainsdraft_model_pathandnum_draft_tokenswith lm-only validation.MLXLMHandlerpasses draft model and num draft tokens intoMLX_LMand uses keyword args forcontext_lengthto match the updated constructor.Example
Related issues
#177