ARahim3/mlx-dspark
MLX speculative decoding for faster local LLM inference on Apple Silicon
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
mlx-dspark is a Python inference engine that uses MLX to run speculative decoding on Apple Silicon GPUs. It keeps the target model in charge of the output and shares a verification loop across several drafting methods. DSpark uses target hidden states to propose seven tokens and applies a previous-token correction through a Markov head. DFlash denoises a 16-token block in parallel and reuses the target's embeddings and output head. DFlash 2 builds a chain from top candidates; DSpine conditions each position on its predecessor.
The target verifies proposed tokens in blocks, allowing one pass to advance multiple positions when the draft matches. Greedy output matches plain target decoding apart from floating-point tie-breaking; speculative sampling preserves the target distribution under the selected sampling settings, rather than promising the same sampled transcript. Matched drafters load from Hugging Face checkpoints and default to 4-bit quantization. For a loadable target without a matched drafter, n-gram lookup can instead propose a continuation seen earlier in the context.
Key Capabilities & Differentiators
The engine is available through a CLI, Python, and a local HTTP server. The server exposes /v1/chat/completions, /v1/messages, and /v1/responses on one port, with controls for sampling and reasoning as well as tool calling. The CLI can compare plain decoding with speculation, and the separate native Mac app adds model-fit estimates, per-round acceptance telemetry, and a side-by-side output check.
Matched checkpoints cover families including Gemma-4, Qwen3, LFM2.5, and Muse-Glimmer. On a warm M4 Pro at short context, Qwen3.8-27B 4-bit with DFlash 2 decoded at roughly 42–65 tokens/s, with a 2.72× chat speedup and a 4.23× math speedup. The gap matters: measure with your own prompts, and report decode throughput separately from time to first token and end-to-end agent runtime.
Trade-offs & Limitations
Against plain MLX decoding, the key question is whether accepted tokens repay the cost of drafting and verification. The engine profiles the Mac on the first run of a model pair and caches the result to choose a draft cap, but calibration cannot fix a poor target–drafter match. Lookup also cannot guarantee a speedup on prompts without useful repetition. Benchmark the same checkpoint and quantization with and without speculation, then repeat at the 16k–32k context lengths relevant to coding agents rather than extrapolating short-context results.
Compared with the hosted OpenAI API, this is a way to keep inference local and choose your own checkpoints, not a guarantee of hosted model quality, feature parity, or managed concurrency. Unified memory is a practical constraint: Qwen3-8B-8bit is listed at about 11 GB peak RAM, while Qwen3.8-27B 4-bit is about 18 GB and is not a sensible default for a 16 GB Mac. The MIT license covers the engine; check target and drafter weight terms separately.
Hardware & Deployment Guide
Install the engine with pip install mlx-dspark on an Apple Silicon Mac with Python 3.10 or later. v0.21.4 requires MLX 0.32.5 or later, whose few-row quantized matmul and attention kernels reduce verification cost; the release reports up to 16% faster speculative decoding. Weights are not bundled: populate the Hugging Face cache on first use or supply compatible local files for offline operation. The separately distributed Mac app is not included in the Python wheel.
Start with mlx-dspark serve --model mlx-community/Qwen3-8B-8bit; the default listener is 127.0.0.1:8080. Use --no-model and then /admin/load to defer loading or swap checkpoints. The server is designed for local, single-user use. If exposing it beyond loopback, set --api-key; with a key configured, only GET /health remains unauthenticated. Custom checkpoint Python is refused by default, and --trust-remote-code changes that policy for the entire process, not just one model load.
--mode auto can fall back to drafter-free n-gram lookup.--max-draft auto can adapt the cap each round.--no-model and /admin/load support deferred loading and model swaps; custom checkpoint Python is blocked by default.Apple Silicon users serving a local chat or coding workflow who can choose a matched target–drafter pair and measure gains at their actual context length.
You need DeepSeek-V4 inference, a non-Apple GPU runtime, or a managed multi-tenant API with predictable concurrency.
Quick Start & Installation
brew tap ARahim3/mlx-dspark https://github.com/ARahim3/mlx-dspark brew trust arahim3/mlx-dspark # Homebrew 6+: third-party taps need explicit trust brew install --cask mlx-dspark xattr -dr com.apple.quarantine /Applications/mlx-dspark.app # not notarized yet: clear # quarantine once, or use System Settings › Privacy & # Security › "Open Anyway" after the first launch
Comparison vs. Top LLMs & Inference Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| mlx-dspark ★ | 811 | +6 | Python | MIT | MLX speculative decoding for faster local LLM inference on Apple Silicon |
| OmniRoute | 92.1k | +1.5k | TypeScript | MIT | Self-hosted OpenAI-compatible gateway for multi-provider routing and fallback |
| ollama | 189k | +703 | Go | MIT | Go-based LLM serving layer for local model management and inference |
| nano-vllm | 16.7k | +95 | Python | MIT | A compact vLLM-style Python engine for offline GPU batch inference |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/ARahim3/mlx-dspark.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about mlx-dspark
How do I connect an existing API client or Claude Code?
mlx-dspark claude launcher redirects only the Claude Code process it starts, without rewriting persistent settings. Test streaming, tool calls, and multi-turn tool history with your chosen model before switching an existing workflow.Which models are practical on a 16 GB Apple Silicon Mac?
Can I use mlx-dspark commercially and self-host it?
--api-key if exposing it beyond loopback, and leave custom checkpoint code disabled unless you trust its source.When should I choose it over plain MLX decoding or the OpenAI API?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy