quantprobe 1.28.1__tar.gz → 1.28.2__tar.gz
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.
- {quantprobe-1.28.1/quantprobe.egg-info → quantprobe-1.28.2}/PKG-INFO +1 -1
- {quantprobe-1.28.1 → quantprobe-1.28.2}/pyproject.toml +1 -1
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/__init__.py +1 -1
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/detect.py +477 -474
- {quantprobe-1.28.1 → quantprobe-1.28.2/quantprobe.egg-info}/PKG-INFO +1 -1
- {quantprobe-1.28.1 → quantprobe-1.28.2}/LICENSE +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/README.md +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/__main__.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/auto.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/branding.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/calibrate.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/cli.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/dashboard.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/fetch.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/ollama.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/optimize.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/plan.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/probe.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/recipes/mistral-7b.json +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/recipes/qwen2.5-7b.json +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/recipes/qwen3-30b.json +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/recipes/qwen3.5-35b.json +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/recipes/qwen3.8-27b.json +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/recipes.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/report.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/runtime.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/spec.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe/target.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe.egg-info/SOURCES.txt +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe.egg-info/dependency_links.txt +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe.egg-info/entry_points.txt +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe.egg-info/requires.txt +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/quantprobe.egg-info/top_level.txt +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/setup.cfg +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/tests/test_engine.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/tests/test_evaluator.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/tests/test_pipeline.py +0 -0
- {quantprobe-1.28.1 → quantprobe-1.28.2}/tests/test_transforms.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quantprobe
|
|
3
|
-
Version: 1.28.
|
|
3
|
+
Version: 1.28.2
|
|
4
4
|
Summary: Probe-then-quantize for LLMs: measure a model's fragility curve, plan bit/tier placement by the tiered decode law, and emit ready-to-run llama.cpp recipes.
|
|
5
5
|
Author: Federico Sciuca
|
|
6
6
|
License: MIT
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "quantprobe"
|
|
7
|
-
version = "1.28.
|
|
7
|
+
version = "1.28.2"
|
|
8
8
|
description = "Probe-then-quantize for LLMs: measure a model's fragility curve, plan bit/tier placement by the tiered decode law, and emit ready-to-run llama.cpp recipes."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
@@ -8,4 +8,4 @@ Three commands, all grounded in measured laws (see LAWS.md in the repo):
|
|
|
8
8
|
Every constant in `plan` is fitted from measurements published in the repo, including two
|
|
9
9
|
pre-registered hardware predictions confirmed within 8%.
|
|
10
10
|
"""
|
|
11
|
-
__version__ = "1.28.
|
|
11
|
+
__version__ = "1.28.2"
|
|
@@ -1,474 +1,477 @@
|
|
|
1
|
-
"""quantprobe hw - read the local machine's memory tiers, no questions asked.
|
|
2
|
-
|
|
3
|
-
Every printed value is tagged with its source:
|
|
4
|
-
[os] read from the operating system / driver (capacity, stick speed, GPU name)
|
|
5
|
-
[table] looked up from the device name (bandwidth spec, eta class)
|
|
6
|
-
[default] a conservative fallback - override it with flags
|
|
7
|
-
Bandwidths are THEORETICAL peaks (the law's eta absorbs realism, same convention as the presets).
|
|
8
|
-
Nothing is sent anywhere; this only reads local OS interfaces.
|
|
9
|
-
"""
|
|
10
|
-
from __future__ import annotations
|
|
11
|
-
import os, platform, re, shutil, subprocess
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def _run(cmd, timeout=10):
|
|
15
|
-
try:
|
|
16
|
-
return subprocess.run(cmd, capture_output=True, text=True, timeout=timeout).stdout
|
|
17
|
-
except Exception:
|
|
18
|
-
return ""
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# name-fragment -> (VRAM bandwidth GB/s, geta, gl). 1060 measured on the reference box; rest spec-sheet [table].
|
|
22
|
-
GPU_TABLE = [
|
|
23
|
-
("5090", 1792, 0.62, 0.42), ("5080", 960, 0.62, 0.42), ("5070 ti", 896, 0.62, 0.42),
|
|
24
|
-
("5070", 672, 0.6, 0.4), ("5060 ti", 448, 0.58, 0.38), ("5060", 448, 0.58, 0.38),
|
|
25
|
-
("4090", 1008, 0.62, 0.42), ("4080", 717, 0.6, 0.4),
|
|
26
|
-
("4070", 504, 0.55, 0.35), ("4060", 272, 0.5, 0.3),
|
|
27
|
-
("3090", 936, 0.6, 0.4), ("3080", 760, 0.58, 0.38), ("3070", 448, 0.52, 0.32),
|
|
28
|
-
("3060 ti", 448, 0.5, 0.3), ("3060", 360, 0.5, 0.3), ("3050", 224, 0.45, 0.28),
|
|
29
|
-
("2080", 448, 0.45, 0.25), ("2070", 448, 0.45, 0.25), ("2060", 336, 0.42, 0.22),
|
|
30
|
-
("1080", 320, 0.38, 0.06), ("1070", 256, 0.36, 0.05), ("1060", 192, 0.35, 0.04),
|
|
31
|
-
("a100", 1935, 0.7, 0.55), ("h100", 3350, 0.75, 0.6), ("rtx 6000", 960, 0.62, 0.42),
|
|
32
|
-
# AMD / Intel, added for issue #1 (an RX 5700 XT owner got "GPU: none detected" and had to
|
|
33
|
-
# hand-pass the exact 448 this table now carries). Spec-sheet peaks, same [table] convention
|
|
34
|
-
# as above; the geta/gl hints are the generic-unknown values because NO eta has been
|
|
35
|
-
# measured on RDNA/Arc backends here - resolve_gpu_eta's size-classed floor and the user's
|
|
36
|
-
# own `calibrate` anchors do the honest work, exactly as they did for E-13's +0.1%.
|
|
37
|
-
("rx 9070 xt", 640, 0.45, 0.27), ("rx 9070", 640, 0.45, 0.27),
|
|
38
|
-
("rx 7900 xtx", 960, 0.45, 0.27), ("rx 7900 xt", 800, 0.45, 0.27),
|
|
39
|
-
("rx 7900 gre", 576, 0.45, 0.27), ("rx 7800 xt", 624, 0.45, 0.27),
|
|
40
|
-
("rx 7700 xt", 432, 0.45, 0.27), ("rx 7600 xt", 288, 0.45, 0.27),
|
|
41
|
-
("rx 7600", 288, 0.45, 0.27), ("rx 6950 xt", 576, 0.45, 0.27),
|
|
42
|
-
("rx 6900 xt", 512, 0.45, 0.27), ("rx 6800 xt", 512, 0.45, 0.27),
|
|
43
|
-
("rx 6800", 512, 0.45, 0.27), ("rx 6750 xt", 432, 0.45, 0.27),
|
|
44
|
-
("rx 6700 xt", 384, 0.45, 0.27), ("rx 6700", 320, 0.45, 0.27),
|
|
45
|
-
("rx 6650 xt", 280, 0.45, 0.27), ("rx 6600 xt", 256, 0.45, 0.27),
|
|
46
|
-
("rx 6600", 224, 0.45, 0.27), ("rx 5700 xt", 448, 0.45, 0.27),
|
|
47
|
-
("rx 5700", 448, 0.45, 0.27), ("rx 5600 xt", 288, 0.45, 0.27),
|
|
48
|
-
("radeon vii", 1024, 0.45, 0.27), ("vega 64", 484, 0.45, 0.27), ("vega 56", 410, 0.45, 0.27),
|
|
49
|
-
("arc a770", 560, 0.45, 0.27), ("arc a750", 512, 0.45, 0.27),
|
|
50
|
-
("arc b580", 456, 0.45, 0.27), ("arc b570", 380, 0.45, 0.27),
|
|
51
|
-
]
|
|
52
|
-
MAC_BW = {"m1 ultra": 800, "m1 max": 400, "m1 pro": 200, "m1": 68,
|
|
53
|
-
"m2 ultra": 800, "m2 max": 400, "m2 pro": 200, "m2": 100,
|
|
54
|
-
"m3 ultra": 819, "m3 max": 400, "m3 pro": 150, "m3": 100,
|
|
55
|
-
"m4 max": 546, "m4 pro": 273, "m4": 120}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def _parse_rocm_text(text):
|
|
59
|
-
"""Parse rocm-smi combined text output into per-card dicts.
|
|
60
|
-
|
|
61
|
-
Pure parser, testable without a GPU (same convention as _parse_win_adapters).
|
|
62
|
-
Section state machine over GPU[n]-prefixed lines, keyword matching (case-insensitive
|
|
63
|
-
substring; metric strings drift across rocm-smi versions). Returns [{name, vram_gb,
|
|
64
|
-
sclk, mclk, temp, sclk_max}, ...], one dict per card.
|
|
65
|
-
"""
|
|
66
|
-
cards = {}
|
|
67
|
-
in_sclk_section = False
|
|
68
|
-
for line in (text or "").strip().splitlines():
|
|
69
|
-
m = re.match(r"GPU\[(\d+)\]\s*:\s*(.*)", line)
|
|
70
|
-
if not m:
|
|
71
|
-
continue
|
|
72
|
-
gpu_id = int(m.group(1))
|
|
73
|
-
rest = m.group(2).strip()
|
|
74
|
-
if not rest:
|
|
75
|
-
# Bare "GPU[n] :" — terminates any active section
|
|
76
|
-
in_sclk_section = False
|
|
77
|
-
continue
|
|
78
|
-
cur = cards.setdefault(gpu_id, dict(name=None, vram_gb=None, sclk=None,
|
|
79
|
-
mclk=None, temp=None, sclk_max=None))
|
|
80
|
-
rest_lower = rest.lower()
|
|
81
|
-
# Name: "Card series" contains the full product name (e.g. "AMD Radeon RX 9070 XT").
|
|
82
|
-
if "card series" in rest_lower:
|
|
83
|
-
cur["name"] = rest.split(":", 1)[1].strip()
|
|
84
|
-
# VRAM total
|
|
85
|
-
elif "vram total memory (b):" in rest_lower:
|
|
86
|
-
try:
|
|
87
|
-
cur["vram_gb"] = int(rest.split(":", 1)[1].strip()) / 2**30
|
|
88
|
-
except (ValueError, IndexError):
|
|
89
|
-
pass
|
|
90
|
-
# VRAM used
|
|
91
|
-
elif "vram total used memory (b):" in rest_lower:
|
|
92
|
-
try:
|
|
93
|
-
cur["vram_used_b"] = int(rest.split(":", 1)[1].strip())
|
|
94
|
-
except (ValueError, IndexError):
|
|
95
|
-
pass
|
|
96
|
-
# sclk clock level: "3: (1200.Mhz)" or "S: (238Mhz)" — level may be numeric or a letter.
|
|
97
|
-
elif "sclk clock level:" in rest_lower:
|
|
98
|
-
m = re.search(r"\((\d+)\.?Mhz\)", rest)
|
|
99
|
-
if m:
|
|
100
|
-
cur["sclk"] = int(m.group(1))
|
|
101
|
-
# mclk clock level
|
|
102
|
-
elif "mclk clock level:" in rest_lower:
|
|
103
|
-
val = rest.split(":", 1)[1].strip()
|
|
104
|
-
m = re.search(r"\((\d+)\.?Mhz\)", val)
|
|
105
|
-
if m:
|
|
106
|
-
cur["mclk"] = int(m.group(1))
|
|
107
|
-
# Temperature (Sensor edge)
|
|
108
|
-
elif "temperature (sensor edge)" in rest_lower:
|
|
109
|
-
try:
|
|
110
|
-
cur["temp"] = int(float(rest.split(":", 1)[1].strip()))
|
|
111
|
-
except (ValueError, IndexError):
|
|
112
|
-
pass
|
|
113
|
-
# Supported sclk frequencies section header
|
|
114
|
-
elif "supported sclk frequencies" in rest_lower:
|
|
115
|
-
in_sclk_section = True
|
|
116
|
-
continue
|
|
117
|
-
# Inside sclk section: lines like "0: 400Mhz" or "12: 2400Mhz *"
|
|
118
|
-
# The `*` marks the current active frequency (level may be numeric or state letter like "S:").
|
|
119
|
-
if in_sclk_section:
|
|
120
|
-
sm = re.match(r"^\S+\s*:\s*(\d+)\s*Mhz", rest)
|
|
121
|
-
if sm:
|
|
122
|
-
freq = int(sm.group(1))
|
|
123
|
-
if cur["sclk_max"] is None or freq > cur["sclk_max"]:
|
|
124
|
-
cur["sclk_max"] = freq
|
|
125
|
-
if "*" in rest:
|
|
126
|
-
cur["sclk"] = freq
|
|
127
|
-
return [cards[k] for k in sorted(cards)]
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
def _rocm_state():
|
|
131
|
-
"""Run rocm-smi, return parsed list. [] on missing tool / no driver."""
|
|
132
|
-
cmds = [
|
|
133
|
-
["rocm-smi", "--showclkfrq"],
|
|
134
|
-
["rocm-smi", "--showclocks"],
|
|
135
|
-
["rocm-smi", "--showmeminfo", "vram"],
|
|
136
|
-
["rocm-smi", "--showproductname"],
|
|
137
|
-
["rocm-smi", "--showtemp"],
|
|
138
|
-
]
|
|
139
|
-
parts = []
|
|
140
|
-
for cmd in cmds:
|
|
141
|
-
out = _run(cmd)
|
|
142
|
-
if out.strip():
|
|
143
|
-
parts.append(out)
|
|
144
|
-
if not parts:
|
|
145
|
-
return []
|
|
146
|
-
merged = "\n".join(parts)
|
|
147
|
-
try:
|
|
148
|
-
return _parse_rocm_text(merged)
|
|
149
|
-
except (subprocess.SubprocessError, OSError):
|
|
150
|
-
return []
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
def gpus_amd():
|
|
154
|
-
"""[(name, vram_gb)] via rocm-smi; empty list if no AMD GPU detected."""
|
|
155
|
-
state = _rocm_state()
|
|
156
|
-
return [(d["name"], d["vram_gb"]) for d in state if d["name"] and d["vram_gb"]]
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
def _price_gpus(gs):
|
|
160
|
-
"""Price a list of (name, vram_gb) tuples through gpu_lookup.
|
|
161
|
-
|
|
162
|
-
Returns (known, unknown) where known/unknown are lists of
|
|
163
|
-
(name, vram_gb, bw, geta, gl, src) — src contains 'table' for known cards.
|
|
164
|
-
"""
|
|
165
|
-
priced = [(n, gb) + gpu_lookup(n) for n, gb in gs]
|
|
166
|
-
known = [p for p in priced if "table" in p[5]]
|
|
167
|
-
unknown = [p for p in priced if "table" not in p[5]]
|
|
168
|
-
return known, unknown
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
def gpus():
|
|
172
|
-
"""[(name, vram_gb)] via nvidia-smi; empty list if none/AMD."""
|
|
173
|
-
out = _run(["nvidia-smi", "--query-gpu=name,memory.total", "--format=csv,noheader,nounits"])
|
|
174
|
-
gs = []
|
|
175
|
-
for line in out.strip().splitlines():
|
|
176
|
-
if "," in line:
|
|
177
|
-
name, mem = line.rsplit(",", 1)
|
|
178
|
-
try:
|
|
179
|
-
gs.append((name.strip(), float(mem) / 1024))
|
|
180
|
-
except ValueError:
|
|
181
|
-
pass
|
|
182
|
-
return gs
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
def gpu_lookup(name):
|
|
186
|
-
n = name.lower()
|
|
187
|
-
for frag, bw, geta, gl in GPU_TABLE:
|
|
188
|
-
if frag in n:
|
|
189
|
-
return bw, geta, gl, "[table]"
|
|
190
|
-
return 300, 0.45, 0.27, "[default: unknown GPU, pass --vram-bw]"
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
def _parse_win_adapters(text):
|
|
194
|
-
"""'DriverDesc|bytes' lines -> [(name, vram_gb)], virtual adapters filtered, dedup by max.
|
|
195
|
-
Pure parser so the smoke suite can test it without the registry."""
|
|
196
|
-
VIRTUAL = ("basic display", "basic render", "remote", "virtual", "vnc", "dameware",
|
|
197
|
-
"parsec", "spacedesk", "idd", "usb", "mirage", "citrix")
|
|
198
|
-
out = {}
|
|
199
|
-
for line in (text or "").strip().splitlines():
|
|
200
|
-
if "|" not in line:
|
|
201
|
-
continue
|
|
202
|
-
name, _, raw = line.rpartition("|")
|
|
203
|
-
name = name.strip()
|
|
204
|
-
if not name or any(v in name.lower() for v in VIRTUAL):
|
|
205
|
-
continue
|
|
206
|
-
try:
|
|
207
|
-
gb = int(raw.strip()) / 2**30
|
|
208
|
-
except ValueError:
|
|
209
|
-
gb = 0.0
|
|
210
|
-
out[name] = max(gb, out.get(name, 0.0))
|
|
211
|
-
return sorted(out.items())
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
def gpus_other():
|
|
215
|
-
"""Non-NVIDIA adapters, Windows: driver registry first - qwMemorySize is the reliable VRAM
|
|
216
|
-
field; Win32_VideoController.AdapterRAM is a uint32 that CAPS AT 4 GB and under-reports
|
|
217
|
-
every modern card - CIM only as fallback. Issue #1's contributor ran an RX 5700 XT and this
|
|
218
|
-
tool printed 'GPU: none detected'; this function is the fix."""
|
|
219
|
-
if os.name != "nt":
|
|
220
|
-
return []
|
|
221
|
-
ps = ("$k='HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Class\\"
|
|
222
|
-
"{4d36e968-e325-11ce-bfc1-08002be10318}\\0*';"
|
|
223
|
-
"$r=Get-ItemProperty $k -ErrorAction SilentlyContinue | "
|
|
224
|
-
"Where-Object { $_.DriverDesc } | "
|
|
225
|
-
"ForEach-Object { $_.DriverDesc + '|' + $_.'HardwareInformation.qwMemorySize' };"
|
|
226
|
-
"if (-not $r) { $r = Get-CimInstance Win32_VideoController | "
|
|
227
|
-
"ForEach-Object { $_.Name + '|' + $_.AdapterRAM } };"
|
|
228
|
-
"$r")
|
|
229
|
-
return _parse_win_adapters(_run(["powershell", "-NoProfile", "-c", ps]))
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
def ram_windows():
|
|
233
|
-
"""(total_gb[os], mts[os], channels[os]) via CIM (wmic fallback)."""
|
|
234
|
-
ps = _run(["powershell", "-NoProfile", "-c",
|
|
235
|
-
"$m=Get-CimInstance Win32_PhysicalMemory; "
|
|
236
|
-
"($m|Measure-Object Capacity -Sum).Sum; "
|
|
237
|
-
"($m|Select-Object -First 1).ConfiguredClockSpeed; ($m|Measure-Object).Count"])
|
|
238
|
-
vals = [v.strip() for v in ps.strip().splitlines() if v.strip()]
|
|
239
|
-
if len(vals) >= 3:
|
|
240
|
-
try:
|
|
241
|
-
return float(vals[0]) / 2**30, float(vals[1]), int(vals[2])
|
|
242
|
-
except ValueError:
|
|
243
|
-
pass
|
|
244
|
-
return None, None, None
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
WIDE_CPU = ("threadripper", "epyc", "xeon w-3", "xeon(r) w9", "xeon(r) w7", "xeon gold",
|
|
248
|
-
"xeon platinum", "xeon silver")
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
def ram_channels(sticks, cpu_name):
|
|
252
|
-
"""(channels, provenance) - CHANNEL COUNT IS NOT STICK COUNT.
|
|
253
|
-
|
|
254
|
-
The first external replication (RTX 3090 + Ryzen 8600G, 4 DIMMs on dual-channel AM5) hit
|
|
255
|
-
exactly this: `min(sticks, 8)` assumed 4-channel and quoted 173 GB/s where the platform
|
|
256
|
-
delivers ~86 peak - a 2x input error that a correct Law 4 turned into a 2x wrong prediction.
|
|
257
|
-
Consumer desktop platforms (AM4/AM5, LGA17xx/18xx) are DUAL-channel regardless of stick
|
|
258
|
-
count; only HEDT/server parts go wider, and those we recognise by CPU name. When in doubt:
|
|
259
|
-
2, plus a note - `quantprobe calibrate` measures the real stream and overrides all of this.
|
|
260
|
-
|
|
261
|
-
THIS IS A FUNCTION so the rule can be tested. Before v1.24.0 the same logic was inline in
|
|
262
|
-
`detect()` and its guard test re-implemented the WIDE list in the test body, which meant the
|
|
263
|
-
test stayed green with the 2x bug restored (verified by mutation). A regression test that
|
|
264
|
-
cannot see the code it guards is not a regression test.
|
|
265
|
-
"""
|
|
266
|
-
cpu = (cpu_name or "").lower()
|
|
267
|
-
if any(w in cpu for w in WIDE_CPU):
|
|
268
|
-
n = max(1, min(sticks or 4, 8))
|
|
269
|
-
return n, f"assumes {n}-channel [HEDT/server CPU detected]"
|
|
270
|
-
n = min(sticks, 2) if sticks else 2
|
|
271
|
-
if sticks and sticks > 2:
|
|
272
|
-
return n, (f"dual-channel [consumer platform; {sticks} sticks does NOT mean {sticks} "
|
|
273
|
-
f"channels]")
|
|
274
|
-
return n, f"assumes {n}-channel"
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
def detect():
|
|
278
|
-
"""Return the machine as quantprobe hardware kwargs + a provenance report."""
|
|
279
|
-
sysname = platform.system()
|
|
280
|
-
hw, notes = {}, []
|
|
281
|
-
|
|
282
|
-
if sysname == "Darwin":
|
|
283
|
-
mem = _run(["sysctl", "-n", "hw.memsize"]).strip()
|
|
284
|
-
chip = _run(["sysctl", "-n", "machdep.cpu.brand_string"]).lower()
|
|
285
|
-
total = float(mem) / 2**30 if mem else 16.0
|
|
286
|
-
bw = next((b for frag, b in sorted(MAC_BW.items(), key=lambda x: -len(x[0])) if frag in chip), 100)
|
|
287
|
-
hw = dict(vram=round(total * 0.8), vram_bw=bw, ram=8, ram_bw=bw, disk_bw=3.5,
|
|
288
|
-
geta=0.26, gl=0.24)
|
|
289
|
-
notes.append(f"Apple unified memory: {total:.0f} GB [os], {bw} GB/s [table, est eta 0.26 - unvalidated: bench me]")
|
|
290
|
-
return hw, notes
|
|
291
|
-
|
|
292
|
-
# RAM
|
|
293
|
-
total, mts, sticks = (ram_windows() if os.name == "nt" else (None, None, None))
|
|
294
|
-
if total is None and os.path.exists("/proc/meminfo"):
|
|
295
|
-
with open("/proc/meminfo") as f:
|
|
296
|
-
kb = int(re.search(r"MemTotal:\s*(\d+)", f.read()).group(1))
|
|
297
|
-
total, mts, sticks = kb / 2**20, None, None
|
|
298
|
-
if total is None:
|
|
299
|
-
total = 16.0; notes.append("RAM capacity: 16 GB [default - detection failed]")
|
|
300
|
-
channels, chan_src = ram_channels(sticks, platform.processor())
|
|
301
|
-
if mts:
|
|
302
|
-
ram_bw = round(channels * mts * 8 / 1000) # theoretical peak, preset convention
|
|
303
|
-
notes.append(f"RAM: {total:.0f} GB, {sticks} stick(s) @ {mts:.0f} MT/s [os] -> {ram_bw} GB/s peak "
|
|
304
|
-
f"({chan_src}); the DELIVERED stream is far below peak - the one box we have "
|
|
305
|
-
f"measured ran 26.1 of a 48 GB/s peak (0.544; n=1 machine, so this is a "
|
|
306
|
-
f"datapoint, not a population). Run `quantprobe calibrate` to measure yours")
|
|
307
|
-
else:
|
|
308
|
-
ram_bw = 48
|
|
309
|
-
notes.append(f"RAM: {total:.0f} GB [os]; speed unknown -> 48 GB/s [default: DDR4-3000 dual, pass --ram-bw]")
|
|
310
|
-
|
|
311
|
-
# GPU(s)
|
|
312
|
-
gs = gpus() or gpus_amd()
|
|
313
|
-
if gs:
|
|
314
|
-
vram = sum(g[1] for g in gs)
|
|
315
|
-
per = [gpu_lookup(g[0]) for g in gs] # per-card lookup (mixed pairs differ)
|
|
316
|
-
bw_sum = sum(p[0] for p in per)
|
|
317
|
-
vram_bw = bw_sum * (1.0 if len(gs) == 1 else 0.85) # aggregate w/ tensor-parallel loss
|
|
318
|
-
geta, gl, src = per[0][1], per[0][2], per[0][3] # eta class from the primary card
|
|
319
|
-
names = " + ".join(g[0] for g in gs)
|
|
320
|
-
notes.append(f"GPU: {names}, {vram:.0f} GB total [os], {vram_bw:.0f} GB/s {src}"
|
|
321
|
-
+ (f" (x{len(gs)} per-card sum, 0.85 TP efficiency [est]; slower card gates its share)" if len(gs) > 1 else ""))
|
|
322
|
-
hw.update(vram=vram, vram_bw=round(vram_bw), geta=geta, gl=gl)
|
|
323
|
-
else:
|
|
324
|
-
# nvidia-smi saw nothing - check AMD via rocm-smi, then Windows driver registry for
|
|
325
|
-
# Intel (or any GPU with no driver tools). Field case: issue #1, RX 5700 XT, "none detected".
|
|
326
|
-
amd = gpus_amd()
|
|
327
|
-
others = gpus_other() if not amd else []
|
|
328
|
-
gs
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
the
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
#
|
|
380
|
-
#
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
#
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
f"
|
|
466
|
-
f"
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
1
|
+
"""quantprobe hw - read the local machine's memory tiers, no questions asked.
|
|
2
|
+
|
|
3
|
+
Every printed value is tagged with its source:
|
|
4
|
+
[os] read from the operating system / driver (capacity, stick speed, GPU name)
|
|
5
|
+
[table] looked up from the device name (bandwidth spec, eta class)
|
|
6
|
+
[default] a conservative fallback - override it with flags
|
|
7
|
+
Bandwidths are THEORETICAL peaks (the law's eta absorbs realism, same convention as the presets).
|
|
8
|
+
Nothing is sent anywhere; this only reads local OS interfaces.
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
import os, platform, re, shutil, subprocess
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _run(cmd, timeout=10):
|
|
15
|
+
try:
|
|
16
|
+
return subprocess.run(cmd, capture_output=True, text=True, timeout=timeout).stdout
|
|
17
|
+
except Exception:
|
|
18
|
+
return ""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# name-fragment -> (VRAM bandwidth GB/s, geta, gl). 1060 measured on the reference box; rest spec-sheet [table].
|
|
22
|
+
GPU_TABLE = [
|
|
23
|
+
("5090", 1792, 0.62, 0.42), ("5080", 960, 0.62, 0.42), ("5070 ti", 896, 0.62, 0.42),
|
|
24
|
+
("5070", 672, 0.6, 0.4), ("5060 ti", 448, 0.58, 0.38), ("5060", 448, 0.58, 0.38),
|
|
25
|
+
("4090", 1008, 0.62, 0.42), ("4080", 717, 0.6, 0.4),
|
|
26
|
+
("4070", 504, 0.55, 0.35), ("4060", 272, 0.5, 0.3),
|
|
27
|
+
("3090", 936, 0.6, 0.4), ("3080", 760, 0.58, 0.38), ("3070", 448, 0.52, 0.32),
|
|
28
|
+
("3060 ti", 448, 0.5, 0.3), ("3060", 360, 0.5, 0.3), ("3050", 224, 0.45, 0.28),
|
|
29
|
+
("2080", 448, 0.45, 0.25), ("2070", 448, 0.45, 0.25), ("2060", 336, 0.42, 0.22),
|
|
30
|
+
("1080", 320, 0.38, 0.06), ("1070", 256, 0.36, 0.05), ("1060", 192, 0.35, 0.04),
|
|
31
|
+
("a100", 1935, 0.7, 0.55), ("h100", 3350, 0.75, 0.6), ("rtx 6000", 960, 0.62, 0.42),
|
|
32
|
+
# AMD / Intel, added for issue #1 (an RX 5700 XT owner got "GPU: none detected" and had to
|
|
33
|
+
# hand-pass the exact 448 this table now carries). Spec-sheet peaks, same [table] convention
|
|
34
|
+
# as above; the geta/gl hints are the generic-unknown values because NO eta has been
|
|
35
|
+
# measured on RDNA/Arc backends here - resolve_gpu_eta's size-classed floor and the user's
|
|
36
|
+
# own `calibrate` anchors do the honest work, exactly as they did for E-13's +0.1%.
|
|
37
|
+
("rx 9070 xt", 640, 0.45, 0.27), ("rx 9070", 640, 0.45, 0.27),
|
|
38
|
+
("rx 7900 xtx", 960, 0.45, 0.27), ("rx 7900 xt", 800, 0.45, 0.27),
|
|
39
|
+
("rx 7900 gre", 576, 0.45, 0.27), ("rx 7800 xt", 624, 0.45, 0.27),
|
|
40
|
+
("rx 7700 xt", 432, 0.45, 0.27), ("rx 7600 xt", 288, 0.45, 0.27),
|
|
41
|
+
("rx 7600", 288, 0.45, 0.27), ("rx 6950 xt", 576, 0.45, 0.27),
|
|
42
|
+
("rx 6900 xt", 512, 0.45, 0.27), ("rx 6800 xt", 512, 0.45, 0.27),
|
|
43
|
+
("rx 6800", 512, 0.45, 0.27), ("rx 6750 xt", 432, 0.45, 0.27),
|
|
44
|
+
("rx 6700 xt", 384, 0.45, 0.27), ("rx 6700", 320, 0.45, 0.27),
|
|
45
|
+
("rx 6650 xt", 280, 0.45, 0.27), ("rx 6600 xt", 256, 0.45, 0.27),
|
|
46
|
+
("rx 6600", 224, 0.45, 0.27), ("rx 5700 xt", 448, 0.45, 0.27),
|
|
47
|
+
("rx 5700", 448, 0.45, 0.27), ("rx 5600 xt", 288, 0.45, 0.27),
|
|
48
|
+
("radeon vii", 1024, 0.45, 0.27), ("vega 64", 484, 0.45, 0.27), ("vega 56", 410, 0.45, 0.27),
|
|
49
|
+
("arc a770", 560, 0.45, 0.27), ("arc a750", 512, 0.45, 0.27),
|
|
50
|
+
("arc b580", 456, 0.45, 0.27), ("arc b570", 380, 0.45, 0.27),
|
|
51
|
+
]
|
|
52
|
+
MAC_BW = {"m1 ultra": 800, "m1 max": 400, "m1 pro": 200, "m1": 68,
|
|
53
|
+
"m2 ultra": 800, "m2 max": 400, "m2 pro": 200, "m2": 100,
|
|
54
|
+
"m3 ultra": 819, "m3 max": 400, "m3 pro": 150, "m3": 100,
|
|
55
|
+
"m4 max": 546, "m4 pro": 273, "m4": 120}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _parse_rocm_text(text):
|
|
59
|
+
"""Parse rocm-smi combined text output into per-card dicts.
|
|
60
|
+
|
|
61
|
+
Pure parser, testable without a GPU (same convention as _parse_win_adapters).
|
|
62
|
+
Section state machine over GPU[n]-prefixed lines, keyword matching (case-insensitive
|
|
63
|
+
substring; metric strings drift across rocm-smi versions). Returns [{name, vram_gb,
|
|
64
|
+
sclk, mclk, temp, sclk_max}, ...], one dict per card.
|
|
65
|
+
"""
|
|
66
|
+
cards = {}
|
|
67
|
+
in_sclk_section = False
|
|
68
|
+
for line in (text or "").strip().splitlines():
|
|
69
|
+
m = re.match(r"GPU\[(\d+)\]\s*:\s*(.*)", line)
|
|
70
|
+
if not m:
|
|
71
|
+
continue
|
|
72
|
+
gpu_id = int(m.group(1))
|
|
73
|
+
rest = m.group(2).strip()
|
|
74
|
+
if not rest:
|
|
75
|
+
# Bare "GPU[n] :" — terminates any active section
|
|
76
|
+
in_sclk_section = False
|
|
77
|
+
continue
|
|
78
|
+
cur = cards.setdefault(gpu_id, dict(name=None, vram_gb=None, sclk=None,
|
|
79
|
+
mclk=None, temp=None, sclk_max=None))
|
|
80
|
+
rest_lower = rest.lower()
|
|
81
|
+
# Name: "Card series" contains the full product name (e.g. "AMD Radeon RX 9070 XT").
|
|
82
|
+
if "card series" in rest_lower:
|
|
83
|
+
cur["name"] = rest.split(":", 1)[1].strip()
|
|
84
|
+
# VRAM total
|
|
85
|
+
elif "vram total memory (b):" in rest_lower:
|
|
86
|
+
try:
|
|
87
|
+
cur["vram_gb"] = int(rest.split(":", 1)[1].strip()) / 2**30
|
|
88
|
+
except (ValueError, IndexError):
|
|
89
|
+
pass
|
|
90
|
+
# VRAM used
|
|
91
|
+
elif "vram total used memory (b):" in rest_lower:
|
|
92
|
+
try:
|
|
93
|
+
cur["vram_used_b"] = int(rest.split(":", 1)[1].strip())
|
|
94
|
+
except (ValueError, IndexError):
|
|
95
|
+
pass
|
|
96
|
+
# sclk clock level: "3: (1200.Mhz)" or "S: (238Mhz)" — level may be numeric or a letter.
|
|
97
|
+
elif "sclk clock level:" in rest_lower:
|
|
98
|
+
m = re.search(r"\((\d+)\.?Mhz\)", rest)
|
|
99
|
+
if m:
|
|
100
|
+
cur["sclk"] = int(m.group(1))
|
|
101
|
+
# mclk clock level
|
|
102
|
+
elif "mclk clock level:" in rest_lower:
|
|
103
|
+
val = rest.split(":", 1)[1].strip()
|
|
104
|
+
m = re.search(r"\((\d+)\.?Mhz\)", val)
|
|
105
|
+
if m:
|
|
106
|
+
cur["mclk"] = int(m.group(1))
|
|
107
|
+
# Temperature (Sensor edge)
|
|
108
|
+
elif "temperature (sensor edge)" in rest_lower:
|
|
109
|
+
try:
|
|
110
|
+
cur["temp"] = int(float(rest.split(":", 1)[1].strip()))
|
|
111
|
+
except (ValueError, IndexError):
|
|
112
|
+
pass
|
|
113
|
+
# Supported sclk frequencies section header
|
|
114
|
+
elif "supported sclk frequencies" in rest_lower:
|
|
115
|
+
in_sclk_section = True
|
|
116
|
+
continue
|
|
117
|
+
# Inside sclk section: lines like "0: 400Mhz" or "12: 2400Mhz *"
|
|
118
|
+
# The `*` marks the current active frequency (level may be numeric or state letter like "S:").
|
|
119
|
+
if in_sclk_section:
|
|
120
|
+
sm = re.match(r"^\S+\s*:\s*(\d+)\s*Mhz", rest)
|
|
121
|
+
if sm:
|
|
122
|
+
freq = int(sm.group(1))
|
|
123
|
+
if cur["sclk_max"] is None or freq > cur["sclk_max"]:
|
|
124
|
+
cur["sclk_max"] = freq
|
|
125
|
+
if "*" in rest:
|
|
126
|
+
cur["sclk"] = freq
|
|
127
|
+
return [cards[k] for k in sorted(cards)]
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _rocm_state():
|
|
131
|
+
"""Run rocm-smi, return parsed list. [] on missing tool / no driver."""
|
|
132
|
+
cmds = [
|
|
133
|
+
["rocm-smi", "--showclkfrq"],
|
|
134
|
+
["rocm-smi", "--showclocks"],
|
|
135
|
+
["rocm-smi", "--showmeminfo", "vram"],
|
|
136
|
+
["rocm-smi", "--showproductname"],
|
|
137
|
+
["rocm-smi", "--showtemp"],
|
|
138
|
+
]
|
|
139
|
+
parts = []
|
|
140
|
+
for cmd in cmds:
|
|
141
|
+
out = _run(cmd)
|
|
142
|
+
if out.strip():
|
|
143
|
+
parts.append(out)
|
|
144
|
+
if not parts:
|
|
145
|
+
return []
|
|
146
|
+
merged = "\n".join(parts)
|
|
147
|
+
try:
|
|
148
|
+
return _parse_rocm_text(merged)
|
|
149
|
+
except (subprocess.SubprocessError, OSError):
|
|
150
|
+
return []
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def gpus_amd():
|
|
154
|
+
"""[(name, vram_gb)] via rocm-smi; empty list if no AMD GPU detected."""
|
|
155
|
+
state = _rocm_state()
|
|
156
|
+
return [(d["name"], d["vram_gb"]) for d in state if d["name"] and d["vram_gb"]]
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _price_gpus(gs):
|
|
160
|
+
"""Price a list of (name, vram_gb) tuples through gpu_lookup.
|
|
161
|
+
|
|
162
|
+
Returns (known, unknown) where known/unknown are lists of
|
|
163
|
+
(name, vram_gb, bw, geta, gl, src) — src contains 'table' for known cards.
|
|
164
|
+
"""
|
|
165
|
+
priced = [(n, gb) + gpu_lookup(n) for n, gb in gs]
|
|
166
|
+
known = [p for p in priced if "table" in p[5]]
|
|
167
|
+
unknown = [p for p in priced if "table" not in p[5]]
|
|
168
|
+
return known, unknown
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def gpus():
|
|
172
|
+
"""[(name, vram_gb)] via nvidia-smi; empty list if none/AMD."""
|
|
173
|
+
out = _run(["nvidia-smi", "--query-gpu=name,memory.total", "--format=csv,noheader,nounits"])
|
|
174
|
+
gs = []
|
|
175
|
+
for line in out.strip().splitlines():
|
|
176
|
+
if "," in line:
|
|
177
|
+
name, mem = line.rsplit(",", 1)
|
|
178
|
+
try:
|
|
179
|
+
gs.append((name.strip(), float(mem) / 1024))
|
|
180
|
+
except ValueError:
|
|
181
|
+
pass
|
|
182
|
+
return gs
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def gpu_lookup(name):
|
|
186
|
+
n = name.lower()
|
|
187
|
+
for frag, bw, geta, gl in GPU_TABLE:
|
|
188
|
+
if frag in n:
|
|
189
|
+
return bw, geta, gl, "[table]"
|
|
190
|
+
return 300, 0.45, 0.27, "[default: unknown GPU, pass --vram-bw]"
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def _parse_win_adapters(text):
|
|
194
|
+
"""'DriverDesc|bytes' lines -> [(name, vram_gb)], virtual adapters filtered, dedup by max.
|
|
195
|
+
Pure parser so the smoke suite can test it without the registry."""
|
|
196
|
+
VIRTUAL = ("basic display", "basic render", "remote", "virtual", "vnc", "dameware",
|
|
197
|
+
"parsec", "spacedesk", "idd", "usb", "mirage", "citrix")
|
|
198
|
+
out = {}
|
|
199
|
+
for line in (text or "").strip().splitlines():
|
|
200
|
+
if "|" not in line:
|
|
201
|
+
continue
|
|
202
|
+
name, _, raw = line.rpartition("|")
|
|
203
|
+
name = name.strip()
|
|
204
|
+
if not name or any(v in name.lower() for v in VIRTUAL):
|
|
205
|
+
continue
|
|
206
|
+
try:
|
|
207
|
+
gb = int(raw.strip()) / 2**30
|
|
208
|
+
except ValueError:
|
|
209
|
+
gb = 0.0
|
|
210
|
+
out[name] = max(gb, out.get(name, 0.0))
|
|
211
|
+
return sorted(out.items())
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def gpus_other():
|
|
215
|
+
"""Non-NVIDIA adapters, Windows: driver registry first - qwMemorySize is the reliable VRAM
|
|
216
|
+
field; Win32_VideoController.AdapterRAM is a uint32 that CAPS AT 4 GB and under-reports
|
|
217
|
+
every modern card - CIM only as fallback. Issue #1's contributor ran an RX 5700 XT and this
|
|
218
|
+
tool printed 'GPU: none detected'; this function is the fix."""
|
|
219
|
+
if os.name != "nt":
|
|
220
|
+
return []
|
|
221
|
+
ps = ("$k='HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Class\\"
|
|
222
|
+
"{4d36e968-e325-11ce-bfc1-08002be10318}\\0*';"
|
|
223
|
+
"$r=Get-ItemProperty $k -ErrorAction SilentlyContinue | "
|
|
224
|
+
"Where-Object { $_.DriverDesc } | "
|
|
225
|
+
"ForEach-Object { $_.DriverDesc + '|' + $_.'HardwareInformation.qwMemorySize' };"
|
|
226
|
+
"if (-not $r) { $r = Get-CimInstance Win32_VideoController | "
|
|
227
|
+
"ForEach-Object { $_.Name + '|' + $_.AdapterRAM } };"
|
|
228
|
+
"$r")
|
|
229
|
+
return _parse_win_adapters(_run(["powershell", "-NoProfile", "-c", ps]))
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def ram_windows():
|
|
233
|
+
"""(total_gb[os], mts[os], channels[os]) via CIM (wmic fallback)."""
|
|
234
|
+
ps = _run(["powershell", "-NoProfile", "-c",
|
|
235
|
+
"$m=Get-CimInstance Win32_PhysicalMemory; "
|
|
236
|
+
"($m|Measure-Object Capacity -Sum).Sum; "
|
|
237
|
+
"($m|Select-Object -First 1).ConfiguredClockSpeed; ($m|Measure-Object).Count"])
|
|
238
|
+
vals = [v.strip() for v in ps.strip().splitlines() if v.strip()]
|
|
239
|
+
if len(vals) >= 3:
|
|
240
|
+
try:
|
|
241
|
+
return float(vals[0]) / 2**30, float(vals[1]), int(vals[2])
|
|
242
|
+
except ValueError:
|
|
243
|
+
pass
|
|
244
|
+
return None, None, None
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
WIDE_CPU = ("threadripper", "epyc", "xeon w-3", "xeon(r) w9", "xeon(r) w7", "xeon gold",
|
|
248
|
+
"xeon platinum", "xeon silver")
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def ram_channels(sticks, cpu_name):
|
|
252
|
+
"""(channels, provenance) - CHANNEL COUNT IS NOT STICK COUNT.
|
|
253
|
+
|
|
254
|
+
The first external replication (RTX 3090 + Ryzen 8600G, 4 DIMMs on dual-channel AM5) hit
|
|
255
|
+
exactly this: `min(sticks, 8)` assumed 4-channel and quoted 173 GB/s where the platform
|
|
256
|
+
delivers ~86 peak - a 2x input error that a correct Law 4 turned into a 2x wrong prediction.
|
|
257
|
+
Consumer desktop platforms (AM4/AM5, LGA17xx/18xx) are DUAL-channel regardless of stick
|
|
258
|
+
count; only HEDT/server parts go wider, and those we recognise by CPU name. When in doubt:
|
|
259
|
+
2, plus a note - `quantprobe calibrate` measures the real stream and overrides all of this.
|
|
260
|
+
|
|
261
|
+
THIS IS A FUNCTION so the rule can be tested. Before v1.24.0 the same logic was inline in
|
|
262
|
+
`detect()` and its guard test re-implemented the WIDE list in the test body, which meant the
|
|
263
|
+
test stayed green with the 2x bug restored (verified by mutation). A regression test that
|
|
264
|
+
cannot see the code it guards is not a regression test.
|
|
265
|
+
"""
|
|
266
|
+
cpu = (cpu_name or "").lower()
|
|
267
|
+
if any(w in cpu for w in WIDE_CPU):
|
|
268
|
+
n = max(1, min(sticks or 4, 8))
|
|
269
|
+
return n, f"assumes {n}-channel [HEDT/server CPU detected]"
|
|
270
|
+
n = min(sticks, 2) if sticks else 2
|
|
271
|
+
if sticks and sticks > 2:
|
|
272
|
+
return n, (f"dual-channel [consumer platform; {sticks} sticks does NOT mean {sticks} "
|
|
273
|
+
f"channels]")
|
|
274
|
+
return n, f"assumes {n}-channel"
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def detect():
|
|
278
|
+
"""Return the machine as quantprobe hardware kwargs + a provenance report."""
|
|
279
|
+
sysname = platform.system()
|
|
280
|
+
hw, notes = {}, []
|
|
281
|
+
|
|
282
|
+
if sysname == "Darwin":
|
|
283
|
+
mem = _run(["sysctl", "-n", "hw.memsize"]).strip()
|
|
284
|
+
chip = _run(["sysctl", "-n", "machdep.cpu.brand_string"]).lower()
|
|
285
|
+
total = float(mem) / 2**30 if mem else 16.0
|
|
286
|
+
bw = next((b for frag, b in sorted(MAC_BW.items(), key=lambda x: -len(x[0])) if frag in chip), 100)
|
|
287
|
+
hw = dict(vram=round(total * 0.8), vram_bw=bw, ram=8, ram_bw=bw, disk_bw=3.5,
|
|
288
|
+
geta=0.26, gl=0.24)
|
|
289
|
+
notes.append(f"Apple unified memory: {total:.0f} GB [os], {bw} GB/s [table, est eta 0.26 - unvalidated: bench me]")
|
|
290
|
+
return hw, notes
|
|
291
|
+
|
|
292
|
+
# RAM
|
|
293
|
+
total, mts, sticks = (ram_windows() if os.name == "nt" else (None, None, None))
|
|
294
|
+
if total is None and os.path.exists("/proc/meminfo"):
|
|
295
|
+
with open("/proc/meminfo") as f:
|
|
296
|
+
kb = int(re.search(r"MemTotal:\s*(\d+)", f.read()).group(1))
|
|
297
|
+
total, mts, sticks = kb / 2**20, None, None
|
|
298
|
+
if total is None:
|
|
299
|
+
total = 16.0; notes.append("RAM capacity: 16 GB [default - detection failed]")
|
|
300
|
+
channels, chan_src = ram_channels(sticks, platform.processor())
|
|
301
|
+
if mts:
|
|
302
|
+
ram_bw = round(channels * mts * 8 / 1000) # theoretical peak, preset convention
|
|
303
|
+
notes.append(f"RAM: {total:.0f} GB, {sticks} stick(s) @ {mts:.0f} MT/s [os] -> {ram_bw} GB/s peak "
|
|
304
|
+
f"({chan_src}); the DELIVERED stream is far below peak - the one box we have "
|
|
305
|
+
f"measured ran 26.1 of a 48 GB/s peak (0.544; n=1 machine, so this is a "
|
|
306
|
+
f"datapoint, not a population). Run `quantprobe calibrate` to measure yours")
|
|
307
|
+
else:
|
|
308
|
+
ram_bw = 48
|
|
309
|
+
notes.append(f"RAM: {total:.0f} GB [os]; speed unknown -> 48 GB/s [default: DDR4-3000 dual, pass --ram-bw]")
|
|
310
|
+
|
|
311
|
+
# GPU(s)
|
|
312
|
+
gs = gpus() or gpus_amd()
|
|
313
|
+
if gs:
|
|
314
|
+
vram = sum(g[1] for g in gs)
|
|
315
|
+
per = [gpu_lookup(g[0]) for g in gs] # per-card lookup (mixed pairs differ)
|
|
316
|
+
bw_sum = sum(p[0] for p in per)
|
|
317
|
+
vram_bw = bw_sum * (1.0 if len(gs) == 1 else 0.85) # aggregate w/ tensor-parallel loss
|
|
318
|
+
geta, gl, src = per[0][1], per[0][2], per[0][3] # eta class from the primary card
|
|
319
|
+
names = " + ".join(g[0] for g in gs)
|
|
320
|
+
notes.append(f"GPU: {names}, {vram:.0f} GB total [os], {vram_bw:.0f} GB/s {src}"
|
|
321
|
+
+ (f" (x{len(gs)} per-card sum, 0.85 TP efficiency [est]; slower card gates its share)" if len(gs) > 1 else ""))
|
|
322
|
+
hw.update(vram=vram, vram_bw=round(vram_bw), geta=geta, gl=gl)
|
|
323
|
+
else:
|
|
324
|
+
# nvidia-smi saw nothing - check AMD via rocm-smi, then Windows driver registry for
|
|
325
|
+
# Intel (or any GPU with no driver tools). Field case: issue #1, RX 5700 XT, "none detected".
|
|
326
|
+
amd = gpus_amd()
|
|
327
|
+
others = gpus_other() if not amd else []
|
|
328
|
+
# NO `if gs:` guard around this chain. _price_gpus([]) returns ([], []), so the empty
|
|
329
|
+
# case falls to the else and gets vram=0 + the "none detected" note like every other
|
|
330
|
+
# dead end. Guarding it skipped BOTH on a machine with no GPU at all: hw came back
|
|
331
|
+
# with no vram/vram_bw keys and no GPU line, which is how None hardware reached the
|
|
332
|
+
# contribute payload once already (issue #1). CI caught it; a GPU box cannot.
|
|
333
|
+
known, unknown = _price_gpus(amd or others)
|
|
334
|
+
if known:
|
|
335
|
+
vram = sum(p[1] for p in known)
|
|
336
|
+
vram_bw = sum(p[2] for p in known) * (1.0 if len(known) == 1 else 0.85)
|
|
337
|
+
names = " + ".join(p[0] for p in known)
|
|
338
|
+
is_amd = bool(amd)
|
|
339
|
+
hw.update(vram=round(vram, 1), vram_bw=round(vram_bw),
|
|
340
|
+
geta=known[0][3], gl=known[0][4])
|
|
341
|
+
src_note = ("AMD via rocm-smi (amdgpu driver required)" if is_amd
|
|
342
|
+
else "non-NVIDIA path: VRAM from the driver registry, bandwidth from spec")
|
|
343
|
+
notes.append(f"GPU: {names}, {vram:.0f} GB [os], {vram_bw:.0f} GB/s [table] - "
|
|
344
|
+
f"{src_note}; eta on this backend is UNVALIDATED here, so run "
|
|
345
|
+
f"`quantprobe calibrate` with your llama.cpp build to anchor it")
|
|
346
|
+
elif unknown:
|
|
347
|
+
names = ", ".join(f"{p[0]} ({p[1]:.0f} GB)" for p in unknown)
|
|
348
|
+
hw.update(vram=0, vram_bw=0)
|
|
349
|
+
notes.append(f"GPU: {names} detected [os] but not in the bandwidth table - pass "
|
|
350
|
+
f"--vram <GB> --vram-bw <GB/s> (spec sheet) to include the GPU tier; "
|
|
351
|
+
f"planning CPU-only until then")
|
|
352
|
+
else:
|
|
353
|
+
hw.update(vram=0, vram_bw=0)
|
|
354
|
+
notes.append("GPU: none detected (nvidia-smi absent/empty; AMD/Intel: pass --vram/--vram-bw) [os]")
|
|
355
|
+
|
|
356
|
+
# disk: class default; a real measured number needs `quantprobe hw --measure` (reads a large file)
|
|
357
|
+
hw.update(ram=round(total), ram_bw=ram_bw, disk_bw=0.5)
|
|
358
|
+
notes.append("disk: 0.5 GB/s [default: SATA-class; NVMe ~3.5, Gen4 ~7 - pass --disk-bw or run hw --measure]")
|
|
359
|
+
return hw, notes
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
def probe_offset(size, span, rnd=None):
|
|
363
|
+
"""Where the next disk probe reads from. Uniform over the WHOLE file, not the tail.
|
|
364
|
+
|
|
365
|
+
C-17: the old probe read a fixed 512 MB TAIL region jittered by at most 7 MB, so ~98.6% of
|
|
366
|
+
the span overlapped between calls, and `buffering=0` does NOT bypass the OS page cache.
|
|
367
|
+
Measured on this box: cold 0.44 GB/s, then 2.99 / 2.99 GB/s on re-reads - the warm number is
|
|
368
|
+
RAM, not disk, and it shipped as a disk-tier input 6.8x too fast.
|
|
369
|
+
|
|
370
|
+
Split out of `measure_disk` so the property can be tested WITHOUT a multi-gigabyte file and
|
|
371
|
+
without timing anything: draw N offsets and check they span the file. The previous regression
|
|
372
|
+
test needed a >2 GB fixture, silently skipped without one, and asserted only that repeated
|
|
373
|
+
timings AGREE - which a fully page-cached file also satisfies, so it could not tell "fixed"
|
|
374
|
+
from "warm every time". This one fails on the tail-jitter code by construction.
|
|
375
|
+
"""
|
|
376
|
+
room = max(0, size - span)
|
|
377
|
+
if room <= 0:
|
|
378
|
+
return 0
|
|
379
|
+
# 8 bytes, not 4. `os.urandom(4)` caps the draw at 2**32-1, so on any file larger than 4 GiB
|
|
380
|
+
# the probe could never read past the 4 GiB mark: on a 20 GB GGUF - exactly the size class
|
|
381
|
+
# the disk tier exists to model - 80% of the file was unreachable, and the reachable prefix
|
|
382
|
+
# is the part a partial download or a header read has already warmed. The C-17 fix shipped
|
|
383
|
+
# half-done and this is the other half; caught by the offset test in tests/smoke.py.
|
|
384
|
+
r = rnd() if rnd else int.from_bytes(os.urandom(8), "big")
|
|
385
|
+
return r % (room + 1)
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
def _one_read(path, mb):
|
|
389
|
+
"""One timed read of one random region. GB/s."""
|
|
390
|
+
import time
|
|
391
|
+
size = os.path.getsize(path)
|
|
392
|
+
span = min(mb * 1024 * 1024, size)
|
|
393
|
+
off = probe_offset(size, span)
|
|
394
|
+
t0 = time.perf_counter()
|
|
395
|
+
with open(path, "rb", buffering=0) as f:
|
|
396
|
+
f.seek(off)
|
|
397
|
+
left = span
|
|
398
|
+
while left > 0:
|
|
399
|
+
chunk = f.read(min(1 << 24, left))
|
|
400
|
+
if not chunk:
|
|
401
|
+
break
|
|
402
|
+
left -= len(chunk)
|
|
403
|
+
dt = time.perf_counter() - t0
|
|
404
|
+
return (span - left) / 1e9 / dt
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
def measure_disk(path, mb=512, samples=5, detail=False):
|
|
408
|
+
"""Disk read bandwidth, GB/s: the MINIMUM over `samples` disjoint random regions.
|
|
409
|
+
|
|
410
|
+
WHY THE MINIMUM AND NOT ONE SAMPLE (prereg #97, measured 2026-08-01). The previous version
|
|
411
|
+
took a single sample and told the USER, in this docstring, to "treat a single number above
|
|
412
|
+
~1.5 GB/s as evidence of a warm cache rather than a fast disk." Asking the caller to perform
|
|
413
|
+
the check the code should do is not a guard. Hours after that text was written, verify.py
|
|
414
|
+
caught it live: reads of [0.413, 3.171, 0.415] GB/s on one file, because an experiment had
|
|
415
|
+
streamed 15 GB of it minutes earlier. A single draw can BE that middle sample.
|
|
416
|
+
|
|
417
|
+
Measured, 8 draws per arm on a 13.7 GB GGUF:
|
|
418
|
+
file with 73% deliberately warmed : 6 of 8 draws returned >1.5 GB/s, max 2.854 - RAM
|
|
419
|
+
reported as disk, a 6.3x error
|
|
420
|
+
file after deliberate eviction : still 1 of 8 draws at 2.092 - a 4.7x error
|
|
421
|
+
minimum over the draws : 0.4499 and 0.4537 - both correct against the
|
|
422
|
+
independent raw-read baseline of 0.452-0.459 (D-28)
|
|
423
|
+
|
|
424
|
+
The second line is the one that matters: on this box a cold read cannot be *guaranteed* even
|
|
425
|
+
after evicting 16 GB of an unrelated file, so single-sample probing is structurally
|
|
426
|
+
unreliable rather than merely unlucky-after-a-download. Nothing reads FASTER than the device
|
|
427
|
+
except cache, so the minimum is the estimator; a warm region can only push a sample up.
|
|
428
|
+
|
|
429
|
+
NOT DONE HERE, deliberately: this does not nudge the number toward the ~0.25 GB/s that
|
|
430
|
+
llama.cpp actually achieves while streaming (C-23). That gap is a RUNTIME inefficiency and
|
|
431
|
+
belongs in the law, not in a probe whose job is to measure the DEVICE. Letting a
|
|
432
|
+
mis-measured probe cancel an unmodelled runtime cost is the mutually-consistent-presets trap
|
|
433
|
+
C-17 exists to warn about - two errors that cancel are still two errors.
|
|
434
|
+
|
|
435
|
+
Cost: `samples` x `mb` of reading (default ~2.5 GB, a few seconds) on a once-per-machine
|
|
436
|
+
calibration path. `detail=True` also returns the individual draws and how many look warm.
|
|
437
|
+
"""
|
|
438
|
+
reads = [_one_read(path, mb) for _ in range(max(1, samples))]
|
|
439
|
+
lo = min(reads)
|
|
440
|
+
# POST-HOC (labelled as such): the staked spread test max/min > 2.0 was REFUTED - it fired
|
|
441
|
+
# on both arms, because neither arm was truly cold. The warm FRACTION does discriminate
|
|
442
|
+
# (1/8 evicted vs 7/8 warmed), but it was chosen after seeing those numbers and has not
|
|
443
|
+
# been confirmed on an independent run. It is reported, never used to alter the estimate.
|
|
444
|
+
warm = sum(1 for r in reads if r > 2.0 * lo)
|
|
445
|
+
if detail:
|
|
446
|
+
return lo, {"draws": [round(r, 4) for r in reads], "disk_gbs": round(lo, 4),
|
|
447
|
+
"warm_draws": warm, "samples": len(reads)}
|
|
448
|
+
return lo
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
def run(a):
|
|
452
|
+
hw, notes = detect()
|
|
453
|
+
print("quantprobe hw - this machine, as the law sees it\n")
|
|
454
|
+
for n in notes:
|
|
455
|
+
print(" " + n)
|
|
456
|
+
if getattr(a, "measure", None):
|
|
457
|
+
p = a.measure
|
|
458
|
+
if os.path.isfile(p):
|
|
459
|
+
bw, info = measure_disk(p, detail=True)
|
|
460
|
+
hw["disk_bw"] = round(bw, 2)
|
|
461
|
+
print(f" disk MEASURED on {os.path.basename(p)}: {bw:.2f} GB/s sequential [measured]")
|
|
462
|
+
print(f" minimum of {info['samples']} probes at random offsets: {info['draws']}")
|
|
463
|
+
if info["warm_draws"]:
|
|
464
|
+
print(f" {info['warm_draws']} of {info['samples']} draws returned >2x the "
|
|
465
|
+
f"minimum - page cache, not disk. The minimum is\n used and is the "
|
|
466
|
+
f"right number. Measured on a deliberately warmed 13.7 GB file, 6 of 8 "
|
|
467
|
+
f"single\n draws came back above 1.5 GB/s (max 2.854, a 6.3x error) "
|
|
468
|
+
f"while the minimum stayed correct;\n even after evicting 16 GB, 1 in 8 "
|
|
469
|
+
f"draws still hit cache. One sample was never safe. (#97)")
|
|
470
|
+
else:
|
|
471
|
+
print(f" --measure: file not found: {p}")
|
|
472
|
+
flags = (f"--vram {hw['vram']:g} --vram-bw {hw['vram_bw']:g} --ram {hw['ram']:g} "
|
|
473
|
+
f"--ram-bw {hw['ram_bw']:g} --disk-bw {hw['disk_bw']:g}")
|
|
474
|
+
print(f"\n equivalent flags (for sharing / estimating this box elsewhere):\n {flags}")
|
|
475
|
+
print("\n every command now uses these automatically when you pass no hardware flags;")
|
|
476
|
+
print(" pass --machine or explicit flags to estimate a DIFFERENT machine instead.")
|
|
477
|
+
return hw
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quantprobe
|
|
3
|
-
Version: 1.28.
|
|
3
|
+
Version: 1.28.2
|
|
4
4
|
Summary: Probe-then-quantize for LLMs: measure a model's fragility curve, plan bit/tier placement by the tiered decode law, and emit ready-to-run llama.cpp recipes.
|
|
5
5
|
Author: Federico Sciuca
|
|
6
6
|
License: MIT
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|