Retrieved article excerpt
Open article · Retrieved 2026-11-03T06:25:45.068484+00:00
# gfx803 / Polaris Metal performance fork
Work on **Apple's Metal driver for AMD Polaris (GCN 4, `gfx803`)**, carried as a fork of
[engeldlgado/toshllm](https://github.com/engeldlgado/toshllm) — which is upstream, credited below,
and not this project's name or claim. Host of record: an RX 580 (36 CUs, 8 GB) under macOS 12 on an
Intel Xeon box, with the same card measured under Linux/RADV for comparison.
One checkpoint (`Ornith-1.5-9B-heretic-Q4_K_M`), one `llama-bench` request, medians of four
repetitions on a quiet, warmed card:
| build | pp512 | tg128 |
| --- | --- | --- |
| upstream engine, none of this branch's work | 100.5 | 22.4 |
| **this branch** | **167.5** | **26.67** |
| same card, Linux/RADV, official llama.cpp | 206.6 | 29.20 |
Build it from `vendor/llama.cpp` (`make -C build-static llama-server`); read
`patches/llama/metal/0052-*.patch` for what the engine carries, and the note in the commit that
introduced it for the one series defect still open.
## Polaris performance work (RX 580 / `gfx803`) 🧪
> ⚠️ One card, one model, one branch. Measured on an **AMD Radeon RX 580 (GCN 4 / `gfx803`, 36 CUs,
> 8 GB)** with `Ornith-1.5-9B-heretic-Q4_K_M` (5.23 GiB, q4\_K weights + q6\_K output/FFN-down),
> Flash Attention on and a q4\_0 KV cache. Not reproduced on any other card or driver.
`llama-bench -ngl 99 -fa 1 -ctk q4_0 -ctv q4_0 -b 2048 -ub 1024 -pg 512,128 -r 4 -t 10`, on a quiet
and warmed card, base and tuned alternated in one session:
| build | pp512 | tg128 |
| --- | --- | --- |
| upstream engine, no Polaris work | 100.5 | 22.4 |
| this branch | **167.5** | **26.7** |
| same card under Linux/RADV, official llama.cpp | 206.6 | 29.2 |
So **+66.7% prefill and +19.0% decode** over what this branch started from, with 19% of prefill and
8.7% of decode still to give before the Metal path matches Linux on identical silicon.
**The kernel changes that got there.**
- **Float accumulators in the tiled prefill matmul.** GCN4 round-trips a half-precision product
through the register file on every accumulate step; accumulating in fp32 is worth **+22%** on its
own — the largest single change in the whole effort.
- **One wavefront per tile, eight output columns per lane, two loads prefetched** in that same
tile: 2.03 → 2.97 TFLOP/s standalone at `12288×4096`. Reordering the panel loads and splitting the
tile-order dependency added a further few percent in situ.
- **16-byte vectorised activation reads in the wave64 decode mat-vec**, four `float4` instead of
sixteen scalars — the shape RADV's shader emits — for **+6.6% decode** at the same traffic.
- **Decode geometry chosen per shape and type**: rows per group and lanes per block are not one
constant. q4\_K wants sixteen lanes and four rows at the FFN widths, q6\_K wants four rows and eight
rows at different row counts, and the wave64 kernels are separate entry points from the wave32
ones rather than the same code with a different warp size.
- **Fusions on the decode path**: swiglu, RMS-norm and norm-add folded into the q4\_K mat-vec itself
(worth +3.7%, +1.7% and +1.4% respectively when switched back off to measure), and a dispatch-fusion
pass over the tail of tiny elementwise kernels that a decode token issues several hundred of.
- **A wave64 flash-attention path** covering quantized KV, plus shared-dequant multi-column mat-vec
kernels so a batched step reads and unpacks each weight block once instead of once per column.
- **Alignment and architecture probed, never assumed.** Cards older than Vega return the aligned
bytes for a dword read on a word boundary, so the fast unaligned path is granted only to hardware
measured to tolerate it, by `amdgpu_gfx<N>` ISA target where the OS reports one and by device name
where it does not. Unknown hardware stays correct rather than fast.
---
# Upstream: ToshLLM
The remainder of this file is the upstream README, kept
intact and unedited for attribution and for how the engine is built and
packaged.
# ToshLLM
**Run large language models locally on Intel Macs with AMD GPUs.**
Native macOS app · Metal acceleration · No cloud, no accounts, no per-token costs
[Build & Release](https://github.com/engeldlgado/toshllm/actions/workflows/build.yml)
[License: GPL-3.0](https://github.com/graydini/toshllm/blob/polaris_perf/LICENSE)
[Platform](https://github.com/graydini/toshllm#requirements)
[Status: Beta](https://github.com/engeldlgado/toshllm/issues)
[Sponsor](https://github.com/graydini/toshllm#support-the-project)
[DOI](https://doi.org/10.5281/zenodo.21908524)
### [⬇️ Download the latest release](https://github.com/engeldlgado/toshllm/releases/latest) · [📝 Changelog](https://github.com/graydini/toshllm/blob/polaris_perf/CHANGELOG.md)
*[Versión en español más abajo](https://github.com/graydini/toshllm#toshllm-en-espa%C3%B1ol)*
[ToshLLM home screen — hardware detection and model recommendations](https://github.com/graydini/toshllm/blob/polaris_perf/Assets/home.jpg)
---
## What is ToshLLM?
ToshLLM lets you run modern open LLMs **entirely on your own Mac** — your chats never leave the machine, there are no accounts, and there's nothing to pay per token.
Most local-LLM tools on macOS only target Apple Silicon. Intel Macs with discrete AMD GPUs — including Hackintosh builds — get left behind: the stock engines produce **corrupted output** on AMD dGPUs and read model weights over PCIe at a fraction of the possible speed.
**ToshLLM fixes that.** It bundles `llama.cpp` built with AMD-specific patches and wraps it in a polished native SwiftUI app — so a card like the RX 6700 XT goes from unusable to genuinely fast:
| | Stock llama.cpp on AMD dGPU | ToshLLM |
| --- | --- | --- |
| Output | corrupted | correct |
| Qwen3-8B generation | 0.6–2.6 t/s | **~61 t/s** |
| Qwen3.6-35B (MoE) generation | unusable | **~29 t/s**, flat on long runs |
It opens, detects your hardware, and recommends models that will actually run well — no guesswork.
## Features
- **Native chat** — multiple persistent conversations, full Markdown with code-copy, regenerate, system prompt, live tokens/sec, file attachments, conversation forking and per-message metrics
- **Agent tools and MCP** — the model can read, edit and run files and commands with per-step permission, run JavaScript in a sandbox, and use tools from external Model Context Protocol servers you connect
- **Symbolic math (SymPy)** — optional exact math tools for the model: simplify, solve equations and systems, derivatives, integrals, limits, series, differential equations, matrices, Laplace and Fourier transforms, and checking that two expressions are equivalent or that a solution holds. The runtime ships inside the app, nothing else to install; off by default, in chat settings under Agents ([details](https://github.com/graydini/toshllm/blob/polaris_perf/helpers/tosh-sympy/README.md))
- **Scientific computing (NumPy and SciPy)** — optional numerical tools for the model: definite integrals without a closed form, roots, optimization and curve fitting, differential equations over an interval, linear algebra on decimal matrices, FFT and filters, and statistics. The model sends an operation and its numbers, never code. Same bundled runtime, its own switch, off by default ([details](https://github.com/graydini/toshllm/blob/polaris_perf/helpers/tosh-scientific/README.md))
- **Math answers you can check** — with either math tool set on, the engine runs the turn itself: a calculation has to go through a tool or a question back, every call is checked against your message, and the answer only states numbers from your message or from a validated result. The app's chat, the web chat and any OpenAI client that sends `X-Tosh-Agent: on` get the same agent, also from another computer; requests that bring their own tools get the model as it is ([how to call it](https://github.com/graydini/toshllm/blob/polaris_perf/helpers/tosh-sympy/README.md#four-ways-to-reach-the-tools))
- **GPU speech and subtitle studio** — Whisper.cpp transcribes microphone dictation into one clean paragraph, while the Audio workspace can disable Silero VAD, use Whisper.cpp's native defaults or tune it with calibrated profiles, previews audio or video with a synchronized editable transcript, preserves recoverable original and translated tracks, keeps Chat translation consistent with context and a glossary, and exports SRT, VTT, TXT, JSON or a captioned MOV; nothing leaves the Mac
- **Vision** — attach images (or paste a screenshot with Cmd+V) and vision-capable models describe them; the matching projector (`mmproj`) is paired automatically
- **Image generation (beta)** — a local text-to-image studio (stable-diffusion.cpp on the same AMD Metal stack): text-to-image and image-to-image, with a model catalog sized to your VRAM, a live preview of the image forming, and an **upscaler** that takes your own photos too (x2/x4, batches, and a drag-to-compare view)
- **Model manager** — a curated catalog with **per-model VRAM/RAM estimates for *your* hardware**, plus Hugging Face browsing sorted by trending, downloads, likes or last update, downloads with live progress, and a flag when a repo re-publishes a model you already have
- **MoE-aware** — automatic `--n-cpu-moe` calculation so 35B-class Mixture-of-Experts models run well on 12 GB GPUs
- **Speculative decoding, automatic and lossless** — MTP engages by itself on models that ship the head, and DFlash uses a small per-model draft when one is downloaded; both size themselves to your VRAM, back off on content where drafting doesn't pay, and never change the output
- **Bundled engine** — official llama.cpp with the **AMD Flash Attention kernel** on by default, so attention runs on the GPU instead of falling back to the CPU (see the [research note](https://github.com/graydini/toshllm#research-amd-gpus-on-metal))
- **Benchmarks** — measure prompt/generation speed per configuration, with history and side-by-side comparison charts
- **OpenAI-compatible API** — use it at `http://127.0.0.1:8080`, with optional local-network access and Bonjour discovery; can also serve embeddings for local RAG clients
- **Router mode** — one server that auto-loads whichever model each OpenAI-compatible request names, no restart between models; external clients and the built-in chat switch on the fly
- **Multiple servers** — run several independent engine instances at once from the Dashboard, each with its own model, GPU, port and profile; serve different models side by side or pin one model per GPU
- **Multi-GPU and eGPU** — split a model across all your GPUs or an exact set of cards (validated on dual-GPU setups); external GPUs run at full speed with VRAM-resident weights
- **Every parameter explained** — bilingual tooltips and built-in docs (English/Spanish)
- **Profiles, menu bar mode, auto-start** — save full configurations and switch with one click
### In testing 🧪
These are new and still being validated — enable them in Settings, but expect rough edges:
- **Dynamic MoE (off by default)** — for Mixture-of-Experts models that do not fit in VRAM: the most used experts stay in VRAM, the rest in RAM, sized for your context and for the memory the Mac has free right now, and the model is not loaded when nothing fits safely. On an RX 6700 XT it reads prompts nearly twice as fast as the standard offload on Qwen3.6-35B-A3B and generates about 50% faster. Off, MoE models use the standard offload as before. [How it works](https://github.com/graydini/toshllm#dynamic-moe-experimental-off-by-default).
- **Video generation (experimental, first cut)** — a Video mode next to Chat and Images, on the same stable-diffusion.cpp engine, with Wan 2.1/2.2, LTX-2 and HunyuanVideo. Read this before downloading 7 GB: a few seconds of video take minutes, 49 frames at 480p already fill a 12 GB card, and **only Wan 2.1 1.3B fits one at all** — the others ask for 24 GB or more. Asking for more frames or more pixels than fit fails instead of degrading. The clip comes