web: Ollama and fx (local model) offer the registry's quantized tags (Qwen3 0.6B and 1.7B the defaults, no fp16 entries) and the llama.cpp, Ollama and fx apps drop the hints that quantized models abort

This commit is contained in:
Pooya Parsa
2026-11-24 21:21:48 +00:00
parent 7d74d40f94
commit 48f4732df5
4 changed files with 206 additions and 164 deletions

View File

@@ -927,8 +927,8 @@ external buffer), else as wl_shm windows (frames read back).
token limit, the context shifted when full, end-of-text ignored; the
model has no chat template), `TURNS=1` a story the user continues a
turn at a time, and a model with a template chats.
`MODEL=stories15M|PATH|URL` picks another GGUF; quantized ones abort for
now (vk.md, Unsupported), and wider F32 ones on software WebGPU. Only
`MODEL=stories15M|PATH|URL` picks another GGUF; quantized ones run too
(2026-11-24; mixture-of-experts models abort: vk.md, Unsupported). Only
llama's errors and timings reach the terminal (the rest is in
`llama.log`), and a refused shader or a lost device gets a one-line
hint. Nothing to deploy for it: both downloads come from their
@@ -974,29 +974,47 @@ external buffer), else as wl_shm windows (frames read back).
weights read and uploaded, the first pipelines made), and `ollama run
--verbose` ends each reply with Ollama's timings (eval rate: tokens per
second), the numbers to compare GPUs and builds by. On a terminal ollama.sh asks which model (a numbered list; Enter takes
the first, SmolLM2 135M, which is also the default without a terminal;
the first, Qwen3 0.6B, which is also the default without a terminal;
`MODEL=` skips the question); a model with a chat template gets `ollama
run`'s chat. `THINK=0` runs a thinking model without its reasoning,
`TEMP=N` serves a derived model with that temperature, a model that does
not fit the data disk is refused before its download, and the server is
started again when Ollama's GPU discovery (30 s) times out on a cold
start. Short names: `smollm2` (served as `smollm2-tools`: a ChatML
template with a tool section), `qwen`, `qwen-coder`, `qwen1.5` (Qwen2.5
1.5B, 2950 MiB), `llama3.2` (1B, 2364 MiB), `qwen3.5` (0.8B, BF16),
start. The list's models are the registry's quantized tags (2026-11-24;
the fp16 ones before quantized types ran on kwvk), by short name:
`qwen3` (`qwen3:0.6b`, Q4_K_M, 498 MiB), `qwen3-1.7b` (`qwen3:1.7b`, 1296
MiB), `qwen` (`qwen2.5:0.5b`, 379 MiB), `qwen1.5` (`qwen2.5:1.5b`, 940
MiB), `qwen-coder` (`qwen2.5-coder:0.5b`, 379 MiB), `qwen3.5`
(`qwen3.5:0.8b-q8_0`, 971 MiB with its vision projector; not
`qwen3.5:0.8b`, whose MTP draft makes Ollama start llama-server with
speculative decoding, whose gated_delta_net replay pipelines kwvk
refuses), `llama3.2` (`llama3.2:1b`, Q8_0, 1259 MiB), `smollm2`
(`smollm2:135m-instruct-q4_K_M`, 100 MiB, served as
`smollm2-tools:q4_K_M`: a ChatML template with a tool section),
`stories260K`. Models:
- `MODEL=stories260K`, the story model, runs on software WebGPU too: the
script writes a story from "Once upon a time" and reads the user's
- `MODEL=stories260K`, the story model, the fastest on software WebGPU:
the script writes a story from "Once upon a time" and reads the user's
story starts, sending each as `ollama run --verbose stories260k
"TEXT"` (Ollama's generate path), not through `ollama run`'s own
prompt, which chats through llama-server's chat endpoint with a
template this model does not know.
- `MODEL=smollm2` (SmolLM2 135M Instruct, F16, 271 MiB) and the default
are small coding models for a real GPU. On SwiftShader both abort at
rms_norm_mul_f32_512 (512-wide workgroups) with the hint; on the
user's GPU SmolLM2 loaded and answered (2026-11-24). Of the two, only
Qwen2.5-Coder's template has tools (`ollama show`).
- `MODEL=[user/]name[:tag]` takes any model of Ollama's registry.
- `MODEL=PATH.gguf` takes another GGUF. Quantized models abort for now.
- The chat models run on SwiftShader too, at a token every few seconds
or slower. Checked 2026-11-24 with llama.cpp b12651's own Vulkan build
(x86-64, natively through `test/vk/relay.mjs` on SwiftShader,
`llama-completion -ngl 99 --temp 0`; Ollama's GGUFs): `qwen3:0.6b` and
`qwen3.5:0.8b`'s Q8_0 weights with every layer on kwvk, no pipeline
refused, 2 graph splits (only the token embeddings' lookup on the
CPU); Qwen3 0.6B gave the CPU backend's text for 4 tokens, then a
sane text of its own, at 0.08 tokens/s, Qwen3.5 0.8B the CPU backend's
for all 11 tokens it made, at about 0.04 (two runs at once). On the host's CPU Ollama reports tools and
thinking for Qwen3 and Qwen3.5 (and vision for Qwen3.5), tools for
Qwen2.5, neither for SmolLM2's own template (Llama 3.2's template has
a tool section). Not yet run
through Ollama in the guest; on the user's GPU SmolLM2 F16 loaded and
answered (2026-11-24).
- `MODEL=[user/]name[:tag]` takes any model of Ollama's registry (an
fp16 tag too).
- `MODEL=PATH.gguf` takes another GGUF.
`ollama pull` cannot work in the guest. It refuses redirects to hosts
that resolve to non-public addresses, and the page's network answers DNS
@@ -1049,12 +1067,14 @@ external buffer), else as wl_shm windows (frames read back).
0 (`TEMP=`) and a thinking model with `reasoning_effort: "none"` in the
connection's per-model request fields (`THINK=1` for thinking; untested
in fx). The
first and default model is `MODEL=qwen` (Qwen2.5 0.5B Instruct,
`qwen2.5:0.5b-instruct-fp16`: the smallest one ollama.sh offers that
calls fx's tools; CTX 16384; guest memory 3 GiB or more). Qwen2.5-Coder
0.5B (`MODEL=qwen-coder`, the same size) answered fx with JSON in a code
block instead of tool calls (3 tasks of 3; Qwen2.5 0.5B called tools in
2; host CPU, 2026-11-24). fx sends
first and default model is `MODEL=qwen3-1.7b` (Qwen3 1.7B, `qwen3:1.7b`,
Q4_K_M, 1296 MiB; CTX 16384, whose KV cache is 1.75 GiB of kwvk's 4 GiB;
guest memory 3 GiB or more), then `qwen3` (Qwen3 0.6B, 498 MiB): on the
host's CPU (2026-11-24, fx 0.0.17, temperature 0, no thinking) Qwen3 0.6B
wrote a requested file with a real `write_file` call (one task tried).
As fp16 tags then, Qwen2.5-Coder 0.5B (`MODEL=qwen-coder`) answered fx
with JSON in a code block instead of tool calls (3 tasks of 3; Qwen2.5
0.5B, `MODEL=qwen`, called tools in 2; host CPU, 2026-11-24). fx sends
its tools with every request whatever `supports_tool_use` says, and
Ollama answers HTTP 400 for a model without them (SmolLM2, the story
model), so fx-local.sh stops before fx with such a model. The
@@ -1062,7 +1082,9 @@ external buffer), else as wl_shm windows (frames read back).
`/api/show` reports, and tool use follows its capabilities
(`OLLAMA_MODEL_TOOLS` for the story model; `TOOLS=0|1` overrides). On
a real GPU (the user's, 2026-11-24) SmolLM2 loaded and fx reached it
(and got that 400); Qwen2.5 with fx on a GPU is untried. The field names
(and got that 400), and Qwen2.5 0.5B (fp16) answered fx but described or
invented tool results more often than it called a tool; Qwen3 with fx on
a GPU is untried. The field names
follow fx's docs for 0.0.17.
- The page needs a base bundle with the ICD (vk.md). `test/vk/page-check.mjs`:
the dev server on a free port with `KW_KERNEL=$KW_BUILD/vk/base/unkernel.wasm`

View File

@@ -24,30 +24,35 @@
// preferences there stay), and selects it per run with FX_PROVIDER=local and
// FX_MODEL, with FX_AUTO_UPGRADE=0. The server's OLLAMA_CONTEXT_LENGTH and
// the connection's context_window agree: CTX, by default the model's
// trained context (8192 for SmolLM2) but 16384 for Qwen2.5 (of 32768:
// device memory), and context_window never above what Ollama's /api/show
// trained context (8192 for SmolLM2) but 16384 for Qwen2.5 and Qwen3 (of
// 32768 and 40960: device memory; Qwen3's KV cache is 112 KiB a token, 1.75
// GiB at 16384), and context_window never above what Ollama's /api/show
// reports for the model; supports_tool_use is what /api/show's capabilities
// say ("tools": from the model's template), or OLLAMA_MODEL_TOOLS for the
// Ollama app's own default, or TOOLS=0|1.
//
// On a terminal fx-local.sh asks which model; the first and default is Qwen2.5 0.5B Instruct (F16, 994 MiB, Ollama's library
// tag qwen2.5:0.5b-instruct-fp16; ollama.sh's MODEL=qwen), the smallest
// model ollama.sh offers that calls fx's tools. Qwen2.5-Coder 0.5B
// (MODEL=qwen-coder: the same architecture, size and memory) answered fx
// with JSON in a code block instead of a tool call in three tasks of three;
// Qwen2.5 0.5B made real tool calls in two (fx 0.0.17, Ollama 0.40.18 and
// llama.cpp b12651 on the host's CPU, 2026-11-24). fx needs tools: it sends
// its tools with every request whatever supports_tool_use says, and Ollama answers a
// model without them with HTTP 400 ("does not support tools": SmolLM2 135M,
// the user's first run on a real GPU, 2026-11-24, where it did load; and the
// Ollama app's story model, which has no chat template). So fx-local.sh
// stops before fx with such a model (SmolLM2 is served as smollm2-tools,
// under a template of ollama.sh's with a tool section). Qwen2.5 aborts on
// software WebGPU (SwiftShader) at a 512-wide shader; on real GPUs (the
// user's, 2026-11-24) Qwen2.5 0.5B loads and answers fx, but describes or
// invents tool results more often than it calls a tool: Qwen2.5 1.5B
// (MODEL=qwen1.5) is the larger choice. The model runs at temperature 0
// (TEMP=), and a thinking model without its reasoning (THINK=1 for it).
// On a terminal fx-local.sh asks which model; the first and default is
// Qwen3 1.7B (Q4_K_M, 1296 MiB, Ollama's library tag qwen3:1.7b; ollama.sh's
// MODEL=qwen3-1.7b; guest memory 3 GiB or more), a thinking model with tools
// that runs here without thinking. The models are the registry's quantized
// tags, which run on guest Vulkan since 2026-11-24 (ollama.ts). Qwen3 0.6B
// (MODEL=qwen3, 498 MiB) is the quicker choice: fx 0.0.17 on it (Ollama
// 0.40.18 and llama.cpp b12651 on the host's CPU, temperature 0, no
// thinking, 2026-11-24) wrote a requested file with a real write_file call
// (one task tried). Qwen2.5 0.5B (MODEL=qwen) made real tool calls in two
// tasks of three, Qwen2.5-Coder 0.5B (MODEL=qwen-coder) in none (JSON in a
// code block instead), and on a real GPU (the user's, 2026-11-24) Qwen2.5
// 0.5B answered fx but described or invented tool results more often than
// it called a tool (all three as fp16 tags then). fx needs tools: it sends
// its tools with every request whatever supports_tool_use says, and Ollama
// answers a model without them with HTTP 400 ("does not support tools":
// SmolLM2 135M, the user's first run on a real GPU, 2026-11-24, where it did
// load; and the Ollama app's story model, which has no chat template). So
// fx-local.sh stops before fx with such a model (SmolLM2 is served under a
// template of ollama.sh's with a tool section). On software WebGPU
// (SwiftShader) the models run, at a token every few seconds: too slow for
// fx's prompts. The model runs at temperature 0 (TEMP=), and a thinking
// model without its reasoning (THINK=1 for it).
import type { TerminalApp } from "../types.ts";
import ollama, { OLLAMA_MODEL, OLLAMA_MODEL_CTX, OLLAMA_MODEL_TOOLS } from "./ollama.ts";
@@ -60,12 +65,15 @@ const FX_LOCAL_SH = String.raw`#!/bin/bash
# server (SERVE=1 ollama.sh) on guest Vulkan (kwvk: this browser's WebGPU),
# as fx's custom connection "local". Written by the unkernel launcher's
# "fx (local model)" app.
# ./fx-local.sh asks which model (on a terminal); Enter: Qwen2.5 0.5B Instruct (F16, 994 MiB): tool calls; guest memory 3 GiB or more
# MODEL=smollm2 ./fx-local.sh SmolLM2 135M Instruct (F16, 271 MiB): the fastest; tool calls through a template of ours, seldom right
# MODEL=qwen1.5 ./fx-local.sh Qwen2.5 1.5B Instruct (F16, 2950 MiB): far better at tool calls; guest memory 4 GiB
# MODEL=llama3.2 ./fx-local.sh Llama 3.2 1B Instruct (F16, 2364 MiB)
# MODEL=qwen-coder ./fx-local.sh Qwen2.5-Coder 0.5B Instruct (the same size): better code, but rarely calls fx's tools
# MODEL=PATH.gguf|NAME ./fx-local.sh another F32 or F16 model, as ollama.sh takes it
# ./fx-local.sh asks which model (on a terminal); Enter: Qwen3 1.7B (Q4_K_M, 1296 MiB): tool calls; guest memory 3 GiB or more
# MODEL=qwen3 ./fx-local.sh Qwen3 0.6B (Q4_K_M, 498 MiB): quicker, weaker at tool calls
# MODEL=qwen1.5 ./fx-local.sh Qwen2.5 1.5B Instruct (Q4_K_M, 940 MiB): tool calls, no thinking
# MODEL=qwen ./fx-local.sh Qwen2.5 0.5B Instruct (Q4_K_M, 379 MiB): calls tools, seldom well
# MODEL=qwen3.5 ./fx-local.sh Qwen3.5 0.8B (Q8_0, 971 MiB): newer; untried with fx
# MODEL=llama3.2 ./fx-local.sh Llama 3.2 1B Instruct (Q8_0, 1259 MiB)
# MODEL=smollm2 ./fx-local.sh SmolLM2 135M Instruct (Q4_K_M, 100 MiB): the fastest; tool calls through a template of ours, seldom right
# MODEL=qwen-coder ./fx-local.sh Qwen2.5-Coder 0.5B Instruct (379 MiB): better code, but rarely calls fx's tools
# MODEL=PATH.gguf|NAME ./fx-local.sh another model, as ollama.sh takes it
# CTX=N the context length (server and fx; default: the model's, at most 16384)
# TEMP=N the sampling temperature (default 0; TEMP=model for the model's own)
# THINK=1 let a thinking model (Qwen3, Qwen3.5) reason before answers (default: off)
@@ -94,7 +102,7 @@ command -v jq >/dev/null || die "No jq (the launcher installs it): sudo apt-get
# change it later), which fx's context_window matches.
# No MODEL= on a terminal: ask. Enter takes the first; a number, or any
# other name ollama.sh takes (an Ollama name with an fp16 tag, a .gguf).
# other name ollama.sh takes (an Ollama name, a .gguf).
pick_model() {
local i=0 k l ans
printf "$B%s$N\n" "Which model? (Enter: 1; or type an Ollama name or a .gguf path; MODEL=... skips this)"
@@ -116,21 +124,23 @@ MENU
esac
}
if [ -z "$MODEL" ] && [ -t 0 ]; then
pick_model 'qwen|Qwen2.5 0.5B (994 MiB): the smallest that calls tools, seldom well
qwen1.5|Qwen2.5 1.5B (2950 MiB): far better at tool calls; guest memory 4 GiB
llama3.2|Llama 3.2 1B (2364 MiB)
qwen3.5|Qwen3.5 0.8B (1684 MiB, BF16): newer, untried on guest Vulkan
smollm2|SmolLM2 135M (271 MiB): the fastest; tool calls seldom right
qwen-coder|Qwen2.5-Coder 0.5B (994 MiB): better code, rarely calls tools'
pick_model 'qwen3-1.7b|Qwen3 1.7B (1296 MiB): tool calls; guest memory 3 GiB or more
qwen3|Qwen3 0.6B (498 MiB): quicker, weaker at tool calls
qwen1.5|Qwen2.5 1.5B (940 MiB): tool calls, no thinking
qwen|Qwen2.5 0.5B (379 MiB): calls tools, seldom well
qwen3.5|Qwen3.5 0.8B (971 MiB, Q8_0): newer; untried with fx
llama3.2|Llama 3.2 1B (1259 MiB, Q8_0)
smollm2|SmolLM2 135M (100 MiB): the fastest; tool calls seldom right
qwen-coder|Qwen2.5-Coder 0.5B (379 MiB): better code, rarely calls tools'
fi
[ -n "$MODEL" ] || MODEL=qwen
[ -n "$MODEL" ] || MODEL=qwen3-1.7b
case $MODEL in
*.gguf) [ ! -e "$MODEL" ] || MODEL=$(realpath "$MODEL") ;;
esac
case $MODEL in
stories260K) c=${OLLAMA_MODEL_CTX} ;;
smollm2) c=8192 ;;
qwen | qwen-coder | qwen1.5 | llama3.2 | qwen3.5) c=16384 ;;
qwen3 | qwen3-1.7b | qwen | qwen-coder | qwen1.5 | llama3.2 | qwen3.5) c=16384 ;;
*) c=8192 ;;
esac
[ -n "$CTX" ] || CTX=$c
@@ -168,10 +178,7 @@ until [ -s "$OLLAMA_DIR/ollama.ready" ]; do
# ollama.sh's status: 3 a download failed, 4 a shader refused, 5 device lost.
case $st in
3) say "A download failed (above: which); run ./fx-local.sh again to resume it." ;;
4) case $MODEL in
stories260K) ;;
*) say "On software WebGPU (SwiftShader) $MODEL aborts at a 512-wide shader: fx on a local model needs a real GPU." ;;
esac ;;
4) say "Guest Vulkan cannot run one of $MODEL's shaders: try the default, Qwen3 1.7B (./fx-local.sh), or MODEL=qwen3." ;;
esac
die "ollama.sh stopped before the model was ready (exit $st; above: why)."
fi
@@ -229,7 +236,7 @@ mv "$S.new" "$S"
printf "$B%s$N\n" "fx on $NAME: context $WIN tokens, replies up to $OUT, tool use $T (the connection local in $S)"
# fx sends its tools with every request, and Ollama refuses them (HTTP 400)
# for a model whose template takes none.
[ "$T" = true ] || die "$NAME cannot call tools (Ollama's capabilities for it), and fx needs them: Ollama would answer its requests with HTTP 400. Run ./fx-local.sh for the default, Qwen2.5 0.5B, or MODEL= another model with tools; to talk with $NAME without fx: cd $OLLAMA_DIR && MODEL=$MODEL ./ollama.sh"
[ "$T" = true ] || die "$NAME cannot call tools (Ollama's capabilities for it), and fx needs them: Ollama would answer its requests with HTTP 400. Run ./fx-local.sh for the default, Qwen3 1.7B, or MODEL= another model with tools; to talk with $NAME without fx: cd $OLLAMA_DIR && MODEL=$MODEL ./ollama.sh"
say "fx works in $PWD/work. Slow: each turn sends fx's whole prompt and tool list through this tab's GPU, so a first reply can take minutes. Quitting fx stops the server."
cd work
trap : INT
@@ -246,19 +253,20 @@ const README = "fx, the coding agent, talking to a model that runs in this brows
"~/.apps/fx-local/fx-home (FX_HOME): your own ~/.fx is not touched.\n" +
"\n" +
"fx-local.sh asks which model (MODEL=NAME skips the question). The first is\n" +
"Qwen2.5 0.5B Instruct (F16, 994 MiB, fetched once): small, and it can call\n" +
"tools, which fx needs, though it often answers without calling one; Qwen2.5\n" +
"1.5B (MODEL=qwen1.5, 2950 MiB, guest memory 4 GiB) does better. The model\n" +
"runs at temperature 0 (TEMP=N) and without thinking (THINK=1). It needs guest memory\n" +
"of 3 GiB or more (Settings) and a GPU whose WebGPU allows 512-wide\n" +
"workgroups (most real GPUs; not software WebGPU, SwiftShader, where it\n" +
"aborts). Others:\n" +
" MODEL=qwen-coder ./fx-local.sh (Qwen2.5-Coder 0.5B, the same size: better\n" +
" code, but rarely calls fx's tools)\n" +
"Qwen3 1.7B (Q4_K_M, 1296 MiB, fetched once): small, and it can call tools,\n" +
"which fx needs, though models this small often answer without calling one.\n" +
"The model runs at temperature 0 (TEMP=N) and without thinking (THINK=1). It\n" +
"needs guest memory of 3 GiB or more (Settings) and a real GPU to be usable\n" +
"(software WebGPU, SwiftShader, runs it at a token every few seconds).\n" +
"Others:\n" +
" MODEL=qwen3 ./fx-local.sh (Qwen3 0.6B, 498 MiB: quicker, weaker at\n" +
" tool calls)\n" +
" MODEL=qwen-coder ./fx-local.sh (Qwen2.5-Coder 0.5B: better code, but\n" +
" rarely calls fx's tools)\n" +
" MODEL=NAME ./fx-local.sh (another model of Ollama's library with\n" +
" tools, an fp16 tag; fx cannot use a model\n" +
" without tools, such as smollm2)\n" +
" MODEL=PATH.gguf ./fx-local.sh (another F32 or F16 GGUF with tools)\n" +
" tools; fx cannot use a model without\n" +
" tools, such as stories260K)\n" +
" MODEL=PATH.gguf ./fx-local.sh (another GGUF with tools)\n" +
" CTX=4096 ./fx-local.sh (a smaller context: less device memory)\n" +
"\n" +
"Slow and limited: every turn sends fx's whole prompt and tool list (thousands\n" +
@@ -268,8 +276,8 @@ const README = "fx, the coding agent, talking to a model that runs in this brows
"search and remote MCP servers still use the network (update checks are off\n" +
"for this run).\n" +
"\n" +
"If it fails: quantized models (q4_0, q4_K_M ...) abort on guest Vulkan for\n" +
"now (F32 and F16 run); the driver reports 4 GiB of GPU memory (KWVK_HEAP_MB=N sets it), so a\n" +
"If it fails: guest Vulkan cannot run some models (mixture-of-experts ones\n" +
"abort at a refused shader); the driver reports 4 GiB of GPU memory (KWVK_HEAP_MB=N sets it), so a\n" +
"model and its context that do not fit load partly or not at all on the GPU:\n" +
"more guest memory (Settings), or a smaller CTX; a lost WebGPU device: run\n" +
"./fx-local.sh again.\n";
@@ -277,7 +285,7 @@ const README = "fx, the coding agent, talking to a model that runs in this brows
export default {
id: "fx-local",
title: "fx (local model)",
desc: "fx on a model in this browser's GPU: Ollama on guest Vulkan as fx's local connection; asks which model (Qwen2.5 0.5B, 994 MiB, guest memory 3 GiB or more; or larger ones), fetched with Ollama and llama.cpp on first run",
desc: "fx on a model in this browser's GPU: Ollama on guest Vulkan as fx's local connection; asks which model (Qwen3 1.7B, 1296 MiB, guest memory 3 GiB or more; or smaller ones), fetched with Ollama and llama.cpp on first run",
icon: "𝒇x",
// fx's tile in the Ollama app's teal.
colors: ["#0f766e", "#09090b"],

View File

@@ -25,13 +25,13 @@
// Face, which sends CORS headers): F32, 1.1 MiB, fetched by the page into
// the installer (`downloads`, cached in the browser) and kept in the app's
// directory on the data disk. It writes short children's stories, often
// ungrammatical: a demo of the GPU path, not of a useful model. F32
// because quantized models (q4_0, q8_0 ...) abort: ggml's shaders for them
// do not translate to WGSL yet (vk.md, Unsupported). Larger F32 models
// also want the norm shaders' 512-invocation workgroups, which software
// WebGPU (SwiftShader: 256) refuses, so MODEL=stories15M (F32, 94 MiB) and
// other GGUFs (MODEL=PATH or MODEL=https://...) are for a real GPU, and
// untried on one. stories260K has no chat template, so llama-completion
// ungrammatical: a demo of the GPU path, not of a useful model. Quantized
// models run too (2026-11-24: Q4_K_M on a real GPU; mixture-of-experts
// models abort, vk.md, Unsupported), and the norm shaders' 512-invocation
// workgroups run on software WebGPU (SwiftShader: 256) as virtual
// invocations, so MODEL=stories15M (F32, 94 MiB) and other GGUFs
// (MODEL=PATH or MODEL=https://...) run there too, slowly. stories260K has
// no chat template, so llama-completion
// writes stories without end (no token limit, the context shifted when
// full, end-of-text ignored), or with TURNS=1 continues the text the user
// types (interactive mode); a model with a template gets its chat
@@ -59,10 +59,9 @@ const LLAMA_SH = String.raw`#!/bin/bash
# WebGPU). Written by the unkernel launcher's llama.cpp app.
# ./llama.sh stories260K (F32, 1.1 MiB): stories without end
# TURNS=1 ./llama.sh the same model continues what you type, a turn at a time
# MODEL=stories15M ./llama.sh F32, 94 MiB: better stories, needs a real GPU
# MODEL=stories15M ./llama.sh F32, 94 MiB: better stories, slow on software WebGPU
# MODEL=PATH.gguf ./llama.sh any GGUF here, or MODEL=https://.../x.gguf
# ./llama.sh ARGS... more llama-completion arguments (-n 256, --temp 0)
# Quantized models (q4_0, q8_0 ...) abort on guest Vulkan for now: use F32.
set -e
VER=${VER}
URL=${TARBALL}
@@ -129,7 +128,6 @@ if [ ! -s "$F" ]; then
[ -z "$MSHA" ] || echo "$MSHA $F.part" | sha256sum -c --quiet || { rm -f "$F.part"; die "$F: wrong SHA-256, deleted"; }
mv "$F.part" "$F"
fi
case $(basename "$F") in *[Qq][2-8]_* | *[Ii][Qq][1-4]*) say "A quantized model: these abort on guest Vulkan for now (their shaders do not translate yet); F32 ones run." ;; esac
# A model with a chat template chats; one without continues your text.
if head -c 16777216 "$F" | grep -qa tokenizer.chat_template; then
@@ -187,8 +185,8 @@ export default {
"(guest Vulkan in Options): every layer on the GPU (-ngl 99). stories260K is a\n" +
"tiny F32 story model (1.1 MiB): expect odd children's stories, without end\n" +
"until Ctrl-C. Quantized\n" +
"models (q4_0 ...) abort on guest Vulkan for now; F32 ones run. More to try:\n" +
" MODEL=stories15M ./llama.sh (F32, 94 MiB; needs a GPU, not software WebGPU)\n" +
"models (q4_0, Q4_K_M ...) run too. More to try:\n" +
" MODEL=stories15M ./llama.sh (F32, 94 MiB; slow on software WebGPU)\n" +
" MODEL=https://.../model-f32.gguf ./llama.sh\n" +
" TURNS=1 ./llama.sh (you type, it continues: 128 tokens a turn)\n" +
" ./llama.sh --temp 0 -n 64 (more llama-completion arguments)\n" +

View File

@@ -35,34 +35,41 @@
// llama-server --list-devices through the Vulkan loader and finds "kwvk
// (WebGPU)" with no other requirement (no memory budget extension, no sysfs).
//
// On a terminal ollama.sh asks which model (its list: SmolLM2 135M first,
// Qwen2.5 0.5B and 1.5B, Qwen2.5-Coder 0.5B, Llama 3.2 1B, Qwen3.5 0.8B,
// stories260K); MODEL= names one, and SmolLM2 is the default without a
// terminal. All but the story model load on a real GPU only. MODEL=stories260K, as in llama.ts (F32, 1.1 MiB,
// fetched by the page into the installer), runs on software WebGPU too:
// made an Ollama model by `ollama create` from a
// Modelfile (FROM the GGUF, num_predict 128), which keeps its F32 weights;
// Ollama's library models are quantized and abort on guest Vulkan for now
// (vk.md, Unsupported), except their fp16 tags. F16 GGUFs run too
// (stories260K converted to F16 by llama-quantize: the same text, 100% GPU).
// Wider models need ggml's 512-wide norm shaders (rms_norm_mul_f32_512 is
// the first refused), which SwiftShader's WebGPU (256 invocations) refuses
// and the renderer, asking for the adapter's best limits, gets on most real
// GPUs (1024); so the chat models need a real
// GPU: MODEL=smollm2 (SmolLM2 135M Instruct, Ollama's
// smollm2:135m-instruct-fp16, 271 MiB, Apache-2.0; served as smollm2-tools,
// the same weights under a ChatML template with a tool section) and
// MODEL=qwen-coder (Qwen2.5-Coder 0.5B Instruct,
// qwen2.5-coder:0.5b-instruct-fp16, 994 MiB, Apache-2.0; 3 GiB of guest memory or more), fetched
// from Ollama's registry by ollama.sh with curl into Ollama's store (manifest
// and blobs, checked): ollama pull cannot, as it refuses redirects to hosts
// that resolve to non-public addresses, and the page's network answers DNS
// with synthetic ones (198.18.0.0/15). ollama.sh's exit status says why it
// stopped: 3 a download failed, 4 guest Vulkan refused a shader, 5 the WebGPU
// device was lost, 1 anything else. Both answered "a Python function that reverses
// a string" correctly at temperature 0 on the host's CPU; on kwvk with
// SwiftShader both abort at that shader, with the hint. A model with a chat
// template gets `ollama run`'s chat. stories260K has no chat template,
// On a terminal ollama.sh asks which model (its list: Qwen3 0.6B first,
// Qwen3 1.7B, Qwen2.5 0.5B and 1.5B, Qwen2.5-Coder 0.5B, Qwen3.5 0.8B,
// Llama 3.2 1B, SmolLM2 135M, stories260K); MODEL= names one, and Qwen3 0.6B
// is the default without a terminal. The chat models are the registry's
// quantized tags (Q4_K_M, Q8_0 where the registry has no Q4_K_M), which run
// on guest Vulkan since 2026-11-24 (vk.md: Qwen2.5 0.5B Q4_K_M at about 45
// tokens/s on an Apple M4 Pro with llama.cpp; on software WebGPU,
// SwiftShader, they run too, at a tenth of a token a second or less, where
// ggml's 512-wide workgroups run as virtual invocations). On 2026-11-24
// llama.cpp b12651's own Vulkan build (x86-64, natively through
// test/vk/relay.mjs on SwiftShader) ran Ollama's qwen3:0.6b (Q4_K_M) and
// qwen3.5:0.8b (Q8_0) with every layer on kwvk, no pipeline refused and no
// op on the CPU but the token embeddings' lookup (2 graph splits), and sane
// text (the CPU backend's for its first tokens). MODEL=qwen3 (Qwen3 0.6B, qwen3:0.6b, Q4_K_M, 498 MiB, Apache-2.0)
// is a thinking model with tools (THINK=0: no reasoning). MODEL=qwen3.5 is
// Qwen3.5 0.8B as qwen3.5:0.8b-q8_0 (971 MiB with its vision projector,
// which Ollama hands llama-server as --mmproj), not qwen3.5:0.8b: that tag
// adds an MTP draft, for which Ollama starts llama-server with speculative
// decoding (--spec-type draft-mtp), whose gated_delta_net replay pipelines
// guest Vulkan refuses (vk.md, Unsupported). MODEL=smollm2 is SmolLM2 135M
// Instruct (smollm2:135m-instruct-q4_K_M, 100 MiB, Apache-2.0) served as
// smollm2-tools:q4_K_M, the same weights under a ChatML template with a tool
// section. F32 and F16 models run too (stories260K converted to F16 by
// llama-quantize: the same text, 100% GPU; an fp16 tag of the registry when
// MODEL= names one). MODEL=stories260K, as in llama.ts (F32, 1.1 MiB,
// fetched by the page into the installer), the fastest on software WebGPU,
// is made an Ollama model by `ollama create` from a Modelfile (FROM the
// GGUF, num_predict 128), which keeps its F32 weights. Registry models are
// fetched by ollama.sh with curl into Ollama's store (manifest and blobs,
// checked): ollama pull cannot, as it refuses redirects to hosts that
// resolve to non-public addresses, and the page's network answers DNS with
// synthetic ones (198.18.0.0/15). ollama.sh's exit status says why it
// stopped: 3 a download failed, 4 guest Vulkan refused a shader, 5 the
// WebGPU device was lost, 1 anything else. A model with a chat template
// gets `ollama run`'s chat. stories260K has no chat template,
// so Ollama sends the text as it is and the model continues it: ollama.sh
// writes a story from "Once upon a time", then reads the user's own story
// starts, each sent as `ollama run stories260k "TEXT"` (Ollama's generate
@@ -77,7 +84,7 @@
// "offloaded N/M layers to GPU", N > 0), and stops with a message otherwise,
// since a model on the CPU would be a misleading demo; it stops the server
// when it ends. A loud failure of guest Vulkan (a refused pipeline aborts
// ggml, vk.md, Errors) gets a one-line hint. On 2026-11-24 (the guest in
// ggml, vk.md, Errors) gets a one-line hint. On 2026-11-24 (stories260K, the guest in
// headless Chromium on SwiftShader, one CPU, 1 GiB) the server answered
// after 2 s, the model loaded in 7.5-8.5 s and generated 4.5-6.0 tokens/s
// (the same model on the guest's CPU: 43, much faster than on software
@@ -102,21 +109,25 @@ export const OLLAMA_MODEL_TOOLS = false;
const OLLAMA_SH = String.raw`#!/bin/bash
# Ollama with llama.cpp's Vulkan backend on guest Vulkan (kwvk: this page's
# WebGPU). Written by the unkernel launcher's Ollama app.
# ./ollama.sh asks which model (on a terminal); Enter: SmolLM2 135M Instruct (F16, 271 MiB): a small, fast chat model that writes simple code (fx's default too; as smollm2-tools, with a tool-call template)
# MODEL=qwen-coder ./ollama.sh Qwen2.5-Coder 0.5B Instruct (F16, 994 MiB): a small coding chat model; guest memory 3 GiB or more
# MODEL=qwen ./ollama.sh Qwen2.5 0.5B Instruct (F16, 994 MiB): the general model of that size, better at tool calls
# MODEL=qwen1.5 ./ollama.sh Qwen2.5 1.5B Instruct (F16, 2950 MiB): three times the size, far better at tool calls; guest memory 4 GiB
# MODEL=llama3.2 ./ollama.sh Llama 3.2 1B Instruct (F16, 2364 MiB): tool calls too
# MODEL=stories260K ./ollama.sh stories260K (F32, 1.1 MiB): a story, then you type story starts; runs on software WebGPU too
# (both need a GPU whose WebGPU allows 512-wide workgroups: not SwiftShader)
# MODEL=PATH.gguf ./ollama.sh another GGUF here (ollama create), F32 or F16
# ./ollama.sh asks which model (on a terminal); Enter: Qwen3 0.6B (Q4_K_M, 498 MiB): a small thinking chat model with tools
# MODEL=qwen3-1.7b ./ollama.sh Qwen3 1.7B (Q4_K_M, 1296 MiB): better answers and tool calls (fx's default); guest memory 3 GiB or more
# MODEL=qwen ./ollama.sh Qwen2.5 0.5B Instruct (Q4_K_M, 379 MiB): no thinking, tool calls
# MODEL=qwen1.5 ./ollama.sh Qwen2.5 1.5B Instruct (Q4_K_M, 940 MiB): better at tool calls
# MODEL=qwen-coder ./ollama.sh Qwen2.5-Coder 0.5B Instruct (Q4_K_M, 379 MiB): a small coding chat model
# MODEL=qwen3.5 ./ollama.sh Qwen3.5 0.8B (Q8_0, 971 MiB with its vision projector): newer, a thinking model with tools
# MODEL=llama3.2 ./ollama.sh Llama 3.2 1B Instruct (Q8_0, 1259 MiB): tool calls too
# MODEL=smollm2 ./ollama.sh SmolLM2 135M Instruct (Q4_K_M, 100 MiB): the fastest; simple answers (as smollm2-tools, with a tool-call template)
# MODEL=stories260K ./ollama.sh stories260K (F32, 1.1 MiB): a story, then you type story starts; the fastest on software WebGPU
# MODEL=PATH.gguf ./ollama.sh another GGUF here (ollama create)
# TEMP=0 ./ollama.sh the sampling temperature as the model's default (a derived model NAME-tN)
# THINK=0 ./ollama.sh a thinking model (Qwen3, Qwen3.5) answers without reasoning first (as /set nothink)
# SERVE=1 ./ollama.sh the server only, for other programs: once the model is on kwvk,
# its Ollama name goes to ollama.ready; Ctrl-C stops the server
# MODEL=NAME ./ollama.sh another model of Ollama's registry ([user/]name[:tag], fetched by curl): an fp16 tag, as the default ones are quantized
# The server runs while this script does: ollama.log has its log.
# Quantized models (q4_0, q8_0, q4_K_M ...) abort on guest Vulkan for now: use F32 or F16.
# MODEL=NAME ./ollama.sh another model of Ollama's registry ([user/]name[:tag], fetched by curl)
# The server runs while this script does: ollama.log has its log. Software
# WebGPU (SwiftShader) runs the chat models too, at a token every few seconds.
# Mixture-of-experts models abort on guest Vulkan (a refused pipeline), and
# so does speculative decoding of Qwen3.5 (the qwen3.5 tags with a draft).
set -e
VER=${VER}
URL=https://github.com/ollama/ollama/releases/download/$VER/ollama-linux-arm64.tar.zst
@@ -146,7 +157,7 @@ die() { printf "$R%s$N\n" "$*" >&2; exit 1; }
fail() { local st=$1; shift; printf "$R%s$N\n" "$*" >&2; exit $st; }
# No MODEL= on a terminal: ask. Enter takes the first; a number, or any
# other name ollama.sh takes (an Ollama name with an fp16 tag, a .gguf).
# other name ollama.sh takes (an Ollama name, a .gguf).
pick_model() {
local i=0 k l ans
printf "$B%s$N\n" "Which model? (Enter: 1; or type an Ollama name or a .gguf path; MODEL=... skips this)"
@@ -168,13 +179,15 @@ MENU
esac
}
if [ -z "$MODEL" ] && [ -z "$SERVE" ] && [ -t 0 ]; then
pick_model 'smollm2|SmolLM2 135M (271 MiB): the fastest; simple code
qwen|Qwen2.5 0.5B (994 MiB): general chat
qwen-coder|Qwen2.5-Coder 0.5B (994 MiB): code
llama3.2|Llama 3.2 1B (2364 MiB)
qwen1.5|Qwen2.5 1.5B (2950 MiB): the best here; guest memory 4 GiB
qwen3.5|Qwen3.5 0.8B (1684 MiB, BF16): newer, untried on guest Vulkan
stories260K|stories260K (1.1 MiB): stories only; runs on software WebGPU too'
pick_model 'qwen3|Qwen3 0.6B (498 MiB): thinks before it answers (THINK=0: not), tools
qwen3-1.7b|Qwen3 1.7B (1296 MiB): the best here; guest memory 3 GiB or more
qwen|Qwen2.5 0.5B (379 MiB): general chat, no thinking
qwen1.5|Qwen2.5 1.5B (940 MiB): better at tool calls
qwen-coder|Qwen2.5-Coder 0.5B (379 MiB): code
qwen3.5|Qwen3.5 0.8B (971 MiB, Q8_0): newer, thinks; untried in Ollama on guest Vulkan
llama3.2|Llama 3.2 1B (1259 MiB, Q8_0)
smollm2|SmolLM2 135M (100 MiB): the fastest; simple answers
stories260K|stories260K (1.1 MiB): stories only; the fastest on software WebGPU'
fi
# Guest Vulkan: the base's ICD, and a device named kwvk.
@@ -323,19 +336,24 @@ fetch_model() {
mv "$man.part" "$man"
}
# The model: SmolLM2 135M by default (the fx (local model) app's too), from Ollama's
# registry; stories260K from the page (models/), made an Ollama model once.
# The model: Qwen3 0.6B by default, from Ollama's registry (its quantized
# tags); stories260K from the page (models/), made an Ollama model once.
M=$MODEL
[ -n "$M" ] || M=smollm2
[ -n "$M" ] || M=qwen3
BASE=
case $M in
stories260K) F=models/stories260K.gguf NAME=stories260k ;;
smollm2) F= NAME=smollm2-tools BASE=smollm2:135m-instruct-fp16 ;;
qwen-coder) F= NAME=qwen2.5-coder:0.5b-instruct-fp16 ;;
qwen) F= NAME=qwen2.5:0.5b-instruct-fp16 ;;
qwen1.5) F= NAME=qwen2.5:1.5b-instruct-fp16 ;;
llama3.2) F= NAME=llama3.2:1b-instruct-fp16 ;;
qwen3.5) F= NAME=qwen3.5:0.8b-bf16 ;;
qwen3) F= NAME=qwen3:0.6b ;;
qwen3-1.7b) F= NAME=qwen3:1.7b ;;
qwen) F= NAME=qwen2.5:0.5b ;;
qwen1.5) F= NAME=qwen2.5:1.5b ;;
qwen-coder) F= NAME=qwen2.5-coder:0.5b ;;
# Not qwen3.5:0.8b: its MTP draft makes Ollama run speculative decoding,
# whose gated_delta_net replay pipelines guest Vulkan refuses.
qwen3.5) F= NAME=qwen3.5:0.8b-q8_0 ;;
llama3.2) F= NAME=llama3.2:1b ;;
# (A tag of its own: an older smollm2-tools was made from the fp16 weights.)
smollm2) F= NAME=smollm2-tools:q4_K_M BASE=smollm2:135m-instruct-q4_K_M ;;
*.gguf) F=$M NAME=$(basename "$M" .gguf | tr 'A-Z' 'a-z' | tr -c 'a-z0-9._\n-' -) ;;
*) F= NAME=$M ;;
esac
@@ -348,10 +366,6 @@ if [ -n "$F" ]; then
out=$("$OLLAMA" create "$NAME" -f "models/$NAME.Modelfile" 2>&1) || { printf '%s\n' "$out" | tail -n 3 >&2; die "ollama create failed"; }
fi
else
case $NAME in
*fp16* | *f16* | *fp32* | *f32*) ;;
*) say "$NAME: Ollama's library models are quantized unless the tag says fp16; quantized ones abort on guest Vulkan for now (their shaders do not translate yet)." ;;
esac
if [ -n "$BASE" ]; then
# Ollama's SmolLM2 template declares no tools, so Ollama refuses requests
# that carry them (fx's all do): the same weights under a ChatML template
@@ -432,12 +446,11 @@ if [ -n "$TEMP" ]; then
fi
NAME=$TN
fi
case $NAME in *[Qq][2-8]_* | *[Ii][Qq][1-4]*) say "A quantized model: these abort on guest Vulkan for now (their shaders do not translate yet); F32 and F16 ones run." ;; esac
hint() {
if grep -qaE 'pipeline creation failed|ErrorInvalidShaderNV|ErrorFeatureNotPresent' "$LOG"; then
grep -aE '^kwvk:|pipeline creation failed' "$LOG" | tail -n 2 >&2
fail 4 "Hint: guest Vulkan refused one of this model's shaders: quantized types, or (models wider than stories260K) 512-wide workgroups, which software WebGPU (SwiftShader: 256) refuses and most real GPUs allow. Try the default stories260K."
fail 4 "Hint: guest Vulkan refused one of this model's shaders (WebGPU cannot run some of llama.cpp's: mixture-of-experts models, speculative decoding of Qwen3.5, some bf16 norms on software WebGPU). Try the default, MODEL=qwen3."
elif grep -qa 'device lost' "$LOG"; then
fail 5 "Hint: the WebGPU device was lost; run ./ollama.sh again (it gets a new one)."
fi
@@ -508,7 +521,7 @@ fi
export default {
id: "ollama",
title: "Ollama",
desc: "Ollama on the GPU: its server and ollama run on llama.cpp's Vulkan backend, on this browser's WebGPU (guest Vulkan); asks which model (SmolLM2 135M, 271 MiB, to Qwen2.5 1.5B, 2950 MiB; a real GPU), fetched with Ollama (12 MiB) and llama.cpp (29 MiB) on first run",
desc: "Ollama on the GPU: its server and ollama run on llama.cpp's Vulkan backend, on this browser's WebGPU (guest Vulkan); asks which model (Qwen3 0.6B, 498 MiB, first; SmolLM2 135M, 100 MiB, to Qwen3 1.7B, 1296 MiB), fetched with Ollama (12 MiB) and llama.cpp (29 MiB) on first run",
// A speech bubble with three dots (crafted).
icon: { svg: '<path d="M5.5 4h13Q20 4 20 5.5v9q0 1.5-1.5 1.5H11l-4.6 3.7q-.4.3-.4-.2V16h-.5Q4 16 4 14.5v-9Q4 4 5.5 4Z"/><circle cx="8.5" cy="10" r="1.2" fill="#0f766e"/><circle cx="12" cy="10" r="1.2" fill="#0f766e"/><circle cx="15.5" cy="10" r="1.2" fill="#0f766e"/>' },
colors: ["#0f766e", "#1e1b4b"],
@@ -520,18 +533,19 @@ export default {
README: "Ollama runs this model on the guest's Vulkan, which is this browser's WebGPU\n" +
"(guest Vulkan in Options): its server (ollama serve, while ollama.sh runs; its\n" +
"log: ollama.log) loads every layer on the GPU. ollama.sh asks which model\n" +
"(Enter: SmolLM2 135M Instruct, F16, 271 MiB, fetched once; MODEL=NAME skips\n" +
"the question): ask it, e.g., Write a Python function that reverses a string.\n" +
"The larger ones need more guest memory (Settings: 3 GiB for the 0.5B models,\n" +
"4 GiB above), and all a real GPU (software WebGPU refuses their 512-wide\n" +
"workgroups). THINK=0 turns a thinking model's reasoning off, TEMP=N sets the\n" +
"temperature. Ctrl-D or /bye quits and stops the\n" +
"server. Quantized models (Ollama's library: q4_K_M ...) abort on guest Vulkan\n" +
"for now; F32 and F16 ones run. Others:\n" +
" MODEL=qwen1.5 ./ollama.sh (Qwen2.5 1.5B Instruct, 2950 MiB: the best here)\n" +
"(Enter: Qwen3 0.6B, Q4_K_M, 498 MiB, fetched once; MODEL=NAME skips the\n" +
"question): ask it, e.g., Write a Python function that reverses a string.\n" +
"Qwen3 thinks before it answers: THINK=0 turns that off. The larger models\n" +
"want more guest memory (Settings: 3 GiB or more for the 1-2 GB ones), and\n" +
"all a real GPU to be quick (software WebGPU runs them at a token every few\n" +
"seconds). TEMP=N sets the temperature. Ctrl-D or /bye quits and stops the\n" +
"server. Others:\n" +
" MODEL=qwen3-1.7b ./ollama.sh (Qwen3 1.7B, 1296 MiB: the best here)\n" +
" MODEL=smollm2 ./ollama.sh (SmolLM2 135M, 100 MiB: the fastest)\n" +
" MODEL=stories260K ./ollama.sh (a tiny F32 story model, 1.1 MiB, no chat\n" +
" template: type story starts; runs on\n" +
" software WebGPU too)\n" +
" template: type story starts; the\n" +
" fastest on software WebGPU)\n" +
" MODEL=qwen3:4b ./ollama.sh (any model of Ollama's library)\n" +
" MODEL=PATH.gguf ./ollama.sh (another GGUF, made an Ollama model)\n" +
" ~/.local/share/ollama/" + VER + "/bin/ollama ps (in another tab while it runs: 100% GPU)\n",
},