Apple Silicon 上的生产级本地 LLM 推理:MLX、MLC-LLM、Ollama、llama.cpp 与 PyTorch MPS 的比较研究
Production-Grade Local LLM Inference on Apple Silicon: A Comparative Study of MLX, MLC-LLM, Ollama, llama.cpp, and PyTorch MPS
AI总结:
本文在 Apple Silicon 上系统比较了五种本地 LLM 推理运行时,发现 MLX 吞吐量最高、MLC-LLM 首 token 延迟更低,并给出面向私有设备端部署的选型建议。
摘要:
我们对 Apple Silicon 上的五种本地大语言模型(LLM)运行时进行了系统的实证评估:MLX、MLC-LLM、llama.cpp、Ollama 和 PyTorch MPS。实验在一台配备 M2 Ultra 处理器和 192 GB 统一内存的 Mac Studio 上进行。使用 Qwen-2.5 模型系列,在从几百个 token 到 100,000 个 token 的提示范围内,我们测量了首 token 时间(TTFT)、稳态吞吐量、延迟百分位数、长上下文行为(键值和提示缓存)、量化支持、流式性能、批处理与并发行为以及部署复杂度。在我们的设置下,MLX 实现了最高的持续生成吞吐量,而 MLC-LLM 在中等提示规模下提供了持续较低的 TTFT,并提供了更强的开箱即用推理特性。llama.cpp 在轻量级单流使用中非常高效,Ollama 强调开发者易用性但在吞吐量和 TTFT 上落后,而 PyTorch MPS 在大模型和长上下文场景下仍受内存限制。所有框架均完全在设备端执行且无遥测,确保了强大的隐私保障。我们发布了脚本、日志和图表以复现所有结果。我们的分析阐明了以 Apple 为中心的 LLM 部署中的设计权衡,并为交互式和长上下文处理提供了基于证据的建议。尽管 Apple Silicon 推理框架在绝对性能上仍落后于 vLLM 等基于 NVIDIA GPU 的系统,但它们正在迅速成熟为可行的、生产级的私有设备端 LLM 推理解决方案。
英文摘要:
We present a systematic, empirical evaluation of five local large language model (LLM) runtimes on Apple Silicon: MLX, MLC-LLM, llama.cpp, Ollama, and PyTorch MPS. Experiments were conducted on a Mac Studio equipped with an M2 Ultra processor and 192 GB of unified memory. Using the Qwen-2.5 model family across prompts ranging from a few hundred to 100,000 tokens, we measure time-to-first-token (TTFT), steady-state throughput, latency percentiles, long-context behavior (key-value and prompt caching), quantization support, streaming performance, batching and concurrency behavior, and deployment complexity. Under our settings, MLX achieves the highest sustained generation throughput, while MLC-LLM delivers consistently lower TTFT for moderate prompt sizes and offers stronger out-of-the-box inference features. llama.cpp is highly efficient for lightweight single-stream use, Ollama emphasizes developer ergonomics but lags in throughput and TTFT, and PyTorch MPS remains limited by memory constraints on large models and long contexts. All frameworks execute fully on-device with no telemetry, ensuring strong privacy guarantees. We release scripts, logs, and plots to reproduce all results. Our analysis clarifies the design trade-offs in Apple-centric LLM deployments and provides evidence-based recommendations for interactive and long-context processing. Although Apple Silicon inference frameworks still trail NVIDIA GPU-based systems such as vLLM in absolute performance, they are rapidly maturing into viable, production-grade solutions for private, on-device LLM inference.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。