From GGUF weights to a local answer — in Rust and Metal.
roton is an experimental inference engine for developers exploring Rust, GGUF and Apple GPU kernels. It maps model weights into Metal buffers and ships as a macOS arm64 binary, with no external Rust crates and no Rust, Python or Xcode installation needed to run it.
- Inspect the whole path: load GGUF weights, run the model, and read the GPU kernels.
- Experiment on your Mac: compare Metal 3 and supported Metal 4 / MPP paths, then try packed-weight decode and chunked prefill on a real model.
- Use the current CLI:
run, interactivechat, and a local text-only HTTP/SSEserve. v0.6.0 adds GEMV optimizations and in-memory KV prefix reuse in chat/server sessions.
On an Apple Silicon Mac, copy this into Terminal:
curl -fsSL https://raw.githubusercontent.com/chainhelen/roton/main/try.sh | shThe demo script downloads the v0.6.0 binary + Qwen3-0.6B Q4_K_M (about 397 MB), verifies their pinned SHA256 hashes, and asks the model to explain a GPU. No Rust, Python, Xcode or PATH setup. It prints a ready-to-copy command to continue chatting.
Files are cached in ~/Library/Caches/roton/demo/v0.6.0; a repeat run reuses verified files. last-run.txt records the device, command, output and errors locally; nothing is uploaded. Set ROTON_DEMO_DIR when running the script to choose another cache directory. Remove that directory to remove the demo.
Prefer a small GPU-only trial? This downloads only the approximately 360 KB release archive and runs the built-in kernel benchmark:
curl -fsSL https://raw.githubusercontent.com/chainhelen/roton/main/try.sh | sh -s -- --gpu-onlyRecorded output and validation · Report a result or blocker
Install permanently or run the model commands yourself
On an Apple Silicon Mac, install the release binary and run its built-in kernel benchmark:
curl -fsSL https://raw.githubusercontent.com/chainhelen/roton/main/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
roton info
roton bench 2048 2048 2048The installer verifies the release checksum. info prints your GPU and backend; bench prints GEMM latency/TFLOPS and quantized GEMV bandwidth. MPP results appear only where the pipeline is available. These are kernel measurements, not chatbot tokens/second or a comparison with another engine.
Verified v0.6.0 output and exact test conditions. The build targets macOS 13+; CI covers macOS 15 and the recorded real-model check used macOS 26. Other machines still need testing.
Download Qwen3-0.6B Q4_K_M (about 397 MB) and run a short, deterministic request:
curl -fL --retry 2 -o Qwen3-0.6B-Q4_K_M.gguf \
https://huggingface.co/unsloth/Qwen3-0.6B-GGUF/resolve/50968a4468ef4233ed78cd7c3de230dd1d61a56b/Qwen3-0.6B-Q4_K_M.gguf
roton run Qwen3-0.6B-Q4_K_M.gguf \
"Reply with one sentence explaining what a GPU does. /no_think" \
--chat --temp 0 --max-tokens 128 --max-ctx 512 --prefill-batch 64This small model checks installation and text generation. The recorded run returned a sentence beginning “A GPU is a powerful computing device…” after an empty <think> block. Output and speed can vary with backend and release. The first-run report includes the model hash, full answer and command output.
For an interactive session, use roton chat Qwen3-0.6B-Q4_K_M.gguf --prefill-batch 64 (/clear starts over, /exit quits). For local HTTP text generation, follow the server and curl examples.
Tried it? Tell us what you wanted to do, what happened, and whether you would use it again. Failed installations and unsupported Macs are useful reports too. You do not need to run a full benchmark suite.
Useful for your Rust/Metal experiments? Star this repository to keep it handy.
Manual installation, PATH and source builds
(
set -eu
mkdir -p /tmp/roton-install "$HOME/.local/bin"
cd /tmp/roton-install
curl -fLO https://github.com/chainhelen/roton/releases/download/v0.6.0/roton-macos-arm64.tar.gz
curl -fLO https://github.com/chainhelen/roton/releases/download/v0.6.0/SHA256SUMS
shasum -a 256 -c SHA256SUMS
tar -xzf roton-macos-arm64.tar.gz
install -m 755 roton "$HOME/.local/bin/roton"
)
export PATH="$HOME/.local/bin:$PATH"
roton infoAdd the PATH line to ~/.zshrc for future terminals. Releases are not Apple-notarized; if macOS blocks execution, review it through Privacy & Security. Do not disable system protections.
Only source builds need Rust and Apple Command Line Tools:
git clone https://github.com/chainhelen/roton
cd roton
cargo build --release --locked
./target/release/roton info| Evidence | Version | What it establishes |
|---|---|---|
| First-run checks and raw output | v0.6.0 | Release installation, kernel execution, a Qwen3-0.6B answer, chat prefix reuse and text HTTP/SSE smoke checks on one M5 Pro. |
| Qwen3-1.7B repeated prefill | v0.5.0 | 30 measured runs; 1.18–1.49× MPP vs Metal 3 across three input lengths, within roton. |
| Pinned llama.cpp comparison | v0.3.0 | On the tested SmolLM2 model, llama.cpp had faster model-side prefill and decode. This is not a v0.6.0 comparison. |
The chart separates kernel throughput from model prefill, and labels each version. There is no verified v0.6.0 performance advantage over llama.cpp or MLX. Decode throughput in CLI logs counts forward steps after prefill and excludes streaming output time.
Earlier model measurements
Apple M5 Pro (48 GiB, macOS 26), zero-copy mmap → Metal, --chat with ChatML special tokens, greedy decoding (--temp 0):
Model (Q4_K_M) |
Prompt | Prefill Path | Prefill | Decode | Notes |
|---|---|---|---|---|---|
Qwen2.5-0.5B-Instruct (qwen2, 24L, Q/K/V bias) |
18 tok | Sequential GEMV | 288.82 ms (62.3 tok/s) | 194.8 steps/s | Identical 26-tok reply across all 3 paths |
Qwen2.5-0.5B-Instruct (qwen2) |
18 tok | Metal 3 batch 64 | 91.93 ms (195.8 tok/s) | 194.0 steps/s | 3.14× prefill vs sequential |
Qwen2.5-0.5B-Instruct (qwen2) |
18 tok | Metal 4 MPP batch 64 | 69.78 ms (258.0 tok/s) | 199.1 steps/s | 4.14× vs sequential, 1.32× vs Metal 3 |
Qwen3-0.6B (qwen3, 28L, q_dim=2048, QK-Norm) |
21 tok | Metal 4 MPP batch 64 | 78.71 ms (266.8 tok/s) | 101.1 steps/s | Native <think> output verified |
Public release binary, Q4_K_M, raw prompts, batch 64, five measurements after one warmup per case/backend:
| Prompt tokens | Metal 3 | MPP | Metal 3 / MPP |
|---|---|---|---|
| 5 | 252.11 ms | 214.43 ms | 1.18× |
| 117 | 464.44 ms | 323.77 ms | 1.43× |
| 453 | 1575.33 ms | 1059.28 ms | 1.49× |
All 30 measured runs produced matching 16-token output within each prompt. These are model-side prefill timings, not startup latency or a comparison with other engines. Raw data, reproducible commands and limits.
SmolLM2-135M-Instruct Q5_K_S, Apple M5 Pro, 48 GiB, macOS 26. Each cell is the median of 5 runs after one warmup, on the same model and prompt. Batch size: 64. This measures model-side prefill, including weight staging and final logits; process startup and model loading are excluded.
| Prompt tokens | Sequential GEMV | Metal 3 batch 64 | MPP batch 64 | Sequential / MPP |
|---|---|---|---|---|
| 5 | 25.22 ms | 30.17 ms | 20.74 ms | 1.22× |
| 117 | 501.49 ms | 53.43 ms | 32.77 ms | 15.30× |
| 453 | 4433.88 ms | 204.37 ms | 132.25 ms | 33.53× |
All three paths produced the same 16-token continuation for these inputs. FP16 prefill can change outputs on other prompts. On the shortest input, Metal 3 batching was slower than sequential execution. These are comparisons within roton, not against llama.cpp or MLX.
Raw results, memory figures and reproduction commands.
A separate pinned llama.cpp Metal comparison now includes decode and whole-command latency on the same model and prompts. llama.cpp was faster in model-side prefill and decode in every tested configuration. The five configurations produced matching 32-token output text on these three inputs; this is not general model parity.
- Verified end-to-end today (
roton run):- Dense
llama,qwen2(Qwen2.5), andqwen3GGUF models (tied or untiedoutput.weight, Q/K/V biases, explicithead_dim/q_dim, per-head QK-Norm), verified onSmolLM2-135M-Instruct(Q8_0/Q4_K_M/Q5_K_M/Q5_K_S),Qwen2.5-0.5B-Instruct-Q4_K_M,Qwen3-0.6B-Q4_K_M, andQwen3-1.7B-Q4_K_M(plusroton serveOpenAI/v1/chat/completions& Anthropic/v1/messageswith SSE streaming). - Supported matrix tensor types:
Q8_0,Q4_0,Q4_K,Q5_0,Q5_1,Q5_K,Q6_K,F16,F32(withF32RMSNorm weights). - Zero-copy
mmap→ MetalnewBufferWithBytesNoCopy, built-in GGUF BPE / SentencePiece tokenizer, and single-command-buffer per-token GPU execution.
- Dense
- Current limitations:
- HTTP support is text-only. Tools, tool results and image blocks are not supported; unsupported fields may be silently ignored. Stop reasons are not yet accurate for token-limit termination. Endpoint shape alone does not establish coding-agent compatibility.
- In-memory KV prefix reuse in
roton chatandroton servereuses a common token prefix across sequential requests. The server holds one shared cache; it has no per-user session slots or disk persistence./clearresets terminal chat; restarting resets the server cache. - Sequential prefill by default; chunked FP16 prefill is opt-in and can change numerical rounding and generated tokens.
- MoE (
Qwen3.6/LFM2.5), GLM-5.x native runners, and tool-calling JSON grammar and multi-session KV cache management are planned milestones.
roton run SmolLM2-135M-Instruct-Q8_0.gguf "Your prompt here" \
--max-tokens 32 --max-ctx 1024 --prefill-batch 64 --prefill-backend autoUse --prefill-batch 1 for the original sequential path, or 2–512 to process a chunk at a time. --prefill-backend auto|metal3|mpp chooses the FP16 matrix-multiply backend. The CLI reports the path used, elapsed prefill time and allocated scratch memory.
For each projection, the GPU unpacks GGUF weights into one reusable FP16 transpose buffer. Activations are cast to FP16 and matrix products accumulate into FP32 output. Weights stay mmap-backed; decode and the final LM head use packed GEMV. There is no full-model FP16 cache. Scratch is capped at 512 MiB; configurations above the cap return an error. Causal GQA and absolute-position RoPE handle chunk boundaries and preserve the KV cache for subsequent decode.
Support for Q5_0, Q5_1 and Q5_K decoding and Metal GEMV was added in v0.2.3. Mixed files can contain several tensor types: SmolLM2 Q4_K_M uses Q5_0 fallback tensors, while Q5_K_M and Q5_K_S use Q5_1 on dimensions that are not multiples of 256. These files now run; the old v0.2.1 binary rejected them.
curl -fL -o SmolLM2-135M-Instruct-Q4_K_M.gguf \
https://huggingface.co/bartowski/SmolLM2-135M-Instruct-GGUF/resolve/main/SmolLM2-135M-Instruct-Q4_K_M.gguf
roton run SmolLM2-135M-Instruct-Q4_K_M.gguf \
"The capital of France is" --max-tokens 32 --max-ctx 256See validation and reproduction notes for the tested files, upstream reference fixtures and numerical tolerances. Passing these checks does not establish full model parity or faster performance than other engines.
Chunked prefill uses MPP FP16 when its pipeline compiles successfully, with Metal 3 fallback. For chunked prefill, pass --prefill-backend metal3 or mpp to select a backend explicitly; unavailable MPP returns an error. Decode uses quantized GEMV. Automatic per-model tuning is not implemented.
roton startup probe (MTLDevice + NSProcessInfo)
├── Apple10 (M5) + macOS 26+ ──▶ Metal 4 / MPP `matmul2d` (GPU Neural Accelerators)
├── Apple7–9 (M1–M4) + macOS 26+ ──▶ MPP `matmul2d` or Metal 3 `simdgroup_matrix` (capability-dependent)
└── macOS 13–15 (any M-series) ──▶ Metal 3 `simdgroup_matrix` universal fallback
crates/
├── roton-core/ # GGUF v2/v3 zero-copy mmap loader, BPE/SentencePiece tokenizer, quant layouts, memory planner
├── roton-metal/ # Persistent Metal 3 & Metal 4/MPP engine, GPU kernels, GgufRunner
└── roton-cli/ # Single-binary `roton` CLI (`info`, `plan`, `bench`, `inspect`, `run`, `chat`, `serve`)
Planned crates as milestones land:
roton-moe— Top-K expert routing, hot-expert residency cache, online domain expert pruningroton-server— Extract the existing CLI HTTP server and add multi-session cache management / tool supportroton-cluster— Heterogeneous multi-Mac Thunderbolt clustering (mDNS discovery + weighted sharding + TB5 RDMA)
Read the full technical design in 66C3 docs/ARCHITECTURE.md and milestone plan in docs/ROADMAP.md.
Contributions, benchmarks on M1–M5 hardware, and kernel PRs are very welcome! See CONTRIBUTING.md.
MIT License © 2026 chainhelen.