在 Mac Studio 上使用 MLX 与 RDMA 进行本地及分布式大语言模型推理
原题Local and Distributed Large LLM Inference with MLX and RDMA on Mac Studio
读前速览
Apple 的 MLX 团队展示了如何在 Mac Studio 上本地运行前沿级 LLM,通过 Thunderbolt 上的 RDMA 将接近万亿参数的 MoE 模型扩展到四台 M5 Ultra 机器上,达到每秒超过 36 个 token。
M5 Ultra 的 GPU 神经加速器大幅降低了计算密集型预填充的首 token 时间。
专用矩阵乘法硬件在 Qwen 3.8 和 Mistral Medium 3.5 上相比 M3 Ultra 将 TTFT 提升至多 4.6 倍,使 M5 Ultra 成为超长上下文场景的首选桌面设备。
解码速度受内存带宽限制,M5 Ultra 的 1.2 TB/s 统一内存带宽相比 M3 Ultra 的 819 GB/s 带来 1.6 倍的解码加速。
带宽提升直接转化为生成吞吐量,同时峰值功耗保持在约 200W(M3 Ultra)至 300W(M5 Ultra)的适中水平,适合在任何家庭或办公室环境中部署。
对于单台机器无法容纳的模型,如 816B 参数的 Muse Spark Open,可以通过 RDMA 上的流水线或张量并行拆分到多台 Mac Studio 上。
macOS 26.2 新增了低延迟 RDMA-over-Thunderbolt 5 驱动,MLX v0.30.1+ 提供了 jaccl 集合通信原语和 mlx.launch 辅助工具;流水线并行按深度切分且实现简单,张量并行按宽度切分且随机器增加扩展性更好。
流水线并行基本不改变解码速度,但通过重叠块计算在超大上下文下加速预填充。
MLX 将大上下文切分为 8,192 token 的块,使连续块在多台机器间重叠计算,在 65,536 token 时 TTFT 提升至多约 1.8 倍,但在 8,192 token 时没有提升。
张量并行随机器增加带来最大加速,四台 M5 Ultra 在 Muse Spark Open 上达到 36.73 tokens/s。
稠密架构在多机器上的扩展性更好;对于 MoE 模型,在超大上下文下通信开销可能抵消计算收益,但四台机器时该方案收益明显,每条链路使用两根 Thunderbolt 线缆可将 TTFT 从约 50.5 秒降至 40.6 秒。
完整摘要
Apple 的 MLX 团队详细介绍了在搭载 Apple 芯片的 Mac Studio 上进行前沿级 LLM 的本地与分布式推理。在配备 512GB 内存的单台 Mac Studio 上,Qwen 3.8(27B)和 Mistral Medium 3.5(128B)等稠密模型可以轻松运行,M5 Ultra 的 GPU 神经加速器将首 token 时间(TTFT)提升至多 4.6 倍,解码速度相比 M3 Ultra 提升 1.6 倍,而峰值功耗仅为 200-300W。对于 816B 参数的 MoE 模型 Muse Spark Open,其在 NVFP4 下需要约 493GB 内存,无法装入单台机器,文章展示了两种基于 MLX 的 jaccl 集合通信原语和 macOS 26.2 中新增的低延迟 RDMA-over-Thunderbolt 5 驱动的并行方案。流水线并行按深度切分模型,实现简单,解码速度基本不变,但在 65,536 token 上下文下可将预填充速度提升至多 1.8 倍。张量并行按宽度切分,需要低延迟通信,且随着机器数量增加扩展性更好:四台 M5 Ultra 在 Muse Spark Open 上达到 36.73 tokens/s,Mistral Medium 3.5 为 23.37,Qwen 3.8 为 50.89。文章最后展示了如何使用 mlx_lm.server 在本地为 OpenCode 等智能体编程工具提供这些模型的推理服务。
目录 · 7 节
MLX on Mac with Apple silicon lets AI researchers and developers experiment locally with the latest models and methods in a private environment. The open-source array framework leverages the unified memory architecture of Apple silicon, enabling anyone to run new inference and fine-tuning methods on their own hardware and explore other AI techniques. In a previous post, we highlighted the advantages of the M5 architecture and its GPU Neural Accelerators.
In this post, we show how to run the latest frontier-class model — Muse Spark Open, with nearly a trillion parameters — right from your desk, using the latest version of MLX, released today. On a cluster of four Mac Studios, Muse Spark Open generates over 36 tokens per second (see Figure 1), well above average human reading speed.
Beginning on a single Mac Studio (up to 512GB of unified memory), then scaling out across multiple Macs with the RDMA over Thunderbolt driver, below we share an overview of the range of models you can now run on Mac Studio.
Muse Spark Open Decode Speed
Context size of 8,192 tokens
Running Large Language Models with MLX
We benchmark several popular open-weight LLMs on Mac Studio, using the MLX LM package, as described in our prior post. We compare two generations of Mac Studio: the recently released M5 Ultra and the previous generation, M3 Ultra. The M5 generation features the GPU Neural Accelerator, which supports dedicated matrix multiplication operations, essential for many machine learning workloads.
We evaluate three frontier-class models (Table 1) spanning a wide range of sizes (in billions of parameters, B): the newly released Muse Spark Open (816 B), Mistral Medium 3.5 (128 B), and Qwen 3.8 (27 B). Muse Spark Open is a mixture of experts (MoE) model, which keeps only a fraction of its experts — and thus parameters — active, reducing compute at inference, and it is evaluated in NVFP4 precision. Mistral Medium 3.5 and Qwen 3.8 are dense architectures, where all parameters are active at inference, and they are evaluated in their native floating-point precision (FP8 and BF16, respectively).
| Model | Total Parameters | Active Parameters | Native Precision | Evaluation Precision |
|---|---|---|---|---|
| Muse Spark Open | 816B | 42B | BF16 | NVFP4 |
| Mistral Medium 3.5 | 128B | 128B | FP8 | FP8 |
| Qwen 3.8 | 27B | 27B | BF16 | BF16 |
Our evaluation measures three metrics across a range of context sizes: time to first token (TTFT, in seconds), generation throughput (in tokens/second), and peak power usage (in watts). All the performance numbers in this post were obtained with mlx_lm.benchmark. For example, running Qwen 3.8 with 8,192 tokens of context and generating 128 tokens is performed with the command line:
mlx_lm.benchmark --model Qwen/Qwen3.8-27B -p 8192 -g 128 -b 1
A popular use of local LLMs on Mac Studio is running agentic experiences in a private environment, including agentic coding applications that often need large contexts. We therefore report performance at both 8,192 and 65,536 context sizes.
Raw TTFT and decode throughput are reported in Table 2 and Table 3, respectively.
Inference Performance on a Single Mac Studio
Qwen 3.8 27B and Mistral Medium 3.5 128B fit comfortably on a single Mac Studio with 512GB, taking up to 68GB and 158GB of RAM in the large context size (65,536 tokens) setup. In Figure 2, we compare their inference performance on a single Mac Studio with 512GB of RAM, both on M3 Ultra and M5 Ultra.
Time to first token (TTFT) is essentially compute bound, and that is where the Neural Accelerators in the M5 Ultra GPU shine: the specialized hardware support for fast matrix-multiplication of the GPU Neural Accelerator directly translates into significant speedups for TTFT, up to 4.6× faster compared to an M3 Ultra (see Figure 2). That makes the Mac Studio with M5 Ultra the desktop of choice when it comes to handling tasks involving very large contexts.
Generation speed (in tokens per second) is memory-bandwidth bound. The M5 Ultra chip delivers 1.2 TB/s of unified memory bandwidth, up from 819 GB/s for the M3 Ultra. Here again, that translates directly into generation speed (see Figure 3), with the Mac Studio with M5 Ultra reporting 1.6× faster tokens/s.
TTFT Speedup
Single Mac Studio, M5 Ultra over an M3 Ultra baseline (1.0×)
Decode Speedup
Single Mac Studio, M5 Ultra over an M3 Ultra baseline (1.0×)
The Mac Studio is also energy-efficient for LLM inference (see Figure 4): peak power consumption is about 200W for the Mac Studio with M3 Ultra, and 300W for the Mac Studio with M5 Ultra — a fraction of the power used by a common toaster. More importantly, that modest amount of power consumption means a Mac Studio can be deployed for AI work in any home or office environment.
Peak Power Consumption
Context size of 65,536 tokens
While both the Qwen and Mistral models fit on a single Mac Studio with 512GB of RAM, Muse Spark Open would require more than 1.6TB of RAM in its native precision (BF16) for the model parameters alone. In a 4-bit quantized (NVFP4) format, the model memory footprint is lowered to about 493GB. Add the memory needed for intermediate computations during inference, and the model cannot fit on a single machine. It requires parallelization across multiple Mac Studio computers.
Pipelining Inference Across Two Mac Studio Computers
Very large frontier-class models like Muse Spark Open will not fit on a single machine. It is, however, possible to store half of the model on one Mac Studio and the other half on another. We can then pipeline the model’s inference across two computers: the first Mac Studio executes the first half of the model’s layers, then sends the output to the second Mac Studio, which executes the second half. This parallelization scheme is called pipeline parallelization (see Figure 5) and is extremely simple to implement, requiring only minimal code changes.
Splitting Large Models Across Multiple Computers
MLX supports different parallelization schemes, as described in the MLX distributed documentation. These rely on fast inter-machine communication: macOS 26.2 introduced a low-latency RDMA driver over Thunderbolt 5, and MLX (v0.30.1 and later) builds on top of this driver and provides new communication collectives (jaccl, pronounced “jackal”) for different parallelization schemes. In our setup, the two Mac Studios are connected with two Thunderbolt cables (to double the link bandwidth), providing the RDMA-over-Thunderbolt link that jaccl uses. Once the hosts are set up, MLX provides mlx.launch, a helper command to launch jobs across multiple nodes:
mlx.launch --hostfile hostfile.json --backend jaccl --env MLX_METAL_FAST_SYNCH=1 -- \
mlx_lm.benchmark --model mistralai/Mistral-Medium-3.5-128B -p 8192 -g 128 -b 1 --prefill-step-size 8192 --pipeline
In this command, --backend jaccl specifies the RDMA Thunderbolt driver backend. The --env MLX_METAL_FAST_SYNCH=1 flag enables an experimental MLX feature for fast CPU-GPU synchronization, reducing communication overhead between the CPU (which initiates the Thunderbolt communication) and the GPU (which does the compute).
In general, decode inference speed with pipeline parallelization (see Figure 7) is very similar to that of a single machine, since the layers are still evaluated sequentially. Communication overhead is also very low, as only the intermediate outputs between the two sets of layers need to be exchanged.
It is however notable that for very large contexts (65,536 tokens in our benchmark), pipeline parallelization ends up faster than a single node for prefill — up to ~1.8× faster (see Figure 6). This is because MLX segments large contexts into smaller chunks (here, 8,192 tokens, as set by --prefill-step-size 8192) and pipelines the prefill across the machines: while the second machine computes the later layers of chunk
kk
, the first machine computes the earlier layers of chunk
k+1k+1
, so consecutive chunks overlap in time. For even better compute parallelization, we next turn to tensor parallelization.
TTFT Speedup
Two Mac Studios with pipeline parallelization, over a single M5 Ultra baseline (1.0×)
Decode Speedup
Two Mac Studios with pipeline parallelization, over a single M5 Ultra baseline (1.0×)
Tensor Parallelization for Faster Inference
Tensor parallelization (see Figure 5) distributes the LLM’s width across several computers, in contrast to pipeline parallelization, which distributes the model across its depth. Each machine now holds a fraction of each of the layers of the model, such that per-layer computation is parallelized. When efficiently implemented, tensor parallelization improves inference speed. However, tensor parallelization is more complex to implement than pipeline parallelization: each layer must be parallelized, which increases code complexity. The scheme also involves many small communication operations: for each input token and for each layer, one must broadcast inputs and aggregate outputs. As a result, a very low-latency communication technology like Thunderbolt RDMA, supported by MLX jaccl, is critical for this approach to yield any speedup.
With MLX’s high-level mlx.launch helper, it is easy to switch to tensor parallelization. The Mac Studio computers are connected in a Thunderbolt mesh, with each pair of machines linked peer-to-peer by two Thunderbolt cables. Assuming the hosts are set up, we simply launch the benchmark across multiple machines with:
mlx.launch --hostfile hostfile.json --backend jaccl --env MLX_METAL_FAST_SYNCH=1 -- \
mlx_lm.benchmark --model meta-models/Muse-Spark-Open-816B-A42B-NVFP4 -p 8192 -g 128 -b 1
Figure 8 and Figure 9 show the speedups obtained with two or four Mac Studio computers with M5 Ultra, relative to a single-machine baseline (or, for Muse Spark Open, the pipeline parallelization baseline). Notably, dense architectures scale better across multiple computers.
With a small number of machines, the communication overhead of tensor parallelization can offset some of its compute benefits at very large contexts, though this applies to prefill only. This shows up with Muse Spark Open, where separate normalization of the experts’ outputs adds some prefill communication, enough that at very large contexts (65,536 tokens), two-machine tensor parallelization lags behind two-machine pipeline parallelization. The approach however pays off as machines are added, as seen with four M5 Ultras. Decode is unaffected: Muse Spark Open sustains a significant decode speedup under tensor parallelization even at large contexts, comparable to dense models like Qwen 3.8 and Mistral Medium 3.5.
The two-cable mesh also pays off during prefill, where the extra link bandwidth is felt. For Muse Spark Open on four M5 Ultras at a 65,536-token context, two cables per link cut TTFT from about 50.5s (one cable) to 40.6s — the two-cable value reported in Table 2, the one-cable run being an additional experiment.
TTFT Speedup
Two or four Mac Studios with tensor parallelization, over a single M5 Ultra baseline (1.0×; Muse Spark Open: two-machine pipeline)
Decode Speedup
Two or four Mac Studios with tensor parallelization, over a single M5 Ultra baseline (1.0×; Muse Spark Open: two-machine pipeline)
Time to First Token (seconds)
Lower is better
| Model | M3 Ultra | M5 Ultra | 2 M5 Pipeline | 2 M5 Tensor | 4 M5 Tensor |
|---|---|---|---|---|---|
| Muse Spark Open | — | — | 8.4 | 8.2 | 4.8 |
| Mistral Medium 3.5 | 95.9 | 24.6 | 24.5 | 14.4 | 7.5 |
| Qwen 3.8 | 18.2 | 4.1 | 4.1 | 3.1 | 1.7 |
Decode Speed (tokens per second)
Higher is better
| Model | M3 Ultra | M5 Ultra | 2 M5 Pipeline | 2 M5 Tensor | 4 M5 Tensor |
|---|---|---|---|---|---|
| Muse Spark Open | — | — | 15.74 | 24.99 | 36.73 |
| Mistral Medium 3.5 | 4.95 | 7.70 | 7.70 | 13.69 | 23.37 |
| Qwen 3.8 | 12.46 | 19.69 | 19.44 | 33.27 | 50.89 |
Local Agentic AI on Mac
Recently, agentic AI on Mac has gained considerable traction, with agentic coding tools seeing widespread adoption among developers. With MLX, powering these tools locally is as simple as launching a server with the mlx_lm.server tool. For example, a server running Muse Spark Open on port 8080 is started with:
mlx.launch --hostfile hostfile.json --backend jaccl --env MLX_METAL_FAST_SYNCH=1 -- \
mlx_lm.server --model meta-models/Muse-Spark-Open-816B-A42B-NVFP4 --port 8080
As with mlx_lm.benchmark, the mlx_lm.server helper can be prefixed with mlx.launch to parallelize computation across multiple Mac Studios. From there, agentic AI can be enabled with tools like OpenCode, which can be easily configured to use that local LLM server:
{
"$schema": "https://opencode.ai/config.json",
"model": "meta-models/Muse-Spark-Open-816B-A42B-NVFP4",
"provider": {
"mlx": {
"npm": "@ai-sdk/openai-compatible",
"name": "Local MLX",
"options": {
"baseURL": "http://127.0.0.1:8080/v1"
},
"models": {
"meta-models/Muse-Spark-Open-816B-A42B-NVFP4": {
"name": "Muse Spark Open 816B (MLX)"
}
}
}
}
}
Many other local agentic AI experiences can be enabled through a similar approach.
Conclusion
Over the past year, we have worked on several key innovations in MLX to make it easier and more efficient to run state-of-the-art LLMs locally on recent Apple silicon. These include software support for the Neural Accelerators in the GPU of the M5 family of chips, low-latency communication across several Macs using RDMA over Thunderbolt, and efficient implementations of recent popular architectures such as mixture of experts (MoE). Each of these helps on its own, but it is their combination with the latest Apple silicon — Mac Studio with M5 Ultra, Neural Accelerators in the M5 Ultra GPU, 512GB of unified memory, and RDMA over Thunderbolt 5 — that now lets us run models like Muse Spark Open with more than 800B parameters locally, at up to 4.6× the start-up (time-to-first-token) speed of the previous generation of Mac Studio.