Skip to content

vllm_mlx.vllm_platform

MLX Platform implementation for vLLM.

View the complete module source at #L1-L351.

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_platform

MLX Platform implementation for vLLM.

This module provides the MLXPlatform class that integrates Apple's MLX framework with vLLM's platform system, enabling native Apple Silicon GPU acceleration.

vllm_mlx.vllm_platform.logger module-attribute

logger = logging.getLogger(__name__)

vllm_mlx.vllm_platform.MLXPlatform

Platform implementation for Apple Silicon using MLX.

This platform uses Apple's MLX framework for GPU-accelerated inference on Apple Silicon Macs. It integrates with mlx-lm for LLM inference and mlx-vlm for vision-language models.

Key features: - Unified memory model (no CPU<->GPU transfers) - Native Metal GPU acceleration - Optimized kernels for Apple Silicon - Support for quantized models (4-bit, 8-bit)

vllm_mlx.vllm_platform.MLXPlatform._enum property

_enum

vllm_mlx.vllm_platform.MLXPlatform.device_name class-attribute instance-attribute

device_name: str = 'mlx'

vllm_mlx.vllm_platform.MLXPlatform.device_type class-attribute instance-attribute

device_type: str = 'mlx'

vllm_mlx.vllm_platform.MLXPlatform.dispatch_key class-attribute instance-attribute

dispatch_key: str = 'CPU'

vllm_mlx.vllm_platform.MLXPlatform.ray_device_key class-attribute instance-attribute

ray_device_key: str = ''

vllm_mlx.vllm_platform.MLXPlatform.device_control_env_var class-attribute instance-attribute

device_control_env_var: str = 'MLX_VISIBLE_DEVICES'

vllm_mlx.vllm_platform.MLXPlatform.simple_compile_backend class-attribute instance-attribute

simple_compile_backend: str = 'eager'

vllm_mlx.vllm_platform.MLXPlatform.dist_backend class-attribute instance-attribute

dist_backend: str = 'gloo'

vllm_mlx.vllm_platform.MLXPlatform.supported_quantization class-attribute instance-attribute

supported_quantization: list[str] = ['mlx-4bit', 'mlx-8bit']

vllm_mlx.vllm_platform.MLXPlatform.additional_env_vars class-attribute instance-attribute

additional_env_vars: list[str] = []

vllm_mlx.vllm_platform.MLXPlatform._global_graph_pool class-attribute instance-attribute

_global_graph_pool: Any | None = None

vllm_mlx.vllm_platform.MLXPlatform.supported_dtypes property

supported_dtypes: list[dtype]

Return supported dtypes for MLX.

vllm_mlx.vllm_platform.MLXPlatform.is_cuda

is_cuda() -> bool

Return False because this platform does not use CUDA.

Source code in vllm_mlx/vllm_platform.py
def is_cuda(self) -> bool:
    """Return ``False`` because this platform does not use CUDA."""

    return False

vllm_mlx.vllm_platform.MLXPlatform.is_rocm

is_rocm() -> bool

Return False because this platform does not use ROCm.

Source code in vllm_mlx/vllm_platform.py
def is_rocm(self) -> bool:
    """Return ``False`` because this platform does not use ROCm."""

    return False

vllm_mlx.vllm_platform.MLXPlatform.is_tpu

is_tpu() -> bool

Return False because this platform is not a TPU backend.

Source code in vllm_mlx/vllm_platform.py
def is_tpu(self) -> bool:
    """Return ``False`` because this platform is not a TPU backend."""

    return False

vllm_mlx.vllm_platform.MLXPlatform.is_xpu

is_xpu() -> bool

Return False because this platform does not use Intel XPU.

Source code in vllm_mlx/vllm_platform.py
def is_xpu(self) -> bool:
    """Return ``False`` because this platform does not use Intel XPU."""

    return False

vllm_mlx.vllm_platform.MLXPlatform.is_cpu

is_cpu() -> bool

Return False because MLX targets Apple GPU acceleration here.

Source code in vllm_mlx/vllm_platform.py
def is_cpu(self) -> bool:
    """Return ``False`` because MLX targets Apple GPU acceleration here."""

    return False

vllm_mlx.vllm_platform.MLXPlatform.is_mlx

is_mlx() -> bool

Return True to identify the MLX platform plugin.

Source code in vllm_mlx/vllm_platform.py
def is_mlx(self) -> bool:
    """Return ``True`` to identify the MLX platform plugin."""

    return True

vllm_mlx.vllm_platform.MLXPlatform.is_out_of_tree

is_out_of_tree() -> bool

Return True because MLX is registered as a vLLM plugin.

Source code in vllm_mlx/vllm_platform.py
def is_out_of_tree(self) -> bool:
    """Return ``True`` because MLX is registered as a vLLM plugin."""

    return True

vllm_mlx.vllm_platform.MLXPlatform.is_cuda_alike

is_cuda_alike() -> bool

Return False because MLX does not implement CUDA semantics.

