@simplexai/localmodels-linux-x64 0.1.0-dev.32.build.git0f60eee490864cf83e343f8db13a335676a19dd8 → 0.1.0-dev.35
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/bootstrap.identity +1 -1
- package/bootstrap.sha256 +138 -97
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/__main__.py +4 -0
- package/modules/localmodels/app.py +7 -2
- package/modules/localmodels/approval.py +4 -4
- package/modules/localmodels/bifrost_checks.py +121 -3
- package/modules/localmodels/bifrost_provider.py +53 -0
- package/modules/localmodels/bifrost_unit.py +32 -1
- package/modules/localmodels/budget.py +5 -1
- package/modules/localmodels/catalog.json +51 -10
- package/modules/localmodels/catalog.py +30 -29
- package/modules/localmodels/catalog_add.py +1 -0
- package/modules/localmodels/cli_parser.py +10 -2
- package/modules/localmodels/component.py +7 -1
- package/modules/localmodels/decode_calibration.json +6 -0
- package/modules/localmodels/decode_calibration.py +104 -0
- package/modules/localmodels/deploy.py +44 -7
- package/modules/localmodels/deploy_steps.py +10 -1
- package/modules/localmodels/engines-strata-0.1.49.2.json +31 -0
- package/modules/localmodels/engines.json +57 -1
- package/modules/localmodels/engines.py +6 -2
- package/modules/localmodels/estimator.py +21 -7
- package/modules/localmodels/frontend.py +4 -4
- package/modules/localmodels/gateway.py +14 -4
- package/modules/localmodels/gateway_app_bifrost.py +4 -3
- package/modules/localmodels/gateway_bifrost.py +70 -57
- package/modules/localmodels/gateway_probe.py +3 -4
- package/modules/localmodels/gguf.py +7 -0
- package/modules/localmodels/harness.py +24 -25
- package/modules/localmodels/harness_gateway.py +19 -10
- package/modules/localmodels/harness_probe.py +33 -6
- package/modules/localmodels/hosts.py +73 -9
- package/modules/localmodels/install.py +36 -6
- package/modules/localmodels/library_cli.py +179 -0
- package/modules/localmodels/library_convert.py +132 -0
- package/modules/localmodels/library_gateway.py +471 -0
- package/modules/localmodels/library_jobs.py +314 -0
- package/modules/localmodels/library_model.py +246 -0
- package/modules/localmodels/library_pricing.py +347 -0
- package/modules/localmodels/library_serve.py +348 -0
- package/modules/localmodels/library_state.py +373 -0
- package/modules/localmodels/library_status.py +349 -0
- package/modules/localmodels/llm_rank.py +16 -2
- package/modules/localmodels/memcalc.py +7 -30
- package/modules/localmodels/metal.py +26 -0
- package/modules/localmodels/plan_envelope.py +4 -1
- package/modules/localmodels/preparation.py +49 -0
- package/modules/localmodels/probe.py +8 -8
- package/modules/localmodels/process_identity.py +536 -9
- package/modules/localmodels/quant_formats.py +123 -0
- package/modules/localmodels/recommend_cli.py +8 -4
- package/modules/localmodels/records.py +1 -0
- package/modules/localmodels/remote_ops.py +104 -6
- package/modules/localmodels/remote_ops_download.py +17 -2
- package/modules/localmodels/remote_ops_prepare.py +406 -0
- package/modules/localmodels/remote_ops_remove.py +40 -7
- package/modules/localmodels/remote_ops_service.py +110 -8
- package/modules/localmodels/remote_ops_verify.py +15 -2
- package/modules/localmodels/runtime_auth.py +31 -1
- package/modules/localmodels/runtime_cli.py +3 -4
- package/modules/localmodels/runtime_io.py +50 -6
- package/modules/localmodels/service_autostart.py +45 -1
- package/modules/localmodels/service_control.py +13 -0
- package/modules/localmodels/service_deployment.py +12 -3
- package/modules/localmodels/service_jobs.py +33 -4
- package/modules/localmodels/service_probe.py +67 -13
- package/modules/localmodels/service_stop.py +152 -0
- package/modules/localmodels/service_worker.py +9 -1
- package/modules/localmodels/services_cli.py +50 -6
- package/modules/localmodels/setup_inspection.py +34 -25
- package/modules/localmodels/setup_text.py +118 -0
- package/modules/localmodels/sizecalc.py +625 -0
- package/modules/localmodels/sizecalc_cli.py +249 -0
- package/modules/localmodels/stack.py +69 -17
- package/modules/localmodels/stack_args.py +91 -19
- package/modules/localmodels/stack_auto.py +78 -0
- package/modules/localmodels/stack_binding.py +23 -35
- package/modules/localmodels/stack_card.py +195 -0
- package/modules/localmodels/stack_cleanup.py +379 -0
- package/modules/localmodels/stack_clients.py +4 -1
- package/modules/localmodels/stack_compose.py +150 -194
- package/modules/localmodels/stack_console.py +2 -0
- package/modules/localmodels/stack_decision.py +3 -2
- package/modules/localmodels/stack_down.py +189 -0
- package/modules/localmodels/stack_events.py +54 -0
- package/modules/localmodels/stack_hardware.py +22 -23
- package/modules/localmodels/stack_journal.py +29 -8
- package/modules/localmodels/stack_ledger.py +411 -0
- package/modules/localmodels/stack_lifecycle.py +162 -167
- package/modules/localmodels/stack_llm_ram.py +57 -5
- package/modules/localmodels/stack_memory.py +721 -0
- package/modules/localmodels/stack_picks.py +139 -0
- package/modules/localmodels/stack_plan.py +140 -22
- package/modules/localmodels/stack_ports.py +22 -0
- package/modules/localmodels/stack_preflight.py +699 -0
- package/modules/localmodels/stack_review.py +123 -5
- package/modules/localmodels/stack_rollback.py +2 -0
- package/modules/localmodels/stack_route.py +256 -0
- package/modules/localmodels/stack_run.py +11 -0
- package/modules/localmodels/stack_suite.py +102 -17
- package/modules/localmodels/stack_summary.py +65 -4
- package/modules/localmodels/stack_try.py +354 -0
- package/modules/localmodels/stack_try_client.py +194 -0
- package/modules/localmodels/stack_try_docs.py +139 -0
- package/modules/localmodels/stack_up.py +8 -1
- package/modules/localmodels/stack_update.py +29 -4
- package/modules/localmodels/stack_verify.py +3 -1
- package/modules/localmodels/stack_view.py +10 -11
- package/modules/localmodels/stack_view_apply.py +4 -2
- package/modules/localmodels/stack_view_events.py +2 -1
- package/modules/localmodels/stack_view_serve.py +3 -0
- package/modules/localmodels/stack_view_text.py +1 -1
- package/modules/localmodels/stack_view_words.py +4 -1
- package/modules/localmodels/stack_warm.py +574 -0
- package/modules/localmodels/stack_whatif.py +558 -0
- package/modules/localmodels/suite.py +48 -39
- package/modules/localmodels/tool_archive.py +40 -0
- package/modules/localmodels/tools.json +8 -0
- package/modules/localmodels/transport.py +1 -0
- package/modules/localmodels/vision.py +8 -1
- package/modules/localmodels/web/sizecalc/app.js +431 -0
- package/modules/localmodels/web/sizecalc/calc.js +269 -0
- package/modules/localmodels/web/sizecalc/page.html +362 -0
- package/modules/localmodels/web/view/ASSET-SOURCES.md +11 -0
- package/modules/localmodels/web/view/i18n.js +1 -1
- package/modules/localmodels/web/view/logo-claude.svg +3 -0
- package/modules/localmodels/web/view/logo-codex.png +0 -0
- package/modules/localmodels/web/view/logo-pi.svg +6 -0
- package/modules/localmodels/web/view/view.css +4 -0
- package/modules/localmodels/web/view/view.js +15 -6
- package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev35.dist-info}/METADATA +1 -1
- package/modules/simplex_localmodels-0.1.0.dev35.dist-info/RECORD +241 -0
- package/package.json +1 -1
- package/tool.json +1 -1
- package/modules/simplex_localmodels-0.1.0.dev32.dist-info/RECORD +0 -200
- /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev35.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev35.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev35.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev32.dist-info → simplex_localmodels-0.1.0.dev35.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
// The sizing model of localmodels/sizecalc.py, line for line. Every table (formats, engines,
|
|
2
|
+
// devices with their usable memory, constants) comes from sizecalc.page_data(), which the CLI
|
|
3
|
+
// inlines as SIZECALC_DATA; tests/test_sizecalc.py runs this file under Node and compares its
|
|
4
|
+
// reports with Python's. Every number is an estimate for sizing, not a measurement.
|
|
5
|
+
const SizeCalc = (data) => {
|
|
6
|
+
const C = data.constants;
|
|
7
|
+
const FORMATS = Object.fromEntries(data.formats.map((f) => [f.name, f]));
|
|
8
|
+
const DEVICES = data.devices;
|
|
9
|
+
const TIERS = data.tiers; // [id, label, detail]
|
|
10
|
+
|
|
11
|
+
function nearest(bits, families = ["gguf"]) {
|
|
12
|
+
let pool = data.formats.filter((f) => families.includes(f.family));
|
|
13
|
+
if (!pool.length) pool = data.formats;
|
|
14
|
+
return pool.reduce((best, f) => {
|
|
15
|
+
const d = Math.abs(f.bits - bits), b = Math.abs(best.bits - bits);
|
|
16
|
+
return d < b || (d === b && f.name < best.name) ? f : best;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function lookup(name) {
|
|
21
|
+
let key = name.trim().toUpperCase();
|
|
22
|
+
if (key.startsWith("UD-")) key = key.slice(3);
|
|
23
|
+
if (FORMATS[key]) return FORMATS[key];
|
|
24
|
+
for (const prefix of ["EXL2-", "EXL3-"]) {
|
|
25
|
+
if (key.startsWith(prefix)) {
|
|
26
|
+
const bits = Number(key.slice(prefix.length));
|
|
27
|
+
if (Number.isFinite(bits) && bits >= 1 && bits <= 16)
|
|
28
|
+
return { name: key, family: "exl", bits, basis: "target", note: "ExLlama: embeddings stay 16-bit" };
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function resolveFormat(text) {
|
|
36
|
+
const found = lookup(text);
|
|
37
|
+
if (found) return found;
|
|
38
|
+
const bits = Number(text);
|
|
39
|
+
if (!Number.isFinite(bits) || text.trim() === "") throw new Error(`unknown format ${text}`);
|
|
40
|
+
if (bits < 1 || bits > 32) throw new Error(`${text} bits per weight is outside 1-32`);
|
|
41
|
+
const near = nearest(bits);
|
|
42
|
+
return { name: `${fmtG(bits)} bpw`, family: near.family, bits, basis: "exact", note: `priced as ${near.family}` };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Python's f"{x:g}" for the values a page produces.
|
|
46
|
+
const fmtG = (x) => String(Number(x.toPrecision(6)));
|
|
47
|
+
|
|
48
|
+
function guessKvPerToken(active, attention) {
|
|
49
|
+
const full = C.kv_ref_bytes * Math.pow(active / C.kv_ref_params, C.kv_exponent);
|
|
50
|
+
return Math.trunc(full * C.attention_kv_share[attention]);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// { params, active, fmt, fileBytes, attention, kvPerToken } -> { shape, notes }
|
|
54
|
+
function shape(o) {
|
|
55
|
+
const notes = [];
|
|
56
|
+
let { params, active, fileBytes } = o;
|
|
57
|
+
const fileBytes0 = fileBytes;
|
|
58
|
+
const given = [params, o.fmt, fileBytes].filter((x) => x != null).length;
|
|
59
|
+
if (given < 2) throw new Error("give two of params, format and file size");
|
|
60
|
+
if ((params != null && params <= 0) || (fileBytes != null && fileBytes <= 0))
|
|
61
|
+
throw new Error("parameters and file size must be positive");
|
|
62
|
+
let f;
|
|
63
|
+
if (params == null) {
|
|
64
|
+
f = resolveFormat(o.fmt);
|
|
65
|
+
params = Math.trunc((fileBytes * 8) / f.bits);
|
|
66
|
+
notes.push(`${(params / 1e9).toFixed(1)}B parameters inferred from the file size at ${fmtG(f.bits)} bpw`);
|
|
67
|
+
} else if (fileBytes == null) {
|
|
68
|
+
f = resolveFormat(o.fmt);
|
|
69
|
+
fileBytes = Math.trunc((params * f.bits) / 8);
|
|
70
|
+
} else {
|
|
71
|
+
const bits = (fileBytes * 8) / params;
|
|
72
|
+
if (o.fmt == null) {
|
|
73
|
+
const near = nearest(bits);
|
|
74
|
+
f = { name: `${bits.toFixed(2)} bpw`, family: near.family, bits, basis: "exact", note: `nearest listed: ${near.name}` };
|
|
75
|
+
notes.push(`${bits.toFixed(2)} bits per weight; the nearest listed format is ${near.name}`);
|
|
76
|
+
} else {
|
|
77
|
+
f = resolveFormat(o.fmt);
|
|
78
|
+
if (Math.abs(bits - f.bits) / f.bits > 0.15)
|
|
79
|
+
notes.push(
|
|
80
|
+
`the file holds ${bits.toFixed(2)} bits per weight, ${f.name} is typically ${fmtG(f.bits)}: ` +
|
|
81
|
+
"check the parameter count (embeddings, vision tower, MTP heads)",
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (f.family === "exl" && fileBytes0 == null)
|
|
86
|
+
notes.push(
|
|
87
|
+
"EXL bit rates leave out the 16-bit embeddings and 6-bit head, so the file runs " +
|
|
88
|
+
"larger than this; give --file-size when known",
|
|
89
|
+
);
|
|
90
|
+
if (params < C.small_model_params && o.fmt != null && fileBytes0 == null)
|
|
91
|
+
notes.push(
|
|
92
|
+
"small model: embeddings are a large share, so real files run above the table " +
|
|
93
|
+
"(Qwen3-0.6B Q4_K_M holds 5.30 bits per weight); give --file-size when known",
|
|
94
|
+
);
|
|
95
|
+
active = active == null ? params : active;
|
|
96
|
+
if (!(active > 0 && active <= params)) throw new Error("active parameters must be positive and at most the total");
|
|
97
|
+
const attention = o.attention || "full";
|
|
98
|
+
let kv, source;
|
|
99
|
+
if (o.kvPerToken == null) {
|
|
100
|
+
kv = guessKvPerToken(active, attention);
|
|
101
|
+
source = `guessed for ${attention} attention`;
|
|
102
|
+
} else {
|
|
103
|
+
kv = o.kvPerToken;
|
|
104
|
+
source = "given";
|
|
105
|
+
}
|
|
106
|
+
const s = { params, active, format: f, fileBytes, kvPerToken: kv, kvSource: source };
|
|
107
|
+
return { shape: s, notes };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const isMoe = (s) => s.active < s.params;
|
|
111
|
+
const bitsOf = (s) => (s.fileBytes * 8) / s.params;
|
|
112
|
+
const activeBytes = (s) => (s.fileBytes * s.active) / s.params;
|
|
113
|
+
|
|
114
|
+
const expertShare = (s) => (isMoe(s) ? 1 - (C.moe_shared_of_active * s.active) / s.params : 0);
|
|
115
|
+
|
|
116
|
+
const kvBytes = (s, p) => Math.trunc(s.kvPerToken * (C.kv_bytes_per_elem[p.kvType] / 2) * p.context * p.slots);
|
|
117
|
+
|
|
118
|
+
function support(f, d) {
|
|
119
|
+
const rule = (data.support[f.family] || {})[d.backend];
|
|
120
|
+
if (!rule) return [d.backend === "metal" || d.backend === "ios" ? "mlx" : "llama.cpp", "convert"];
|
|
121
|
+
const [engine, native, runs] = rule;
|
|
122
|
+
if (d.backend !== "cuda" || d.sm >= native) return [engine, "native"];
|
|
123
|
+
return d.sm >= runs ? [engine, "fallback"] : [engine, "convert"];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function need(s, engine, p, count = 1) {
|
|
127
|
+
const e = data.engines[engine];
|
|
128
|
+
const out = {
|
|
129
|
+
weights: s.fileBytes,
|
|
130
|
+
kv: kvBytes(s, p),
|
|
131
|
+
overhead: (e.fixed_bytes + e.per_context_token * p.context) * count,
|
|
132
|
+
};
|
|
133
|
+
out.total = out.weights + out.kv + out.overhead;
|
|
134
|
+
return out;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function tokS(readGpu, bwGpu, readHost = 0, bwHost = 1) {
|
|
138
|
+
const seconds = readGpu / (bwGpu * 1e9) + readHost / (bwHost * 1e9);
|
|
139
|
+
return seconds > 0 ? Math.round(10 / seconds) / 10 : 0;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function place(s, d, p) {
|
|
143
|
+
const [engine, status] = support(s.format, d);
|
|
144
|
+
const room = d.usable[engine];
|
|
145
|
+
const parts = need(s, engine, p, d.count);
|
|
146
|
+
const kvRead = parts.kv / p.slots;
|
|
147
|
+
const row = {
|
|
148
|
+
device: d.id, name: d.name, tier: d.tier, engine, format_support: status,
|
|
149
|
+
usable_bytes: room, need: parts, verdict: "no", decode_ceiling_tok_s: 0,
|
|
150
|
+
};
|
|
151
|
+
const bandwidth = d.bandwidth_gb_s * d.count;
|
|
152
|
+
if (parts.total <= room) {
|
|
153
|
+
row.verdict = "fits";
|
|
154
|
+
row.decode_ceiling_tok_s = tokS(activeBytes(s) + kvRead, bandwidth);
|
|
155
|
+
return row;
|
|
156
|
+
}
|
|
157
|
+
if (d.host_offload) {
|
|
158
|
+
const off = offload(s, d, p);
|
|
159
|
+
if (off) Object.assign(row, off);
|
|
160
|
+
}
|
|
161
|
+
return row;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function offload(s, d, p) {
|
|
165
|
+
const room = d.usable["llama.cpp"];
|
|
166
|
+
const hostRoom = p.hostRam - C.host_ram_floor - C.llama_host_base;
|
|
167
|
+
const parts = need(s, "llama.cpp", p);
|
|
168
|
+
const kvRead = parts.kv / p.slots;
|
|
169
|
+
let movable, movableRead;
|
|
170
|
+
if (isMoe(s)) {
|
|
171
|
+
movable = s.fileBytes * expertShare(s);
|
|
172
|
+
movableRead = activeBytes(s) * (1 - C.moe_shared_of_active);
|
|
173
|
+
} else {
|
|
174
|
+
movable = s.fileBytes + parts.kv;
|
|
175
|
+
movableRead = activeBytes(s) + kvRead;
|
|
176
|
+
}
|
|
177
|
+
if (parts.total - movable > room) return null;
|
|
178
|
+
const toHost = Math.max(0, parts.total - room);
|
|
179
|
+
if (toHost > hostRoom) return null;
|
|
180
|
+
const readHost = (movableRead * toHost) / movable;
|
|
181
|
+
const readGpu = activeBytes(s) + kvRead - readHost;
|
|
182
|
+
const hostKv = isMoe(s) ? 0 : Math.trunc(parts.kv * (toHost / movable));
|
|
183
|
+
return {
|
|
184
|
+
verdict: "offload", engine: "llama.cpp",
|
|
185
|
+
format_support: s.format.family === "gguf" || s.format.family === "mxfp4" ? "native" : "convert",
|
|
186
|
+
usable_bytes: room, need: parts, offload_bytes: Math.trunc(toHost),
|
|
187
|
+
host_weights_bytes: Math.trunc(toHost) - hostKv, host_kv_bytes: hostKv,
|
|
188
|
+
host_room_bytes: Math.trunc(hostRoom),
|
|
189
|
+
decode_ceiling_tok_s: tokS(readGpu, d.bandwidth_gb_s, readHost, p.hostBandwidth),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Fitting before offloading, and the format as given before a conversion.
|
|
194
|
+
const rank = (r) => (r.verdict !== "fits" ? 2 : 0) + (r.format_support === "convert" ? 1 : 0);
|
|
195
|
+
|
|
196
|
+
function tiers(rows) {
|
|
197
|
+
return TIERS.map(([tier, label]) => {
|
|
198
|
+
const usable = rows.filter((r) => r.tier === tier && r.verdict !== "no");
|
|
199
|
+
const pick = usable.reduce((best, r) => (best == null || rank(r) < rank(best) ? r : best), null);
|
|
200
|
+
return {
|
|
201
|
+
tier, label, verdict: pick ? pick.verdict : "no", format_support: pick ? pick.format_support : null,
|
|
202
|
+
device: pick ? pick.device : null, name: pick ? pick.name : null,
|
|
203
|
+
decode_ceiling_tok_s: pick ? pick.decode_ceiling_tok_s : 0,
|
|
204
|
+
};
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function magnitude(tierRows) {
|
|
209
|
+
const fits = tierRows.find((t) => t.verdict === "fits");
|
|
210
|
+
const asIs = tierRows.find((t) => t.verdict === "fits" && t.format_support !== "convert");
|
|
211
|
+
const runs = tierRows.find((t) => t.verdict !== "no");
|
|
212
|
+
return { fits: fits ? fits.tier : null, fits_as_is: asIs ? asIs.tier : null, runs: runs ? runs.tier : null };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function ladder(s, p) {
|
|
216
|
+
const names = [...data.ladder];
|
|
217
|
+
if (!names.includes(s.format.name)) names.push(s.format.name);
|
|
218
|
+
const out = names.map((name) => {
|
|
219
|
+
const other = name === s.format.name
|
|
220
|
+
? s
|
|
221
|
+
: { ...s, format: FORMATS[name], fileBytes: Math.trunc((s.params * FORMATS[name].bits) / 8) };
|
|
222
|
+
const mag = magnitude(tiers(DEVICES.map((d) => place(other, d, p))));
|
|
223
|
+
return {
|
|
224
|
+
format: other.format.name, bits: Math.round(bitsOf(other) * 1000) / 1000, file_bytes: other.fileBytes,
|
|
225
|
+
fits: mag.fits, fits_as_is: mag.fits_as_is, runs: mag.runs, current: name === s.format.name,
|
|
226
|
+
};
|
|
227
|
+
});
|
|
228
|
+
return out.sort((a, b) => b.bits - a.bits);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function posture(o = {}) {
|
|
232
|
+
return {
|
|
233
|
+
context: o.context ?? C.default_context,
|
|
234
|
+
slots: o.slots ?? 1,
|
|
235
|
+
kvType: o.kvType ?? "f16",
|
|
236
|
+
hostRam: o.hostRam ?? C.default_host_ram,
|
|
237
|
+
hostBandwidth: o.hostBandwidth ?? C.default_host_bandwidth_gb_s,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function report(s, p, notes = []) {
|
|
242
|
+
const rows = DEVICES.map((d) => place(s, d, p));
|
|
243
|
+
const tierRows = tiers(rows);
|
|
244
|
+
const engine = data.default_engine[s.format.family];
|
|
245
|
+
return {
|
|
246
|
+
schema: data.schema,
|
|
247
|
+
model: {
|
|
248
|
+
kind: isMoe(s) ? "moe" : "dense", params: s.params, active_params: s.active,
|
|
249
|
+
expert_share: Math.round(expertShare(s) * 1e4) / 1e4,
|
|
250
|
+
},
|
|
251
|
+
format: {
|
|
252
|
+
name: s.format.name, family: s.format.family, bits_per_weight: Math.round(bitsOf(s) * 1000) / 1000,
|
|
253
|
+
default_engine: engine, note: s.format.note,
|
|
254
|
+
},
|
|
255
|
+
file_bytes: s.fileBytes,
|
|
256
|
+
kv_bytes_per_token: s.kvPerToken,
|
|
257
|
+
kv_source: s.kvSource,
|
|
258
|
+
runtime: need(s, engine, p),
|
|
259
|
+
magnitude: magnitude(tierRows),
|
|
260
|
+
tiers: tierRows,
|
|
261
|
+
devices: rows,
|
|
262
|
+
ladder: ladder(s, p),
|
|
263
|
+
notes,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return { shape, report, posture, place, need, kvBytes, expertShare, guessKvPerToken, resolveFormat, support };
|
|
268
|
+
};
|
|
269
|
+
if (typeof module !== "undefined") module.exports = SizeCalc;
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>模型体量计算器</title>
|
|
7
|
+
<style>
|
|
8
|
+
/* Layout: a control rail on the left, the answer on the right. The answer leads with the class
|
|
9
|
+
of device (the magnitude), then the memory ruler that shows why, then the selected device's
|
|
10
|
+
memory, the same model in other formats, and the method. */
|
|
11
|
+
:root {
|
|
12
|
+
--bg: #eceef1;
|
|
13
|
+
--surface: #fcfcfb;
|
|
14
|
+
--ink: #15181d;
|
|
15
|
+
--ink-2: #4a515c;
|
|
16
|
+
--muted: #747b86;
|
|
17
|
+
--line: #dde1e6;
|
|
18
|
+
--line-2: #c4c9d0;
|
|
19
|
+
--accent: #1c5cab;
|
|
20
|
+
--accent-wash: #e3edf9;
|
|
21
|
+
--good: #0b7a0b;
|
|
22
|
+
--warn: #a86400;
|
|
23
|
+
--bad: #c23434;
|
|
24
|
+
--none: #a9afb8;
|
|
25
|
+
--s-w: #2a78d6;
|
|
26
|
+
--s-kv: #eb6834;
|
|
27
|
+
--s-ov: #8a93a0;
|
|
28
|
+
--s-off: #eda100;
|
|
29
|
+
--f-sans: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
|
|
30
|
+
--f-num: "IBM Plex Sans Condensed", "IBM Plex Sans", "Noto Sans SC", system-ui, sans-serif;
|
|
31
|
+
--f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
|
|
32
|
+
--r: 6px;
|
|
33
|
+
}
|
|
34
|
+
@media (prefers-color-scheme: dark) {
|
|
35
|
+
:root:not([data-theme="light"]) {
|
|
36
|
+
--bg: #0f1114; --surface: #17191d; --ink: #eceef1; --ink-2: #b7bdc6; --muted: #868d98;
|
|
37
|
+
--line: #262a30; --line-2: #383d45; --accent: #6ea8f0; --accent-wash: #16243a;
|
|
38
|
+
--good: #2fb52f; --warn: #e0a030; --bad: #e66767; --none: #4b515a;
|
|
39
|
+
--s-w: #3987e5; --s-kv: #d95926; --s-ov: #6b7380; --s-off: #c98500; color-scheme: dark;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
:root[data-theme="dark"] {
|
|
43
|
+
--bg: #0f1114; --surface: #17191d; --ink: #eceef1; --ink-2: #b7bdc6; --muted: #868d98;
|
|
44
|
+
--line: #262a30; --line-2: #383d45; --accent: #6ea8f0; --accent-wash: #16243a;
|
|
45
|
+
--good: #2fb52f; --warn: #e0a030; --bad: #e66767; --none: #4b515a;
|
|
46
|
+
--s-w: #3987e5; --s-kv: #d95926; --s-ov: #6b7380; --s-off: #c98500; color-scheme: dark;
|
|
47
|
+
}
|
|
48
|
+
* { box-sizing: border-box; }
|
|
49
|
+
[hidden] { display: none !important; }
|
|
50
|
+
html { -webkit-text-size-adjust: 100%; }
|
|
51
|
+
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-sans); font-size: 14px; line-height: 1.55; }
|
|
52
|
+
.page { max-width: 1320px; margin: 0 auto; padding-block: 28px 64px;
|
|
53
|
+
padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
|
|
54
|
+
h1, h2, h3 { text-wrap: balance; margin: 0; }
|
|
55
|
+
h1 { font-size: clamp(26px, 3.4vw, 36px); font-weight: 700; letter-spacing: 0.01em; }
|
|
56
|
+
h2 { font-size: 17px; font-weight: 700; }
|
|
57
|
+
h3 { font-size: 14px; font-weight: 700; }
|
|
58
|
+
p { margin: 0; }
|
|
59
|
+
code, .mono { font-family: var(--f-mono); font-size: 0.92em; }
|
|
60
|
+
a { color: var(--accent); }
|
|
61
|
+
.mast { display: grid; gap: 8px; margin-bottom: 22px; max-width: 76ch; }
|
|
62
|
+
.eyebrow { font-size: 12px; letter-spacing: 0.08em; color: var(--muted); font-weight: 500; }
|
|
63
|
+
.lede { color: var(--ink-2); font-size: 15px; }
|
|
64
|
+
.mast-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
|
|
65
|
+
.theme { font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 5px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); cursor: pointer; white-space: nowrap; }
|
|
66
|
+
.bench { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
|
|
67
|
+
@media (min-width: 1040px) { .bench { grid-template-columns: 320px minmax(0, 1fr); } }
|
|
68
|
+
|
|
69
|
+
/* controls */
|
|
70
|
+
.controls { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 4px 16px 16px; display: grid; min-width: 0; }
|
|
71
|
+
@media (min-width: 1040px) {
|
|
72
|
+
.controls { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
|
|
73
|
+
}
|
|
74
|
+
.group { display: grid; gap: 10px; padding-block: 14px; border-bottom: 1px solid var(--line); min-width: 0; }
|
|
75
|
+
.group:last-child { border-bottom: 0; }
|
|
76
|
+
.group > .gt { font-size: 11px; letter-spacing: 0.1em; color: var(--muted); font-weight: 600; }
|
|
77
|
+
.field { display: grid; gap: 5px; min-width: 0; }
|
|
78
|
+
.field > label, .field > .lab { font-size: 12.5px; color: var(--ink-2); display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
|
|
79
|
+
.field .val { font-family: var(--f-mono); color: var(--ink); font-size: 12.5px; }
|
|
80
|
+
select, input[type="number"], input[type="text"] {
|
|
81
|
+
width: 100%; min-width: 0; font: inherit; font-size: 13.5px; color: var(--ink); background: var(--bg);
|
|
82
|
+
border: 1px solid var(--line-2); border-radius: 5px; padding: 6px 8px; }
|
|
83
|
+
select:focus-visible, input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
|
|
84
|
+
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 2px 0; }
|
|
85
|
+
.seg { display: flex; border: 1px solid var(--line-2); border-radius: 5px; overflow: hidden; }
|
|
86
|
+
.seg input { position: absolute; opacity: 0; pointer-events: none; }
|
|
87
|
+
.seg label { flex: 1 1 0; text-align: center; padding: 5px 4px; font-size: 12.5px; cursor: pointer; color: var(--ink-2); border-right: 1px solid var(--line-2); white-space: nowrap; background: var(--bg); }
|
|
88
|
+
.seg label:last-of-type { border-right: 0; }
|
|
89
|
+
.seg input:checked + label { background: var(--ink); color: var(--surface); }
|
|
90
|
+
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: -2px; }
|
|
91
|
+
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
|
|
92
|
+
.hint { font-size: 12px; color: var(--muted); }
|
|
93
|
+
.err { font-size: 12.5px; color: var(--bad); }
|
|
94
|
+
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
95
|
+
.presets button { font: inherit; font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--bg); color: var(--ink-2); cursor: pointer; white-space: nowrap; }
|
|
96
|
+
.presets button[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
|
|
97
|
+
|
|
98
|
+
/* results */
|
|
99
|
+
.results { display: grid; gap: 20px; min-width: 0; }
|
|
100
|
+
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 14px; min-width: 0; }
|
|
101
|
+
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 16px; }
|
|
102
|
+
.panel-head p { color: var(--muted); font-size: 12.5px; }
|
|
103
|
+
.readouts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
|
|
104
|
+
@media (max-width: 760px) { .readouts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
|
105
|
+
.tile { background: var(--surface); padding: 14px 16px; display: grid; gap: 4px; align-content: start; min-width: 0; }
|
|
106
|
+
.tile .tl { font-size: 12px; color: var(--muted); }
|
|
107
|
+
.tile .tv { font-family: var(--f-num); font-size: clamp(22px, 2.6vw, 30px); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; overflow-wrap: anywhere; }
|
|
108
|
+
.tile .tv small { font-size: 0.5em; font-weight: 500; color: var(--ink-2); margin-left: 3px; }
|
|
109
|
+
.tile .ts { font-size: 12px; color: var(--ink-2); }
|
|
110
|
+
.tile.hero { background: var(--accent-wash); }
|
|
111
|
+
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 1px 8px 1px 6px; border-radius: 999px; width: fit-content; white-space: nowrap; }
|
|
112
|
+
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
|
|
113
|
+
.pill.fits { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
|
|
114
|
+
.pill.offload { color: var(--warn); background: color-mix(in srgb, var(--s-off) 18%, transparent); }
|
|
115
|
+
.pill.no { color: var(--muted); background: color-mix(in srgb, var(--none) 18%, transparent); }
|
|
116
|
+
.tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; white-space: nowrap; }
|
|
117
|
+
.tag.convert { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
|
|
118
|
+
.tag.fallback { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
|
|
119
|
+
|
|
120
|
+
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); }
|
|
121
|
+
.legend span { display: inline-flex; align-items: center; gap: 6px; }
|
|
122
|
+
.legend i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
|
|
123
|
+
.legend i.sq { border-radius: 3px; }
|
|
124
|
+
.legend i.line { width: 16px; height: 0; border-radius: 0; border-top: 2px solid var(--ink); }
|
|
125
|
+
.legend i.dash { width: 16px; height: 0; border-radius: 0; border-top: 2px dashed var(--muted); }
|
|
126
|
+
|
|
127
|
+
/* the memory ruler */
|
|
128
|
+
.chart-wrap { position: relative; }
|
|
129
|
+
#ruler { width: 100%; height: auto; display: block; overflow: visible; }
|
|
130
|
+
#ruler text { font-family: var(--f-mono); font-size: 11px; fill: var(--muted); }
|
|
131
|
+
#ruler .tl { font-family: var(--f-sans); fill: var(--ink-2); font-size: 12px; }
|
|
132
|
+
#ruler .dl { font-family: var(--f-sans); fill: var(--ink-2); font-size: 10.5px; }
|
|
133
|
+
#ruler .need { font-family: var(--f-sans); fill: var(--ink); font-size: 12px; font-weight: 600; }
|
|
134
|
+
#ruler .halo { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
|
|
135
|
+
#ruler .dev { cursor: pointer; }
|
|
136
|
+
#ruler .dev:focus-visible circle { stroke: var(--accent); stroke-width: 3px; }
|
|
137
|
+
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line-2); border-radius: 6px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.12); min-width: 200px; display: grid; gap: 3px; z-index: 3; }
|
|
138
|
+
.tip .th { font-weight: 600; margin-bottom: 2px; }
|
|
139
|
+
.tip .tr { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
|
|
140
|
+
.tip .tr span:first-child { color: var(--ink-2); }
|
|
141
|
+
|
|
142
|
+
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
|
|
143
|
+
th, td { text-align: left; padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
|
|
144
|
+
th { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; white-space: nowrap; }
|
|
145
|
+
td.n, th.n { text-align: right; font-family: var(--f-mono); font-size: 12.5px; white-space: nowrap; }
|
|
146
|
+
tr.cur td { background: var(--accent-wash); }
|
|
147
|
+
tr.tierhead td { font-weight: 600; color: var(--ink); padding-top: 14px; border-bottom: 1px solid var(--line-2); }
|
|
148
|
+
tr.tierhead td span { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 8px; }
|
|
149
|
+
tbody tr.dev { cursor: pointer; }
|
|
150
|
+
tbody tr.dev:hover td { background: color-mix(in srgb, var(--accent-wash) 60%, transparent); }
|
|
151
|
+
.scroll { overflow-x: auto; min-width: 0; }
|
|
152
|
+
|
|
153
|
+
/* memory bar of one device */
|
|
154
|
+
.mbar { display: grid; gap: 8px; }
|
|
155
|
+
.mbar .mh { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--ink-2); flex-wrap: wrap; }
|
|
156
|
+
.mbar .mh b { color: var(--ink); font-weight: 600; }
|
|
157
|
+
.bar { position: relative; height: 30px; display: flex; gap: 2px; margin-top: 20px; margin-bottom: 20px; }
|
|
158
|
+
.bar > div { height: 100%; min-width: 0; border-radius: 2px; }
|
|
159
|
+
.bar .free { border: 1px dashed var(--line-2); }
|
|
160
|
+
.bar .over { background: repeating-linear-gradient(135deg, var(--bad) 0 2px, transparent 2px 6px); }
|
|
161
|
+
.bar .mark { position: absolute; top: -6px; bottom: -6px; width: 0; border-left: 2px solid var(--ink); z-index: 2; }
|
|
162
|
+
.bar .mark span { position: absolute; top: -19px; transform: translateX(-50%); font-size: 11px; white-space: nowrap; color: var(--ink); background: var(--surface); padding: 0 3px; }
|
|
163
|
+
.bar .mark.end span { transform: translateX(-100%); }
|
|
164
|
+
.bar .mark.start span { transform: none; }
|
|
165
|
+
|
|
166
|
+
/* the format ladder */
|
|
167
|
+
.lad { display: grid; gap: 7px; }
|
|
168
|
+
.lad .lr { display: grid; grid-template-columns: 110px minmax(0, 1fr) minmax(0, 190px); gap: 10px; align-items: center; font-size: 12.5px; }
|
|
169
|
+
.lad .ln { font-family: var(--f-mono); color: var(--ink); white-space: nowrap; }
|
|
170
|
+
.lad .ln small { color: var(--muted); margin-left: 4px; }
|
|
171
|
+
.lad .lb { display: flex; align-items: center; gap: 8px; min-width: 0; }
|
|
172
|
+
.lad .lb > div { height: 14px; border-radius: 0 3px 3px 0; background: color-mix(in srgb, var(--s-w) 40%, var(--surface)); min-width: 2px; }
|
|
173
|
+
.lad .lr.on .lb > div { background: var(--s-w); }
|
|
174
|
+
.lad .lr.on .ln { font-weight: 600; }
|
|
175
|
+
.lad .lb em { font-style: normal; font-family: var(--f-mono); font-size: 12px; color: var(--ink-2); white-space: nowrap; }
|
|
176
|
+
.lad .lt { color: var(--ink-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
177
|
+
@media (max-width: 600px) {
|
|
178
|
+
.lad .lr { grid-template-columns: minmax(0, 1fr); gap: 2px; }
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.cmd { position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 10px 84px 10px 12px; font-family: var(--f-mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-all; color: var(--ink); }
|
|
182
|
+
.cmd button { position: absolute; top: 7px; right: 7px; font: inherit; font-family: var(--f-sans); font-size: 12px; padding: 3px 10px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer; }
|
|
183
|
+
.two { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
|
|
184
|
+
@media (min-width: 900px) { .two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
|
|
185
|
+
.prose { display: grid; gap: 10px; max-width: 86ch; color: var(--ink-2); font-size: 13.5px; }
|
|
186
|
+
.prose b { color: var(--ink); }
|
|
187
|
+
.prose ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
|
|
188
|
+
.notes { display: grid; gap: 4px; font-size: 12.5px; color: var(--ink-2); }
|
|
189
|
+
.notes:empty { display: none; }
|
|
190
|
+
</style>
|
|
191
|
+
</head>
|
|
192
|
+
<body>
|
|
193
|
+
<div class="page">
|
|
194
|
+
<header class="mast">
|
|
195
|
+
<div class="mast-row">
|
|
196
|
+
<div class="eyebrow">LOCALMODELS · SIZECALC · 估算,不是实测</div>
|
|
197
|
+
<button class="theme" id="theme" type="button">切换深浅色</button>
|
|
198
|
+
</div>
|
|
199
|
+
<h1>模型体量计算器</h1>
|
|
200
|
+
<p class="lede">给出模型是稠密还是 MoE、总参数和激活参数、量化方案,算出权重文件多大、跑起来占多少显存和内存,以及最小能放进哪一档设备:手机、轻薄本、家用 N 卡、大内存 Mac、工作站、单张服务器卡,还是 8 卡服务器。</p>
|
|
201
|
+
</header>
|
|
202
|
+
|
|
203
|
+
<div class="bench">
|
|
204
|
+
<aside class="controls" aria-label="参数">
|
|
205
|
+
<div class="group">
|
|
206
|
+
<div class="gt">预设模型</div>
|
|
207
|
+
<div class="presets" id="presets"></div>
|
|
208
|
+
<p class="hint">预设的 KV 每 token 取自各自 config.json;其余参数可以随意改。</p>
|
|
209
|
+
</div>
|
|
210
|
+
<div class="group">
|
|
211
|
+
<div class="gt">模型形状</div>
|
|
212
|
+
<div class="seg" role="radiogroup" aria-label="结构">
|
|
213
|
+
<input type="radio" name="kind" id="k-dense" value="dense" checked><label for="k-dense">稠密 Dense</label>
|
|
214
|
+
<input type="radio" name="kind" id="k-moe" value="moe"><label for="k-moe">混合专家 MoE</label>
|
|
215
|
+
</div>
|
|
216
|
+
<div class="row2">
|
|
217
|
+
<div class="field"><label for="params">总参数 <span class="hint">B</span></label><input type="number" id="params" min="0.05" step="any" value="27"></div>
|
|
218
|
+
<div class="field" id="active-field"><label for="active">激活参数 <span class="hint">B</span></label><input type="number" id="active" min="0.05" step="any" value="3"></div>
|
|
219
|
+
</div>
|
|
220
|
+
<div class="field">
|
|
221
|
+
<label for="attention">注意力类型 <span class="val" id="kv-val"></span></label>
|
|
222
|
+
<select id="attention">
|
|
223
|
+
<option value="full">全注意力 GQA(Llama、Qwen3)</option>
|
|
224
|
+
<option value="swa">滑窗混合(Gemma 3、gpt-oss)</option>
|
|
225
|
+
<option value="hybrid">线性 / SSM 混合(Qwen3.5+、Nemotron-H)</option>
|
|
226
|
+
<option value="mla">MLA 潜向量(DeepSeek、Kimi)</option>
|
|
227
|
+
</select>
|
|
228
|
+
</div>
|
|
229
|
+
<div class="field">
|
|
230
|
+
<label for="kvpt">KV 每 token <span class="hint">KiB,f16,留空则按参数估</span></label>
|
|
231
|
+
<input type="number" id="kvpt" min="0" step="any" placeholder="自动估算">
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
<div class="group">
|
|
235
|
+
<div class="gt">量化</div>
|
|
236
|
+
<div class="field">
|
|
237
|
+
<label for="quant">量化方案 <span class="val" id="bits-val"></span></label>
|
|
238
|
+
<select id="quant"></select>
|
|
239
|
+
</div>
|
|
240
|
+
<div class="field" id="custom-field" hidden>
|
|
241
|
+
<label for="custom-bits">每权重位数 <span class="hint">bpw</span></label>
|
|
242
|
+
<input type="number" id="custom-bits" min="1" max="32" step="0.05" value="4.0">
|
|
243
|
+
</div>
|
|
244
|
+
<div class="field">
|
|
245
|
+
<label for="filesize">权重文件大小 <span class="hint">GB,已知则填,可反推</span></label>
|
|
246
|
+
<input type="number" id="filesize" min="0" step="any" placeholder="按参数 × 位数算">
|
|
247
|
+
</div>
|
|
248
|
+
<div class="seg" role="radiogroup" aria-label="已知文件大小时反推什么" id="infer-seg">
|
|
249
|
+
<input type="radio" name="infer" id="i-bits" value="bits" checked><label for="i-bits">反推位数</label>
|
|
250
|
+
<input type="radio" name="infer" id="i-params" value="params"><label for="i-params">反推参数量</label>
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
<div class="group">
|
|
254
|
+
<div class="gt">运行姿态</div>
|
|
255
|
+
<div class="field">
|
|
256
|
+
<label for="ctx">上下文 / 每路 <span class="val" id="ctx-val"></span></label>
|
|
257
|
+
<input type="range" id="ctx" min="0" max="8" step="1" value="1">
|
|
258
|
+
</div>
|
|
259
|
+
<div class="row2">
|
|
260
|
+
<div class="field"><label for="slots">并发路数</label><input type="number" id="slots" min="1" max="64" step="1" value="1"></div>
|
|
261
|
+
<div class="field"><label for="kvtype">KV 类型</label>
|
|
262
|
+
<select id="kvtype"><option value="f16">f16 / bf16</option><option value="fp8">fp8</option><option value="q8_0">q8_0</option><option value="q4_0">q4_0</option></select></div>
|
|
263
|
+
</div>
|
|
264
|
+
<div class="field">
|
|
265
|
+
<label for="hostram">PC 系统内存 <span class="hint">GB,给家用卡卸载用</span></label>
|
|
266
|
+
<input type="number" id="hostram" min="0" step="8" value="64">
|
|
267
|
+
</div>
|
|
268
|
+
</div>
|
|
269
|
+
<p class="err" id="err" role="alert"></p>
|
|
270
|
+
</aside>
|
|
271
|
+
|
|
272
|
+
<main class="results">
|
|
273
|
+
<section class="readouts" aria-label="结论">
|
|
274
|
+
<div class="tile hero"><span class="tl">量级:最小能放进</span><span class="tv" id="r-tier">—</span><span class="ts" id="r-tier-s"></span></div>
|
|
275
|
+
<div class="tile"><span class="tl">权重文件</span><span class="tv" id="r-file">—</span><span class="ts" id="r-file-s"></span></div>
|
|
276
|
+
<div class="tile"><span class="tl">运行占用(默认引擎)</span><span class="tv" id="r-run">—</span><span class="ts" id="r-run-s"></span></div>
|
|
277
|
+
<div class="tile"><span class="tl">每 token 读取</span><span class="tv" id="r-read">—</span><span class="ts" id="r-read-s"></span></div>
|
|
278
|
+
</section>
|
|
279
|
+
<div class="notes" id="notes"></div>
|
|
280
|
+
|
|
281
|
+
<section class="panel">
|
|
282
|
+
<div class="panel-head">
|
|
283
|
+
<h2>内存标尺:每档设备能给模型多少</h2>
|
|
284
|
+
<p>横轴是对数内存(GiB);点是每台设备扣掉系统与引擎预留后的可用量</p>
|
|
285
|
+
</div>
|
|
286
|
+
<div class="legend">
|
|
287
|
+
<span><i style="background:var(--good)"></i>放得下</span>
|
|
288
|
+
<span><i style="background:var(--s-off)"></i>借系统内存卸载</span>
|
|
289
|
+
<span><i style="background:var(--none)"></i>放不下</span>
|
|
290
|
+
<span><i class="line"></i>运行所需(权重 + KV + 引擎)</span>
|
|
291
|
+
<span><i class="dash"></i>只算权重</span>
|
|
292
|
+
</div>
|
|
293
|
+
<div class="chart-wrap" id="ruler-wrap">
|
|
294
|
+
<svg id="ruler" role="img" aria-label="各档设备可用内存与模型需求"></svg>
|
|
295
|
+
<div class="tip" id="tip" hidden></div>
|
|
296
|
+
</div>
|
|
297
|
+
</section>
|
|
298
|
+
|
|
299
|
+
<section class="panel">
|
|
300
|
+
<div class="panel-head">
|
|
301
|
+
<h2 id="dev-title">设备明细</h2>
|
|
302
|
+
<p>点一行看它的内存拆分。tok/s 是单路 decode 的带宽上限,实测通常只到它的一半到八成</p>
|
|
303
|
+
</div>
|
|
304
|
+
<div class="mbar" id="mbar"></div>
|
|
305
|
+
<div class="scroll">
|
|
306
|
+
<table id="devtable">
|
|
307
|
+
<thead><tr><th>设备</th><th>引擎</th><th>格式</th><th class="n">需要</th><th class="n">可用</th><th>结论</th><th class="n">tok/s ≤</th></tr></thead>
|
|
308
|
+
<tbody></tbody>
|
|
309
|
+
</table>
|
|
310
|
+
</div>
|
|
311
|
+
</section>
|
|
312
|
+
|
|
313
|
+
<div class="two">
|
|
314
|
+
<section class="panel">
|
|
315
|
+
<div class="panel-head"><h2>同一模型换量化</h2><p>文件大小,以及最小能放进的档位</p></div>
|
|
316
|
+
<div class="lad" id="ladder"></div>
|
|
317
|
+
</section>
|
|
318
|
+
<section class="panel">
|
|
319
|
+
<div class="panel-head"><h2>命令行</h2><p>同一套表和公式</p></div>
|
|
320
|
+
<div class="cmd"><span id="cmd"></span><button type="button" id="copy">复制</button></div>
|
|
321
|
+
<div class="prose">
|
|
322
|
+
<p><code>sizecalc --json</code> 输出 <code>localmodels.sizecalc/v1</code>,<code>--devices all</code> 列出每台设备。具体某个模型的上下文曲线用 <code>memcalc</code>,它也会打印真实的 KV 每 token,可以填回左边。</p>
|
|
323
|
+
</div>
|
|
324
|
+
</section>
|
|
325
|
+
</div>
|
|
326
|
+
|
|
327
|
+
<section class="panel">
|
|
328
|
+
<div class="panel-head"><h2>量化方案速查</h2><p>典型文件的平均每权重位数,含嵌入和不量化的层</p></div>
|
|
329
|
+
<div class="scroll">
|
|
330
|
+
<table id="fmttable">
|
|
331
|
+
<thead><tr><th>格式</th><th>家族</th><th class="n">bpw</th><th>来源</th><th class="n">1B 参数</th><th>默认引擎</th><th>说明</th></tr></thead>
|
|
332
|
+
<tbody></tbody>
|
|
333
|
+
</table>
|
|
334
|
+
</div>
|
|
335
|
+
</section>
|
|
336
|
+
|
|
337
|
+
<section class="panel" id="method">
|
|
338
|
+
<div class="panel-head"><h2>怎么算的</h2></div>
|
|
339
|
+
<div class="prose">
|
|
340
|
+
<ul>
|
|
341
|
+
<li><b>权重文件</b> = 总参数 × bpw ÷ 8。bpw 是整个文件的平均值,不是名义位宽:GGUF k-quant 把 output 和部分 attn_v / ffn_down 升到 Q6_K,分组量化每组还要存 scale(和 zero),AWQ / GPTQ / FP8 / NF4 通常把嵌入和 lm_head 留在 16 bit。表里「file」是 llama.cpp README 中 Llama-3.1-8B 的整文件实测,「block」只算块结构(整文件会再高 0.2–0.8),「derived」是张量结构加 16 bit 嵌入、按 30B 级模型推算。3B 以下的小模型嵌入占比大,实际文件明显更大(Qwen3-0.6B 的 Q4_K_M 是 5.30 bpw);知道真实文件大小时直接填,最准。</li>
|
|
342
|
+
<li><b>KV 缓存</b> = KV 每 token × 上下文 × 路数 × KV 类型系数(f16 = 1,fp8 = ½,q8_0 = 34/64,q4_0 = 18/64)。没填时按激活参数估:128 KiB × (激活参数 / 8B)<sup>0.45</sup>,以 Llama-3.1-8B 为基准,对 70B、32B、235B-A22B、30B-A3B 误差在 20% 内;滑窗混合约取三分之一,线性 / SSM 混合取四分之一,MLA 取不到三分之一。只有 4 个 KV 头的模型(如 Qwen2.5-7B)实际只有估值的一半。</li>
|
|
343
|
+
<li><b>引擎开销</b>:llama.cpp 用仓库在 CUDA 上实测的常数(进程 448 MiB + 计算缓冲 612 MiB + 上下文 × 512 × 2 字节);vLLM 估 2 GiB 且只占整卡 92%(<code>gpu_memory_utilization</code> 默认值);MLX 估 1.05 GiB。</li>
|
|
344
|
+
<li><b>可用内存</b>:独立显卡扣 1 GiB(分配器余量 + 显示);Mac 取 Metal 默认工作集(仓库实测 16/24 GB 机型为 74%)与「总量 − 系统预留 − 2 GiB」的较小者,再扣 0.5 GiB;安卓按 Android 17 Memory Limiter 给前台 App 的上限(8 / 12 / 16 GB 机型 5 / 8 / 10 GiB);iOS 没有公开数字,暂按一半 RAM,真机以 <code>os_proc_available_memory()</code> 为准。8 卡服务器按张量并行合计。</li>
|
|
345
|
+
<li><b>卸载</b>:只算家用 N 卡 + 系统内存,按 llama.cpp 的做法:MoE 把路由专家(<code>--n-cpu-moe</code>)挪到内存,注意力、共享部分和 KV 留在卡上;稠密模型整层连同这些层的 KV(<code>-ngl</code>)挪过去。系统内存要留 4 GiB 和 llama-server 的 0.86 GiB。MoE 按「激活参数里一半在路由专家之外」切分(Qwen3-30B-A3B 1.5 / 3.3B、gpt-oss-120b 2.5 / 5.1B、DeepSeek V3 17 / 37B),Mixtral 这类 8 选 2 的老 MoE 卡上部分会估高。</li>
|
|
346
|
+
<li><b>速度上限</b> = 带宽 ÷ 每 token 读取的字节(激活权重 + 一路的 KV);卸载时把显卡和内存两段读取时间相加。多卡忽略通信。</li>
|
|
347
|
+
<li><b>格式支持</b>:<span class="tag">native</span> 原生 kernel;<span class="tag fallback">fallback</span> 能跑但走回退路径(如 Ampere 上的 FP8 Marlin);<span class="tag convert">convert</span> 这台设备不跑这种格式,按同样大小换成 GGUF / MLX 计算。</li>
|
|
348
|
+
</ul>
|
|
349
|
+
<p id="refs-intro"><b>参考与对照的现有工具</b>(逐项比较见 <code>research/2026-11-13-model-size-tools.md</code>):</p>
|
|
350
|
+
<ul id="refs"></ul>
|
|
351
|
+
</div>
|
|
352
|
+
</section>
|
|
353
|
+
</main>
|
|
354
|
+
</div>
|
|
355
|
+
</div>
|
|
356
|
+
<script>
|
|
357
|
+
/*@DATA@*/
|
|
358
|
+
/*@CALC@*/
|
|
359
|
+
/*@APP@*/
|
|
360
|
+
</script>
|
|
361
|
+
</body>
|
|
362
|
+
</html>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Client logo sources
|
|
2
|
+
|
|
3
|
+
These official assets were downloaded on November 10, 2026 and copied without changes.
|
|
4
|
+
|
|
5
|
+
| Local asset | Attribution and source | SHA256 |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| `logo-pi.svg` | pi. [Official logo](https://pi.dev/logo-auto.svg) from [pi.dev](https://pi.dev). | `abd66e7868b2d24f0f0895f9237ee8a6dcb22337583b0dc54aeb595acecb4d6b` |
|
|
8
|
+
| `logo-claude.svg` | Anthropic Claude. [Official icon](https://claude.com/icon.svg). Used for Claude and Claude Code. | `b150888bc7257af83e3b85d3c2be4294f88986026f8168f6c12fc1fde6697350` |
|
|
9
|
+
| `logo-codex.png` | OpenAI Codex. [Official app icon](https://images.ctfassets.net/8su2tbn87fck/37ep8OPlSuUYpcTFkkW9NO/1a6381ac6612a83ec6d07b3fac5c5228/Blossom_4k_Icon_1.png?w=128&h=128&fit=fill&fm=png), selected as the Codex app icon by [the Codex page](https://chatgpt.com/codex). | `c1a05012ec3675d31a73c7a678a9ea952d57a100a0e0994c6b086af18690f655` |
|
|
10
|
+
|
|
11
|
+
The brand marks remain the property of their respective owners. Their use identifies the clients and does not imply endorsement.
|