Codebase map¶
This map identifies the primary owner of each runtime concern. Use the generated Python API reference for every object and line-precise source links.
Entry points¶
| Path | Responsibility |
|---|---|
vllm_mlx/cli.py |
vllm-mlx command tree, server configuration, model workflow, and benchmark dispatch |
vllm_mlx/server.py |
FastAPI application, route handlers, protocol streaming, lifecycle integration, and process entry point |
vllm_mlx/benchmark.py |
Local model benchmark entry point |
vllm_mlx/bench_serve.py |
HTTP serving benchmark and workload contract runner |
vllm_mlx/gradio_app.py |
Multimodal Gradio chat application |
vllm_mlx/gradio_text_app.py |
Text-only Gradio chat application |
vllm_mlx/plugin.py |
vLLM out-of-tree MLX platform registration |
API contracts¶
vllm_mlx/api/ contains Pydantic wire models and conversion helpers:
models.pydefines OpenAI-compatible requests and responses.responses_models.pydefines Responses API items and streaming events.anthropic_models.pydefines Anthropic Messages types.anthropic_adapter.pyconverts Anthropic content and tools to internal OpenAI-style messages and converts results back.prompt_canonicalize.pynormalizes system prompts.streaming.pyprovides a low-overhead SSE JSON encoder.tool_calling.pycontains protocol-level tool utilities.harmony_tools.pyrenders Harmony tool definitions.utils.pycontains shared content and model-detection helpers.
Engines and request state¶
engine/base.pyis the stable engine interface and shared generation output.engine/simple.pyhandles direct text and multimodal generation.engine/batched.pyadapts the continuous-batching core toBaseEngine.engine/chat_template_safety.pynormalizes messages before Jinja templates.engine_core.pyowns the background scheduler loop, request collectors, and model ownership.request.pydefines request status, sampling parameters, request state, and scheduler output.output_collector.pymaps scheduler deltas and terminal results back to individual async callers.
Scheduling and inference¶
scheduler.pyruns text continuous batching with mlx-lmBatchGenerator.mllm_scheduler.pyschedules multimodal requests.mllm_batch_generator.pyadvances multimodal batches and reports throughput.model_runner.pyexposes the vLLM-facing MLX model runner.mlx_streams.pyowns MLX thread-stream binding helpers.multimodal_processor.pyprepares text, image, and video model inputs.
Model ownership and workflow¶
models/llm.pywraps text models.models/mllm.pywraps vision-language models.model_registry.pyprovides registry-backed loading, leases, memory budgets, and eviction.lifecycle.pyprovides lazy load and automatic idle unload for the default model.model_workflow.pyimplements inspect, acquire, convert, register, and qualify operations.text_model_from_vlm.pyreconstructs an mlx-lm text model from mlx-vlm-loaded weights.endpoint_model_policies.pyresolves compatible optional-endpoint models.
Caches¶
prefix_cache.pyimplements entry and block-aware prefix reuse.memory_cache.pyimplements memory-budgeted prefix reuse and optional quantization.paged_cache.pyimplements reference-counted block storage and sharing.ssd_cache.pyimplements serialized disk tiering.mllm_cache.pystores multimodal prompt state.vision_embedding_cache.pystores reusable vision preprocessing results.utils/mamba_cache.pyadapts state-space model caches to batching.
Output interpretation¶
reasoning/contains complete and streaming reasoning parsers.tool_parsers/contains model-family-specific tool-call parsers and the parser registry.constrained/contains tokenizer enforcement caches, JSON Schema logits processing, and the thinking state machine.utils/harmony_render.pyrenders GPT-OSS Harmony prompts.api/harmony_tools.pyconverts tool definitions for Harmony.
Optional model services¶
audio/contains preprocessing, STT, and TTS engines.audio_limits.pyvalidates optional audio route inputs.embedding.pyloads and serves embedding models.rerank.pyloads and serves reranking models.rerank_forward.pyimplements the MLX sequence-classification forward pass.
MCP¶
mcp/config.pyloads and validates server definitions.mcp/client.pymanages one MCP connection.mcp/manager.pycoordinates all configured servers.mcp/tools.pyconverts tool schemas.mcp/executor.pyapplies concurrency and invokes tools.mcp/security.pyvalidates commands, paths, arguments, and environment.mcp/types.pydefines MCP-facing data structures.
Model-specific compatibility¶
patches/ contains narrow runtime adaptations for Gemma 4, GLM-4V MoE, Qwen3.5, and Qwen3-Next MTP. specprefill.py contains sparse-prefill logic. optimizations.py reports hardware and selects safe optimization values.
Tests¶
Tests are organized by behavior rather than mirroring every module. Search for the public object or endpoint first, then inspect the nearest regression file. Linux CI covers static checks and non-MLX behavior. Apple Silicon CI covers model, scheduler, cache, server, and streaming paths that require MLX.
Documentation tools¶
scripts/docs_inventory.pyparses tracked Python source without importing it.scripts/gen_api_reference.pycreates module pages and source maps.scripts/check_docs_coverage.pyenforces module, symbol, and public-docstring coverage.scripts/mkdocs_hooks.pycreates Markdown mirrors,llms-full.txt, andapi-inventory.json..github/workflows/docs.ymlvalidates pull requests targetinggh-pagesand deploys pushes from that branch.