Source code in vllm_mlx/vllm_platform.py
def is_cuda_alike(self) -> bool:
    """Return ``False`` because MLX does not implement CUDA semantics."""

    return False

vllm_mlx.vllm_platform.MLXPlatform.is_sleep_mode_available

is_sleep_mode_available() -> bool

Return False because vLLM sleep mode is unavailable on MLX.

Source code in vllm_mlx/vllm_platform.py
def is_sleep_mode_available(self) -> bool:
    """Return ``False`` because vLLM sleep mode is unavailable on MLX."""

    return False

vllm_mlx.vllm_platform.MLXPlatform.get_device_name classmethod

get_device_name(device_id: int = 0) -> str

Get the Apple Silicon chip name.

Source code in vllm_mlx/vllm_platform.py
@classmethod
def get_device_name(cls, device_id: int = 0) -> str:
    """Get the Apple Silicon chip name."""
    return _get_apple_chip_name()

vllm_mlx.vllm_platform.MLXPlatform.get_device_uuid classmethod

get_device_uuid(device_id: int = 0) -> str

Get device UUID (not applicable for MLX).

Source code in vllm_mlx/vllm_platform.py
@classmethod
def get_device_uuid(cls, device_id: int = 0) -> str:
    """Get device UUID (not applicable for MLX)."""
    return "mlx-0"

vllm_mlx.vllm_platform.MLXPlatform.get_device_total_memory classmethod

get_device_total_memory(device_id: int = 0) -> int

Get total unified memory in bytes.

Source code in vllm_mlx/vllm_platform.py
@classmethod
def get_device_total_memory(cls, device_id: int = 0) -> int:
    """Get total unified memory in bytes."""
    return _get_unified_memory_size()

vllm_mlx.vllm_platform.MLXPlatform.inference_mode classmethod

inference_mode()

Return inference mode context manager.

Source code in vllm_mlx/vllm_platform.py
@classmethod
def inference_mode(cls):
    """Return inference mode context manager."""
    # MLX doesn't need a special inference mode
    # Return torch.no_grad() for compatibility
    return torch.no_grad()

vllm_mlx.vllm_platform.MLXPlatform.set_device classmethod

set_device(device: device) -> None

Set the device (no-op for MLX, uses default device).

Source code in vllm_mlx/vllm_platform.py
@classmethod
def set_device(cls, device: torch.device) -> None:
    """Set the device (no-op for MLX, uses default device)."""
    # MLX automatically uses the GPU
    pass

vllm_mlx.vllm_platform.MLXPlatform.seed_everything classmethod

seed_everything(seed: int | None = None) -> None

Set random seeds for reproducibility.

Source code in vllm_mlx/vllm_platform.py
@classmethod
def seed_everything(cls, seed: int | None = None) -> None:
    """Set random seeds for reproducibility."""
    import random
    import numpy as np

    if seed is not None:
        random.seed(seed)
        np.random.seed(seed)
        torch.manual_seed(seed)

        # Set MLX seed
        try:
            import mlx.core as mx

            mx.random.seed(seed)
        except Exception:
            pass

vllm_mlx.vllm_platform.MLXPlatform.import_kernels classmethod

import_kernels() -> None

Import MLX kernels (no custom C kernels).

Source code in vllm_mlx/vllm_platform.py
@classmethod
def import_kernels(cls) -> None:
    """Import MLX kernels (no custom C kernels)."""
    # MLX uses its own Metal kernels, no vllm._C needed
    pass

vllm_mlx.vllm_platform.MLXPlatform.get_attn_backend_cls classmethod

get_attn_backend_cls(selected_backend, head_size: int, dtype: dtype, kv_cache_dtype, block_size: int, use_mla: bool, has_sink: bool, use_sparse: bool, attn_type: str | None = None) -> str

Return MLX attention backend class path.

Source code in vllm_mlx/vllm_platform.py
@classmethod
def get_attn_backend_cls(
    cls,
    selected_backend,
    head_size: int,
    dtype: torch.dtype,
    kv_cache_dtype,
    block_size: int,
    use_mla: bool,
    has_sink: bool,
    use_sparse: bool,
    attn_type: str | None = None,
) -> str:
    """Return MLX attention backend class path."""
    # Use our custom MLX attention backend
    return "vllm_mlx.attention.MLXAttentionBackend"

vllm_mlx.vllm_platform.MLXPlatform.check_and_update_config classmethod

check_and_update_config(vllm_config: VllmConfig) -> None

Check and update vLLM configuration for MLX.

