Skip to content

vllm_mlx

vllm-mlx: Apple Silicon MLX backend for vLLM This package provides native Apple Silicon GPU acceleration for vLLM using Apple's MLX framework, mlx-lm for LLMs, and mlx-vlm for vision-language models.

View the complete module source at #L1-L132.

API details

Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.

vllm_mlx

vllm-mlx: Apple Silicon MLX backend for vLLM

This package provides native Apple Silicon GPU acceleration for vLLM using Apple's MLX framework, mlx-lm for LLMs, and mlx-vlm for vision-language models.

Features: - Continuous batching via vLLM-style scheduler - OpenAI-compatible API server - Support for LLM and multimodal models

vllm_mlx.__version__ module-attribute

__version__ = '0.4.1'

vllm_mlx.__all__ module-attribute

__all__ = ['MLXPlatform', 'MLXWorker', 'MLXModelRunner', 'MLXAttentionBackend', 'Request', 'RequestOutput', 'RequestStatus', 'SamplingParams', 'Scheduler', 'SchedulerConfig', 'SchedulerOutput', 'EngineCore', 'AsyncEngineCore', 'EngineConfig', 'get_registry', 'ModelOwnershipError', 'PrefixCacheManager', 'PrefixCacheStats', 'BlockAwarePrefixCache', 'PagedCacheManager', 'CacheBlock', 'BlockTable', 'CacheStats', 'MLLMCacheManager', 'MLLMCacheStats', 'VLMCacheManager', 'VLMCacheStats', '__version__']

vllm_mlx.__getattr__

__getattr__(name)

Lazy load all components to avoid mlx_lm import on non-Apple platforms.

Source code in vllm_mlx/__init__.py
def __getattr__(name):
    """Lazy load all components to avoid mlx_lm import on non-Apple platforms."""
    # Request management
    if name in ("Request", "RequestOutput", "RequestStatus", "SamplingParams"):
        from vllm_mlx import request

        return getattr(request, name)

    # Scheduler
    if name in ("Scheduler", "SchedulerConfig", "SchedulerOutput"):
        from vllm_mlx import scheduler

        return getattr(scheduler, name)

    # Engine
    if name in ("EngineCore", "AsyncEngineCore", "EngineConfig"):
        from vllm_mlx import engine_core

        return getattr(engine_core, name)

    # Prefix cache
    if name in ("PrefixCacheManager", "PrefixCacheStats", "BlockAwarePrefixCache"):
        from vllm_mlx import prefix_cache

        return getattr(prefix_cache, name)

    # Paged cache
    if name in ("PagedCacheManager", "CacheBlock", "BlockTable", "CacheStats"):
        from vllm_mlx import paged_cache

        return getattr(paged_cache, name)

    # MLLM cache (with legacy VLM aliases)
    if name in (
        "MLLMCacheManager",
        "MLLMCacheStats",
        "VLMCacheManager",
        "VLMCacheStats",
    ):
        from vllm_mlx import mllm_cache

        # Map legacy VLM names to MLLM
        mllm_name = name.replace("VLM", "MLLM") if name.startswith("VLM") else name
        return getattr(mllm_cache, mllm_name)

    # Model registry
    if name in ("get_registry", "ModelOwnershipError"):
        from vllm_mlx import model_registry

        return getattr(model_registry, name)

    # vLLM integration components (require torch)
    if name == "MLXPlatform":
        from vllm_mlx.vllm_platform import MLXPlatform

        return MLXPlatform
    if name == "MLXWorker":
        from vllm_mlx.worker import MLXWorker

        return MLXWorker
    if name == "MLXModelRunner":
        from vllm_mlx.model_runner import MLXModelRunner

        return MLXModelRunner
    if name == "MLXAttentionBackend":
        from vllm_mlx.attention import MLXAttentionBackend

        return MLXAttentionBackend

    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

Complete contract reference

Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.

vllm_mlx.__getattr__ · function
vllm_mlx.__getattr__(name) -> not annotated

Lazy load all components to avoid mlx_lm import on non-Apple platforms.

Parameters

Name Type Required Default Description
name not annotated yes none Required positional or keyword input.

Returns

  • Type: not annotated
  • Direct return expressions: getattr(request, name); getattr(scheduler, name); getattr(engine_core, name); getattr(prefix_cache, name); getattr(paged_cache, name); getattr(mllm_cache, mllm_name); getattr(model_registry, name); MLXPlatform; MLXWorker; MLXModelRunner; MLXAttentionBackend

Exceptions and behavior

Function __getattr__ calls getattr, name.startswith, name.replace, AttributeError; can raise AttributeError; has 11 explicit return paths. Directly raised exceptions: AttributeError.

View source #L21-L90.

Complete symbol map

This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.

Symbol Kind Signature and inputs What it does Source
__getattr__ function __getattr__(name) -> not annotated Lazy load all components to avoid mlx_lm import on non-Apple platforms. #L21-L90