8000 Make the first model answer a single verified command by chainhelen · Pull Request #5 · chainhelen/roton · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/first-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ body:
options:
- "Read the README, did not install / 看了介绍,未安装"
- "Installation or startup failed / 安装或启动失败"
- "One-command demo completed / 一键演示已完成"
- "GPU benchmark completed / 已完成 GPU 测试"
- "Model generation worked / 已得到模型输出"
- "Tried chat or HTTP / 已试用聊天或 HTTP"
Expand All @@ -36,7 +37,7 @@ body:
id: result
attributes:
label: Command, result or blocker / 命令、结果或阻碍
description: Include the model filename and command when relevant. Remove private prompts and local paths before sharing logs.
description: "The one-command demo saves ~/Library/Caches/roton/demo/v0.6.0/last-run.txt (or under ROTON_DEMO_DIR). You may paste it here after removing private prompts and local paths. Nothing is uploaded automatically. / 一键演示会在缓存目录保存 last-run.txt,检查并去除私人内容后可粘贴;不会自动上传。"
render: text
- type: textarea
id: repeat-use
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ on:
branches: [main]

jobs:
check-demo:
name: Demo download and cache checks (${{ matrix.os }})
strategy:
matrix:
os: [ubuntu-latest, macos-15]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Check POSIX shell syntax
run: sh -n try.sh
- name: Exercise verified downloads, cache reuse and failures
run: python3 scripts/test_try.py -v

check-macos:
name: Build & Test (macOS Apple Silicon)
runs-on: macos-15
Expand Down
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# roton — Rust + Metal inference for Apple Silicon

**Run a GGUF model. Compare Metal kernels. Follow the Rust code.**
**From GGUF weights to a local answer — in Rust and Metal.**

[English](README.md) · [简体中文](README.zh-CN.md)