Source code in vllm_mlx/vllm_platform.py
@classmethod
def check_and_update_config(cls, vllm_config: "VllmConfig") -> None:
    """Check and update vLLM configuration for MLX."""
    logger.info("Configuring vLLM for MLX backend on Apple Silicon")

    # Get chip info
    chip_name = _get_apple_chip_name()
    memory_gb = _get_unified_memory_size() / (1024**3)
    logger.info(f"Detected: {chip_name} with {memory_gb:.1f}GB unified memory")

    # Disable CUDA-specific features
    if hasattr(vllm_config, "compilation_config"):
        # Disable CUDA graphs
        vllm_config.compilation_config.cudagraph_capture_sizes = []

    # Set worker class to MLX worker
    if hasattr(vllm_config, "parallel_config"):
        parallel_config = vllm_config.parallel_config
        if parallel_config.worker_cls == "auto":
            parallel_config.worker_cls = "vllm_mlx.worker.MLXWorker"

        # Disable features not supported on MLX
        if parallel_config.enable_dbo:
            logger.warning("Dual-Batch Overlap not supported on MLX, disabling")
            parallel_config.enable_dbo = False

    # Configure cache
    if hasattr(vllm_config, "cache_config"):
        cache_config = vllm_config.cache_config
        if cache_config.block_size is None:
            cache_config.block_size = 16  # Default for MLX

vllm_mlx.vllm_platform.MLXPlatform.verify_model_arch classmethod

verify_model_arch(model_arch: str) -> None

Verify model architecture is supported on MLX.

Source code in vllm_mlx/vllm_platform.py
@classmethod
def verify_model_arch(cls, model_arch: str) -> None:
    """Verify model architecture is supported on MLX."""
    # mlx-lm supports most transformer architectures
    # Log a warning for potentially unsupported models
    unsupported_hints = ["mamba", "rwkv", "retnet"]
    for hint in unsupported_hints:
        if hint.lower() in model_arch.lower():
            logger.warning(
                f"Model architecture {model_arch} may not be fully "
                f"supported on MLX. Please verify with mlx-lm."
            )
            break

vllm_mlx.vllm_platform.MLXPlatform.verify_quantization classmethod

verify_quantization(quant: str) -> None

Verify quantization method is supported.

Source code in vllm_mlx/vllm_platform.py
@classmethod
def verify_quantization(cls, quant: str) -> None:
    """Verify quantization method is supported."""
    supported = ["mlx-4bit", "mlx-8bit", None, ""]
    if quant and quant not in supported:
        raise ValueError(
            f"Quantization '{quant}' not supported on MLX. "
            f"Supported: {supported}"
        )

vllm_mlx.vllm_platform.MLXPlatform.is_pin_memory_available classmethod

is_pin_memory_available() -> bool

Pin memory not needed with unified memory.

Source code in vllm_mlx/vllm_platform.py
@classmethod
def is_pin_memory_available(cls) -> bool:
    """Pin memory not needed with unified memory."""
    return False

vllm_mlx.vllm_platform.MLXPlatform.get_current_memory_usage classmethod

get_current_memory_usage(device=None) -> float

Get current memory usage in bytes.

Source code in vllm_mlx/vllm_platform.py
@classmethod
def get_current_memory_usage(cls, device=None) -> float:
    """Get current memory usage in bytes."""
    try:

        # MLX doesn't have a direct memory query
        # Use system memory info instead
        import psutil

        process = psutil.Process()
        return float(process.memory_info().rss)
    except Exception:
        return 0.0

vllm_mlx.vllm_platform.MLXPlatform.supports_fp8 classmethod

supports_fp8() -> bool

FP8 not supported on MLX.

Source code in vllm_mlx/vllm_platform.py
@classmethod
def supports_fp8(cls) -> bool:
    """FP8 not supported on MLX."""
    return False

vllm_mlx.vllm_platform.MLXPlatform.use_custom_allreduce classmethod

use_custom_allreduce() -> bool

Custom allreduce not available.

Source code in vllm_mlx/vllm_platform.py
@classmethod
def use_custom_allreduce(cls) -> bool:
    """Custom allreduce not available."""
    return False

vllm_mlx.vllm_platform.MLXPlatform.support_static_graph_mode classmethod

support_static_graph_mode() -> bool

Static graph mode (CUDA graphs) not supported.

Source code in vllm_mlx/vllm_platform.py
@classmethod
def support_static_graph_mode(cls) -> bool:
    """Static graph mode (CUDA graphs) not supported."""
    return False

vllm_mlx.vllm_platform.MLXPlatform.get_device_communicator_cls classmethod

get_device_communicator_cls() -> str

Return the communicator class for distributed.

Source code in vllm_mlx/vllm_platform.py
@classmethod
def get_device_communicator_cls(cls) -> str:
    """Return the communicator class for distributed."""
    return "vllm_mlx.distributed.MLXCommunicator"

vllm_mlx.vllm_platform.MLXPlatform.get_punica_wrapper classmethod

get_punica_wrapper() -> str

Return LoRA wrapper (not yet implemented for MLX).

Source code in vllm_mlx/vllm_platform.py
@classmethod
def get_punica_wrapper(cls) -> str:
    """Return LoRA wrapper (not yet implemented for MLX)."""
    raise NotImplementedError("LoRA not yet supported on MLX backend")

