Vibeleaderboard
← All Intel
Intel / article

Perplexity's Lily: model-specific Metal kernels beat MLX-LM on a Mac

Source
perplexity.ai
Author
Perplexity
Date

Context

Perplexity built Lily so the local half of Perplexity Computer's hybrid compute mode can keep up with the cloud half. In that setup, cloud models handle research and reasoning while a model on the user's Mac works with private files and apps, so slow holds up the whole task. Perplexity open-sourced Lily as an engine that runs exactly one model, Qwen3.6-35B-A3B, on Apple silicon, and its technical write-up argues that this narrowness is the point. A general framework such as Apple's MLX-LM has to support many model architectures, while an engine built for one model can arrange its GPU kernels, memory traffic and scheduling around that model's fixed shape. Lily is a Rust runtime with custom Metal kernels and an chat API, and neither PyTorch nor MLX is in its execution path.

The write-up treats the two phases of inference as different problems. Prefill reads the whole prompt at once, so each block of weights can be reused across many tokens, which suits the M5 GPU's Neural Accelerators for matrix math. Decode generates one token at a time for a single request, so the engine must read through the weights again for every token; its speed depends mostly on how many bytes move through memory, which suits the GPU's ordinary vector units instead. Qwen3.6 makes both phases uneven because it is a model: it has 35 billion parameters but activates about 3 billion per token, sending each token to eight of 256 expert subnetworks plus one shared expert. Many of Lily's gains come from avoiding pauses and extra memory trips. In Perplexity's ablations, which compare otherwise identical versions of its own engine, keeping expert routing on the GPU instead of stopping for the CPU raised prefill throughput by 89% at a 512-token prompt, and unpacking the 4-bit weights inside the matrix multiplication, rather than first writing an expanded copy to memory, raised it by 77.4%.

Against MLX-LM on one MacBook Pro with an M5 Max (40-core GPU, 128 GB of unified memory), loading identical 4-bit checkpoint bytes and running one request at a time, Perplexity reports that Lily averaged 1.22 times MLX-LM's prefill throughput and 1.32 times its decode throughput across lengths from 256 to 128K tokens, and was faster at every length it recorded. At 4K tokens it reports 5,749.9 prefill and 186.6 decode tokens per second, against 4,737.5 and 140.9 for MLX-LM. Because specialised kernels can change the order of floating-point operations, it also compared next-token predictions at 192 positions: Lily's perplexity was 0.04% higher and it chose the same top token 96.35% of the time. These are Perplexity's own measurements on one machine and one model; the post lists wider coverage of models, chips and serving workloads as future work.

The write-up also reports what did not help, which supports its argument that the right choice depends on both model and hardware. , where a small model drafts tokens for the large one to verify, made single-request decode 18% slower here: verification produced small groups of two to five rows, an inefficient shape on this hardware, and those rows often selected different experts, increasing the expert weights read. Perplexity notes that its batched Qwen deployment on Blackwell GPUs still uses speculative decoding under different conditions.

Terms in this piece · Glossary
  • Local inference — Running a model on a machine you control, whether a laptop or a server you administer, so that the model's own computation happens there rather than on a provider's servers.
  • OpenAI-compatible API — An API that accepts the common OpenAI request shape so existing clients can call another provider with fewer code changes.
  • mixture-of-experts — A model built from many specialist sub-networks where only a few activate per token, giving big-model capability at small-model running cost.
  • speculative decoding — A speed trick where a small model drafts several tokens ahead and the big model verifies them in one pass, often doubling generation speed.

Get the Brief

A cited digest of what matters for people building with AI, every morning. Unsubscribe anytime. See today’s edition

Read the source www.perplexity.ai
More from Perplexity
Recommended reads