Expand All @@ -20,8 +20,33 @@
- **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`, interactive `chat`, and a local text-only HTTP/SSE `serve`. v0.6.0 adds GEMV optimizations and in-memory KV prefix reuse in chat/server sessions.

<a href="docs/FIRST_RUN.md#one-command-demo"><img src="docs/assets/first-answer.svg" alt="Actual v0.6.0 Qwen3-0.6B output on M5 Pro: A GPU is a powerful computing device that accelerates complex tasks by parallelizing the processing of data. Includes an empty thinking block." width="840"></a>

## Quick Start

### One command → one local answer

On an **Apple Silicon Mac**, copy this into Terminal:

```sh
curl -fsSL https://raw.githubusercontent.com/chainhelen/roton/main/try.sh | sh
```

The [demo script](try.sh) 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:

```sh
curl -fsSL https://raw.githubusercontent.com/chainhelen/roton/main/try.sh | sh -s -- --gpu-only
```

[Recorded output and validation](docs/FIRST_RUN.md#one-command-demo) · [Report a result or blocker](https://github.com/chainhelen/roton/issues/new?template=first-run.yml)

<details>
<summary>Install permanently or run the model commands yourself</summary>

### 1. Test your GPU — no model download

On an **Apple Silicon Mac**, install the release binary and run its built-in kernel benchmark:
Expand Down Expand Up @@ -53,8 +78,12 @@ This small model checks installation and text generation. The recorded run retur

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](docs/HTTP_SERVER.md).

</details>

**Tried it?** [Tell us what you wanted to do, what happened, and whether you would use it again](https://github.com/chainhelen/roton/issues/new?template=first-run.yml). 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.**

<details>
<summary>Manual installation, PATH and source builds</summary>

Expand Down
31 changes: 30 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# roton — Apple Silicon 上的 Rust + Metal 推理引擎

**跑一个 GGUF 模型,比较 Metal 算子,沿着 Rust 源码看懂推理。**
**从 GGUF 权重到本地回答,沿着 Rust 与 Metal 看懂推理。**

[English](README.md) · [简体中文](README.zh-CN.md)

Expand All @@ -20,8 +20,33 @@
- **在自己的 Mac 上做实验**:比较 Metal 3 与可用的 Metal 4 / MPP 路径,再运行真实模型,观察量化权重 Decode 和分块 Prefill。
- **使用现有命令**:`run`、交互式 `chat` 和本地文本 HTTP/SSE `serve`。v0.6.0 增加了 GEMV 优化,以及聊天和服务中的内存 KV 前缀复用。

<a href="docs/FIRST_RUN.md#one-command-demo"><img src="docs/assets/first-answer.svg" alt="v0.6.0 在 M5 Pro 上运行 Qwen3-0.6B 的真实输出:空 thinking 块后,用一句话解释 GPU 的作用。" width="840"></a>

## 快速开始

### 一条命令,得到本地模型回答

在 **Apple Silicon Mac** 的终端中复制运行:

```sh
curl -fsSL https://raw.githubusercontent.com/chainhelen/roton/main/try.sh | sh
```

[演示脚本](try.sh)会下载 **v0.6.0 程序及 Qwen3-0.6B Q4_K_M 模型(约 397 MB)**,按固定 SHA256 校验,然后让模型用一句话解释 GPU。无需安装 Rust、Python、Xcode 或配置 PATH。运行结束后会打印可直接复制的聊天命令。

文件缓存在 `~/Library/Caches/roton/demo/v0.6.0`,再次运行会复用校验通过的文件。`last-run.txt` 在本地记录设备、命令、输出和错误,**不会自动上传**。运行脚本时可用 `ROTON_DEMO_DIR` 指定其他缓存目录;删除该目录即可移除演示。

**只想先测 GPU?** 下面只下载约 360 KB 的发布压缩包,运行内置算子测试:

```sh
curl -fsSL https://raw.githubusercontent.com/chainhelen/roton/main/try.sh | sh -s -- --gpu-only
```

[已记录的输出与验证](docs/FIRST_RUN.md#one-command-demo) · [反馈结果或阻碍](https://github.com/chainhelen/roton/issues/new?template=first-run.yml)

<details>
<summary>长期安装,或自己执行下载与推理命令</summary>

### 1. 先测 GPU,不用下载模型

在 **Apple Silicon Mac** 上安装发布程序,运行内置算子测试:
Expand Down Expand Up @@ -53,8 +78,12 @@ roton run Qwen3-0.6B-Q4_K_M.gguf \

继续对话可运行 `roton chat Qwen3-0.6B-Q4_K_M.gguf --prefill-batch 64`,输入 `/clear` 清空上下文,`/exit` 退出。需要 HTTP 文本接口时,见[服务启动与 curl 示例](docs/HTTP_SERVER.md)。

</details>

**试过以后,欢迎[告诉我们你想做什么、实际发生了什么、是否还会再用](https://github.com/chainhelen/roton/issues/new?template=first-run.yml)。** 安装失败和不支持的机器同样值得反馈,不必先跑完整套性能测试。

如果它对你的 Rust/Metal 实验有用,欢迎 **Star 收藏,方便下次找到**。

<details>
<summary>手动安装、PATH 与源码构建</summary>

Expand Down
32 changes: 32 additions & 0 deletions docs/FIRST_RUN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,38 @@ Checked on December 1, 2026 using the **public release binary**, installed into

This records the README's first-use path. It is a smoke check on one machine, not a repeated performance study or a comparison with another engine. [Full raw output, responses and hashes](benchmarks/v0.6.0-first-run.json).

## One-command demo

The README now offers `curl -fsSL https://raw.githubusercontent.com/chainhelen/roton/main/try.sh | sh`.
This script runs the existing **v0.6.0 release**, not a newly built engine. It pins
the release archive, executable and model SHA256 values, keeps verified files in
a cache directory, and writes a local `last-run.txt`. No telemetry is sent, shell
profiles are unchanged, and model generation works without PATH configuration.

Checked on December 1, 2026, on the same M5 Pro/macOS 26.6.2:

- **Empty cache:** downloaded the release and approximately 397 MB model from
their public URLs, verified hashes, and generated the complete answer below.
- **Repeat run:** reused both verified files and generated the same answer.
- **`--gpu-only`, separate empty cache:** downloaded just the approximately
360 KB release archive, ran GEMM/GEMV benchmarks, and created no model file.
- **Eight fixture-based checks:** download/corruption failures, cached reruns,
paths with spaces and quotes, GPU-only mode, generation errors, invalid
platforms/options and concurrent-run locking. These use tiny files and no
network, and run on Linux and macOS in CI.

[Demo output, checksums and validation record](benchmarks/v0.6.0-demo.json).
The [README illustration](assets/first-answer.svg) reproduces the model output
from this run, including its empty thinking block; it omits diagnostic lines.
It is a rendered transcript, not a screenshot or a quality/performance claim.

The default cache is `~/Library/Caches/roton/demo/v0.6.0`. Override
`ROTON_DEMO_DIR` when invoking the script to choose another location. The report
contains the latest run only. Review it before copying it into a first-run issue;
the script does not submit feedback for you. Delete the cache directory to remove
the demo. `--help` lists the options. The existing `install.sh` remains available
for installing the executable into your usual shell PATH.

## GPU check without model weights