vllm_mlx.vllm_platform.MLXPlatform.__repr__

__repr__() -> str
Source code in vllm_mlx/vllm_platform.py
def __repr__(self) -> str:
    return f"<MLXPlatform device={self.device_name}>"

vllm_mlx.vllm_platform._get_apple_chip_name

_get_apple_chip_name() -> str

Get the name of the Apple Silicon chip.

Source code in vllm_mlx/vllm_platform.py
def _get_apple_chip_name() -> str:
    """Get the name of the Apple Silicon chip."""
    try:
        result = subprocess.run(
            ["sysctl", "-n", "machdep.cpu.brand_string"],
            capture_output=True,
            text=True,
            check=True,
        )
        return result.stdout.strip()
    except Exception:
        return "Apple Silicon"

vllm_mlx.vllm_platform._get_unified_memory_size

_get_unified_memory_size() -> int

Get the total unified memory size in bytes.

Source code in vllm_mlx/vllm_platform.py
def _get_unified_memory_size() -> int:
    """Get the total unified memory size in bytes."""
    try:
        result = subprocess.run(
            ["sysctl", "-n", "hw.memsize"],
            capture_output=True,
            text=True,
            check=True,
        )
        return int(result.stdout.strip())
    except Exception:
        # Fallback: return 8GB
        return 8 * 1024 * 1024 * 1024

vllm_mlx.vllm_platform._is_mlx_available

_is_mlx_available() -> bool

Check if MLX is available and working.

Source code in vllm_mlx/vllm_platform.py
def _is_mlx_available() -> bool:
    """Check if MLX is available and working."""
    try:
        import mlx.core as mx

        # Verify we can actually use MLX
        _ = mx.array([1.0, 2.0, 3.0])
        return True
    except Exception as e:
        logger.debug("MLX not available: %s", e)
        return False

vllm_mlx.vllm_platform._is_apple_silicon

_is_apple_silicon() -> bool

Check if running on Apple Silicon.

Source code in vllm_mlx/vllm_platform.py
def _is_apple_silicon() -> bool:
    """Check if running on Apple Silicon."""
    return sys.platform == "darwin" and platform.machine() == "arm64"

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.vllm_platform._get_apple_chip_name · function
vllm_mlx.vllm_platform._get_apple_chip_name() -> str

Get the name of the Apple Silicon chip.

Parameters

This callable has no explicit inputs.

Returns

  • Type: str
  • Direct return expressions: result.stdout.strip(); 'Apple Silicon'

Exceptions and behavior

Function _get_apple_chip_name calls subprocess.run, result.stdout.strip; has 2 explicit return paths. No direct raise statement appears in this definition.

View source #L24-L35.

vllm_mlx.vllm_platform._get_unified_memory_size · function
vllm_mlx.vllm_platform._get_unified_memory_size() -> int

Get the total unified memory size in bytes.

Parameters

This callable has no explicit inputs.

Returns

  • Type: int
  • Direct return expressions: int(result.stdout.strip()); 8 * 1024 * 1024 * 1024

Exceptions and behavior

Function _get_unified_memory_size calls subprocess.run, int, result.stdout.strip; has 2 explicit return paths. No direct raise statement appears in this definition.

View source #L38-L50.

vllm_mlx.vllm_platform._is_mlx_available · function
vllm_mlx.vllm_platform._is_mlx_available() -> bool

Check if MLX is available and working.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: True; False

Exceptions and behavior

Function _is_mlx_available calls mx.array, logger.debug; has 2 explicit return paths. No direct raise statement appears in this definition.

View source #L53-L63.

vllm_mlx.vllm_platform._is_apple_silicon · function
vllm_mlx.vllm_platform._is_apple_silicon() -> bool

Check if running on Apple Silicon.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: sys.platform == 'darwin' and platform.machine() == 'arm64'

Exceptions and behavior

Function _is_apple_silicon calls platform.machine; returns sys.platform == 'darwin' and platform.machine() == 'arm64'. No direct raise statement appears in this definition.

View source #L66-L68.

vllm_mlx.vllm_platform.MLXPlatform · class
vllm_mlx.vllm_platform.MLXPlatform()

Platform implementation for Apple Silicon using MLX.

Parameters

This callable has no explicit inputs.

Returns

  • Constructs: vllm_mlx.vllm_platform.MLXPlatform

Exceptions and behavior

Class MLXPlatform declares 30 direct member(s). No direct raise statement appears in this definition.

View source #L71-L351.

vllm_mlx.vllm_platform.MLXPlatform._enum · method
vllm_mlx.vllm_platform.MLXPlatform._enum() -> not annotated

Method MLXPlatform._enum returns PlatformEnum.OOT.

Parameters

This callable has no explicit inputs.

Returns

  • Type: not annotated
  • Direct return expressions: PlatformEnum.OOT

Exceptions and behavior

Method MLXPlatform._enum returns PlatformEnum.OOT. No direct raise statement appears in this definition.

View source #L90-L93.

