{"slug": "roton-rust-metal-gguf-prefill-on-apple-silicon-with-a-reproducible-llama-cpp", "title": "Roton: Rust/Metal GGUF prefill on Apple Silicon, with a reproducible llama.cpp baseline", "summary": "The maintainer of roton, an MIT-licensed GGUF inference engine written in Rust and Metal, published archived v0.3.0 measurements showing roton's chunked Metal prefill cut native prefill time on a 453-token prompt from 4395.50 ms (sequential) to 131.85 ms (MPP FP16, batch 64), while a pinned llama.cpp Metal reference with batch 512, FP16 KV and automatic flash attention completed the same prefill in 15.34 ms and decoded at 534.0 steps/s versus roton's 55.0. The tests ran on an M5 Pro with 48 GiB of memory and macOS 26.6.2 using SmolLM2-135M-Instruct Q5_K_S, with 32 greedy output tokens and a 1,024-token context, and the maintainer said the long-context decode gap is the next profiling target. The v0.4.0 source adds dense Qwen2.5/Qwen3 handling, including Q/K/V biases, NeoX-style RoPE, explicit head dimensions and QK normalization, though the maintainer cautioned that validation remains narrow.", "body_md": "I maintain **roton**, an experimental MIT-licensed GGUF inference engine written in Rust and Metal. I’m sharing the implementation and measurements for people interested in Apple GPU inference kernels.\n\nWeights stay memory-mapped in their original GGUF representation. Decode uses packed quantized GEMV. For optional chunked prefill, the GPU expands one projection at a time into a reusable FP16 buffer, converts activations to FP16, and writes FP32 matrix-product output. Causal attention, absolute-position RoPE and the KV cache connect the chunks. Scratch allocation is capped at 512 MiB.\n\nThis trades extra staging and scratch memory for matrix-matrix work. Short prompts can still lose to the sequential path, and FP16 rounding can change generated tokens. Sequential prefill remains the default for the raw run command; the chunked paths can be selected explicitly.\n\nThe v0.4.0 source also adds dense Qwen2.5/Qwen3 handling, including Q/K/V biases, NeoX-style RoPE, explicit head dimensions and QK normalization, plus sampling and terminal chat. Validation is still narrow; adding architecture support is not a claim that every checkpoint works.\n\nThese are **archived v0.3.0 measurements**, not a benchmark of the new Qwen support. Hardware: M5 Pro, 48 GiB, macOS 26.6.2. Model: SmolLM2-135M-Instruct Q5_K_S. This case uses 453 prompt tokens, 32 greedy output tokens and a 1,024-token context. Values are medians of five measured runs after a discarded warmup.\n\n| Configuration | Native prefill ms | Decode steps/s | Whole command ms | \n|---|---|---|---|\n| roton sequential | 4395.50 | 54.9 | 5001.43 | \n| roton Metal 3, batch 64 | 204.45 | 55.0 | 810.24 | \n| roton MPP FP16, batch 64 | 131.85 | 55.0 | 738.99 | \n| llama.cpp Metal, batch 64, FP32 KV, FA off | 52.87 | 460.1 | 263.07 | \n| llama.cpp Metal, batch 512, FP16 KV, FA auto | 15.34 | 534.0 | 215.57 | \n\nBatching substantially reduced roton’s own prefill cost, but the pinned llama.cpp reference remained faster on this workload. The long-context decode gap is the next profiling target: roton drops from roughly 368 steps/s on the five-token prompt to 55 here, while the reference stays above 460. These timings alone do not identify the bottleneck.\n\nThe full report includes 5-, 117- and 453-token cases, 75 measured runs, exact prompts, a model hash, build settings, raw JSON and a reproduction script. Output text matched across the five configurations for each of these three prompts; this is not general logit parity or a quality evaluation.\n\nImportant measurement limits: native timer boundaries differ; llama.cpp retains its internal warmup; desktop activity and clocks were not controlled. Whole-command time is not TTFT, and process RSS is not total GPU residency. The batch-512 reference also changes KV precision and attention selection, so it is not a batch-size-only comparison.\n\n[Source and current support scope](https://github.com/chainhelen/roton) · [Pinned reference report, raw data and reproduction steps](https://github.com/chainhelen/roton/blob/main/docs/REFERENCE_BENCHMARKS.md)\n\nDisclosure: maintainer post, drafted with AI assistance from the source and checked-in measurements.", "url": "https://wpnews.pro/news/roton-rust-metal-gguf-prefill-on-apple-silicon-with-a-reproducible-llama-cpp", "canonical_source": "https://discuss.huggingface.co/t/roton-rust-metal-gguf-prefill-on-apple-silicon-with-a-reproducible-llama-cpp-baseline/192884#post_1", "published_at": "2026-11-30 11:58:14+00:00", "updated_at": "2026-11-30 12:14:23.637274+00:00", "lang": "en", "topics": ["ai-infrastructure", "large-language-models", "ai-research", "mlops"], "entities": ["roton", "llama.cpp", "Apple Silicon", "Metal", "SmolLM2-135M-Instruct", "Qwen2.5", "Qwen3", "M5 Pro"], "also_reported_by": [], "takeaway": "On a 453-token prompt with SmolLM2-135M-Instruct Q5_K_S on an M5 Pro, roton's chunked MPP FP16 prefill at batch 64 cut native prefill from 4395.50 ms to 131.85 ms but decoded at 55.0 steps/s versus llama.cpp's 534.0 with batch 512, FP16 KV and automatic flash attention.", "recommendation": {"advice": "Batch prefill chunks (64 or 512) to replace sequential GEMV with matrix-matrix work, but benchmark decode separately: roton's batching cut prefill 33x while decode stayed at 55 steps/s against llama.cpp's 534.", "playbook": "inference-serving", "playbook_url": "https://wpnews.pro/playbooks/inference-serving"}, "alternates": {"html": "https://wpnews.pro/news/roton-rust-metal-gguf-prefill-on-apple-silicon-with-a-reproducible-llama-cpp", "markdown": "https://wpnews.pro/news/roton-rust-metal-gguf-prefill-on-apple-silicon-with-a-reproducible-llama-cpp.md", "text": "https://wpnews.pro/news/roton-rust-metal-gguf-prefill-on-apple-silicon-with-a-reproducible-llama-cpp.txt", "jsonld": "https://wpnews.pro/news/roton-rust-metal-gguf-prefill-on-apple-silicon-with-a-reproducible-llama-cpp.jsonld"}}