feat: configurable prefill step size for SimpleEngine#174
Closed
Thump604 wants to merge 2 commits intowaybarrios:mainfrom
Closed
feat: configurable prefill step size for SimpleEngine#174Thump604 wants to merge 2 commits intowaybarrios:mainfrom
Thump604 wants to merge 2 commits intowaybarrios:mainfrom
Conversation
When both --mllm and --enable-mtp are set, SimpleEngine builds a parallel mlx_lm TextModel sharing the VLM backbone weights (zero-copy). Text-only requests route to mlx_lm with MTP speculative decoding; media requests route to the mlx_vlm MLLM path. Key components: - text_model_from_vlm.py: Build mlx_lm TextModel from VLM weights - Per-request routing in stream_chat() via _has_media_content() - _stream_generate_text() for MTP-accelerated text generation - MTP passthrough: --enable-mtp flag through CLI/server/engine/LLM Tested on Qwen3.5-35B-A3B VLM+MTP (8-bit): - Text (MTP): 65.3 tok/s - Vision (MLLM): 63.8 tok/s - Memory: 38.7 GB (zero-copy, same as single model)
Add --prefill-step-size CLI flag (default: 2048) to control the chunk size used during prompt prefill. mlx-lm defaults MTP to 512 which is overly conservative — benchmarks on M2 Ultra show 512→2048 gives +22-25% prefill throughput with negligible memory increase. Thread the value through cli → server.load_model → SimpleEngine → MLXLanguageModel → mlx_lm.stream_generate(), covering both the direct LLM path and the MLLM+MTP text-routing path.
This was referenced Mar 18, 2026
Collaborator
Author
|
Superseded — configurable prefill step size merged upstream via PR #180. |
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.
Add
--prefill-step-sizeCLI flag to configure chunk size for prompt prefill (default 2048).Why: mlx-lm MTP default is 512. Increasing to 2048 gives +22% prefill throughput on 122B models. Configurable for tuning on different hardware.
Files:
cli.py,engine/simple.pyTest: