quantized-uk 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +19 -2
- package/bin/quantized-uk.mjs +367 -0
- package/package.json +28 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 quantized.uk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `quantized-uk` CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Detect your GPU or Apple Silicon Mac **100% locally** and see which open-weight LLMs fit your VRAM — using the exact same published file bytes, hybrid-attention KV math, and quality-floor rules as [quantized.uk/tools/vram-calc/](https://quantized.uk/tools/vram-calc/).
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Auto-detect local GPU (nvidia-smi / rocm-smi) or Apple Silicon (system_profiler)
|
|
9
|
+
npx quantized-uk
|
|
10
|
+
|
|
11
|
+
# Override VRAM, context length, KV cache precision, or workload
|
|
12
|
+
npx quantized-uk --vram 24 --ctx 32768 --kv q8_0 --use-case coding
|
|
13
|
+
npx quantized-uk --mac 64 --use-case agent
|
|
14
|
+
npx quantized-uk --gpu rtx4090 --json
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Privacy
|
|
18
|
+
|
|
19
|
+
- Zero dependencies, Node.js 18+.
|
|
20
|
+
- Hardware detection runs entirely on your machine; only `GET https://quantized.uk/data/v1/models.json` and `gpus.json` (CC BY 4.0) are fetched.
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* quantized-uk CLI — 100% local hardware detection + architecture-aware LLM fit ranking.
|
|
4
|
+
* Zero runtime dependencies (Node.js 18+). No telemetry: hardware detection never leaves your machine.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* npx quantized-uk
|
|
8
|
+
* npx quantized-uk --vram 24 --ctx 32768 --kv q8_0 --use-case coding
|
|
9
|
+
* npx quantized-uk --mac 64 --json
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { execFileSync } from 'node:child_process';
|
|
13
|
+
import { readFileSync } from 'node:fs';
|
|
14
|
+
import { join } from 'node:path';
|
|
15
|
+
|
|
16
|
+
const SITE_URL = 'https://quantized.uk';
|
|
17
|
+
const KV_BYTES = { f16: 2, q8_0: 34 / 32, q4_0: 18 / 32 };
|
|
18
|
+
const WEIGHT_OVERHEAD = 0.02;
|
|
19
|
+
const ACTIVATION_BUFFER = 0.10;
|
|
20
|
+
const COMFORTABLE_RATIO = 0.88;
|
|
21
|
+
const SUB4_RE = /^(?:IQ[123]|Q[123]|EXL[23]\s*[123](?:\.\d+)?bpw|HQQ\s*2bit|Q8_0-expsIQ[12])/i;
|
|
22
|
+
|
|
23
|
+
function parseArgs(argv) {
|
|
24
|
+
const opts = {
|
|
25
|
+
vram: null,
|
|
26
|
+
mac: null,
|
|
27
|
+
gpu: null,
|
|
28
|
+
ctx: 8192,
|
|
29
|
+
kv: 'f16',
|
|
30
|
+
useCase: 'all',
|
|
31
|
+
limit: 8,
|
|
32
|
+
json: false,
|
|
33
|
+
offline: null,
|
|
34
|
+
help: false,
|
|
35
|
+
};
|
|
36
|
+
for (let i = 0; i < argv.length; i++) {
|
|
37
|
+
const a = argv[i];
|
|
38
|
+
const next = () => argv[++i];
|
|
39
|
+
if (a === '-h' || a === '--help') opts.help = true;
|
|
40
|
+
else if (a === '--json') opts.json = true;
|
|
41
|
+
else if (a === '--vram') opts.vram = Number(next());
|
|
42
|
+
else if (a === '--mac') opts.mac = Number(next());
|
|
43
|
+
else if (a === '--gpu') opts.gpu = String(next() || '').toLowerCase();
|
|
44
|
+
else if (a === '--ctx') opts.ctx = Number(next());
|
|
45
|
+
else if (a === '--kv') opts.kv = String(next() || 'f16').toLowerCase();
|
|
46
|
+
else if (a === '--use-case') opts.useCase = String(next() || 'all').toLowerCase();
|
|
47
|
+
else if (a === '--limit') opts.limit = Math.max(1, Math.min(50, Number(next()) || 8));
|
|
48
|
+
else if (a === '--offline') opts.offline = String(next() || '');
|
|
49
|
+
}
|
|
50
|
+
if (!Object.prototype.hasOwnProperty.call(KV_BYTES, opts.kv)) opts.kv = 'f16';
|
|
51
|
+
if (!Number.isFinite(opts.ctx) || opts.ctx < 512) opts.ctx = 8192;
|
|
52
|
+
return opts;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function printHelp() {
|
|
56
|
+
console.log(`quantized-uk — Find the best local LLMs for your GPU or Mac
|
|
57
|
+
|
|
58
|
+
Usage:
|
|
59
|
+
npx quantized-uk [options]
|
|
60
|
+
|
|
61
|
+
Options:
|
|
62
|
+
--vram <GB> Override discrete GPU VRAM in GB (e.g. 12, 16, 24)
|
|
63
|
+
--mac <GB> Override Apple Silicon unified memory in GB (75% Metal budget)
|
|
64
|
+
--gpu <id> Match a specific catalog GPU ID (e.g. rtx4090, m4-max-64)
|
|
65
|
+
--ctx <tokens> Target context length (default: 8192; e.g. 32768)
|
|
66
|
+
--kv <type> KV cache precision: f16 | q8_0 | q4_0 (default: f16)
|
|
67
|
+
--use-case <kind> Filter: all | coding | agent | vision (default: all)
|
|
68
|
+
--limit <N> Number of top models to show (default: 8)
|
|
69
|
+
--json Emit machine-readable JSON for scripts & AI agents
|
|
70
|
+
--offline <dir> Load models.json & gpus.json from a local directory
|
|
71
|
+
-h, --help Show this help
|
|
72
|
+
`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function tryExec(cmd, args) {
|
|
76
|
+
try {
|
|
77
|
+
return execFileSync(cmd, args, { encoding: 'utf8', timeout: 4000, stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
78
|
+
} catch {
|
|
79
|
+
return '';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function detectLocalHardware() {
|
|
84
|
+
// 1. Apple Silicon macOS
|
|
85
|
+
if (process.platform === 'darwin') {
|
|
86
|
+
const out = tryExec('system_profiler', ['SPHardwareDataType']);
|
|
87
|
+
const chip = out.match(/Chip:\s*(.+)/i)?.[1]?.trim();
|
|
88
|
+
const memMatch = out.match(/Memory:\s*(\d+)\s*GB/i);
|
|
89
|
+
if (chip && memMatch) {
|
|
90
|
+
const totalGB = Number(memMatch[1]);
|
|
91
|
+
return {
|
|
92
|
+
label: `${chip} (${totalGB} GB Unified)`,
|
|
93
|
+
vramGB: totalGB,
|
|
94
|
+
usableGB: Math.round(totalGB * 0.75 * 10) / 10,
|
|
95
|
+
reserveGB: 0,
|
|
96
|
+
backend: 'mlx',
|
|
97
|
+
unified: true,
|
|
98
|
+
source: 'system_profiler',
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// 2. NVIDIA GPU(s)
|
|
103
|
+
const nv = tryExec('nvidia-smi', ['--query-gpu=name,memory.total,memory.free', '--format=csv,noheader,nounits']);
|
|
104
|
+
if (nv) {
|
|
105
|
+
const rows = nv.split('\n').map(l => l.split(',').map(x => x.trim())).filter(r => r.length >= 2);
|
|
106
|
+
if (rows.length > 0) {
|
|
107
|
+
const totalMiB = rows.reduce((s, r) => s + (Number(r[1]) || 0), 0);
|
|
108
|
+
const freeMiB = rows.reduce((s, r) => s + (Number(r[2]) || 0), 0);
|
|
109
|
+
const totalGB = Math.round((totalMiB / 1024) * 10) / 10;
|
|
110
|
+
const freeGB = freeMiB > 0 ? Math.round((freeMiB / 1024) * 10) / 10 : null;
|
|
111
|
+
const reserveGB = freeGB !== null ? Math.max(0, Math.round((totalGB - freeGB) * 100) / 100) : 1.5;
|
|
112
|
+
const name = rows.length > 1 ? `${rows.length}× ${rows[0][0]}` : rows[0][0];
|
|
113
|
+
return {
|
|
114
|
+
label: `${name} (${totalGB} GB)`,
|
|
115
|
+
vramGB: totalGB,
|
|
116
|
+
usableGB: totalGB,
|
|
117
|
+
reserveGB,
|
|
118
|
+
backend: 'cuda',
|
|
119
|
+
unified: false,
|
|
120
|
+
source: 'nvidia-smi',
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// 3. AMD ROCm fallback
|
|
125
|
+
const rocm = tryExec('rocm-smi', ['--showmeminfo', 'vram']);
|
|
126
|
+
if (rocm) {
|
|
127
|
+
const totalMatch = rocm.match(/VRAM Total Memory \(B\):\s*(\d+)/i);
|
|
128
|
+
if (totalMatch) {
|
|
129
|
+
const totalGB = Math.round((Number(totalMatch[1]) / 1024 ** 3) * 10) / 10;
|
|
130
|
+
return {
|
|
131
|
+
label: `AMD ROCm GPU (${totalGB} GB)`,
|
|
132
|
+
vramGB: totalGB,
|
|
133
|
+
usableGB: totalGB,
|
|
134
|
+
reserveGB: 1.0,
|
|
135
|
+
backend: 'rocm',
|
|
136
|
+
unified: false,
|
|
137
|
+
source: 'rocm-smi',
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function calcModelVRAM(model, quant, ctx, kvType) {
|
|
145
|
+
const kvVal = KV_BYTES[kvType] ?? 2;
|
|
146
|
+
const exactBytes = quant.source?.bytes ?? quant.publishedBytes;
|
|
147
|
+
const weightBasisGB = exactBytes !== undefined
|
|
148
|
+
? exactBytes / 1024 ** 3
|
|
149
|
+
: (model.paramsB * 1e9 * (quant.bpw / 8)) / 1024 ** 3;
|
|
150
|
+
const modelWeightsGB = weightBasisGB * (1 + WEIGHT_OVERHEAD);
|
|
151
|
+
|
|
152
|
+
const arch = model.arch || {};
|
|
153
|
+
const layers = arch.layers || 32;
|
|
154
|
+
const kvHeads = arch.kvHeads || 8;
|
|
155
|
+
const headDim = arch.headDim || 128;
|
|
156
|
+
const att = arch.attention;
|
|
157
|
+
|
|
158
|
+
const perLayer = 2 * kvHeads * headDim * kvVal;
|
|
159
|
+
const fullPerLayer = 2 * (att?.fullKvHeads ?? kvHeads) * (att?.fullHeadDim ?? headDim) * kvVal;
|
|
160
|
+
const fullLayers = att?.fullLayers ?? layers;
|
|
161
|
+
const windowLayers = att?.windowLayers ?? 0;
|
|
162
|
+
const windowSpan = Math.min(ctx, att?.windowTokens ?? ctx);
|
|
163
|
+
const compressedBytes = (att?.compressed ?? []).reduce((sum, c) => {
|
|
164
|
+
const rows = Math.ceil(ctx / c.ratio);
|
|
165
|
+
const padded = c.pad ? Math.ceil(rows / c.pad) * c.pad : rows;
|
|
166
|
+
return sum + c.layers * c.values * padded * kvVal;
|
|
167
|
+
}, 0);
|
|
168
|
+
const kvCacheGB = (fullPerLayer * fullLayers * ctx + perLayer * windowLayers * windowSpan + compressedBytes) / 1024 ** 3;
|
|
169
|
+
const activationsGB = (modelWeightsGB + kvCacheGB) * ACTIVATION_BUFFER;
|
|
170
|
+
return Math.round((modelWeightsGB + kvCacheGB + activationsGB) * 100) / 100;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function formatAllowedForBackend(backend, format) {
|
|
174
|
+
if (format === 'GGUF') return true;
|
|
175
|
+
if (format === 'MLX') return backend === 'mlx' || backend === 'metal';
|
|
176
|
+
if (backend === 'cuda') return ['AWQ', 'GPTQ', 'EXL2', 'EXL3', 'HQQ', 'NVFP4'].includes(format);
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async function loadCatalog(offlineDir) {
|
|
181
|
+
if (offlineDir) {
|
|
182
|
+
const modelsData = JSON.parse(readFileSync(join(offlineDir, 'models.json'), 'utf8'));
|
|
183
|
+
const gpusData = JSON.parse(readFileSync(join(offlineDir, 'gpus.json'), 'utf8'));
|
|
184
|
+
return { modelsData, gpusData };
|
|
185
|
+
}
|
|
186
|
+
const fetchJson = async (url) => {
|
|
187
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(10000) });
|
|
188
|
+
if (!res.ok) throw new Error(`HTTP ${res.status} fetching ${url}`);
|
|
189
|
+
return res.json();
|
|
190
|
+
};
|
|
191
|
+
const [modelsData, gpusData] = await Promise.all([
|
|
192
|
+
fetchJson(`${SITE_URL}/data/v1/models.json`),
|
|
193
|
+
fetchJson(`${SITE_URL}/data/v1/gpus.json`),
|
|
194
|
+
]);
|
|
195
|
+
return { modelsData, gpusData };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function matchCatalogGpu(hw, gpus) {
|
|
199
|
+
if (!hw) return null;
|
|
200
|
+
const norm = s => String(s).toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim();
|
|
201
|
+
const hay = ` ${norm(hw.label)} `;
|
|
202
|
+
let best = null;
|
|
203
|
+
let bestLen = 0;
|
|
204
|
+
for (const g of gpus) {
|
|
205
|
+
if (g.cpuOnly) continue;
|
|
206
|
+
const key = norm(g.name.replace(/\s\d+\s?GB?\b/gi, ''));
|
|
207
|
+
if (key && hay.includes(` ${key} `) && Math.abs(g.vramGB - hw.vramGB) <= 2) {
|
|
208
|
+
if (key.length > bestLen) { best = g; bestLen = key.length; }
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return best;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async function main() {
|
|
215
|
+
const opts = parseArgs(process.argv.slice(2));
|
|
216
|
+
if (opts.help) { printHelp(); return; }
|
|
217
|
+
|
|
218
|
+
const { modelsData, gpusData } = await loadCatalog(opts.offline);
|
|
219
|
+
const gpus = gpusData.gpus || [];
|
|
220
|
+
let hw = null;
|
|
221
|
+
let catalogGpu = null;
|
|
222
|
+
|
|
223
|
+
if (opts.gpu) {
|
|
224
|
+
catalogGpu = gpus.find(g => g.id.toLowerCase() === opts.gpu);
|
|
225
|
+
if (!catalogGpu) {
|
|
226
|
+
console.error(`Unknown GPU id "${opts.gpu}". Try e.g. rtx4090, rtx3060, rtx5090, m4-max-64.`);
|
|
227
|
+
process.exitCode = 1;
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
hw = {
|
|
231
|
+
label: catalogGpu.name,
|
|
232
|
+
vramGB: catalogGpu.vramGB,
|
|
233
|
+
usableGB: catalogGpu.usableGB,
|
|
234
|
+
reserveGB: catalogGpu.unified ? 0 : 1.5,
|
|
235
|
+
backend: catalogGpu.backend,
|
|
236
|
+
unified: Boolean(catalogGpu.unified),
|
|
237
|
+
source: '--gpu',
|
|
238
|
+
};
|
|
239
|
+
} else if (opts.mac) {
|
|
240
|
+
hw = {
|
|
241
|
+
label: `Apple Silicon (${opts.mac} GB Unified)`,
|
|
242
|
+
vramGB: opts.mac,
|
|
243
|
+
usableGB: Math.round(opts.mac * 0.75 * 10) / 10,
|
|
244
|
+
reserveGB: 0,
|
|
245
|
+
backend: 'mlx',
|
|
246
|
+
unified: true,
|
|
247
|
+
source: '--mac',
|
|
248
|
+
};
|
|
249
|
+
} else if (opts.vram) {
|
|
250
|
+
hw = {
|
|
251
|
+
label: `Discrete GPU (${opts.vram} GB VRAM)`,
|
|
252
|
+
vramGB: opts.vram,
|
|
253
|
+
usableGB: opts.vram,
|
|
254
|
+
reserveGB: 1.5,
|
|
255
|
+
backend: 'cuda',
|
|
256
|
+
unified: false,
|
|
257
|
+
source: '--vram',
|
|
258
|
+
};
|
|
259
|
+
} else {
|
|
260
|
+
hw = detectLocalHardware();
|
|
261
|
+
if (!hw) {
|
|
262
|
+
console.error('Could not auto-detect GPU/Mac. Pass --vram <GB>, --mac <GB>, or --gpu <id> (e.g. --vram 24).');
|
|
263
|
+
process.exitCode = 1;
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
catalogGpu = matchCatalogGpu(hw, gpus);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const effectiveCtx = opts.useCase === 'agent' ? Math.max(opts.ctx, 32768) : opts.ctx;
|
|
270
|
+
const effectiveKv = opts.useCase === 'agent' && opts.kv === 'f16' ? 'q8_0' : opts.kv;
|
|
271
|
+
|
|
272
|
+
const picks = [];
|
|
273
|
+
for (const m of modelsData.models || []) {
|
|
274
|
+
if (m.status === 'superseded') continue;
|
|
275
|
+
if (effectiveCtx > m.contextLength) continue;
|
|
276
|
+
if (opts.useCase === 'coding' && !(m.categories || []).includes('code')) continue;
|
|
277
|
+
if (opts.useCase === 'agent' && (!(m.categories || []).includes('code') || !m.capabilities?.toolCalling)) continue;
|
|
278
|
+
if (opts.useCase === 'vision' && !m.capabilities?.imageInput) continue;
|
|
279
|
+
|
|
280
|
+
let best = null;
|
|
281
|
+
for (const q of m.quants || []) {
|
|
282
|
+
if (!formatAllowedForBackend(hw.backend, q.format)) continue;
|
|
283
|
+
if (q.bpw < 4 || SUB4_RE.test(q.level)) continue;
|
|
284
|
+
const workload = calcModelVRAM(m, q, effectiveCtx, effectiveKv);
|
|
285
|
+
const totalGB = Math.round((workload + hw.reserveGB) * 100) / 100;
|
|
286
|
+
const ratio = totalGB / hw.usableGB;
|
|
287
|
+
if (ratio > 1.0) continue;
|
|
288
|
+
const fit = ratio <= COMFORTABLE_RATIO ? 'comfortable' : 'tight';
|
|
289
|
+
if (!best || (fit === 'comfortable' && best.fit !== 'comfortable') || (fit === best.fit && q.bpw > best.quant.bpw)) {
|
|
290
|
+
best = { quant: q, totalGB, fit, utilPct: Math.round(ratio * 100) };
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (best) {
|
|
294
|
+
const cmd = best.quant.format === 'GGUF' && best.quant.source?.repo
|
|
295
|
+
? `llama-server ${best.quant.source.file ? `-hfr ${best.quant.source.repo} -hff ${best.quant.source.file}` : `-hf ${best.quant.source.repo}:${best.quant.level}`} -ngl 999 -c ${effectiveCtx}${effectiveKv !== 'f16' ? ` -fa on -ctk ${effectiveKv} -ctv ${effectiveKv}` : ''}`
|
|
296
|
+
: (hw.unified && m.mlxRepo ? `mlx_lm.server --model ${m.mlxRepo}` : null);
|
|
297
|
+
picks.push({
|
|
298
|
+
id: m.id,
|
|
299
|
+
name: m.name,
|
|
300
|
+
paramsB: m.paramsB,
|
|
301
|
+
quant: `${best.quant.format} ${best.quant.level}`,
|
|
302
|
+
totalGB: best.totalGB,
|
|
303
|
+
utilPct: best.utilPct,
|
|
304
|
+
fit: best.fit,
|
|
305
|
+
maxCtx: m.contextLength,
|
|
306
|
+
liveBench: m.quality?.liveBench?.score ?? null,
|
|
307
|
+
command: cmd,
|
|
308
|
+
calculatorUrl: `${SITE_URL}/tools/vram-calc/?mode=forward&model=${m.id}&quant=${encodeURIComponent(best.quant.format === 'GGUF' ? best.quant.level : `${best.quant.format} ${best.quant.level}`)}&ctx=${effectiveCtx}&cache=${effectiveKv}${catalogGpu ? `&gpu=${catalogGpu.id}` : ''}`,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
picks.sort((a, b) => {
|
|
314
|
+
if (a.fit !== b.fit) return a.fit === 'comfortable' ? -1 : 1;
|
|
315
|
+
if (b.paramsB !== a.paramsB) return b.paramsB - a.paramsB;
|
|
316
|
+
return (b.liveBench ?? 0) - (a.liveBench ?? 0);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
const top = picks.slice(0, opts.limit);
|
|
320
|
+
const webUrl = `${SITE_URL}/tools/vram-calc/?mode=reverse${catalogGpu ? `&gpu=${catalogGpu.id}` : ''}&ctx=${effectiveCtx}&cache=${effectiveKv}`;
|
|
321
|
+
|
|
322
|
+
if (opts.json) {
|
|
323
|
+
console.log(JSON.stringify({
|
|
324
|
+
source: SITE_URL,
|
|
325
|
+
dataLastUpdated: modelsData.dataLastUpdated,
|
|
326
|
+
hardware: hw,
|
|
327
|
+
catalogGpuId: catalogGpu?.id ?? null,
|
|
328
|
+
contextLength: effectiveCtx,
|
|
329
|
+
kvCache: effectiveKv,
|
|
330
|
+
useCase: opts.useCase,
|
|
331
|
+
totalMatches: picks.length,
|
|
332
|
+
picks: top,
|
|
333
|
+
calculatorUrl: webUrl,
|
|
334
|
+
}, null, 2));
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
console.log(`\nquantized.uk CLI · Catalog ${modelsData.dataLastUpdated} (${modelsData.count} models)`);
|
|
339
|
+
console.log(`Hardware : ${hw.label} · Usable ${hw.usableGB} GiB (reserve ${hw.reserveGB} GiB) [${hw.source}]`);
|
|
340
|
+
console.log(`Workload : ${opts.useCase} · ${Math.round(effectiveCtx / 1024)}K context · KV ${effectiveKv}\n`);
|
|
341
|
+
|
|
342
|
+
if (top.length === 0) {
|
|
343
|
+
console.log('No ≥4-bit models fit comfortably with these constraints. Try --kv q8_0 or lower --ctx.');
|
|
344
|
+
console.log(`Explore offload & sub-4-bit options: ${webUrl}\n`);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const pad = (s, n) => String(s).length >= n ? String(s).slice(0, n - 1) + '…' : String(s).padEnd(n);
|
|
349
|
+
console.log(`${pad('#', 3)} ${pad('Model', 30)} ${pad('Quant', 14)} ${pad('VRAM', 11)} ${pad('Fit', 18)} Score`);
|
|
350
|
+
console.log('-'.repeat(86));
|
|
351
|
+
top.forEach((p, idx) => {
|
|
352
|
+
const score = p.liveBench !== null ? `LB ${p.liveBench}` : '—';
|
|
353
|
+
console.log(
|
|
354
|
+
`${pad(idx + 1, 3)} ${pad(p.name, 30)} ${pad(p.quant, 14)} ${pad(`${p.totalGB.toFixed(1)} GiB`, 11)} ${pad(`${p.fit} (${p.utilPct}%)`, 18)} ${score}`,
|
|
355
|
+
);
|
|
356
|
+
});
|
|
357
|
+
const quick = top.find(p => p.command);
|
|
358
|
+
if (quick) {
|
|
359
|
+
console.log(`\nQuick start (${quick.name} · ${quick.quant}):\n ${quick.command}`);
|
|
360
|
+
}
|
|
361
|
+
console.log(`\nFull interactive calculator & context decay curve:\n ${webUrl}\n`);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
main().catch(err => {
|
|
365
|
+
console.error('quantized-uk CLI error:', err?.message || err);
|
|
366
|
+
process.exitCode = 1;
|
|
367
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quantized-uk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Detect your GPU or Apple Silicon Mac locally and find the best open-weight LLMs that fit your VRAM — powered by quantized.uk's architecture-aware catalog.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"quantized-uk": "./bin/quantized-uk.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"llm",
|
|
19
|
+
"vram",
|
|
20
|
+
"gguf",
|
|
21
|
+
"ollama",
|
|
22
|
+
"llama-cpp",
|
|
23
|
+
"apple-silicon",
|
|
24
|
+
"gpu",
|
|
25
|
+
"quantization",
|
|
26
|
+
"local-ai"
|
|
27
|
+
],
|
|
28
|
+
"homepage": "https://quantized.uk/tools/vram-calc/",
|
|
29
|
+
"license": "MIT"
|
|
30
|
+
}
|