vllm_mlx.vllm_platform.MLXPlatform.supported_dtypes · method
vllm_mlx.vllm_platform.MLXPlatform.supported_dtypes() -> list[torch.dtype]

Return supported dtypes for MLX.

Parameters

This callable has no explicit inputs.

Returns

  • Type: list[torch.dtype]
  • Direct return expressions: [torch.bfloat16, torch.float16, torch.float32]; [torch.float16, torch.float32]

Exceptions and behavior

Method MLXPlatform.supported_dtypes calls mx.array; has 2 explicit return paths. No direct raise statement appears in this definition.

View source #L122-L133.

vllm_mlx.vllm_platform.MLXPlatform.is_cuda · method
vllm_mlx.vllm_platform.MLXPlatform.is_cuda() -> bool

Return False because this platform does not use CUDA.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: False

Exceptions and behavior

Method MLXPlatform.is_cuda returns False. No direct raise statement appears in this definition.

View source #L135-L138.

vllm_mlx.vllm_platform.MLXPlatform.is_rocm · method
vllm_mlx.vllm_platform.MLXPlatform.is_rocm() -> bool

Return False because this platform does not use ROCm.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: False

Exceptions and behavior

Method MLXPlatform.is_rocm returns False. No direct raise statement appears in this definition.

View source #L140-L143.

vllm_mlx.vllm_platform.MLXPlatform.is_tpu · method
vllm_mlx.vllm_platform.MLXPlatform.is_tpu() -> bool

Return False because this platform is not a TPU backend.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: False

Exceptions and behavior

Method MLXPlatform.is_tpu returns False. No direct raise statement appears in this definition.

View source #L145-L148.

vllm_mlx.vllm_platform.MLXPlatform.is_xpu · method
vllm_mlx.vllm_platform.MLXPlatform.is_xpu() -> bool

Return False because this platform does not use Intel XPU.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: False

Exceptions and behavior

Method MLXPlatform.is_xpu returns False. No direct raise statement appears in this definition.

View source #L150-L153.

vllm_mlx.vllm_platform.MLXPlatform.is_cpu · method
vllm_mlx.vllm_platform.MLXPlatform.is_cpu() -> bool

Return False because MLX targets Apple GPU acceleration here.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: False

Exceptions and behavior

Method MLXPlatform.is_cpu returns False. No direct raise statement appears in this definition.

View source #L155-L158.

vllm_mlx.vllm_platform.MLXPlatform.is_mlx · method
vllm_mlx.vllm_platform.MLXPlatform.is_mlx() -> bool

Return True to identify the MLX platform plugin.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: True

Exceptions and behavior

Method MLXPlatform.is_mlx returns True. No direct raise statement appears in this definition.

View source #L160-L163.

vllm_mlx.vllm_platform.MLXPlatform.is_out_of_tree · method
vllm_mlx.vllm_platform.MLXPlatform.is_out_of_tree() -> bool

Return True because MLX is registered as a vLLM plugin.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: True

Exceptions and behavior

Method MLXPlatform.is_out_of_tree returns True. No direct raise statement appears in this definition.

View source #L165-L168.

vllm_mlx.vllm_platform.MLXPlatform.is_cuda_alike · method
vllm_mlx.vllm_platform.MLXPlatform.is_cuda_alike() -> bool

Return False because MLX does not implement CUDA semantics.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: False

Exceptions and behavior

Method MLXPlatform.is_cuda_alike returns False. No direct raise statement appears in this definition.

View source #L170-L173.

vllm_mlx.vllm_platform.MLXPlatform.is_sleep_mode_available · method
vllm_mlx.vllm_platform.MLXPlatform.is_sleep_mode_available() -> bool

Return False because vLLM sleep mode is unavailable on MLX.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: False

Exceptions and behavior

Method MLXPlatform.is_sleep_mode_available returns False. No direct raise statement appears in this definition.

View source #L175-L178.

vllm_mlx.vllm_platform.MLXPlatform.get_device_name · method
vllm_mlx.vllm_platform.MLXPlatform.get_device_name(device_id: int = 0) -> str

Get the Apple Silicon chip name.

Parameters

Name Type Required Default Description
device_id int no 0 Optional positional or keyword input; defaults to 0.

Returns

  • Type: str
  • Direct return expressions: _get_apple_chip_name()

Exceptions and behavior

Method MLXPlatform.get_device_name calls _get_apple_chip_name; returns _get_apple_chip_name(). No direct raise statement appears in this definition.

View source #L181-L183.

vllm_mlx.vllm_platform.MLXPlatform.get_device_uuid · method
vllm_mlx.vllm_platform.MLXPlatform.get_device_uuid(device_id: int = 0) -> str

Get device UUID (not applicable for MLX).

Parameters

Name Type Required Default Description
device_id int no 0 Optional positional or keyword input; defaults to 0.

Returns

  • Type: str
  • Direct return expressions: 'mlx-0'

Exceptions and behavior