```sh
Expand Down
24 changes: 24 additions & 0 deletions docs/assets/first-answer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions docs/benchmarks/v0.6.0-demo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"checked_date": "2026-12-01",
"kind": "First-use smoke checks; no comparison or repeated performance study",
"script_sha256": "3b5b4f3d80e3cbae2ad3cb0de40449d2af729ee1dbd8448f2aace380d9423e93",
"release": "v0.6.0",
"release_archive_sha256": "094ba70c9e759f2eea8578f74a83678bd68932311c4a82ee8145e78b73914755",
"binary_sha256": "ca946f29259a96f422090e534156e2870386b34f56affc6672e6665b869ab152",
"model_revision": "50968a4468ef4233ed78cd7c3de230dd1d61a56b",
"model_sha256": "ac2d97712095a558e31573f62f466a3f9d93990898b0ec79d7c974c1780d524a",
"model_bytes": 396705472,
"device": "Apple M5 Pro; 48 GiB; macOS 26.6.2",
"cold": {
"command": "ROTON_DEMO_DIR=\"$DEMO_CACHE\" sh try.sh",
"exit_code": 0,
"stdout": "roton v0.6.0 demo | Apple Silicon | model\nCache: $DEMO_CACHE\n[1/3] Downloading release (about 360 KB)...\nroton 0.6.0\n GPU Device : Apple M5 Pro\n Apple GPU Family : Apple10\n Unified Memory : 48.0 GiB (Metal residency cap: 37.4 GiB)\n Metal 4 / MPP : supported (macOS 26+)\n Selected Backend : Metal 4 / MPP FP16 (matmul2d)\n[2/3] Downloading Qwen3-0.6B-Q4_K_M.gguf (about 397 MB, cached for reuse)...\n[3/3] Asking: Reply with one sentence explaining what a GPU does. /no_think\n\n<think>\n\n</think>\n\nA GPU is a powerful computing device that accelerates complex tasks by parallelizing the processing of data.\n\nDemo complete. Local report (nothing uploaded): $DEMO_CACHE/last-run.txt\n\nContinue chatting:\n '$DEMO_CACHE/roton' chat '$DEMO_CACHE/Qwen3-0.6B-Q4_K_M.gguf' --prefill-batch 64\n\nShare a result or blocker (review the local report first):\n https://github.com/chainhelen/roton/issues/new?template=first-run.yml\n",
"diagnostics": [
"[roton] prefill: 22 tok (333.9 tok/s) | generated: 24 tok | decode: 24 steps (210.2 steps/s)",
"[roton] prefill backend: Metal 4 / MPP FP16 (matmul2d) | batch: 64 | scratch: 19.68 MiB | prefill: 65.89 ms"
]
},
"cached": {
"command": "ROTON_DEMO_DIR=\"$DEMO_CACHE\" sh try.sh",
"exit_code": 0,
"stdout": "roton v0.6.0 demo | Apple Silicon | model\nCache: $DEMO_CACHE\n[1/3] Using verified cached roton.\nroton 0.6.0\n GPU Device : Apple M5 Pro\n Apple GPU Family : Apple10\n Unified Memory : 48.0 GiB (Metal residency cap: 37.4 GiB)\n Metal 4 / MPP : supported (macOS 26+)\n Selected Backend : Metal 4 / MPP FP16 (matmul2d)\n[2/3] Using verified cached Qwen3-0.6B-Q4_K_M.gguf.\n[3/3] Asking: Reply with one sentence explaining what a GPU does. /no_think\n\n<think>\n\n</think>\n\nA GPU is a powerful computing device that accelerates complex tasks by parallelizing the processing of data.\n\nDemo complete. Local report (nothing uploaded): $DEMO_CACHE/last-run.txt\n\nContinue chatting:\n '$DEMO_CACHE/roton' chat '$DEMO_CACHE/Qwen3-0.6B-Q4_K_M.gguf' --prefill-batch 64\n\nShare a result or blocker (review the local report first):\n https://github.com/chainhelen/roton/issues/new?template=first-run.yml\n",
"report": "roton demo v0.6.0\nUTC: 2026-12-01T15:50:10Z\nMode: model\nBinary SHA256: ca946f29259a96f422090e534156e2870386b34f56affc6672e6665b869ab152\nmacOS: 26.6.2\nroton 0.6.0\n GPU Device : Apple M5 Pro\n Apple GPU Family : Apple10\n Unified Memory : 48.0 GiB (Metal residency cap: 37.4 GiB)\n Metal 4 / MPP : supported (macOS 26+)\n Selected Backend : Metal 4 / MPP FP16 (matmul2d)\n\nModel: Qwen3-0.6B-Q4_K_M.gguf\nModel revision: 50968a4468ef4233ed78cd7c3de230dd1d61a56b\nModel SHA256: ac2d97712095a558e31573f62f466a3f9d93990898b0ec79d7c974c1780d524a\nCommand: roton run MODEL \"Reply with one sentence explaining what a GPU does. /no_think\" --chat --temp 0 --max-tokens 128 --max-ctx 512 --prefill-batch 64\n\nOutput:\n<think>\n\n</think>\n\nA GPU is a powerful computing device that accelerates complex tasks by parallelizing the processing of data.\n\nDiagnostics:\n[roton] prefill: 22 tok (336.3 tok/s) | generated: 24 tok | decode: 24 steps (209.4 steps/s)\n[roton] prefill backend: Metal 4 / MPP FP16 (matmul2d) | batch: 64 | scratch: 19.68 MiB | prefill: 65.42 ms\n\nExit status: 0\n"
},
"gpu_only": {
"command": "ROTON_DEMO_DIR=\"$GPU_DEMO_CACHE\" sh try.sh --gpu-only",
"exit_code": 0,
"model_files": 0,
"stdout": "roton v0.6.0 demo | Apple Silicon | gpu\nCache: $GPU_DEMO_CACHE\n[1/3] Downloading release (about 360 KB)...\nroton 0.6.0\n GPU Device : Apple M5 Pro\n Apple GPU Family : Apple10\n Unified Memory : 48.0 GiB (Metal residency cap: 37.4 GiB)\n Metal 4 / MPP : supported (macOS 26+)\n Selected Backend : Metal 4 / MPP FP16 (matmul2d)\n[2/3] No model download needed.\n[3/3] Running GPU kernels...\n\n[Prefill GEMM] (2048x2048 * 2048x2048) on Apple M5 Pro (Apple10)\n Metal 3 (simdgroup_matrix) gpu= 4.03 ms 4.27 TFLOPS\n Metal 4 / MPP FP16 (matmul2d) gpu= 1.07 ms 16.06 TFLOPS (3.76x vs M3, diff=6.26e-7)\n Metal 4 / MPP W8A16 (int8) gpu= 1.07 ms 16.09 TFLOPS (3.77x vs M3)\n\n[Decode GEMV Bandwidth] (14336x4096, single-token decode)\n Q8_0 GEMV (unified memory) gpu= 0.292 ms 213.7 GB/s\n Q4_0 GEMV (unified memory) gpu= 0.144 ms 230.4 GB/s\n Q4_K GEMV (8-lane/block) gpu= 0.115 ms 287.8 GB/s\n Q6_K GEMV (8-lane/block) gpu= 0.176 ms 273.6 GB/s\n\nDemo complete. Local report (nothing uploaded): $GPU_DEMO_CACHE/last-run.txt\n\nThese are kernel timings, not model tokens/second.\n\nShare a result or blocker (review the local report first):\n https://github.com/chainhelen/roton/issues/new?template=first-run.yml\n",
"report": "roton demo v0.6.0\nUTC: 2026-12-01T15:50:13Z\nMode: gpu\nBinary SHA256: ca946f29259a96f422090e534156e2870386b34f56affc6672e6665b869ab152\nmacOS: 26.6.2\nroton 0.6.0\n GPU Device : Apple M5 Pro\n Apple GPU Family : Apple10\n Unified Memory : 48.0 GiB (Metal residency cap: 37.4 GiB)\n Metal 4 / MPP : supported (macOS 26+)\n Selected Backend : Metal 4 / MPP FP16 (matmul2d)\n\nCommand: roton bench 2048 2048 2048\n\nOutput:\n[Prefill GEMM] (2048x2048 * 2048x2048) on Apple M5 Pro (Apple10)\n Metal 3 (simdgroup_matrix) gpu= 4.03 ms 4.27 TFLOPS\n Metal 4 / MPP FP16 (matmul2d) gpu= 1.07 ms 16.06 TFLOPS (3.76x vs M3, diff=6.26e-7)\n Metal 4 / MPP W8A16 (int8) gpu= 1.07 ms 16.09 TFLOPS (3.77x vs M3)\n\n[Decode GEMV Bandwidth] (14336x4096, single-token decode)\n Q8_0 GEMV (unified memory) gpu= 0.292 ms 213.7 GB/s\n Q4_0 GEMV (unified memory) gpu= 0.144 ms 230.4 GB/s\n Q4_K GEMV (8-lane/block) gpu= 0.115 ms 287.8 GB/s\n Q6_K GEMV (8-lane/block) gpu= 0.176 ms 273.6 GB/s\n\nDiagnostics:\n\nExit status: 0\n"
},
"fixture_tests": {
"command": "python3 scripts/test_try.py -v",
"passed": 8,
"uses_network": false
},
"note": "Temporary cache paths replaced with placeholders. These local-script checks used real public binary/model downloads; no Rust rebuild. Cached files are rehashed, not trusted solely by filename."
}
Loading
Loading
0