pi-splash-server 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/data/models.json +14 -0
- package/extensions/splash.ts +35 -3
- package/package.json +1 -1
- package/src/catalog.ts +50 -0
package/README.md
CHANGED
|
@@ -72,11 +72,19 @@ In Pi:
|
|
|
72
72
|
/splash update same for a newer runtime release
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
While you type `/splash start`, Pi suggests the measured Qwen3.8-27B quants
|
|
76
|
+
(type part of a name, like `q5` or `iq3`, to filter) with size,
|
|
77
|
+
which one is recommended for which memory, what is already downloaded, and
|
|
78
|
+
how each trades closeness to bf16 against speed (numbers in
|
|
79
|
+
[quants.md](https://github.com/paperniuk/splash/blob/m1/docs/quants.md)). To
|
|
80
|
+
start a different model, run `/splash stop` first. Models from the list start
|
|
81
|
+
with `--language-only` (no vision weights); the memory flags in the table below
|
|
82
|
+
apply only to the model recommended for your Mac.
|
|
76
83
|
|
|
77
84
|
`start` and `use` switch the session to the Splash model; `/model` switches
|
|
78
|
-
back, the server keeps running.
|
|
79
|
-
|
|
85
|
+
back, the server keeps running. When files are missing, `start` says how much
|
|
86
|
+
it will download and how much disk is free, and asks first; the status bar
|
|
87
|
+
then shows what, how much and how fast. Loading takes about one to two
|
|
80
88
|
minutes; the first start also calibrates the Neural Engine on M1/M2. The
|
|
81
89
|
server outlives Pi, so the next Pi session finds it ready.
|
|
82
90
|
|
package/data/models.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "https://github.com/paperniuk/splash/blob/m1/docs/quants.md",
|
|
3
|
+
"measured": "KL to bf16 on wiki and chat text; decode time on M1 Pro relative to MLX 4-bit (percent, + is slower)",
|
|
4
|
+
"models": [
|
|
5
|
+
{ "family": "Qwen3.8-27B", "quant": "GPTQ 4-bit", "model": "mlx-community/Qwen3.8-27B-GPTQ-4bit", "weightsGB": 15.13, "draft": "incoai/Qwen3.8-27B-DFlash2", "klWiki": 0.0399, "klChat": 0.1002, "decodePct": -0.2 },
|
|
6
|
+
{ "family": "Qwen3.8-27B", "quant": "MLX 4-bit", "model": "mlx-community/Qwen3.8-27B-4bit", "weightsGB": 15.13, "draft": "incoai/Qwen3.8-27B-DFlash2", "klWiki": 0.0562, "klChat": 0.1906, "decodePct": 0 },
|
|
7
|
+
{ "family": "Qwen3.8-27B", "quant": "Q4_0", "model": "unsloth/Qwen3.8-27B-GGUF:Q4_0", "weightsGB": 16.06, "draft": "incoai/Qwen3.8-27B-DFlash2", "klWiki": 0.0325, "klChat": 0.1412, "decodePct": 5.9 },
|
|
8
|
+
{ "family": "Qwen3.8-27B", "quant": "UD-Q4_K_M", "model": "unsloth/Qwen3.8-27B-GGUF:UD-Q4_K_M", "weightsGB": 16.46, "draft": "incoai/Qwen3.8-27B-DFlash2", "klWiki": 0.0144, "klChat": 0.0831, "decodePct": 11.1 },
|
|
9
|
+
{ "family": "Qwen3.8-27B", "quant": "UD-Q5_K_S", "model": "unsloth/Qwen3.8-27B-GGUF:UD-Q5_K_S", "weightsGB": 18.67, "draft": "incoai/Qwen3.8-27B-DFlash2", "klWiki": 0.0065, "klChat": 0.0574, "decodePct": 20.2 },
|
|
10
|
+
{ "family": "Qwen3.8-27B", "quant": "SLQ EAR98-Q5_K_S", "model": "kaitchup/Qwen3.8-27B-SLQ-GGUF:EAR98-Q5_K_S", "weightsGB": 18.88, "draft": "incoai/Qwen3.8-27B-DFlash2", "klWiki": 0.0104, "klChat": 0.0486, "decodePct": 19.7 },
|
|
11
|
+
{ "family": "Qwen3.8-27B", "quant": "GSQ IQ3_S", "model": "ISTA-DASLab/Qwen3.8-27B-GSQ-RCO-GGUF:IQ3_S", "weightsGB": 11.77, "draft": "incoai/Qwen3.8-27B-DFlash2", "klWiki": 0.0573, "klChat": 0.2121, "decodePct": 18.2 },
|
|
12
|
+
{ "family": "Ternary-Bonsai-2-27B", "quant": "PQ2_0", "model": "prism-ml/Ternary-Bonsai-2-27B-gguf:PQ2_0", "weightsGB": 7, "draft": "incoai/Qwen3.8-27B-DFlash2", "needs": "needs wired-limit sysctl" }
|
|
13
|
+
]
|
|
14
|
+
}
|
package/extensions/splash.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { readdirSync, readFileSync } from "node:fs";
|
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { runBench } from "../src/bench.ts";
|
|
6
6
|
import { benchReport, shareUrl } from "../src/bench-report.ts";
|
|
7
|
+
import { loadCatalog, startCompletions } from "../src/catalog.ts";
|
|
7
8
|
import { detectMac, macosWarning, runtimeFor } from "../src/mac.ts";
|
|
8
9
|
import { DRAFT_GB, loadEntries, recommend, diskWarnings, isDownloaded } from "../src/recommend.ts";
|
|
9
10
|
import { bytes, bytesOnDisk, downloadLabel, downloadLines, downloadNotice, gb, planDownload } from "../src/download.ts";
|
|
@@ -143,12 +144,36 @@ export default async function (pi: ExtensionAPI) {
|
|
|
143
144
|
ctx.ui.notify("No model given and none recommended for this Mac.", "error");
|
|
144
145
|
return;
|
|
145
146
|
}
|
|
146
|
-
const flags = c.flags ?? (chosen === pick?.model ? pick.flags : []);
|
|
147
|
+
const flags = c.flags ?? (chosen === pick?.model ? pick.flags : loadCatalog().some((m) => m.model === chosen) ? ["--language-only"] : []);
|
|
148
|
+
if (!(await confirmDownload(chosen, flags, ctx))) return ctx.ui.notify("Not started.", "info");
|
|
147
149
|
const pid = start({ launcher: l.path, model: chosen, flags, port: p, keepAwake: c.keepAwake ?? true, stopWithPid: c.stopOnExit ? process.pid : undefined });
|
|
148
150
|
ctx.ui.notify(`Starting ${[chosen, ...flags].join(" ")}. Progress in the status bar; Pi stays usable. Log: ${logPath(p)}`, "info");
|
|
149
151
|
follow(p, pid, chosen, ctx, flags);
|
|
150
152
|
}
|
|
151
153
|
|
|
154
|
+
function draftFor(model: string) {
|
|
155
|
+
return loadEntries().find((e) => e.model === model)?.draft ?? loadCatalog().find((m) => m.model === model)?.draft;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function confirmDownload(model: string, flags: string[], ctx: any) {
|
|
159
|
+
const mac = detectMac();
|
|
160
|
+
const entry = loadCatalog().find((m) => m.model === model);
|
|
161
|
+
const name = entry ? `${entry.family} ${entry.quant}` : model;
|
|
162
|
+
const free = (downloadGB: number) => [
|
|
163
|
+
`${mac.freeDiskGB.toFixed(1)} GB free on disk, about ${Math.max(0, mac.freeDiskGB - downloadGB).toFixed(1)} GB left after. Progress shows in the status bar; Pi stays usable.`,
|
|
164
|
+
...diskWarnings(mac, downloadGB).map((w) => `Warning: ${w}`)].join("\n");
|
|
165
|
+
const plan = await planDownload(model, draftFor(model), flags.includes("--language-only")).catch(() => null);
|
|
166
|
+
if (plan) {
|
|
167
|
+
const missing = bytes(plan.flatMap((r) => r.missing));
|
|
168
|
+
const parts = plan.map((r) => `${r.draft ? "Draft" : "Model"} ${r.repo}${r.draft || !model.includes(":") ? "" : `:${model.split(":")[1]}`}: ${r.missing.length ? gb(bytes(r.missing)) : "already downloaded"}`);
|
|
169
|
+
return !missing || ctx.ui.confirm(`Download ${name}, ${gb(missing)}?`,
|
|
170
|
+
`From Hugging Face into ~/.cache/huggingface/hub:\n${parts.map((x) => ` ${x}`).join("\n")}\n${free(missing / 1e9)}`);
|
|
171
|
+
}
|
|
172
|
+
if (isDownloaded(model)) return true;
|
|
173
|
+
const size = entry?.weightsGB;
|
|
174
|
+
return ctx.ui.confirm(`Download ${name}?`, `${model}${size ? `, about ${(size + DRAFT_GB).toFixed(1)} GB with the draft` : ""} from Hugging Face into ~/.cache/huggingface/hub (Hugging Face not reachable now to check sizes).\n${free(size ? size + DRAFT_GB : 0)}`);
|
|
175
|
+
}
|
|
176
|
+
|
|
152
177
|
function starting(p: number) {
|
|
153
178
|
const record = readRecord(p);
|
|
154
179
|
const phase = describe(record);
|
|
@@ -171,7 +196,7 @@ export default async function (pi: ExtensionAPI) {
|
|
|
171
196
|
let progress: ReturnType<typeof downloadProgress> | null = null;
|
|
172
197
|
try {
|
|
173
198
|
if (model) {
|
|
174
|
-
const draft =
|
|
199
|
+
const draft = draftFor(model);
|
|
175
200
|
const f = flags ?? config().flags ?? recommend(detectMac()).pick?.flags ?? [];
|
|
176
201
|
const plan = await planDownload(model, draft, f.includes("--language-only")).catch(() => null);
|
|
177
202
|
const missing = plan ? bytes(plan.flatMap((r) => r.missing)) : null;
|
|
@@ -208,6 +233,7 @@ export default async function (pi: ExtensionAPI) {
|
|
|
208
233
|
}
|
|
209
234
|
|
|
210
235
|
let bench: { abort: AbortController; done: Promise<void> } | null = null;
|
|
236
|
+
let mac: ReturnType<typeof detectMac> | undefined;
|
|
211
237
|
|
|
212
238
|
async function benchmark(long: boolean, ctx: any, signal: AbortSignal) {
|
|
213
239
|
const p = port();
|
|
@@ -308,7 +334,13 @@ export default async function (pi: ExtensionAPI) {
|
|
|
308
334
|
pi.registerCommand("splash", {
|
|
309
335
|
description: "Local Splash server: status, doctor, start [model], bench [--long | share], stop, use, log, install, update",
|
|
310
336
|
getArgumentCompletions: (prefix: string) => {
|
|
311
|
-
const
|
|
337
|
+
const start = /^\s*start(?:\s+(\S*))?$/.exec(prefix);
|
|
338
|
+
if (start) {
|
|
339
|
+
mac ??= detectMac();
|
|
340
|
+
const items = startCompletions(start[1] ?? "", loadCatalog(), recommend(mac).pick, (m) => isDownloaded(m));
|
|
341
|
+
return items.length ? items : null;
|
|
342
|
+
}
|
|
343
|
+
const items = ["doctor", "start", "bench", "bench --long", "bench share", "stop", "use", "log", "install", "update"].filter((s) => s.startsWith(prefix)).map((s) => ({ value: s === "start" ? "start " : s, label: s }));
|
|
312
344
|
return items.length ? items : null;
|
|
313
345
|
},
|
|
314
346
|
handler: async (args: string, ctx: any) => {
|
package/package.json
CHANGED
package/src/catalog.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import type { Entry } from "./recommend.ts";
|
|
3
|
+
|
|
4
|
+
export type CatalogModel = {
|
|
5
|
+
family: string; quant: string; model: string; weightsGB: number;
|
|
6
|
+
klWiki?: number; klChat?: number; decodePct?: number; needs?: string; draft?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function loadCatalog(): CatalogModel[] {
|
|
10
|
+
return JSON.parse(readFileSync(new URL("../data/models.json", import.meta.url), "utf8")).models;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const signed = (n: number, unit: string) => `${n > 0 ? "+" : "-"}${Math.abs(n).toFixed(unit === "%" ? 0 : 1)}${unit}`;
|
|
14
|
+
|
|
15
|
+
function kl(m: CatalogModel, base: CatalogModel | undefined) {
|
|
16
|
+
if (m.klWiki == null || m.klChat == null) return "bf16 closeness not measured";
|
|
17
|
+
if (!base || base.klWiki == null || base.klChat == null) return `KL wiki ${m.klWiki}, chat ${m.klChat}`;
|
|
18
|
+
const change = (a: number, b: number) => {
|
|
19
|
+
if (a / b >= 2) return `×${(a / b).toFixed(1)}`;
|
|
20
|
+
const pct = Math.round((a / b - 1) * 100);
|
|
21
|
+
return pct ? signed(pct, "%") : "same";
|
|
22
|
+
};
|
|
23
|
+
return `KL wiki ${change(m.klWiki, base.klWiki)}, chat ${change(m.klChat, base.klChat)}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function decode(m: CatalogModel, base: CatalogModel | undefined) {
|
|
27
|
+
if (m.decodePct == null || !base || base.decodePct == null) return null;
|
|
28
|
+
const pct = Math.round(((1 + m.decodePct / 100) / (1 + base.decodePct / 100) - 1) * 100);
|
|
29
|
+
if (Math.abs(pct) < 2) return "decode same";
|
|
30
|
+
return `decode ${Math.abs(pct)}% ${pct > 0 ? "slower" : "faster"}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function startCompletions(query: string, catalog: CatalogModel[], pick: Entry | null, downloaded: (model: string) => boolean) {
|
|
34
|
+
const q = query.trim().toLowerCase();
|
|
35
|
+
const base = catalog.find((m) => m.model === pick?.model);
|
|
36
|
+
const family = base?.family ?? catalog[0]?.family;
|
|
37
|
+
const rank = (m: CatalogModel) => (m === base ? [0, 0] : m.family !== family ? [3, m.weightsGB]
|
|
38
|
+
: base && m.weightsGB > base.weightsGB ? [1, m.weightsGB] : [2, -m.weightsGB]);
|
|
39
|
+
return catalog
|
|
40
|
+
.filter((m) => `${m.model} ${m.family} ${m.quant}`.toLowerCase().includes(q))
|
|
41
|
+
.sort((a, b) => rank(a)[0] - rank(b)[0] || a.family.localeCompare(b.family) || rank(a)[1] - rank(b)[1])
|
|
42
|
+
.map((m) => {
|
|
43
|
+
const parts = m === base
|
|
44
|
+
? ["recommended", downloaded(m.model) ? "downloaded" : "needs download", `${m.weightsGB.toFixed(1)} GB`, "others compared to this", m.needs]
|
|
45
|
+
: [downloaded(m.model) ? "downloaded" : "needs download",
|
|
46
|
+
!base ? `${m.weightsGB.toFixed(1)} GB` : Math.abs(m.weightsGB - base.weightsGB) < 0.05 ? "same size" : signed(m.weightsGB - base.weightsGB, " GB"),
|
|
47
|
+
kl(m, base), decode(m, base), m.needs];
|
|
48
|
+
return { value: `start ${m.model}`, label: `${m.family} · ${m.quant}`, description: parts.filter(Boolean).join(" · ") };
|
|
49
|
+
});
|
|
50
|
+
}
|