Method MLXPlatform.get_device_uuid returns 'mlx-0'. No direct raise statement appears in this definition.

View source #L186-L188.

vllm_mlx.vllm_platform.MLXPlatform.get_device_total_memory · method
vllm_mlx.vllm_platform.MLXPlatform.get_device_total_memory(device_id: int = 0) -> int

Get total unified memory in bytes.

Parameters

Name Type Required Default Description
device_id int no 0 Optional positional or keyword input; defaults to 0.

Returns

  • Type: int
  • Direct return expressions: _get_unified_memory_size()

Exceptions and behavior

Method MLXPlatform.get_device_total_memory calls _get_unified_memory_size; returns _get_unified_memory_size(). No direct raise statement appears in this definition.

View source #L191-L193.

vllm_mlx.vllm_platform.MLXPlatform.inference_mode · method
vllm_mlx.vllm_platform.MLXPlatform.inference_mode() -> not annotated

Return inference mode context manager.

Parameters

This callable has no explicit inputs.

Returns

  • Type: not annotated
  • Direct return expressions: torch.no_grad()

Exceptions and behavior

Method MLXPlatform.inference_mode calls torch.no_grad; returns torch.no_grad(). No direct raise statement appears in this definition.

View source #L196-L200.

vllm_mlx.vllm_platform.MLXPlatform.set_device · method
vllm_mlx.vllm_platform.MLXPlatform.set_device(device: torch.device) -> None

Set the device (no-op for MLX, uses default device).

Parameters

Name Type Required Default Description
device torch.device yes none Required positional or keyword input.

Returns

  • Type: None

Exceptions and behavior

Method MLXPlatform.set_device contains no state mutation, call, raise, return, await, or yield. No direct raise statement appears in this definition.

View source #L203-L206.

vllm_mlx.vllm_platform.MLXPlatform.seed_everything · method
vllm_mlx.vllm_platform.MLXPlatform.seed_everything(seed: int | None = None) -> None

Set random seeds for reproducibility.

Parameters

Name Type Required Default Description
seed int \| None no None Optional positional or keyword input; defaults to None.

Returns

  • Type: None

Exceptions and behavior

Method MLXPlatform.seed_everything calls random.seed, np.random.seed, torch.manual_seed, mx.random.seed. No direct raise statement appears in this definition.

View source #L209-L225.

vllm_mlx.vllm_platform.MLXPlatform.import_kernels · method
vllm_mlx.vllm_platform.MLXPlatform.import_kernels() -> None

Import MLX kernels (no custom C kernels).

Parameters

This callable has no explicit inputs.

Returns

  • Type: None

Exceptions and behavior

Method MLXPlatform.import_kernels contains no state mutation, call, raise, return, await, or yield. No direct raise statement appears in this definition.

View source #L228-L231.

vllm_mlx.vllm_platform.MLXPlatform.get_attn_backend_cls · method
vllm_mlx.vllm_platform.MLXPlatform.get_attn_backend_cls(selected_backend, head_size: int, dtype: torch.dtype, kv_cache_dtype, block_size: int, use_mla: bool, has_sink: bool, use_sparse: bool, attn_type: str | None = None) -> str

Return MLX attention backend class path.

Parameters

Name Type Required Default Description
selected_backend not annotated yes none Required positional or keyword input.
head_size int yes none Required positional or keyword input.
dtype torch.dtype yes none Required positional or keyword input.
kv_cache_dtype not annotated yes none Required positional or keyword input.
block_size int yes none Required positional or keyword input.
use_mla bool yes none Required positional or keyword input.
has_sink bool yes none Required positional or keyword input.
use_sparse bool yes none Required positional or keyword input.
attn_type str \| None no None Optional positional or keyword input; defaults to None.

Returns

  • Type: str
  • Direct return expressions: 'vllm_mlx.attention.MLXAttentionBackend'

Exceptions and behavior

Method MLXPlatform.get_attn_backend_cls returns 'vllm_mlx.attention.MLXAttentionBackend'. No direct raise statement appears in this definition.

View source #L234-L248.

vllm_mlx.vllm_platform.MLXPlatform.check_and_update_config · method
vllm_mlx.vllm_platform.MLXPlatform.check_and_update_config(vllm_config: 'VllmConfig') -> None

Check and update vLLM configuration for MLX.

Parameters

Name Type Required Default Description
vllm_config 'VllmConfig' yes none Required positional or keyword input.

Returns

  • Type: None

Exceptions and behavior

Method MLXPlatform.check_and_update_config calls logger.info, _get_apple_chip_name, _get_unified_memory_size, hasattr. No direct raise statement appears in this definition.

View source #L251-L280.

vllm_mlx.vllm_platform.MLXPlatform.verify_model_arch · method
vllm_mlx.vllm_platform.MLXPlatform.verify_model_arch(model_arch: str) -> None

Verify model architecture is supported on MLX.

Parameters

Name Type Required Default Description
model_arch str yes none Required positional or keyword input.

