oMLX LLM Inference Server

repository·main·Indexed 11 days ago

https://github.com/jundot/omlx

A high-performance LLM inference engine optimized for Apple Silicon. oMLX features continuous batching, a tiered KV cache (RAM hot tier and SSD cold tier), and support for text LLMs, VLMs, OCR models, embeddings, and rerankers. It provides an OpenAI and Anthropic compatible API, a web-based admin dashboard for monitoring and chat, and can be installed as a macOS app, via Homebrew, or from source.

Tokens
24.1K
Snippets
66
Records
123
Agent score
97%

What's inside oMLX

  1. Overview of oMLX capabilities

    main

    oMLX is a high-performance serving engine for Apple Silicon that supports a wide range of models including Text LLMs, Vision-Language Models (VLM), OCR models, Embedding models, and Rerankers.

    Key features include:

    • Admin Dashboard: A web UI at /admin for real-time monitoring, model management, benchmarking, and configuration. It supports multiple languages and operates fully offline.
    • Hierarchical KV Cache: A block-based cache system (inspired by vLLM) that uses a Hot Cache (RAM) for frequent blocks and a Cold Cache (SSD) for overflow, allowing for prefix sharing and persistence across server restarts.
    • Continuous Batching: Uses mlx-lm's BatchGenerator to handle concurrent requests efficiently.
    • Multi-Model Serving: Supports loading multiple model types simultaneously with features like LRU Unloading (to free memory), Model Pinning (to keep models loaded), and Model-specific TTL (idle timeouts).
    • API Compatibility: Provides drop-in replacements for OpenAI and Anthropic APIs, including support for streaming usage statistics, adaptive thinking, and vision inputs.
  2. Overview of oMLX features

    main

    oMLX is a high-performance inference server for Apple Silicon that supports text LLMs, vision-language models (VLM), OCR models, embeddings, and rerankers.

    Key features include:

    • Admin Dashboard: A web UI at /admin for real-time monitoring, model management, chat, and benchmarking. It supports multiple languages and operates fully offline via vendored CDN dependencies.
    • Tiered KV Cache: A block-based cache system (inspired by vLLM) that uses a Hot tier (RAM) for fast access and a Cold tier (SSD) in safetensors format to offload blocks when memory is full, allowing for fast restoration after restarts.
    • Continuous Batching: Uses mlx-lm's BatchGenerator to handle concurrent requests.
    • Multi-Model Serving: Supports loading multiple model types simultaneously with LRU eviction, manual load/unload, model pinning, and per-model TTL (Time-To-Live).
    • API Compatibility: Provides a drop-in replacement for OpenAI and Anthropic APIs, supporting streaming, vision inputs, and tool calling.
  3. Explore oMLX core features and capabilities

    main

    oMLX is an Apple Silicon-optimized inference server supporting Text LLMs, Vision Language Models (VLM), OCR models, Embeddings, and Rerankers.

    Key features include:

    • Web Admin UI: Accessible at /admin for real-time monitoring, model management, benchmarking, and configuration. It supports multiple languages and works fully offline.
    • Hierarchical KV Cache: Uses a block-based management system (inspired by vLLM) with a Hot Cache (RAM) for fast access and a Cold Cache (SSD) that offloads blocks in safetensors format to preserve them across server restarts.
    • Continuous Batching: Processes simultaneous requests via mlx-lm's BatchGenerator.
    • Multi-Model Serving: Supports loading multiple model types simultaneously with LRU eviction, manual load/unload, model pinning, and per-model TTL (Time-To-Live).
    • Claude Code Optimization: Supports context scaling and SSE keep-alive to prevent timeouts during long prefills.
    • Integrations: One-click setup for OpenClaw, OpenCode, Codex, Hermes Agent, Copilot, and Pi via the Admin UI.
  4. Understand oQ: oMLX Universal Dynamic Quantization

    main

    oQ is a data-driven mixed-precision quantization system designed for Apple Silicon. Unlike fixed-rule quantization, oQ measures the actual quantization sensitivity of each layer through calibration and allocates bits where they are most needed to preserve quality.

    Key benefits:

    • Compatibility: Produces standard mlx-lm compatible models (MLX safetensors). No custom loaders are required; they work in oMLX, mlx-lm, and any app supporting MLX safetensors.
    • Efficiency: Uses sensitivity-driven bit allocation to maximize quality at low bitrates.
    • Optimization: The oQ+ variant includes GPTQ-based weight optimization to further reduce error without changing inference speed or format.
  5. What is DFlash and how does it accelerate generation?

    main

    DFlash is an experimental block diffusion speculative decoding technique (based on arXiv:2602.06036) integrated into oMLX via the DFlashEngine. Unlike traditional speculative decoding that drafts tokens one-by-one, DFlash uses block diffusion to propose a block of 16 tokens in parallel. This allows the target model to verify all 16 tokens in a single forward pass, significantly increasing throughput.

    The DFlash Workflow:

    1. PREFILL: The target model processes the prompt and captures hidden states.
    2. DRAFT: The draft model generates a block of 16 tokens simultaneously via parallel denoising.
    3. VERIFY: The target model verifies the entire block in one forward pass.
    4. ACCEPT: A greedy prefix match identifies the longest matching prefix to commit.
    5. REPLAY: For hybrid models (like GatedDeltaNet), the cache is rolled back using tape replay.
    6. REPEAT: The process continues until max_tokens or an EOS token is reached.
    1. PREFILL: target model processes entire prompt, captures hidden states
    2. DRAFT:   draft model generates block of 16 tokens in parallel (block diffusion)
    3. VERIFY:  target model verifies all 16 in one forward pass
    4. ACCEPT:  greedy prefix match — longest matching prefix is committed
    5. REPLAY:  cache rollback via tape replay for hybrid (GatedDeltaNet) models
    6. REPEAT:  until max_tokens or EOS
  6. Manage multiple models and memory usage

    main

    oMLX allows running LLMs, VLMs, embedding models, and reranking models simultaneously in one server. It provides several mechanisms to manage system resources:

    • LRU Eviction: Automatically unloads the Least Recently Used models when memory is low.
    • Manual Control: Load or unload models via the Web UI.
    • Model Pinning: Keep specific models permanently loaded in memory.
    • Model-level TTL: Set an idle timeout for each model to automatically unload it after inactivity.
    • Process Memory Limit: Set a global memory limit (defaults to System RAM - 8GB) to prevent system-wide Out-of-Memory (OOM) errors.
  7. Configure model aliases and profiles in oMLX

    main

    oMLX allows you to customize how models appear in the API and how they behave using aliases and profiles.

    Model Aliases

    Set a custom display name for a model. The alias will be returned in /v1/models. You can use either the alias or the original directory name in your API requests.

    Model Profiles

    You can save specific configurations (sampling parameters, chat templates, etc.) as a named Profile. Profiles can be exposed as independent models in the /v1/models list using the format <model>:<profile> (e.g., qwen3-8b:thinking).

    When requesting a profile:

    • It uses the same engine as the base model.
    • It overrides settings without requiring additional memory or a model reload.
    • If the base model has an alias, the public ID becomes <alias>:<profile>.
    • The original directory name remains valid for requests.
  8. Understand the packaging output structure

    main

    When running the packaging build, the following directory structure is generated within the packaging/ folder:

    • _build/: Contains venvstacks intermediate layers.
    • _export/: The final venvstacks export that is embedded into the .app bundle.
    • _wheels/: Cached local wheels (e.g., mlx + mlx-metal pins).
  9. DFlash temperature sampling behavior

    main

    DFlash supports both greedy and stochastic sampling via a custom implementation of sample_with_temperature(). This sampling is applied at three points: the prefill first token, the draft block, and the verify posterior.

    Sampling Modes:

    • temp=0 (Greedy): Identical to original greedy behavior. Every emitted token matches the target model's argmax. This is lossless and bit-for-bit reproducible.
    • temp>0 (Stochastic): Both the draft and verify steps use temperature sampling. While this increases output diversity, it typically reduces the acceptance rate because the draft and target models are less likely to agree on stochastic samples, resulting in a lower speedup compared to greedy mode.
    def sample_with_temperature(logits, temperature, suppress_token_mask=None):
        if temperature < 1e-5:
            return greedy_tokens_with_mask(logits, suppress_token_mask)  # greedy
        scaled = logits / temperature
        return mx.random.categorical(scaled).astype(mx.uint32)           # stochastic
  10. How tool calling and structured outputs work

    main

    oMLX supports function calling and JSON schema validation. It automatically detects the required format based on the model family using mlx-lm parsers.

    Supported formats include:

    • Llama, Qwen, DeepSeek, etc.: JSON <tool_call>
    • Qwen3.5 Series: XML <function=...>
    • Gemma: <start_function_call>
    • GLM (4.7, 5): XML <arg_key>/<arg_value>
    • MiniMax: <minimax:tool_call>
    • Mistral: [TOOL_CALLS]
    • Kimi K2: <|tool_calls_section_begin|>
    • Longcat: <longcat_tool_call>

    For streaming tool calls, the assistant's text is emitted incrementally, while control tags are stripped from the visible content. Structured tool calls are emitted after the full turn is parsed.

  11. Manage models with Per-Model Settings and Profiles

    main

    oMLX allows fine-grained control over individual models through the Admin Panel or via API-visible aliases and profiles.

    • Model Alias: Set a custom name for a model. The /v1/models endpoint will return this alias, and requests can use either the alias or the directory name.
    • Model Type Override: Manually force a model to be treated as an LLM or VLM if auto-detection fails.
    • Profiles: Save bundles of settings (sampling parameters, chat template kwargs, etc.) as a profile. You can expose a profile as its own model endpoint using the syntax <model>:<profile> (e.g., qwen3-8b:thinking). This allows serving the same engine with different settings without extra memory or reloads.
  12. Configure model-level settings and profiles

    main

    You can customize how specific models behave via the management dashboard without restarting the server. Key features include:

    • Model Aliases: Set custom names for the API. The /v1/models endpoint will return the alias, and you can use either the alias or the original directory name in requests.
    • Model Type Overrides: Manually force a model to be treated as an LLM or VLM regardless of auto-detection.
    • Configuration Profiles: Save combinations of settings (sampling parameters, chat templates, TTL, etc.) as profiles. You can expose these as independent models via the API using the syntax <alias>:<profile_name> (e.g., qwen3-8b:thinking). This allows running the same base model with different settings without extra memory overhead.