atlas-probe 0.0.0-stage → 1.0.0
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 +86 -3
- package/dist/bench.js +190 -0
- package/dist/config.js +18 -0
- package/dist/detect/amd.js +32 -0
- package/dist/detect/common.js +132 -0
- package/dist/detect/index.js +44 -0
- package/dist/detect/linux-unified.js +37 -0
- package/dist/detect/mac.js +32 -0
- package/dist/detect/nvidia.js +26 -0
- package/dist/index.js +213 -0
- package/dist/profile.js +24 -0
- package/dist/reference.js +22 -0
- package/dist/share.js +41 -0
- package/package.json +31 -6
package/README.md
CHANGED
|
@@ -1,3 +1,86 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# atlas-probe
|
|
2
|
+
|
|
3
|
+
Measure your machine for Atlas, the personal map of AI models and the hardware they run on.
|
|
4
|
+
`atlas-probe` detects your GPU, memory and disk, can time two small models with **your own** llama.cpp,
|
|
5
|
+
and prints a profile you paste into Atlas's **Device test** page to see which open models run on your machine and how fast.
|
|
6
|
+
|
|
7
|
+
Requires Node.js 18 or newer. No install needed:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx atlas-probe # detect hardware, print a summary and the profile JSON
|
|
11
|
+
npx atlas-probe --bench # also time 2 small reference models with llama-bench
|
|
12
|
+
npx atlas-probe --bench --share # ...and share the measured speeds with Atlas
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Options
|
|
16
|
+
|
|
17
|
+
| Option | Does |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| *(none)* | Detect hardware; print a summary and the profile JSON |
|
|
20
|
+
| `--bench` | Download 2 small reference GGUFs once (cached in `~/.cache/atlas-probe`) and run `llama-bench` on each |
|
|
21
|
+
| `--model <repo>:<quant>` | Also benchmark that Hugging Face GGUF, e.g. `unsloth/Qwen3-8B-GGUF:Q4_K_M` (asks before downloads over 5 GB) |
|
|
22
|
+
| `--share` | POST the profile to `${ATLAS_URL}/api/runs` (or `--url`) |
|
|
23
|
+
| `--url <https://…>` | Atlas site to share with; the `ATLAS_URL` environment variable takes precedence |
|
|
24
|
+
| `--json` | Print only the JSON (for piping) |
|
|
25
|
+
| `-h`, `--help` / `-v`, `--version` | Help / version |
|
|
26
|
+
|
|
27
|
+
Reference models (about 3.1 GB in total, downloaded once):
|
|
28
|
+
|
|
29
|
+
- `Qwen/Qwen2.5-1.5B-Instruct-GGUF` Q4_K_M (1.1 GB)
|
|
30
|
+
- `bartowski/Llama-3.2-3B-Instruct-GGUF` Q4_K_M (2.0 GB)
|
|
31
|
+
|
|
32
|
+
## Benchmarking needs llama.cpp
|
|
33
|
+
|
|
34
|
+
`--bench` uses the `llama-bench` tool from llama.cpp, so the speeds are what *your* build gets.
|
|
35
|
+
|
|
36
|
+
- macOS: `brew install llama.cpp`
|
|
37
|
+
- Linux / Windows: download a release for your GPU from <https://github.com/ggml-org/llama.cpp/releases> and put `llama-bench` on your `PATH`
|
|
38
|
+
(or set `LLAMA_BENCH` to its full path).
|
|
39
|
+
|
|
40
|
+
Without it, `--bench` prints this hint and you still get a detect-only profile.
|
|
41
|
+
|
|
42
|
+
Each file runs `llama-bench -m <file> -p 512 -n 128 -r 3 -o json`. From the reference models' known sizes:
|
|
43
|
+
|
|
44
|
+
- effective bandwidth (GB/s) = generation tok/s × active parameters (billions) × bits per weight ÷ 8
|
|
45
|
+
- effective FP16 TFLOPS = prompt tok/s × 2 × active parameters ÷ 0.3 ÷ 10¹²
|
|
46
|
+
|
|
47
|
+
Without `--bench`, bandwidth and compute come from a small table of known devices, or a typical value; the summary labels every number
|
|
48
|
+
as *measured*, *spec sheet*, *reported* or *assumed*.
|
|
49
|
+
|
|
50
|
+
## Detection
|
|
51
|
+
|
|
52
|
+
| Platform | How |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| NVIDIA (Linux, Windows) | `nvidia-smi --query-gpu=name,memory.total,pci.link.gen.current` |
|
|
55
|
+
| AMD (Linux) | `rocm-smi --showproductname --showmeminfo vram --json` |
|
|
56
|
+
| Apple Silicon | `sysctl`, `system_profiler` (machine name, chip, memory only); unified memory, Metal |
|
|
57
|
+
| DGX Spark, Ryzen AI Max, Jetson | GPU or chip name → unified memory from `/proc/meminfo` |
|
|
58
|
+
| Anything else | CPU only |
|
|
59
|
+
|
|
60
|
+
System RAM bandwidth is measured with a short multi-threaded memory copy. Free disk is read from the volume holding
|
|
61
|
+
`~/.cache/atlas-probe`; disk read speed is timed on a cached reference file (approximate).
|
|
62
|
+
|
|
63
|
+
## Privacy
|
|
64
|
+
|
|
65
|
+
The profile holds the device model, memory and speed numbers, file names of the models timed, and a random id stored in
|
|
66
|
+
`~/.config/atlas-probe/id` (used only to rate-limit shares). It never contains files, paths, hostnames or user names, and nothing
|
|
67
|
+
leaves your machine unless you pass `--share`.
|
|
68
|
+
|
|
69
|
+
## Profile JSON
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"probe_version": "1.0.0",
|
|
74
|
+
"device_name_raw": "NVIDIA GB10",
|
|
75
|
+
"arch": "unified", "devices": 1,
|
|
76
|
+
"vram_gb": 0, "memory_gb": 128,
|
|
77
|
+
"measured_bw_gbs": 251, "ram_bw_gbs": 251, "fp16_tflops": 118, "fp8": true,
|
|
78
|
+
"backend": "cuda", "disk_free_gb": 2800, "disk_read_gbs": 6.1,
|
|
79
|
+
"fingerprint": "<random uuid>",
|
|
80
|
+
"runs": [ { "file": "unsloth/Qwen3.8-27B-GGUF:UD-Q4_K_XL", "runtime": "llama.cpp", "runtime_version": "b6123", "ctx": 4096, "gen_tps": 9.6, "prompt_tps": 640, "load_s": 3.1 } ]
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT
|
package/dist/bench.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
// --bench / --model: download GGUFs into ~/.cache/atlas-probe and time them with the user's own llama-bench.
|
|
2
|
+
import { execFile } from 'node:child_process';
|
|
3
|
+
import { mkdir, open, rename, rm, stat } from 'node:fs/promises';
|
|
4
|
+
import { platform } from 'node:os';
|
|
5
|
+
import { basename, join } from 'node:path';
|
|
6
|
+
import { createInterface } from 'node:readline/promises';
|
|
7
|
+
import { ASK_ABOVE_GB, BENCH, CACHE_DIR, CACHE_LABEL, PROBE_VERSION } from './config.js';
|
|
8
|
+
import { round } from './profile.js';
|
|
9
|
+
const log = (s) => process.stderr.write(s + '\n');
|
|
10
|
+
const UA = { 'user-agent': `atlas-probe/${PROBE_VERSION}` };
|
|
11
|
+
// ---- llama-bench -----------------------------------------------------------------------------
|
|
12
|
+
/** The llama-bench command to use (LLAMA_BENCH env overrides PATH), or null when it is not installed. */
|
|
13
|
+
export function findLlamaBench() {
|
|
14
|
+
const cmd = process.env.LLAMA_BENCH || 'llama-bench';
|
|
15
|
+
return new Promise(resolve => {
|
|
16
|
+
try {
|
|
17
|
+
execFile(cmd, ['--help'], { timeout: 15_000, windowsHide: true }, err => {
|
|
18
|
+
const code = err?.code;
|
|
19
|
+
resolve(code === 'ENOENT' || code === 'EACCES' ? null : cmd);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
resolve(null);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export function installHint() {
|
|
28
|
+
const release = 'https://github.com/ggml-org/llama.cpp/releases';
|
|
29
|
+
return platform() === 'darwin'
|
|
30
|
+
? 'llama-bench not found. Install llama.cpp with `brew install llama.cpp`, then run again.'
|
|
31
|
+
: `llama-bench not found. Download a llama.cpp release for your GPU from ${release}, put llama-bench on your PATH (or set LLAMA_BENCH to its full path), then run again.`;
|
|
32
|
+
}
|
|
33
|
+
/** `llama-bench -m <file> -p 512 -n 128 -r 3 -o json` → prompt and generation tok/s. */
|
|
34
|
+
export async function runLlamaBench(cmd, file) {
|
|
35
|
+
const args = ['-m', file, '-p', String(BENCH.prompt), '-n', String(BENCH.gen), '-r', String(BENCH.reps), '-o', 'json'];
|
|
36
|
+
const t0 = Date.now();
|
|
37
|
+
const stdout = await new Promise((resolve, reject) => {
|
|
38
|
+
execFile(cmd, args, { timeout: 20 * 60_000, windowsHide: true, maxBuffer: 64 * 1024 * 1024 }, (err, out, errOut) => {
|
|
39
|
+
if (err)
|
|
40
|
+
reject(new Error(`llama-bench failed: ${String(errOut || err.message).trim().split(/\r?\n/).slice(-3).join(' ')}`));
|
|
41
|
+
else
|
|
42
|
+
resolve(String(out));
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
const wallS = (Date.now() - t0) / 1000;
|
|
46
|
+
const a = stdout.indexOf('['), b = stdout.lastIndexOf(']');
|
|
47
|
+
if (a < 0 || b < a)
|
|
48
|
+
throw new Error('llama-bench printed no JSON');
|
|
49
|
+
const rows = JSON.parse(stdout.slice(a, b + 1));
|
|
50
|
+
const gen = rows.find(r => (r.n_gen ?? 0) > 0 && !(r.n_prompt ?? 0));
|
|
51
|
+
const pp = rows.find(r => (r.n_prompt ?? 0) > 0 && !(r.n_gen ?? 0));
|
|
52
|
+
if (!gen?.avg_ts)
|
|
53
|
+
throw new Error('llama-bench JSON has no generation result');
|
|
54
|
+
const any = gen ?? pp;
|
|
55
|
+
const runtimeVersion = any?.build_number ? `b${any.build_number}` : any?.build_commit ? String(any.build_commit).slice(0, 12) : undefined;
|
|
56
|
+
// load time ≈ wall time minus the timed repetitions and one warm-up per test (approximate)
|
|
57
|
+
const testS = rows.reduce((s, r) => s + (r.samples_ns ?? []).reduce((x, y) => x + y, 0) / 1e9 * (1 + 1 / BENCH.reps), 0);
|
|
58
|
+
const load = wallS - testS;
|
|
59
|
+
return { genTps: gen.avg_ts, promptTps: pp?.avg_ts ?? null, runtimeVersion, loadS: load > 0.05 ? round(load, 1) : undefined };
|
|
60
|
+
}
|
|
61
|
+
export const toRun = (fileRef, r) => ({
|
|
62
|
+
file: fileRef, runtime: 'llama.cpp', ...(r.runtimeVersion ? { runtime_version: r.runtimeVersion } : {}), ctx: BENCH.prompt,
|
|
63
|
+
gen_tps: round(r.genTps, 1), ...(r.promptTps != null ? { prompt_tps: round(r.promptTps, 0) } : {}), ...(r.loadS != null ? { load_s: r.loadS } : {}),
|
|
64
|
+
});
|
|
65
|
+
// ---- downloads -------------------------------------------------------------------------------
|
|
66
|
+
const repoDir = (repo) => join(CACHE_DIR, repo.replace(/[\\/]/g, '__'));
|
|
67
|
+
const gb = (bytes) => (bytes / 1e9).toFixed(1) + ' GB';
|
|
68
|
+
async function sizeOnDisk(p) {
|
|
69
|
+
try {
|
|
70
|
+
return (await stat(p)).size;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Stream a URL into `dest` (via a .part file), printing progress to stderr. */
|
|
77
|
+
async function download(url, dest, expected, label) {
|
|
78
|
+
const res = await fetch(url, { headers: UA, redirect: 'follow' });
|
|
79
|
+
if (!res.ok || !res.body)
|
|
80
|
+
throw new Error(`download of ${label} failed: HTTP ${res.status}`);
|
|
81
|
+
const total = Number(res.headers.get('content-length')) || expected || 0;
|
|
82
|
+
const part = dest + '.part';
|
|
83
|
+
const h = await open(part, 'w');
|
|
84
|
+
let got = 0, shown = -1;
|
|
85
|
+
try {
|
|
86
|
+
const reader = res.body.getReader();
|
|
87
|
+
for (;;) {
|
|
88
|
+
const { done, value } = await reader.read();
|
|
89
|
+
if (done)
|
|
90
|
+
break;
|
|
91
|
+
await h.write(value);
|
|
92
|
+
got += value.byteLength;
|
|
93
|
+
const pct = total ? Math.floor((got / total) * 100) : -1;
|
|
94
|
+
if (process.stderr.isTTY && pct !== shown && pct % 5 === 0) {
|
|
95
|
+
shown = pct;
|
|
96
|
+
process.stderr.write(`\r ${label}: ${pct}% of ${gb(total)} `);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
await h.close();
|
|
102
|
+
await rm(part, { force: true });
|
|
103
|
+
throw e;
|
|
104
|
+
}
|
|
105
|
+
await h.close();
|
|
106
|
+
if (process.stderr.isTTY)
|
|
107
|
+
process.stderr.write('\n');
|
|
108
|
+
if (expected && got !== expected) {
|
|
109
|
+
await rm(part, { force: true });
|
|
110
|
+
throw new Error(`download of ${label} was incomplete`);
|
|
111
|
+
}
|
|
112
|
+
await rename(part, dest);
|
|
113
|
+
}
|
|
114
|
+
async function confirm(question) {
|
|
115
|
+
if (!process.stdin.isTTY)
|
|
116
|
+
return false;
|
|
117
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
118
|
+
try {
|
|
119
|
+
return /^y(es)?$/i.test((await rl.question(question)).trim());
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
rl.close();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** Download one reference model if not cached; returns its local path. */
|
|
126
|
+
export async function ensureReference(r) {
|
|
127
|
+
const dir = repoDir(r.repo), dest = join(dir, r.file);
|
|
128
|
+
if ((await sizeOnDisk(dest)) === r.sizeBytes)
|
|
129
|
+
return dest;
|
|
130
|
+
await mkdir(dir, { recursive: true });
|
|
131
|
+
log(`Downloading ${r.repo}:${r.quant} (${gb(r.sizeBytes)}) into ${CACHE_LABEL}`);
|
|
132
|
+
await download(r.url, dest, r.sizeBytes, `${r.repo}:${r.quant}`);
|
|
133
|
+
return dest;
|
|
134
|
+
}
|
|
135
|
+
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
136
|
+
/** Pick the .gguf file(s) for `quant` from a repo listing (split parts summed). */
|
|
137
|
+
function pickQuantFiles(entries, quant) {
|
|
138
|
+
const q = quant.toLowerCase();
|
|
139
|
+
const ggufs = entries.filter(e => e.type === 'file' && e.path.toLowerCase().endsWith('.gguf') && !/mmproj/i.test(e.path));
|
|
140
|
+
const stem = (p) => basename(p).toLowerCase().replace(/\.gguf$/, '').replace(/-\d{5}-of-\d{5}$/, '');
|
|
141
|
+
const hit = (e) => {
|
|
142
|
+
if (e.path.toLowerCase().split('/').slice(0, -1).includes(q))
|
|
143
|
+
return true; // UD-Q4_K_XL/model-00001-of-00002.gguf
|
|
144
|
+
const s = stem(e.path), m = new RegExp(`(^|[-_.])${escapeRe(q)}$`).exec(s);
|
|
145
|
+
if (!m)
|
|
146
|
+
return false;
|
|
147
|
+
const before = s.slice(0, m.index + m[1].length);
|
|
148
|
+
return !/(^|[-_.])(ud|i1)[-_.]$/.test(before); // Q4_K_M must not pick UD-Q4_K_M
|
|
149
|
+
};
|
|
150
|
+
const matches = ggufs.filter(hit);
|
|
151
|
+
if (!matches.length)
|
|
152
|
+
return [];
|
|
153
|
+
const groups = new Map();
|
|
154
|
+
for (const e of matches) {
|
|
155
|
+
const k = e.path.replace(/-\d{5}-of-\d{5}\.gguf$/i, '');
|
|
156
|
+
groups.set(k, [...(groups.get(k) ?? []), e]);
|
|
157
|
+
}
|
|
158
|
+
return [...groups.values()].sort((a, b) => a[0].path.localeCompare(b[0].path))[0].sort((a, b) => a.path.localeCompare(b.path));
|
|
159
|
+
}
|
|
160
|
+
/** `--model <repo>:<quant>`: find, confirm (> 5 GB), download; returns the first part's local path, or null when skipped. */
|
|
161
|
+
export async function ensureModel(repo, quant) {
|
|
162
|
+
const res = await fetch(`https://huggingface.co/api/models/${repo}/tree/main?recursive=true`, { headers: UA });
|
|
163
|
+
if (!res.ok)
|
|
164
|
+
throw new Error(`Hugging Face has no public repo ${repo} (HTTP ${res.status})`);
|
|
165
|
+
const parts = pickQuantFiles((await res.json()), quant);
|
|
166
|
+
if (!parts.length)
|
|
167
|
+
throw new Error(`No .gguf file for quant ${quant} in ${repo}`);
|
|
168
|
+
const size = (e) => e.lfs?.size ?? e.size ?? 0;
|
|
169
|
+
const total = parts.reduce((s, e) => s + size(e), 0);
|
|
170
|
+
const dir = repoDir(repo);
|
|
171
|
+
const local = parts.map(e => ({ e, dest: join(dir, basename(e.path)) }));
|
|
172
|
+
const missing = [];
|
|
173
|
+
for (const x of local)
|
|
174
|
+
if ((await sizeOnDisk(x.dest)) !== size(x.e))
|
|
175
|
+
missing.push(x);
|
|
176
|
+
if (missing.length) {
|
|
177
|
+
const need = missing.reduce((s, x) => s + size(x.e), 0);
|
|
178
|
+
if (need / 1e9 > ASK_ABOVE_GB && !(await confirm(`${repo}:${quant} is ${gb(need)}. Download it into ${CACHE_LABEL}? [y/N] `))) {
|
|
179
|
+
log(`Skipped ${repo}:${quant}${process.stdin.isTTY ? '' : ' (over 5 GB; run in a terminal to confirm the download)'}.`);
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
await mkdir(dir, { recursive: true });
|
|
183
|
+
log(`Downloading ${repo}:${quant} (${gb(total)}) into ${CACHE_LABEL}`);
|
|
184
|
+
for (const x of missing) {
|
|
185
|
+
const url = `https://huggingface.co/${repo}/resolve/main/${x.e.path.split('/').map(encodeURIComponent).join('/')}`;
|
|
186
|
+
await download(url, x.dest, size(x.e) || null, basename(x.e.path));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return local[0].dest;
|
|
190
|
+
}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Static configuration for atlas-probe. No secrets live here: the package is public.
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
/** Kept in step with package.json "version" (hard-coded so the bin needs no JSON import). */
|
|
5
|
+
export const PROBE_VERSION = '1.0.0';
|
|
6
|
+
/** Where `--share` posts when neither ATLAS_URL nor --url is given.
|
|
7
|
+
* Placeholder until the production URL is known; set it before `npm publish`. */
|
|
8
|
+
export const DEFAULT_URL = 'https://atlas-beta-jig.vercel.app';
|
|
9
|
+
export const isPlaceholderUrl = (u) => /\.invalid(?::\d+)?\/?$/i.test(u.replace(/\/+$/, ''));
|
|
10
|
+
/** Ask before any single download larger than this. */
|
|
11
|
+
export const ASK_ABOVE_GB = 5;
|
|
12
|
+
/** llama-bench settings from the spec. */
|
|
13
|
+
export const BENCH = { prompt: 512, gen: 128, reps: 3 };
|
|
14
|
+
export const CACHE_DIR = join(homedir(), '.cache', 'atlas-probe');
|
|
15
|
+
export const CONFIG_DIR = join(homedir(), '.config', 'atlas-probe');
|
|
16
|
+
/** How folders are shown to the user: never print the absolute home path (it contains the username). */
|
|
17
|
+
export const CACHE_LABEL = '~/.cache/atlas-probe';
|
|
18
|
+
export const ID_LABEL = '~/.config/atlas-probe/id';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// AMD GPUs via rocm-smi (Linux). Ryzen AI Max APUs are unified.
|
|
2
|
+
import { cpus, totalmem } from 'node:os';
|
|
3
|
+
import { gib, run } from './common.js';
|
|
4
|
+
import { isUnifiedName, unifiedMemoryGb } from './linux-unified.js';
|
|
5
|
+
export async function detectAmd() {
|
|
6
|
+
const out = await run('rocm-smi', ['--showproductname', '--showmeminfo', 'vram', '--json']);
|
|
7
|
+
if (!out)
|
|
8
|
+
return null;
|
|
9
|
+
let data;
|
|
10
|
+
try {
|
|
11
|
+
data = JSON.parse(out);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const cards = Object.entries(data).filter(([k]) => /^card\d+/i.test(k)).map(([, c]) => {
|
|
17
|
+
const name = c['Card Series'] ?? c['Card series'] ?? c['Card Model'] ?? c['Card model'] ?? c['Device Name'] ?? '';
|
|
18
|
+
const vram = Number(c['VRAM Total Memory (B)'] ?? c['vram Total Memory (B)'] ?? NaN);
|
|
19
|
+
return { name: name.trim(), vramGb: isFinite(vram) ? gib(vram) : 0 };
|
|
20
|
+
}).filter(c => c.name);
|
|
21
|
+
if (!cards.length)
|
|
22
|
+
return null;
|
|
23
|
+
const main = [...cards].sort((a, b) => b.vramGb - a.vramGb)[0];
|
|
24
|
+
const cpu = cpus()[0]?.model ?? '';
|
|
25
|
+
if (isUnifiedName(main.name) || isUnifiedName(cpu)) {
|
|
26
|
+
const mem = await unifiedMemoryGb();
|
|
27
|
+
const name = isUnifiedName(cpu) ? `${cpu.replace(/\s+w\/.*$/i, '').trim()} (${mem}GB)` : main.name;
|
|
28
|
+
return { name, arch: 'unified', devices: 1, vramGb: 0, memoryGb: mem, backend: 'rocm' };
|
|
29
|
+
}
|
|
30
|
+
const same = cards.filter(c => c.name === main.name);
|
|
31
|
+
return { name: main.name, arch: 'discrete', devices: same.length, vramGb: Math.round(main.vramGb), memoryGb: Math.round(gib(totalmem())), backend: 'rocm' };
|
|
32
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Shared detection helpers: run a tool, known spec sheets, RAM bandwidth test, disk.
|
|
2
|
+
import { execFile } from 'node:child_process';
|
|
3
|
+
import * as fs from 'node:fs';
|
|
4
|
+
import { open, readdir, stat } from 'node:fs/promises';
|
|
5
|
+
import { cpus } from 'node:os';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { Worker } from 'node:worker_threads';
|
|
8
|
+
/** Run a command without a shell; resolves stdout, or null when the tool is missing or fails. */
|
|
9
|
+
export function run(cmd, args, timeoutMs = 15_000) {
|
|
10
|
+
return new Promise(resolve => {
|
|
11
|
+
try {
|
|
12
|
+
execFile(cmd, args, { timeout: timeoutMs, windowsHide: true, maxBuffer: 16 * 1024 * 1024 }, (err, stdout) => {
|
|
13
|
+
resolve(err ? null : String(stdout));
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
resolve(null);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export const gib = (bytes) => bytes / 2 ** 30;
|
|
22
|
+
/** Spec-sheet numbers for the catalog's sample devices (prototype DEVICES table): bandwidth GB/s, FP16 TFLOPS, FP8.
|
|
23
|
+
* Used only when `--bench` did not measure. Order matters: more specific names first. */
|
|
24
|
+
const SPEC_SHEETS = [
|
|
25
|
+
{ match: /gb10|dgx spark/i, bw: 273, tf: 125, fp8: true },
|
|
26
|
+
{ match: /ryzen ai max|8060s/i, bw: 256, tf: 59, fp8: false },
|
|
27
|
+
{ match: /jetson agx orin|orin 64/i, bw: 205, tf: 21, fp8: false },
|
|
28
|
+
{ match: /m4 pro/i, bw: 273, tf: 17, fp8: false },
|
|
29
|
+
{ match: /m4 max/i, bw: 546, tf: 34, fp8: false },
|
|
30
|
+
{ match: /m3 ultra/i, bw: 819, tf: 57, fp8: false },
|
|
31
|
+
{ match: /4090 laptop/i, bw: 576, tf: 80, fp8: true },
|
|
32
|
+
{ match: /rtx 3090(?! ti)/i, bw: 936, tf: 71, fp8: false },
|
|
33
|
+
{ match: /rtx 4060 ti/i, bw: 288, tf: 44, fp8: true },
|
|
34
|
+
{ match: /rtx 4090/i, bw: 1008, tf: 165, fp8: true },
|
|
35
|
+
{ match: /rtx 5080/i, bw: 960, tf: 113, fp8: true },
|
|
36
|
+
{ match: /rtx 5090/i, bw: 1792, tf: 209, fp8: true },
|
|
37
|
+
{ match: /7900 xtx/i, bw: 960, tf: 123, fp8: false },
|
|
38
|
+
{ match: /rtx 6000 ada/i, bw: 960, tf: 364, fp8: true },
|
|
39
|
+
{ match: /rtx pro 6000/i, bw: 1792, tf: 500, fp8: true },
|
|
40
|
+
{ match: /l40s/i, bw: 864, tf: 362, fp8: true },
|
|
41
|
+
{ match: /a100.*80|a100-sxm4-80/i, bw: 2039, tf: 312, fp8: false },
|
|
42
|
+
{ match: /h100/i, bw: 3350, tf: 989, fp8: true },
|
|
43
|
+
];
|
|
44
|
+
export const specSheet = (name) => SPEC_SHEETS.find(s => s.match.test(name)) ?? null;
|
|
45
|
+
/** Fallbacks when nothing is known (labelled "assumed"). */
|
|
46
|
+
export const ASSUMED = {
|
|
47
|
+
bw: { discrete: 500, unified: 200, cpu: 50 },
|
|
48
|
+
tf: { discrete: 50, unified: 20, cpu: 2 },
|
|
49
|
+
diskReadGbs: 2,
|
|
50
|
+
};
|
|
51
|
+
/** Approximate RAM bandwidth: a few worker threads copy 64 MB buffers for ~0.4 s (read + write bytes counted). */
|
|
52
|
+
export async function measureRamBandwidth() {
|
|
53
|
+
const workers = Math.max(1, Math.min(8, cpus().length));
|
|
54
|
+
const code = `
|
|
55
|
+
const { parentPort } = require('node:worker_threads');
|
|
56
|
+
const size = 64 * 1024 * 1024, a = Buffer.alloc(size, 1), b = Buffer.alloc(size);
|
|
57
|
+
a.copy(b); // warm up / fault in pages
|
|
58
|
+
let bytes = 0; const t0 = process.hrtime.bigint(), end = t0 + 400000000n;
|
|
59
|
+
while (process.hrtime.bigint() < end) { a.copy(b); bytes += 2 * size; }
|
|
60
|
+
parentPort.postMessage({ bytes, ns: Number(process.hrtime.bigint() - t0) });`;
|
|
61
|
+
try {
|
|
62
|
+
const results = await Promise.all(Array.from({ length: workers }, () => new Promise((resolve, reject) => {
|
|
63
|
+
const w = new Worker(code, { eval: true });
|
|
64
|
+
w.once('message', m => { resolve(m); void w.terminate(); });
|
|
65
|
+
w.once('error', reject);
|
|
66
|
+
})));
|
|
67
|
+
const ns = Math.max(...results.map(r => r.ns));
|
|
68
|
+
const bytes = results.reduce((a, r) => a + r.bytes, 0);
|
|
69
|
+
return ns > 0 ? bytes / (ns / 1e9) / 1e9 : null;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** Free space (GB) on the volume that holds `dir`; null on Node versions without fs.statfs. */
|
|
76
|
+
export async function diskFreeGb(dir) {
|
|
77
|
+
const statfs = fs.promises.statfs;
|
|
78
|
+
if (!statfs)
|
|
79
|
+
return null;
|
|
80
|
+
try {
|
|
81
|
+
const s = await statfs(dir);
|
|
82
|
+
return Number(s.bavail) * Number(s.bsize) / 1e9;
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** Disk read speed (GB/s): read the largest cached .gguf (up to 1 GB) and time it. Approximate: the OS cache may help. */
|
|
89
|
+
export async function diskReadGbs(dir) {
|
|
90
|
+
const files = [];
|
|
91
|
+
const walk = async (d, depth) => {
|
|
92
|
+
let entries;
|
|
93
|
+
try {
|
|
94
|
+
entries = await readdir(d, { withFileTypes: true });
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
for (const e of entries) {
|
|
100
|
+
const p = join(d, e.name);
|
|
101
|
+
if (e.isDirectory() && depth < 3)
|
|
102
|
+
await walk(p, depth + 1);
|
|
103
|
+
else if (e.isFile() && e.name.endsWith('.gguf')) {
|
|
104
|
+
try {
|
|
105
|
+
files.push({ path: p, size: (await stat(p)).size });
|
|
106
|
+
}
|
|
107
|
+
catch { /* gone */ }
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
await walk(dir, 0);
|
|
112
|
+
const f = files.sort((a, b) => b.size - a.size)[0];
|
|
113
|
+
if (!f || f.size < 256 * 2 ** 20)
|
|
114
|
+
return null;
|
|
115
|
+
const limit = Math.min(f.size, 2 ** 30), chunk = Buffer.allocUnsafe(16 * 2 ** 20);
|
|
116
|
+
const h = await open(f.path, 'r');
|
|
117
|
+
try {
|
|
118
|
+
let read = 0;
|
|
119
|
+
const t0 = process.hrtime.bigint();
|
|
120
|
+
while (read < limit) {
|
|
121
|
+
const { bytesRead } = await h.read(chunk, 0, chunk.length, read);
|
|
122
|
+
if (!bytesRead)
|
|
123
|
+
break;
|
|
124
|
+
read += bytesRead;
|
|
125
|
+
}
|
|
126
|
+
const s = Number(process.hrtime.bigint() - t0) / 1e9;
|
|
127
|
+
return s > 0 ? read / s / 1e9 : null;
|
|
128
|
+
}
|
|
129
|
+
finally {
|
|
130
|
+
await h.close();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Runs the per-OS detectors in order and fills in bandwidth / compute / disk with their source.
|
|
2
|
+
import { mkdir } from 'node:fs/promises';
|
|
3
|
+
import { cpus, totalmem } from 'node:os';
|
|
4
|
+
import { CACHE_DIR } from '../config.js';
|
|
5
|
+
import { round } from '../profile.js';
|
|
6
|
+
import { detectAmd } from './amd.js';
|
|
7
|
+
import { ASSUMED, diskFreeGb, diskReadGbs, gib, measureRamBandwidth, specSheet } from './common.js';
|
|
8
|
+
import { detectLinuxUnified } from './linux-unified.js';
|
|
9
|
+
import { detectMac } from './mac.js';
|
|
10
|
+
import { detectNvidia } from './nvidia.js';
|
|
11
|
+
export async function detectHardware() {
|
|
12
|
+
const found = (await detectMac()) ?? (await detectNvidia()) ?? (await detectAmd()) ?? (await detectLinuxUnified()) ?? {
|
|
13
|
+
name: (cpus()[0]?.model ?? 'Unknown CPU').replace(/\s+/g, ' ').trim(),
|
|
14
|
+
arch: 'cpu', devices: 1, vramGb: 0, memoryGb: Math.round(gib(totalmem())), backend: 'cpu',
|
|
15
|
+
};
|
|
16
|
+
const sheet = found.arch === 'cpu' ? null : specSheet(found.name);
|
|
17
|
+
const ramMeasured = found.arch === 'unified' ? null : await measureRamBandwidth();
|
|
18
|
+
const ramBw = ramMeasured != null ? { value: round(ramMeasured), basis: 'measured' } : { value: ASSUMED.bw.cpu, basis: 'assumed' };
|
|
19
|
+
let bw;
|
|
20
|
+
if (found.arch === 'cpu')
|
|
21
|
+
bw = ramBw;
|
|
22
|
+
else if (sheet)
|
|
23
|
+
bw = { value: sheet.bw, basis: 'spec sheet' };
|
|
24
|
+
else
|
|
25
|
+
bw = { value: ASSUMED.bw[found.arch], basis: 'assumed' };
|
|
26
|
+
const tflops = sheet ? { value: sheet.tf, basis: 'spec sheet' } : { value: ASSUMED.tf[found.arch], basis: 'assumed' };
|
|
27
|
+
await mkdir(CACHE_DIR, { recursive: true }).catch(() => undefined);
|
|
28
|
+
const free = await diskFreeGb(CACHE_DIR);
|
|
29
|
+
const read = await diskReadGbs(CACHE_DIR).catch(() => null);
|
|
30
|
+
return {
|
|
31
|
+
...found,
|
|
32
|
+
bw,
|
|
33
|
+
ramBw: found.arch === 'unified' ? bw : ramBw,
|
|
34
|
+
tflops,
|
|
35
|
+
fp8: sheet?.fp8 ?? false,
|
|
36
|
+
diskFree: free != null ? { value: Math.round(free), basis: 'reported' } : { value: 1000, basis: 'assumed' },
|
|
37
|
+
diskRead: read != null ? { value: round(read), basis: 'measured' } : { value: ASSUMED.diskReadGbs, basis: 'assumed' },
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Re-measure disk read after `--bench` downloaded the reference files. */
|
|
41
|
+
export async function remeasureDiskRead() {
|
|
42
|
+
const read = await diskReadGbs(CACHE_DIR).catch(() => null);
|
|
43
|
+
return read != null ? { value: round(read), basis: 'measured' } : null;
|
|
44
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Linux shared-memory boxes: DGX Spark (GB10), Ryzen AI Max, Jetson. GPU name match → arch unified,
|
|
2
|
+
// memory from /proc/meminfo.
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
4
|
+
import { cpus, platform, totalmem } from 'node:os';
|
|
5
|
+
import { gib } from './common.js';
|
|
6
|
+
const UNIFIED = /\bgb10\b|dgx spark|jetson|\borin\b|\bthor\b|ryzen ai max|radeon 8060s|radeon 8050s|strix halo/i;
|
|
7
|
+
export const isUnifiedName = (name) => UNIFIED.test(name);
|
|
8
|
+
/** Total memory in GB: /proc/meminfo MemTotal on Linux, os.totalmem() elsewhere. */
|
|
9
|
+
export async function unifiedMemoryGb() {
|
|
10
|
+
if (platform() === 'linux') {
|
|
11
|
+
try {
|
|
12
|
+
const m = /^MemTotal:\s+(\d+)\s*kB/m.exec(await readFile('/proc/meminfo', 'utf8'));
|
|
13
|
+
if (m)
|
|
14
|
+
return Math.round(Number(m[1]) / 2 ** 20);
|
|
15
|
+
}
|
|
16
|
+
catch { /* fall through */ }
|
|
17
|
+
}
|
|
18
|
+
return Math.round(gib(totalmem()));
|
|
19
|
+
}
|
|
20
|
+
/** Boxes without nvidia-smi / rocm-smi: Jetson (device-tree model) and Ryzen AI Max (CPU brand). */
|
|
21
|
+
export async function detectLinuxUnified() {
|
|
22
|
+
if (platform() !== 'linux')
|
|
23
|
+
return null;
|
|
24
|
+
try {
|
|
25
|
+
const model = (await readFile('/proc/device-tree/model', 'utf8')).replace(/\0/g, '').trim();
|
|
26
|
+
if (/jetson/i.test(model)) {
|
|
27
|
+
return { name: model.replace(/\s+developer kit$/i, ''), arch: 'unified', devices: 1, vramGb: 0, memoryGb: await unifiedMemoryGb(), backend: 'cuda' };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch { /* not a device-tree board */ }
|
|
31
|
+
const cpu = cpus()[0]?.model ?? '';
|
|
32
|
+
if (/ryzen ai max/i.test(cpu)) {
|
|
33
|
+
const mem = await unifiedMemoryGb();
|
|
34
|
+
return { name: `${cpu.replace(/\s+w\/.*$/i, '').trim()} (${mem}GB)`, arch: 'unified', devices: 1, vramGb: 0, memoryGb: mem, backend: 'rocm' };
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Apple Silicon: unified memory, Metal backend. Reads only named fields (machine name, chip, memory);
|
|
2
|
+
// serial numbers, hostnames and user names that system_profiler also prints are never touched.
|
|
3
|
+
import { platform } from 'node:os';
|
|
4
|
+
import { gib, run } from './common.js';
|
|
5
|
+
export async function detectMac() {
|
|
6
|
+
if (platform() !== 'darwin')
|
|
7
|
+
return null;
|
|
8
|
+
const sys = (await run('sysctl', ['-n', 'hw.memsize', 'machdep.cpu.brand_string'])) ?? '';
|
|
9
|
+
const [memLine, brandLine] = sys.split(/\r?\n/);
|
|
10
|
+
const memoryGb = Math.round(gib(Number(memLine) || 0));
|
|
11
|
+
let chip = (brandLine ?? '').trim();
|
|
12
|
+
const disp = await run('system_profiler', ['SPDisplaysDataType', '-json'], 30_000);
|
|
13
|
+
try {
|
|
14
|
+
const d = disp ? JSON.parse(disp).SPDisplaysDataType : undefined;
|
|
15
|
+
const model = d?.find(x => /apple/i.test(x.sppci_model ?? ''))?.sppci_model;
|
|
16
|
+
if (model)
|
|
17
|
+
chip = model.trim();
|
|
18
|
+
}
|
|
19
|
+
catch { /* keep brand string */ }
|
|
20
|
+
let machine = '';
|
|
21
|
+
const hw = await run('system_profiler', ['SPHardwareDataType', '-json'], 30_000);
|
|
22
|
+
try {
|
|
23
|
+
const h = hw ? JSON.parse(hw).SPHardwareDataType?.[0] : undefined;
|
|
24
|
+
machine = (h?.machine_name ?? '').trim();
|
|
25
|
+
}
|
|
26
|
+
catch { /* chip only */ }
|
|
27
|
+
if (!/apple/i.test(chip))
|
|
28
|
+
return null; // Intel Mac: let the CPU fallback handle it
|
|
29
|
+
// "MacBook Pro M4 Max 128GB", the catalog's naming
|
|
30
|
+
const name = [machine, chip.replace(/^apple\s+/i, ''), memoryGb ? `${memoryGb}GB` : ''].filter(Boolean).join(' ');
|
|
31
|
+
return { name, arch: 'unified', devices: 1, vramGb: 0, memoryGb, backend: 'metal' };
|
|
32
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// NVIDIA GPUs via nvidia-smi (Linux and Windows). Unified NVIDIA boxes (GB10 / Jetson) are handed to linux-unified.
|
|
2
|
+
import { totalmem } from 'node:os';
|
|
3
|
+
import { gib, run } from './common.js';
|
|
4
|
+
import { isUnifiedName, unifiedMemoryGb } from './linux-unified.js';
|
|
5
|
+
export async function detectNvidia() {
|
|
6
|
+
const out = await run('nvidia-smi', ['--query-gpu=name,memory.total,pci.link.gen.current', '--format=csv,noheader,nounits']);
|
|
7
|
+
if (!out)
|
|
8
|
+
return null;
|
|
9
|
+
const gpus = out.split(/\r?\n/).map(l => l.trim()).filter(Boolean).map(l => {
|
|
10
|
+
const [name, mem, gen] = l.split(',').map(s => s.trim());
|
|
11
|
+
const m = Number(mem), g = Number(gen);
|
|
12
|
+
return { name, memMiB: isFinite(m) && m > 0 ? m : null, linkGen: isFinite(g) && g > 0 ? g : null };
|
|
13
|
+
}).filter(g => g.name);
|
|
14
|
+
if (!gpus.length)
|
|
15
|
+
return null;
|
|
16
|
+
// the biggest card names the setup; count only cards of that model
|
|
17
|
+
const main = [...gpus].sort((a, b) => (b.memMiB ?? 0) - (a.memMiB ?? 0))[0];
|
|
18
|
+
if (isUnifiedName(main.name) || main.memMiB == null) {
|
|
19
|
+
return { name: main.name, arch: 'unified', devices: 1, vramGb: 0, memoryGb: await unifiedMemoryGb(), backend: 'cuda' };
|
|
20
|
+
}
|
|
21
|
+
const same = gpus.filter(g => g.name === main.name);
|
|
22
|
+
return {
|
|
23
|
+
name: main.name, arch: 'discrete', devices: same.length, vramGb: Math.round(main.memMiB / 1024),
|
|
24
|
+
memoryGb: Math.round(gib(totalmem())), backend: 'cuda', linkGen: main.linkGen ?? undefined,
|
|
25
|
+
};
|
|
26
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// atlas-probe: detect hardware, optionally benchmark with llama.cpp, print an Atlas profile, optionally share runs.
|
|
3
|
+
import { ensureModel, ensureReference, findLlamaBench, installHint, runLlamaBench, toRun } from './bench.js';
|
|
4
|
+
import { CACHE_LABEL, ID_LABEL, PROBE_VERSION, isPlaceholderUrl } from './config.js';
|
|
5
|
+
import { detectHardware, remeasureDiskRead } from './detect/index.js';
|
|
6
|
+
import { fingerprint, round } from './profile.js';
|
|
7
|
+
import { REFERENCE_MODELS, effectiveBandwidth, effectiveTflops } from './reference.js';
|
|
8
|
+
import { share, shareBase } from './share.js';
|
|
9
|
+
const HELP = `atlas-probe ${PROBE_VERSION}: measure your machine for Atlas
|
|
10
|
+
|
|
11
|
+
Usage: npx atlas-probe [options]
|
|
12
|
+
|
|
13
|
+
(no options) Detect hardware; print a summary and the profile JSON
|
|
14
|
+
--bench Also download 2 small reference GGUFs once (cached in ${CACHE_LABEL})
|
|
15
|
+
and time them with your llama-bench
|
|
16
|
+
--model <repo>:<quant> Also benchmark that Hugging Face GGUF (asks before downloads over 5 GB)
|
|
17
|
+
--share POST the profile to \${--url or ATLAS_URL or the Atlas site}/api/runs
|
|
18
|
+
--url <https://...> Atlas site to share with (wins over ATLAS_URL)
|
|
19
|
+
--json Print only the JSON (for piping)
|
|
20
|
+
-h, --help Show this help
|
|
21
|
+
-v, --version Print the version
|
|
22
|
+
|
|
23
|
+
Paste the JSON into Atlas's Device test page to see what runs on this machine.
|
|
24
|
+
Sharing sends only the device model, file names and speeds plus a random id from ${ID_LABEL};
|
|
25
|
+
never files, paths, hostnames or user names.`;
|
|
26
|
+
function parseArgs(argv) {
|
|
27
|
+
const a = { bench: false, share: false, json: false, help: false, version: false };
|
|
28
|
+
for (let i = 0; i < argv.length; i++) {
|
|
29
|
+
const [flag, inline] = argv[i].startsWith('--') && argv[i].includes('=') ? [argv[i].slice(0, argv[i].indexOf('=')), argv[i].slice(argv[i].indexOf('=') + 1)] : [argv[i], undefined];
|
|
30
|
+
const value = () => {
|
|
31
|
+
const v = inline ?? argv[++i];
|
|
32
|
+
if (!v || v.startsWith('--'))
|
|
33
|
+
throw new Error(`${flag} needs a value`);
|
|
34
|
+
return v;
|
|
35
|
+
};
|
|
36
|
+
switch (flag) {
|
|
37
|
+
case '--bench':
|
|
38
|
+
a.bench = true;
|
|
39
|
+
break;
|
|
40
|
+
case '--share':
|
|
41
|
+
a.share = true;
|
|
42
|
+
break;
|
|
43
|
+
case '--json':
|
|
44
|
+
a.json = true;
|
|
45
|
+
break;
|
|
46
|
+
case '--model':
|
|
47
|
+
a.model = value();
|
|
48
|
+
break;
|
|
49
|
+
case '--url':
|
|
50
|
+
a.url = value();
|
|
51
|
+
break;
|
|
52
|
+
case '-h':
|
|
53
|
+
case '--help':
|
|
54
|
+
a.help = true;
|
|
55
|
+
break;
|
|
56
|
+
case '-v':
|
|
57
|
+
case '--version':
|
|
58
|
+
a.version = true;
|
|
59
|
+
break;
|
|
60
|
+
default: throw new Error(`Unknown option ${argv[i]}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (a.model && !/^[^\s:/]+\/[^\s:]+:[^\s:]+$/.test(a.model))
|
|
64
|
+
throw new Error('--model must look like <owner>/<repo>:<quant>, e.g. unsloth/Qwen3-8B-GGUF:Q4_K_M');
|
|
65
|
+
return a;
|
|
66
|
+
}
|
|
67
|
+
const err = (s) => process.stderr.write(s + '\n');
|
|
68
|
+
const fmt = (v, unit) => `${v.value} ${unit} (${v.basis})`;
|
|
69
|
+
function summary(p, hw, benched) {
|
|
70
|
+
const backend = { cuda: 'CUDA', rocm: 'ROCm', metal: 'Metal', vulkan: 'Vulkan', cpu: 'CPU' }[p.backend];
|
|
71
|
+
const kind = p.arch === 'discrete' ? 'graphics card' + (p.devices > 1 ? 's' : '') : p.arch === 'unified' ? 'shared-memory system' : 'CPU only';
|
|
72
|
+
const lines = [
|
|
73
|
+
`atlas-probe ${p.probe_version}`,
|
|
74
|
+
'',
|
|
75
|
+
` Device ${p.device_name_raw}${p.arch === 'discrete' ? ` x ${p.devices} (${p.vram_gb} GB each)` : ''}`,
|
|
76
|
+
` Type ${kind} · ${backend} · FP8 ${p.fp8 ? 'yes' : 'no'}`,
|
|
77
|
+
` Memory ${p.memory_gb} GB ${p.arch === 'unified' ? 'shared' : 'system RAM'}${p.arch === 'unified' ? '' : ` · ${fmt(hw.ramBw, 'GB/s')}`}`,
|
|
78
|
+
` Bandwidth ${fmt(hw.bw, 'GB/s')}`,
|
|
79
|
+
` Compute ${fmt(hw.tflops, 'FP16 TFLOPS')}`,
|
|
80
|
+
` Disk ${hw.diskFree.value} GB free (${hw.diskFree.basis}) · ${fmt(hw.diskRead, 'GB/s read')}`,
|
|
81
|
+
];
|
|
82
|
+
if (!p.runs.length)
|
|
83
|
+
lines.push(` Runs none${benched ? '' : ' (add --bench to time two small models)'}`);
|
|
84
|
+
else {
|
|
85
|
+
lines.push(' Runs');
|
|
86
|
+
for (const r of p.runs)
|
|
87
|
+
lines.push(` ${r.file} ${r.gen_tps} tok/s generate${r.prompt_tps != null ? ` · ${r.prompt_tps} tok/s prompt` : ''}${r.runtime_version ? ` · llama.cpp ${r.runtime_version}` : ''}`);
|
|
88
|
+
}
|
|
89
|
+
if (hw.bw.basis !== 'measured' && p.arch !== 'cpu')
|
|
90
|
+
lines.push('', ' Bandwidth and compute are not measured yet; run with --bench for real numbers.');
|
|
91
|
+
return lines.join('\n');
|
|
92
|
+
}
|
|
93
|
+
async function main() {
|
|
94
|
+
let args;
|
|
95
|
+
try {
|
|
96
|
+
args = parseArgs(process.argv.slice(2));
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
err(`${e.message}\n\nRun atlas-probe --help for usage.`);
|
|
100
|
+
return 2;
|
|
101
|
+
}
|
|
102
|
+
if (args.help) {
|
|
103
|
+
process.stdout.write(HELP + '\n');
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
106
|
+
if (args.version) {
|
|
107
|
+
process.stdout.write(PROBE_VERSION + '\n');
|
|
108
|
+
return 0;
|
|
109
|
+
}
|
|
110
|
+
if (!args.json)
|
|
111
|
+
err('Reading GPU, memory and disk...');
|
|
112
|
+
const hw = await detectHardware();
|
|
113
|
+
const runs = [];
|
|
114
|
+
let benched = false, code = 0;
|
|
115
|
+
if (args.bench || args.model) {
|
|
116
|
+
const lb = await findLlamaBench(); // check before any download
|
|
117
|
+
if (!lb) {
|
|
118
|
+
err(installHint());
|
|
119
|
+
err('Continuing with a detect-only profile.');
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
benched = true;
|
|
123
|
+
const bws = [], tfs = [];
|
|
124
|
+
if (args.bench) {
|
|
125
|
+
for (const r of REFERENCE_MODELS) {
|
|
126
|
+
try {
|
|
127
|
+
const path = await ensureReference(r);
|
|
128
|
+
err(`Timing ${r.repo}:${r.quant} with llama-bench (${3} runs)...`);
|
|
129
|
+
const res = await runLlamaBench(lb, path);
|
|
130
|
+
runs.push(toRun(`${r.repo}:${r.quant}`, res));
|
|
131
|
+
bws.push(effectiveBandwidth(res.genTps, r));
|
|
132
|
+
if (res.promptTps != null)
|
|
133
|
+
tfs.push(effectiveTflops(res.promptTps, r));
|
|
134
|
+
}
|
|
135
|
+
catch (e) {
|
|
136
|
+
err(` ${e.message}`);
|
|
137
|
+
code = 1;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (args.model) {
|
|
142
|
+
const i = args.model.lastIndexOf(':'), repo = args.model.slice(0, i), quant = args.model.slice(i + 1);
|
|
143
|
+
try {
|
|
144
|
+
const path = await ensureModel(repo, quant);
|
|
145
|
+
if (path) {
|
|
146
|
+
err(`Timing ${repo}:${quant} with llama-bench...`);
|
|
147
|
+
runs.push(toRun(`${repo}:${quant}`, await runLlamaBench(lb, path)));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch (e) {
|
|
151
|
+
err(` ${e.message}`);
|
|
152
|
+
code = 1;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (bws.length) {
|
|
156
|
+
hw.bw = { value: Math.round(Math.max(...bws)), basis: 'measured' };
|
|
157
|
+
if (hw.arch !== 'discrete')
|
|
158
|
+
hw.ramBw = hw.bw;
|
|
159
|
+
}
|
|
160
|
+
if (tfs.length)
|
|
161
|
+
hw.tflops = { value: round(Math.max(...tfs), 1), basis: 'measured' };
|
|
162
|
+
const read = await remeasureDiskRead();
|
|
163
|
+
if (read)
|
|
164
|
+
hw.diskRead = read;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const profile = {
|
|
168
|
+
probe_version: PROBE_VERSION,
|
|
169
|
+
device_name_raw: hw.name,
|
|
170
|
+
arch: hw.arch,
|
|
171
|
+
devices: hw.devices,
|
|
172
|
+
vram_gb: hw.vramGb,
|
|
173
|
+
memory_gb: hw.memoryGb,
|
|
174
|
+
measured_bw_gbs: hw.bw.value,
|
|
175
|
+
ram_bw_gbs: hw.ramBw.value,
|
|
176
|
+
fp16_tflops: hw.tflops.value,
|
|
177
|
+
fp8: hw.fp8,
|
|
178
|
+
backend: hw.backend,
|
|
179
|
+
disk_free_gb: hw.diskFree.value,
|
|
180
|
+
disk_read_gbs: hw.diskRead.value,
|
|
181
|
+
fingerprint: await fingerprint(),
|
|
182
|
+
runs,
|
|
183
|
+
};
|
|
184
|
+
const json = JSON.stringify(profile, null, 2);
|
|
185
|
+
if (args.json)
|
|
186
|
+
process.stdout.write(json + '\n');
|
|
187
|
+
else
|
|
188
|
+
process.stdout.write(`${summary(profile, hw, benched)}\n\nProfile (paste into Atlas > Device test):\n${json}\n`);
|
|
189
|
+
if (args.share) {
|
|
190
|
+
const base = shareBase(args.url);
|
|
191
|
+
if (isPlaceholderUrl(base)) {
|
|
192
|
+
err('Not shared: no Atlas site is configured in this build. Set ATLAS_URL=https://<your atlas site> or pass --url https://<your atlas site>.');
|
|
193
|
+
code = 1;
|
|
194
|
+
}
|
|
195
|
+
else if (!runs.length) {
|
|
196
|
+
err('Nothing to share yet: no runs were timed. Run with --bench (needs llama-bench) to share speeds.');
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
try {
|
|
200
|
+
const r = await share(profile, base);
|
|
201
|
+
err(`Shared: ${r.accepted} run${r.accepted === 1 ? '' : 's'} accepted${r.rejected.length ? `, ${r.rejected.length} rejected` : ''}.`);
|
|
202
|
+
for (const x of r.rejected)
|
|
203
|
+
err(` ${x.file}: ${x.reason}`);
|
|
204
|
+
}
|
|
205
|
+
catch (e) {
|
|
206
|
+
err(`Share failed. ${e.message}`);
|
|
207
|
+
code = 1;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return code;
|
|
212
|
+
}
|
|
213
|
+
main().then(c => { process.exitCode = c; }, e => { err(`atlas-probe: ${e.message ?? e}`); process.exitCode = 1; });
|
package/dist/profile.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// The Profile JSON: exact field names from SPEC "atlas-probe CLI". The web Device test page and
|
|
2
|
+
// POST /api/runs both parse this shape. Never add hostnames, usernames, paths or file contents.
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { CONFIG_DIR } from './config.js';
|
|
7
|
+
/** Random install id, created once in ~/.config/atlas-probe/id. It identifies nothing about the machine. */
|
|
8
|
+
export async function fingerprint() {
|
|
9
|
+
const file = join(CONFIG_DIR, 'id');
|
|
10
|
+
try {
|
|
11
|
+
const id = (await readFile(file, 'utf8')).trim();
|
|
12
|
+
if (/^[0-9a-f-]{36}$/i.test(id))
|
|
13
|
+
return id;
|
|
14
|
+
}
|
|
15
|
+
catch { /* first run */ }
|
|
16
|
+
const id = randomUUID();
|
|
17
|
+
try {
|
|
18
|
+
await mkdir(CONFIG_DIR, { recursive: true });
|
|
19
|
+
await writeFile(file, id + '\n', { encoding: 'utf8', mode: 0o600 });
|
|
20
|
+
}
|
|
21
|
+
catch { /* read-only home: use a one-off id */ }
|
|
22
|
+
return id;
|
|
23
|
+
}
|
|
24
|
+
export const round = (n, d = 1) => { const f = 10 ** d; return Math.round(n * f) / f; };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// The two small reference GGUFs `--bench` times. Their numbers are known, so a generation speed turns
|
|
2
|
+
// into an effective memory bandwidth and a prompt speed into effective FP16 compute (SPEC Benchmark).
|
|
3
|
+
// Checked against the public Hugging Face API on 2026-11-24 (file sizes and parameter counts below).
|
|
4
|
+
const hf = (repo, file) => `https://huggingface.co/${repo}/resolve/main/${file}`;
|
|
5
|
+
export const REFERENCE_MODELS = [
|
|
6
|
+
{
|
|
7
|
+
repo: 'Qwen/Qwen2.5-1.5B-Instruct-GGUF', quant: 'Q4_K_M', file: 'qwen2.5-1.5b-instruct-q4_k_m.gguf',
|
|
8
|
+
url: hf('Qwen/Qwen2.5-1.5B-Instruct-GGUF', 'qwen2.5-1.5b-instruct-q4_k_m.gguf'),
|
|
9
|
+
sizeBytes: 1_117_320_736, activeParamsB: 1.5437, bitsPerWeight: 5.79, // 1,543,714,304 params
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
repo: 'bartowski/Llama-3.2-3B-Instruct-GGUF', quant: 'Q4_K_M', file: 'Llama-3.2-3B-Instruct-Q4_K_M.gguf',
|
|
13
|
+
url: hf('bartowski/Llama-3.2-3B-Instruct-GGUF', 'Llama-3.2-3B-Instruct-Q4_K_M.gguf'),
|
|
14
|
+
sizeBytes: 2_019_377_696, activeParamsB: 3.2127, bitsPerWeight: 5.03, // 3,212,749,824 params
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
/** GB read per generated token: active params (billions) x bits / 8. */
|
|
18
|
+
export const gbPerToken = (r) => r.activeParamsB * r.bitsPerWeight / 8;
|
|
19
|
+
/** Effective bandwidth (GB/s) = generation tok/s x GB per token. */
|
|
20
|
+
export const effectiveBandwidth = (genTps, r) => genTps * gbPerToken(r);
|
|
21
|
+
/** Effective FP16 TFLOPS = prompt tok/s x 2 x active params / 0.3 / 1e12 (0.3 = prefill efficiency). */
|
|
22
|
+
export const effectiveTflops = (promptTps, r) => promptTps * 2 * r.activeParamsB * 1e9 / 0.3 / 1e12;
|
package/dist/share.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// --share: POST the profile to `${base}/api/runs`. Only the Profile JSON is sent (device model, file, speeds,
|
|
2
|
+
// a random install id); never files, paths, hostnames or user names.
|
|
3
|
+
import { DEFAULT_URL, PROBE_VERSION, isPlaceholderUrl } from './config.js';
|
|
4
|
+
/** Base URL: ATLAS_URL, then --url, then the built-in default. */
|
|
5
|
+
export const shareBase = (flagUrl) => (flagUrl || process.env.ATLAS_URL || DEFAULT_URL).replace(/\/+$/, '');
|
|
6
|
+
export async function share(profile, base) {
|
|
7
|
+
if (isPlaceholderUrl(base)) {
|
|
8
|
+
throw new Error('No Atlas site is configured yet. Set ATLAS_URL or pass --url https://<your atlas site> to share runs.');
|
|
9
|
+
}
|
|
10
|
+
let url;
|
|
11
|
+
try {
|
|
12
|
+
url = new URL('/api/runs', base + '/');
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw new Error(`Not a valid URL: ${base}`);
|
|
16
|
+
}
|
|
17
|
+
if (url.protocol !== 'https:' && !/^(localhost|127\.0\.0\.1|\[::1\])$/.test(url.hostname)) {
|
|
18
|
+
throw new Error('Refusing to share over plain http (except localhost). Use an https:// URL.');
|
|
19
|
+
}
|
|
20
|
+
const ctl = new AbortController();
|
|
21
|
+
const timer = setTimeout(() => ctl.abort(), 30_000);
|
|
22
|
+
try {
|
|
23
|
+
const res = await fetch(url, {
|
|
24
|
+
method: 'POST', signal: ctl.signal,
|
|
25
|
+
headers: { 'content-type': 'application/json', 'user-agent': `atlas-probe/${PROBE_VERSION}` },
|
|
26
|
+
body: JSON.stringify(profile),
|
|
27
|
+
});
|
|
28
|
+
const body = (await res.json().catch(() => null));
|
|
29
|
+
if (!res.ok)
|
|
30
|
+
throw new Error(`Atlas answered HTTP ${res.status}${body?.error ? `: ${body.error}` : ''}`);
|
|
31
|
+
return { accepted: Number(body?.accepted ?? 0), rejected: Array.isArray(body?.rejected) ? body.rejected : [] };
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
if (e.name === 'AbortError')
|
|
35
|
+
throw new Error('Atlas did not answer within 30 s');
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
clearTimeout(timer);
|
|
40
|
+
}
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "atlas-probe",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "atlas-probe",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Detect your AI hardware, benchmark it with your own llama.cpp, and print an Atlas profile.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"atlas-probe": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=18"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"llm",
|
|
18
|
+
"llama.cpp",
|
|
19
|
+
"benchmark",
|
|
20
|
+
"gpu",
|
|
21
|
+
"hardware"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc -p tsconfig.json",
|
|
25
|
+
"prepack": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^18.19.0",
|
|
29
|
+
"typescript": "^5.9.0"
|
|
30
|
+
}
|
|
31
|
+
}
|