<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: chainhelen</title>
    <description>The latest articles on DEV Community by chainhelen (@chainhelen).</description>
    <link>https://dev.to/chainhelen</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4273247%2Fe06829e0-9362-42b2-816f-c472450a2d8d.jpg</url>
      <title>DEV Community: chainhelen</title>
      <link>https://dev.to/chainhelen</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chainhelen"/>
    <language>en</language>
    <item>
      <title>Rust + Metal GGUF inference: Qwen3 prefill tests and a llama.cpp baseline</title>
      <dc:creator>chainhelen</dc:creator>
      <pubDate>Mon, 30 Nov 2026 03:21:15 +0000</pubDate>
      <link>https://dev.to/chainhelen/running-a-gguf-model-from-rust-on-apple-silicon-roton-4278</link>
      <guid>https://dev.to/chainhelen/running-a-gguf-model-from-rust-on-apple-silicon-roton-4278</guid>
      <description>&lt;p&gt;Updated November 30 for v0.5.0. The Qwen3 tests below are new; the SmolLM2 and llama.cpp tables are archived v0.3.0 results.&lt;/p&gt;

&lt;p&gt;How much does batching the prompt help on an Apple Silicon Mac? I have measured both a small SmolLM2 checkpoint and Qwen3-1.7B, with raw data and reproduction commands. The results depend on prompt length, backend and model.&lt;/p&gt;

&lt;p&gt;I’m building &lt;a href="https://github.com/chainhelen/roton" rel="noopener noreferrer"&gt;roton&lt;/a&gt;, an experimental Rust and Metal GGUF inference engine for Apple Silicon. The prebuilt macOS arm64 binary runs without Cargo, Rust, Python or Xcode.&lt;/p&gt;

&lt;h2&gt;
  
  
  Qwen3-1.7B on the v0.5.0 release binary
&lt;/h2&gt;

&lt;p&gt;I repeated the prefill experiment with the public v0.5.0 binary on Qwen3-1.7B Q4_K_M, M5 Pro / 48 GiB / macOS 26.6.2. At batch 64, five measured runs after one warmup gave:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Raw prompt tokens&lt;/th&gt;
&lt;th&gt;Metal 3&lt;/th&gt;
&lt;th&gt;MPP&lt;/th&gt;
&lt;th&gt;Metal 3 / MPP&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;252.11 ms&lt;/td&gt;
&lt;td&gt;214.43 ms&lt;/td&gt;
&lt;td&gt;1.18x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;117&lt;/td&gt;
&lt;td&gt;464.44 ms&lt;/td&gt;
&lt;td&gt;323.77 ms&lt;/td&gt;
&lt;td&gt;1.43x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;453&lt;/td&gt;
&lt;td&gt;1575.33 ms&lt;/td&gt;
&lt;td&gt;1059.28 ms&lt;/td&gt;
&lt;td&gt;1.49x&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;All 30 measured runs produced matching 16-token output within each prompt. These model-side timings exclude startup/loading and compare roton's own paths. Runs were sequential, with Metal 3 before MPP for each prompt; clocks and desktop activity were not controlled. The older llama.cpp measurements below use v0.3.0 and SmolLM2, and do not establish a Qwen3 engine comparison.&lt;/p&gt;

&lt;p&gt;The current release also adds a checksum-verifying installer and local text-generation HTTP endpoints. JSON and SSE requests passed basic smoke checks for both Chat Completions and Messages shapes. These are limited text APIs: tool calling and complete Claude Code/OpenCode workflows are not verified.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/chainhelen/roton/blob/main/docs/QWEN3_BENCHMARKS.md" rel="noopener noreferrer"&gt;Qwen3 raw measurements and reproduction&lt;/a&gt; · &lt;a href="https://github.com/chainhelen/roton/blob/main/docs/HTTP_SERVER.md" rel="noopener noreferrer"&gt;Try the text HTTP endpoints&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it without compiling
&lt;/h2&gt;