Returns

  • Type: None

Exceptions and behavior

Method MLXPlatform.verify_model_arch calls hint.lower, model_arch.lower, logger.warning. No direct raise statement appears in this definition.

View source #L283-L294.

vllm_mlx.vllm_platform.MLXPlatform.verify_quantization · method
vllm_mlx.vllm_platform.MLXPlatform.verify_quantization(quant: str) -> None

Verify quantization method is supported.

Parameters

Name Type Required Default Description
quant str yes none Required positional or keyword input.

Returns

  • Type: None

Exceptions and behavior

Method MLXPlatform.verify_quantization calls ValueError; can raise ValueError. Directly raised exceptions: ValueError.

View source #L297-L304.

vllm_mlx.vllm_platform.MLXPlatform.is_pin_memory_available · method
vllm_mlx.vllm_platform.MLXPlatform.is_pin_memory_available() -> bool

Pin memory not needed with unified memory.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: False

Exceptions and behavior

Method MLXPlatform.is_pin_memory_available returns False. No direct raise statement appears in this definition.

View source #L307-L309.

vllm_mlx.vllm_platform.MLXPlatform.get_current_memory_usage · method
vllm_mlx.vllm_platform.MLXPlatform.get_current_memory_usage(device = None) -> float

Get current memory usage in bytes.

Parameters

Name Type Required Default Description
device not annotated no None Optional positional or keyword input; defaults to None.

Returns

  • Type: float
  • Direct return expressions: float(process.memory_info().rss); 0.0

Exceptions and behavior

Method MLXPlatform.get_current_memory_usage calls psutil.Process, float, process.memory_info; has 2 explicit return paths. No direct raise statement appears in this definition.

View source #L312-L323.

vllm_mlx.vllm_platform.MLXPlatform.supports_fp8 · method
vllm_mlx.vllm_platform.MLXPlatform.supports_fp8() -> bool

FP8 not supported on MLX.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: False

Exceptions and behavior

Method MLXPlatform.supports_fp8 returns False. No direct raise statement appears in this definition.

View source #L326-L328.

vllm_mlx.vllm_platform.MLXPlatform.use_custom_allreduce · method
vllm_mlx.vllm_platform.MLXPlatform.use_custom_allreduce() -> bool

Custom allreduce not available.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: False

Exceptions and behavior

Method MLXPlatform.use_custom_allreduce returns False. No direct raise statement appears in this definition.

View source #L331-L333.

vllm_mlx.vllm_platform.MLXPlatform.support_static_graph_mode · method
vllm_mlx.vllm_platform.MLXPlatform.support_static_graph_mode() -> bool

Static graph mode (CUDA graphs) not supported.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: False

Exceptions and behavior

Method MLXPlatform.support_static_graph_mode returns False. No direct raise statement appears in this definition.

View source #L336-L338.

vllm_mlx.vllm_platform.MLXPlatform.get_device_communicator_cls · method
vllm_mlx.vllm_platform.MLXPlatform.get_device_communicator_cls() -> str

Return the communicator class for distributed.

Parameters

This callable has no explicit inputs.

Returns

  • Type: str
  • Direct return expressions: 'vllm_mlx.distributed.MLXCommunicator'

Exceptions and behavior

Method MLXPlatform.get_device_communicator_cls returns 'vllm_mlx.distributed.MLXCommunicator'. No direct raise statement appears in this definition.

View source #L341-L343.

vllm_mlx.vllm_platform.MLXPlatform.get_punica_wrapper · method
vllm_mlx.vllm_platform.MLXPlatform.get_punica_wrapper() -> str

Return LoRA wrapper (not yet implemented for MLX).

Parameters

This callable has no explicit inputs.

Returns

  • Type: str

Exceptions and behavior

Method MLXPlatform.get_punica_wrapper calls NotImplementedError; can raise NotImplementedError. Directly raised exceptions: NotImplementedError.

View source #L346-L348.

vllm_mlx.vllm_platform.MLXPlatform.__repr__ · method
vllm_mlx.vllm_platform.MLXPlatform.__repr__() -> str

Method MLXPlatform.__repr__ returns f'<MLXPlatform device={self.device_name}>'.

Parameters

This callable has no explicit inputs.

Returns

  • Type: str
  • Direct return expressions: f'<MLXPlatform device={self.device_name}>'

Exceptions and behavior

Method MLXPlatform.__repr__ returns f'<MLXPlatform device={self.device_name}>'. No direct raise statement appears in this definition.