&lt;p&gt;Install the current release with the checksum-verifying installer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -fsSL https://raw.githubusercontent.com/chainhelen/roton/main/install.sh &lt;span class="o"&gt;|&lt;/span&gt; sh
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$HOME/.local/bin:$PATH"&lt;/span&gt;
roton info
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or download and verify the archive manually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;(&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -eu
mkdir -p /tmp/roton-install
&lt;span class="nb"&gt;cd&lt;/span&gt; /tmp/roton-install
curl -fLO https://github.com/chainhelen/roton/releases/download/v0.5.0/roton-macos-arm64.tar.gz
curl -fLO https://github.com/chainhelen/roton/releases/download/v0.5.0/SHA256SUMS
shasum -a 256 -c SHA256SUMS
tar -xzf roton-macos-arm64.tar.gz
./roton info
&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The binary targets macOS 13+. CI runs on macOS 15, and I ran the real-model tests on macOS 26. The executable has an ad-hoc signature and has not been Apple-notarized. The &lt;a href="https://github.com/chainhelen/roton/blob/main/README.md#quick-start" rel="noopener noreferrer"&gt;Quick Start&lt;/a&gt; includes the model download and the first inference command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Archived v0.3.0: chunked prefill on SmolLM2
&lt;/h2&gt;

&lt;p&gt;Prefill processes the input prompt before the model starts generating. Sequential prefill is still the default. Add &lt;code&gt;--prefill-batch 64 --prefill-backend auto&lt;/code&gt; to opt in to chunks of up to 64 tokens.&lt;/p&gt;

&lt;p&gt;The GPU expands one projection at a time into a reusable FP16 buffer. Activations are converted to FP16, matrix products produce FP32 output, and causal attention writes the KV cache for subsequent decode. The original GGUF weights stay memory-mapped. Decode and the final LM head use the existing packed-weight GEMV path. Total prefill scratch is capped at 512 MiB. FP16 rounding can change generated tokens.&lt;/p&gt;

&lt;p&gt;I measured SmolLM2-135M-Instruct Q5_K_S on an M5 Pro with 48 GiB unified memory and macOS 26.6.2.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Prompt tokens&lt;/th&gt;
&lt;th&gt;Sequential&lt;/th&gt;
&lt;th&gt;Metal 3, batch 64&lt;/th&gt;
&lt;th&gt;MPP, batch 64&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;25.22 ms&lt;/td&gt;
&lt;td&gt;30.17 ms&lt;/td&gt;
&lt;td&gt;20.74 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;117&lt;/td&gt;
&lt;td&gt;501.49 ms&lt;/td&gt;
&lt;td&gt;53.43 ms&lt;/td&gt;
&lt;td&gt;32.77 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;453&lt;/td&gt;
&lt;td&gt;4433.88 ms&lt;/td&gt;
&lt;td&gt;204.37 ms&lt;/td&gt;
&lt;td&gt;132.25 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each figure is median prefill latency over five runs after one warmup, excluding process startup and model loading. This comparison covers three paths within roton. This original run used 16 output tokens. The new 32-token llama.cpp reference run below is separate; there is no MLX comparison. All three paths produced the same 16-token continuation for each of these prompts. Process RSS only measures part of memory use, and the raw results report allocated scratch separately.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/chainhelen/roton/blob/v0.3.0/docs/BENCHMARKS.md" rel="noopener noreferrer"&gt;Raw JSON, exact prompts and reproduction script&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I also tested four SmolLM2 quantizations, Q8_0, Q4_K_M, Q5_K_M and Q5_K_S. For one short prompt, the 32-token result matched the sequential baseline within each quantization on both batching backends. The 19 tests and macOS/Linux CI passed. &lt;a href="https://github.com/chainhelen/roton/blob/v0.3.0/docs/VALIDATION.md" rel="noopener noreferrer"&gt;Validation details and checksums&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Archived v0.3.0: a pinned llama.cpp reference
&lt;/h2&gt;

&lt;p&gt;An improvement over roton's sequential path does not show how it compares with an established engine. I added a separate run against llama.cpp commit &lt;code&gt;9a278b02b83d476d7c9758c8c91e32392f896e66&lt;/code&gt;, with all 31 model layers confirmed on the Metal GPU.&lt;/p&gt;

&lt;p&gt;This run uses the same M5 Pro and Q5_K_S GGUF, a 1,024-token context, 32 greedy output tokens, one warmup per configuration and prompt, and five measured repetitions. Configurations rotate sequentially. Here are medians for the 453-token prompt:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Configuration&lt;/th&gt;
&lt;th&gt;Prefill ms&lt;/th&gt;
&lt;th&gt;Decode steps/s&lt;/th&gt;
&lt;th&gt;Whole command ms&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;roton sequential&lt;/td&gt;
&lt;td&gt;4395.50&lt;/td&gt;
&lt;td&gt;54.9&lt;/td&gt;
&lt;td&gt;5001.43&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;roton Metal 3, batch 64&lt;/td&gt;
&lt;td&gt;204.45&lt;/td&gt;
&lt;td&gt;55.0&lt;/td&gt;
&lt;td&gt;810.24&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;roton MPP FP16, batch 64&lt;/td&gt;
&lt;td&gt;131.85&lt;/td&gt;
&lt;td&gt;55.0&lt;/td&gt;
&lt;td&gt;738.99&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;llama.cpp, batch 64, FP32 KV, FA off&lt;/td&gt;
&lt;td&gt;52.87&lt;/td&gt;
&lt;td&gt;460.08&lt;/td&gt;
&lt;td&gt;263.07&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;llama.cpp, batch 512, FP16 KV, FA auto&lt;/td&gt;
&lt;td&gt;15.34&lt;/td&gt;
&lt;td&gt;533.96&lt;/td&gt;
&lt;td&gt;215.57&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Chunked prefill helps roton, but llama.cpp remains faster on this workload, especially in decode. The report also includes the 5- and 117-token cases, exact commands, build settings, model SHA-256 and all 75 measured trials. All measured continuations matched by text for their respective prompts; that is a narrow output check, not a claim of general numerical parity or model quality.&lt;/p&gt;

&lt;p&gt;The runtime timers and internal warmups differ: llama.cpp's internal warmup remained enabled. Whole-command time includes process overhead and is not time to first token. The desktop, GPU clocks and caches were not controlled, and process RSS does not capture total GPU residency. Treat this as a reproducible development reference, not a general engine ranking.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/chainhelen/roton/blob/main/docs/REFERENCE_BENCHMARKS.md" rel="noopener noreferrer"&gt;Full report, raw JSON and reproduction script&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I’d like to learn from another Mac
&lt;/h2&gt;

&lt;p&gt;At what prompt length does batching start to help on an M1, M2, M3 or M4? I’ve posted the &lt;a href="https://github.com/chainhelen/roton/discussions/1" rel="noopener noreferrer"&gt;commands and a short reporting template&lt;/a&gt;. The chip, macOS version, model filename and prefill latency from the same prompt on both paths would help me compare results. If the binary fails to run, the error is useful too.&lt;/p&gt;

&lt;p&gt;The current release runs dense llama, Qwen2.5 and Qwen3 models on one Mac, with temperature/top-p sampling and terminal chat. Validation remains narrow. MoE and pooling memory across Thunderbolt-connected Macs remain future work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/chainhelen/roton" rel="noopener noreferrer"&gt;Source&lt;/a&gt; · &lt;a href="https://github.com/chainhelen/roton/releases/tag/v0.5.0" rel="noopener noreferrer"&gt;v0.5.0 binary release&lt;/a&gt; · MIT license&lt;/p&gt;

</description>
      <category>rust</category>
      <category>opensource</category>
      <category>machinelearning</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