View source #L350-L351.

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
_get_apple_chip_name function _get_apple_chip_name() -> str Get the name of the Apple Silicon chip. #L24-L35
_get_unified_memory_size function _get_unified_memory_size() -> int Get the total unified memory size in bytes. #L38-L50
_is_mlx_available function _is_mlx_available() -> bool Check if MLX is available and working. #L53-L63
_is_apple_silicon function _is_apple_silicon() -> bool Check if running on Apple Silicon. #L66-L68
MLXPlatform class MLXPlatform() Platform implementation for Apple Silicon using MLX. #L71-L351
MLXPlatform._enum method MLXPlatform._enum() -> not annotated Method MLXPlatform._enum returns PlatformEnum.OOT. #L90-L93
MLXPlatform.supported_dtypes method MLXPlatform.supported_dtypes() -> list[torch.dtype] Return supported dtypes for MLX. #L122-L133
MLXPlatform.is_cuda method MLXPlatform.is_cuda() -> bool Return False because this platform does not use CUDA. #L135-L138
MLXPlatform.is_rocm method MLXPlatform.is_rocm() -> bool Return False because this platform does not use ROCm. #L140-L143
MLXPlatform.is_tpu method MLXPlatform.is_tpu() -> bool Return False because this platform is not a TPU backend. #L145-L148
MLXPlatform.is_xpu method MLXPlatform.is_xpu() -> bool Return False because this platform does not use Intel XPU. #L150-L153
MLXPlatform.is_cpu method MLXPlatform.is_cpu() -> bool Return False because MLX targets Apple GPU acceleration here. #L155-L158
MLXPlatform.is_mlx method MLXPlatform.is_mlx() -> bool Return True to identify the MLX platform plugin. #L160-L163
MLXPlatform.is_out_of_tree method MLXPlatform.is_out_of_tree() -> bool Return True because MLX is registered as a vLLM plugin. #L165-L168
MLXPlatform.is_cuda_alike method MLXPlatform.is_cuda_alike() -> bool Return False because MLX does not implement CUDA semantics. #L170-L173
MLXPlatform.is_sleep_mode_available method MLXPlatform.is_sleep_mode_available() -> bool Return False because vLLM sleep mode is unavailable on MLX. #L175-L178
MLXPlatform.get_device_name method MLXPlatform.get_device_name(device_id: int = 0) -> str Get the Apple Silicon chip name. #L181-L183
MLXPlatform.get_device_uuid method MLXPlatform.get_device_uuid(device_id: int = 0) -> str Get device UUID (not applicable for MLX). #L186-L188
MLXPlatform.get_device_total_memory method MLXPlatform.get_device_total_memory(device_id: int = 0) -> int Get total unified memory in bytes. #L191-L193
MLXPlatform.inference_mode method MLXPlatform.inference_mode() -> not annotated Return inference mode context manager. #L196-L200
MLXPlatform.set_device method MLXPlatform.set_device(device: torch.device) -> None Set the device (no-op for MLX, uses default device). #L203-L206
MLXPlatform.seed_everything method MLXPlatform.seed_everything(seed: int \| None = None) -> None Set random seeds for reproducibility. #L209-L225
MLXPlatform.import_kernels method MLXPlatform.import_kernels() -> None Import MLX kernels (no custom C kernels). #L228-L231
MLXPlatform.get_attn_backend_cls method MLXPlatform.get_attn_backend_cls(selected_backend, head_size: int, dtype: torch.dtype, kv_cache_dtype, block_size: int, use_mla: bool, has_sink: bool, use_sparse: bool, attn_type: str \| None = None) -> str Return MLX attention backend class path. #L234-L248
MLXPlatform.check_and_update_config method MLXPlatform.check_and_update_config(vllm_config: 'VllmConfig') -> None Check and update vLLM configuration for MLX. #L251-L280
MLXPlatform.verify_model_arch method MLXPlatform.verify_model_arch(model_arch: str) -> None Verify model architecture is supported on MLX. #L283-L294
MLXPlatform.verify_quantization method MLXPlatform.verify_quantization(quant: str) -> None Verify quantization method is supported. #L297-L304
MLXPlatform.is_pin_memory_available method MLXPlatform.is_pin_memory_available() -> bool Pin memory not needed with unified memory. #L307-L309
MLXPlatform.get_current_memory_usage method MLXPlatform.get_current_memory_usage(device = None) -> float Get current memory usage in bytes. #L312-L323
MLXPlatform.supports_fp8 method MLXPlatform.supports_fp8() -> bool FP8 not supported on MLX. #L326-L328
MLXPlatform.use_custom_allreduce method MLXPlatform.use_custom_allreduce() -> bool Custom allreduce not available. #L331-L333
MLXPlatform.support_static_graph_mode method MLXPlatform.support_static_graph_mode() -> bool Static graph mode (CUDA graphs) not supported. #L336-L338
MLXPlatform.get_device_communicator_cls method MLXPlatform.get_device_communicator_cls() -> str Return the communicator class for distributed. #L341-L343
MLXPlatform.get_punica_wrapper method MLXPlatform.get_punica_wrapper() -> str Return LoRA wrapper (not yet implemented for MLX). #L346-L348
MLXPlatform.__repr__ method MLXPlatform.__repr__() -> str Method MLXPlatform.__repr__ returns f'<MLXPlatform device={self.device_name}>'. #L350-L351