tuieval 0.2.0.dev62__py3-none-any.whl → 0.2.0.dev66__py3-none-any.whl

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.
tuieval/_version.py CHANGED
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.2.0.dev62'
22
- __version_tuple__ = version_tuple = (0, 2, 0, 'dev62')
21
+ __version__ = version = '0.2.0.dev66'
22
+ __version_tuple__ = version_tuple = (0, 2, 0, 'dev66')
23
23
 
24
24
  __commit_id__ = commit_id = None
tuieval/compare.py CHANGED
@@ -35,7 +35,8 @@ def _load_native(data):
35
35
  m, pack, run = data["model"], data["pack"], data["run"]
36
36
  info = {"label": m["label"], "served": m.get("served_name"), "tags": m.get("tags") or [],
37
37
  "settings": data.get("settings", {}), "load_s": run.get("load_s"),
38
- "peak_rss_mb": run.get("peak_rss_mb"), "pack": pack["name"], "pack_fp": pack["fingerprint"],
38
+ "peak_rss_mb": run.get("peak_rss_mb"), "vram_peak_gb": run.get("vram_peak_gb"),
39
+ "pack": pack["name"], "pack_fp": pack["fingerprint"],
39
40
  # hosted (OpenRouter) models: the provider endpoint and its declared quantization
40
41
  "endpoint": run.get("endpoint"), "quantization": run.get("quantization"),
41
42
  "loaded_alongside": run.get("loaded_alongside") or []}
tuieval/doctor.py CHANGED
@@ -10,6 +10,7 @@ import platform
10
10
  import sys
11
11
 
12
12
  from . import engine
13
+ from . import machines
13
14
  from . import workspace
14
15
 
15
16
  OK, WARN, BAD = "✓", "!", "✗"
@@ -44,6 +45,22 @@ def check(models_path=None):
44
45
  return r.bad
45
46
  r.line(OK, f"workspace {e.root}")
46
47
 
48
+ r.head("Machine")
49
+ mc = e.machine()
50
+ r.line(OK, f"{mc.id}: {mc.summary}")
51
+ if mc.discrete:
52
+ r.line(OK, f"models are sized to {mc.gpu_limit_gb:.0f} GB of VRAM, keeping {e.headroom_gb(mc):g} GB free "
53
+ "(memory_headroom_gb, gpu_memory_gb under [machines.<id>] change it)")
54
+ new = machines.gpu_id(machines.discrete_gpus(), mc.ram_gb)
55
+ if mc.id != new and not os.environ.get("EVALS_MACHINE"):
56
+ r.line(WARN, f"keeping the id {mc.id} this machine had before its GPU was detected, so earlier results "
57
+ "and tuning still match", f"to switch: EVALS_MACHINE={new} (results under the old id "
58
+ "then count as another machine)")
59
+ elif platform.system() == "Linux" and any(os.path.exists(p) for p in ("/dev/nvidia0", "/dev/kfd")):
60
+ r.line(WARN, "this machine seems to have an Nvidia or AMD GPU, but nvidia-smi / amd-smi / rocm-smi "
61
+ "isn't installed, so models are sized against system RAM",
62
+ "install the vendor's tools, or set gpu_memory_gb under [machines.<id>] in models.toml")
63
+
47
64
  r.head("Packs")
48
65
  for err in e.pack_errors:
49
66
  r.line(BAD, err, "fix the pack, then: tuieval selftest")
tuieval/engine.py CHANGED
@@ -1191,7 +1191,19 @@ class Engine:
1191
1191
 
1192
1192
  # ---- serving on this machine
1193
1193
  def machine(self):
1194
- return machines.detect()
1194
+ """This machine, with its models.toml [machines.<id>] gpu_memory_gb applied. A Linux machine
1195
+ that recorded itself before its GPU was detected keeps that id, so its results and tuning
1196
+ still match (EVALS_MACHINE renames it)."""
1197
+ mc = machines.detect()
1198
+ if mc.discrete and not os.environ.get("EVALS_MACHINE"):
1199
+ old = machines.machine_id(mc.chip, mc.ram_gb)
1200
+ if os.path.isdir(os.path.join(self.tuning_dir, old)) and \
1201
+ not os.path.isdir(os.path.join(self.tuning_dir, mc.id)):
1202
+ mc = dataclasses.replace(mc, id=old)
1203
+ override = self.cfg.get("machines", {}).get(mc.id, {}).get("gpu_memory_gb")
1204
+ if override:
1205
+ mc = dataclasses.replace(mc, gpu_limit_gb=float(override))
1206
+ return mc
1195
1207
 
1196
1208
  def machines(self):
1197
1209
  """This machine first, then every other machine recorded in tuning/ (synced)."""
@@ -1203,9 +1215,14 @@ class Engine:
1203
1215
  return [here] + [mc for mc in profiles.known_machines(self.tuning_dir) if mc.id != here.id]
1204
1216
 
1205
1217
  def machine_settings(self, machine_id=None):
1206
- """models.toml [machines.<id>] (optional): memory_headroom_gb, name."""
1218
+ """models.toml [machines.<id>] (optional): memory_headroom_gb, gpu_memory_gb, name."""
1207
1219
  return self.cfg.get("machines", {}).get(machine_id or self.machine().id, {})
1208
1220
 
1221
+ def headroom_gb(self, mc):
1222
+ """GPU memory kept free: memory_headroom_gb, else 4 GB on a Mac (macOS and other apps share
1223
+ it) and 1.5 GB in a discrete GPU's VRAM."""
1224
+ return float(self.machine_settings(mc.id).get("memory_headroom_gb", 1.5 if mc.discrete else 4.0))
1225
+
1209
1226
  def parallel_models(self):
1210
1227
  """How many models a run serves at a time on this machine: models.toml [machines.<id>]
1211
1228
  parallel_models (default 1)."""
@@ -1224,7 +1241,7 @@ class Engine:
1224
1241
  def memory_available_gb(self):
1225
1242
  """GPU memory models may take here (what the fit check sizes contexts against)."""
1226
1243
  mc = self.machine()
1227
- return mc.gpu_limit_gb - self.machine_settings(mc.id).get("memory_headroom_gb", 4.0)
1244
+ return mc.gpu_limit_gb - self.headroom_gb(mc)
1228
1245
 
1229
1246
  def runs_alone(self, m):
1230
1247
  """A server whose before_start step may stop other servers never runs next to another model."""
@@ -1269,8 +1286,7 @@ class Engine:
1269
1286
  if fit_check(server):
1270
1287
  mmproj = expand(m.get("mmproj", ""))
1271
1288
  extra = os.path.getsize(mmproj) if mmproj and os.path.isfile(mmproj) else 0
1272
- headroom = self.machine_settings(mc.id).get("memory_headroom_gb", 4.0)
1273
- f = machines.fit(path, mc, kv_type=kv or "f16", headroom_gb=headroom, extra_bytes=extra,
1289
+ f = machines.fit(path, mc, kv_type=kv or "f16", headroom_gb=self.headroom_gb(mc), extra_bytes=extra,
1274
1290
  want_ctx=want)
1275
1291
  ctx, fits, note, need = f.max_ctx, f.fits, f.note, f.need_gb
1276
1292
  except (OSError, ValueError) as e:
@@ -1484,11 +1500,22 @@ class Engine:
1484
1500
  time.sleep(0.2)
1485
1501
  threading.Thread(target=run, daemon=True).start()
1486
1502
 
1487
- def _watch_memory(self, proc, label, stop, peak):
1503
+ VRAM_EVERY_S = 6 # how often to read a discrete GPU's VRAM while a server runs
1504
+
1505
+ def _watch_memory(self, proc, label, stop, peak, info=None):
1488
1506
  """Peak resident memory of the server's process group (MB). On Apple Silicon this includes
1489
- the model weights mapped for the GPU."""
1507
+ the model weights mapped for the GPU. With discrete GPUs, also the peak VRAM it holds
1508
+ (info["vram_peak_gb"]): its own processes' on Nvidia, the machine's on AMD."""
1509
+ discrete = info is not None and self.machine().discrete
1510
+ last_vram = [0.0]
1511
+
1490
1512
  def run():
1491
1513
  while not stop.is_set():
1514
+ if discrete and time.time() - last_vram[0] >= self.VRAM_EVERY_S:
1515
+ last_vram[0] = time.time()
1516
+ used = machines.vram_used_gb(machines.tree_pids(proc.pid))
1517
+ if used:
1518
+ info["vram_peak_gb"] = round(max(info.get("vram_peak_gb") or 0, used), 2)
1492
1519
  try:
1493
1520
  out = subprocess.run(["ps", "-axo", "pgid=,rss="], capture_output=True, text=True).stdout
1494
1521
  rss = sum(int(r) for g, r in (l.split() for l in out.splitlines() if l.strip())
@@ -1789,7 +1816,7 @@ class Engine:
1789
1816
  f"(see logs/server/{log_name or m['label']}.log)")
1790
1817
  t0 = time.time()
1791
1818
  srv = self._start(cmd, log, cwd=cwd)
1792
- self._watch_memory(srv, m["label"], stop, peak)
1819
+ self._watch_memory(srv, m["label"], stop, peak, info)
1793
1820
  else:
1794
1821
  key_env = server.get("api_key_env")
1795
1822
  if key_env and not os.environ.get(key_env):
@@ -1881,6 +1908,7 @@ class Engine:
1881
1908
  def run_info():
1882
1909
  return {"load_s": info["load_s"], "peak_rss_mb": info["peak_mb"](),
1883
1910
  "server_facts": info["facts"] or None, "gpu_peak_gb": info.get("gpu_peak_gb"),
1911
+ "vram_peak_gb": info.get("vram_peak_gb"),
1884
1912
  "kernel_share_max": info.get("kernel_share_max"),
1885
1913
  **({"loaded_alongside": loaded_alongside} if loaded_alongside else {}), **serving_info}
1886
1914
  failed_in_row = 0
@@ -1965,7 +1993,8 @@ class Engine:
1965
1993
  return tests
1966
1994
 
1967
1995
  # ---- sittings: a pack run over several sessions (stopped and resumed) keeps its total time
1968
- SITTING_KEYS = ("load_s", "peak_rss_mb", "gpu_peak_gb", "kernel_share_max", "machine", "loaded_alongside")
1996
+ SITTING_KEYS = ("load_s", "peak_rss_mb", "gpu_peak_gb", "vram_peak_gb", "kernel_share_max", "machine",
1997
+ "loaded_alongside")
1969
1998
 
1970
1999
  def _sitting(self, job, info):
1971
2000
  now = time.time()
@@ -2037,7 +2066,7 @@ class Engine:
2037
2066
  out = {"started": min(s["started"] for s in sittings),
2038
2067
  "wall_s": round(sum(s.get("wall_s") or 0 for s in sittings), 1),
2039
2068
  "sittings": len(sittings), "sittings_log": sittings}
2040
- for k in ("peak_rss_mb", "gpu_peak_gb", "kernel_share_max"):
2069
+ for k in ("peak_rss_mb", "gpu_peak_gb", "vram_peak_gb", "kernel_share_max"):
2041
2070
  if peak(k) is not None:
2042
2071
  out[k] = peak(k)
2043
2072
  along = sorted({l for s in sittings for l in s.get("loaded_alongside") or []})
tuieval/machines.py CHANGED
@@ -1,6 +1,7 @@
1
1
  """Which machine this is, what a model needs, and whether it fits.
2
2
 
3
- detect() -> Machine (chip, cores, RAM, GPU memory limit, id like "m3max-64gb")
3
+ detect() -> Machine (chip, cores, RAM, GPU memory limit, id like "m3max-64gb";
4
+ with Nvidia/AMD cards on Linux, their VRAM and an id like "rtx4090-128gb")
4
5
  read_gguf(path) -> GGUF header facts (architecture, layers, KV heads, context length, …)
5
6
  fit(model_path, …) -> Fit (largest context that fits this machine, estimated memory)
6
7
 
@@ -9,6 +10,7 @@ the KV cache on its own (that would change answers); a quantized-KV variant is a
9
10
  """
10
11
  import dataclasses
11
12
  import functools
13
+ import json
12
14
  import os
13
15
  import platform
14
16
  import re
@@ -28,15 +30,19 @@ class Machine:
28
30
  id: str
29
31
  chip: str
30
32
  ram_gb: float
31
- gpu_limit_gb: float # what Metal may wire for the GPU
33
+ gpu_limit_gb: float # what Metal may wire for the GPU; with discrete GPUs, their VRAM (all cards)
32
34
  p_cores: int
33
35
  e_cores: int
34
36
  gpu_cores: int | None
35
37
  os: str
38
+ gpu_name: str | None = None # discrete GPUs, e.g. "2× NVIDIA GeForce RTX 4090"
39
+ discrete: bool = False # the GPU has its own memory (VRAM), separate from RAM
36
40
 
37
41
  @property
38
42
  def summary(self):
39
43
  cores = f"{self.p_cores}P+{self.e_cores}E" if self.e_cores else f"{self.p_cores} cores"
44
+ if self.discrete:
45
+ return f"{self.chip} · {self.ram_gb:.0f} GB RAM · {self.gpu_name} · {self.gpu_limit_gb:.0f} GB VRAM · {cores}"
40
46
  gpu = f", {self.gpu_cores}-core GPU" if self.gpu_cores else ""
41
47
  return f"{self.chip} · {self.ram_gb:.0f} GB (GPU up to {self.gpu_limit_gb:.0f} GB) · {cores}{gpu}"
42
48
 
@@ -53,6 +59,129 @@ def machine_id(chip, ram_gb):
53
59
  return re.sub(r"[^a-z0-9]+", "", name.lower()) + f"-{round(ram_gb)}gb"
54
60
 
55
61
 
62
+ def gpu_id(gpus, ram_gb):
63
+ """A machine id from its discrete GPUs: "rtx4090-128gb", "2xrtx4090-128gb", "rx7900xtx+rtx3090-64gb"."""
64
+ names = []
65
+ for name in sorted({n for n, _ in gpus}):
66
+ short = re.sub(r"\b(nvidia|geforce|amd|radeon|ati|graphics|tm)\b", "", name.lower())
67
+ short = re.sub(r"[^a-z0-9]+", "", short) or "gpu"
68
+ count = sum(n == name for n, _ in gpus)
69
+ names.append(f"{count}x{short}" if count > 1 else short)
70
+ return "+".join(names) + f"-{round(ram_gb)}gb"
71
+
72
+
73
+ # ---------------------------------------------------------------- discrete GPUs (Linux: Nvidia, AMD)
74
+ # Read from the vendors' own tools. Anything unexpected counts as "not detected", never an error.
75
+ def _run(cmd, timeout=10):
76
+ try:
77
+ p = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
78
+ except (OSError, subprocess.TimeoutExpired):
79
+ return None
80
+ return p.stdout if p.returncode == 0 else None
81
+
82
+
83
+ def _nvidia_gpus():
84
+ out = _run(["nvidia-smi", "--query-gpu=name,memory.total", "--format=csv,noheader,nounits"])
85
+ gpus = []
86
+ for line in (out or "").splitlines():
87
+ name, _, mib = line.rpartition(",")
88
+ try:
89
+ gpus.append((name.strip(), float(mib) / 1024))
90
+ except ValueError:
91
+ pass
92
+ return [g for g in gpus if g[0] and g[1] > 0]
93
+
94
+
95
+ def _walk(obj):
96
+ """Every dict inside a JSON value."""
97
+ if isinstance(obj, dict):
98
+ yield obj
99
+ for v in obj.values():
100
+ yield from _walk(v)
101
+ elif isinstance(obj, list):
102
+ for v in obj:
103
+ yield from _walk(v)
104
+
105
+
106
+ def _bytes(value, unit=None):
107
+ """VRAM sizes as amd-smi/rocm-smi print them: 25753026560, "24560 MB", {"value": 24560, "unit": "MB"}."""
108
+ if isinstance(value, dict):
109
+ return _bytes(value.get("value"), value.get("unit"))
110
+ m = re.match(r"\s*([\d.]+)\s*([KMGT]i?B|B)?\s*$", str(value), re.I)
111
+ if not m:
112
+ return None
113
+ scale = {"B": 1, "KB": 2**10, "MB": 2**20, "GB": 2**30, "TB": 2**40}
114
+ u = (m.group(2) or unit or "B").upper().replace("I", "")
115
+ return float(m.group(1)) * scale.get(u, 1)
116
+
117
+
118
+ def _amd_gpus():
119
+ out = _run(["amd-smi", "static", "--asic", "--vram", "--json"])
120
+ gpus = []
121
+ try:
122
+ for d in _walk(json.loads(out)) if out else []:
123
+ if "vram" in d and isinstance(d["vram"], dict):
124
+ size = _bytes(d["vram"].get("size"))
125
+ name = (d.get("asic") or {}).get("market_name") or "AMD GPU"
126
+ if size:
127
+ gpus.append((str(name), size / GB))
128
+ except ValueError:
129
+ gpus = []
130
+ if gpus:
131
+ return gpus
132
+ out = _run(["rocm-smi", "--showmeminfo", "vram", "--showproductname", "--json"])
133
+ try:
134
+ cards = json.loads(out) if out else {}
135
+ except ValueError:
136
+ return []
137
+ for key, d in sorted(cards.items()) if isinstance(cards, dict) else []:
138
+ if not key.startswith("card") or not isinstance(d, dict):
139
+ continue
140
+ size = _bytes(d.get("VRAM Total Memory (B)"))
141
+ name = d.get("Card Series") or d.get("Card series") or d.get("Card SKU") or d.get("Card model") or "AMD GPU"
142
+ if size:
143
+ gpus.append((str(name), size / GB))
144
+ return gpus
145
+
146
+
147
+ def discrete_gpus():
148
+ """[(name, VRAM GB)] for the Nvidia or AMD cards this machine has, or [] (none, or tools missing)."""
149
+ return _nvidia_gpus() or _amd_gpus()
150
+
151
+
152
+ def vram_used_gb(pids=None):
153
+ """VRAM in use now (GB): by these processes on Nvidia (all of it when pids is None), or on the
154
+ whole machine on AMD, whose tools don't report it reliably per process. None if unknown."""
155
+ if pids is not None:
156
+ out = _run(["nvidia-smi", "--query-compute-apps=pid,used_memory", "--format=csv,noheader,nounits"])
157
+ if out is not None:
158
+ used = 0.0
159
+ for line in out.splitlines():
160
+ pid, _, mib = line.partition(",")
161
+ if pid.strip() in {str(p) for p in pids}:
162
+ try:
163
+ used += float(mib) / 1024
164
+ except ValueError:
165
+ pass
166
+ return used
167
+ out = _run(["nvidia-smi", "--query-gpu=memory.used", "--format=csv,noheader,nounits"])
168
+ if out is not None:
169
+ try:
170
+ return sum(float(x) for x in out.split()) / 1024
171
+ except ValueError:
172
+ return None
173
+ out = _run(["rocm-smi", "--showmeminfo", "vram", "--json"])
174
+ try:
175
+ cards = json.loads(out) if out else None
176
+ except ValueError:
177
+ return None
178
+ if not isinstance(cards, dict):
179
+ return None
180
+ used = [_bytes(d.get("VRAM Total Used Memory (B)")) for k, d in cards.items()
181
+ if k.startswith("card") and isinstance(d, dict)]
182
+ return sum(u for u in used if u) / GB if any(used) else None
183
+
184
+
56
185
  @functools.lru_cache(maxsize=1)
57
186
  def detect():
58
187
  """This machine. Override the id with EVALS_MACHINE if two machines would collide."""
@@ -73,11 +202,19 @@ def detect():
73
202
  except (OSError, subprocess.TimeoutExpired):
74
203
  pass
75
204
  os_name = "macOS " + platform.mac_ver()[0]
76
- else: # Linux and others: CPU-side facts only
205
+ else: # Linux and others: the CPU side, plus Nvidia/AMD cards if their tools are installed
77
206
  chip = platform.processor() or platform.machine()
78
207
  ram = os.sysconf("SC_PAGE_SIZE") * os.sysconf("SC_PHYS_PAGES") / GB
79
208
  p, e, gpu_cores, limit = os.cpu_count() or 1, 0, None, ram * 0.9
80
209
  os_name = platform.system()
210
+ gpus = discrete_gpus()
211
+ if gpus:
212
+ names = sorted({n for n, _ in gpus})
213
+ gpu_name = " + ".join(f"{sum(n == x for n, _ in gpus)}× {x}" if sum(n == x for n, _ in gpus) > 1 else x
214
+ for x in names)
215
+ mid = os.environ.get("EVALS_MACHINE") or gpu_id(gpus, ram)
216
+ return Machine(mid, chip, round(ram, 1), round(sum(g for _, g in gpus), 1), p, e, None, os_name,
217
+ gpu_name=gpu_name, discrete=True)
81
218
  mid = os.environ.get("EVALS_MACHINE") or machine_id(chip, ram)
82
219
  return Machine(mid, chip, round(ram, 1), round(limit, 1), p, e, gpu_cores, os_name)
83
220
 
@@ -195,14 +332,15 @@ def fit(model_path, machine=None, kv_type="f16", headroom_gb=4.0, extra_bytes=0,
195
332
  model_max = info["context_length"] or 131072
196
333
  max_ctx = int(min(room / per_tok, model_max, want_ctx or model_max)) if room > 0 else 0
197
334
  max_ctx = max_ctx // 1024 * 1024
335
+ of = " of VRAM" if machine.discrete else ""
198
336
  if max_ctx < MIN_CTX:
199
337
  need = fixed + MIN_CTX * per_tok / GB
200
338
  return Fit(False, max_ctx, round(need, 1), round(available, 1),
201
339
  f"doesn't fit on {machine.id}: needs ~{need:.0f} GB at {MIN_CTX // 1024}k context, "
202
- f"{available:.0f} GB available")
340
+ f"{available:.0f} GB{of} available")
203
341
  need = fixed + max_ctx * per_tok / GB
204
342
  return Fit(True, max_ctx, round(need, 1), round(available, 1),
205
- f"fits on {machine.id} up to {max_ctx // 1024}k context (~{need:.0f} of {available:.0f} GB)")
343
+ f"fits on {machine.id} up to {max_ctx // 1024}k context (~{need:.0f} of {available:.0f} GB{of})")
206
344
 
207
345
 
208
346
  # ---------------------------------------------------------------- memory pressure
@@ -287,6 +425,26 @@ def tree_cpu_seconds(pid):
287
425
  return (sum(rows[p][1] for p in tree), sum(rows[p][2] for p in tree))
288
426
 
289
427
 
428
+ def tree_pids(pid):
429
+ """A process and all its descendants (pids), or [pid] if ps can't be read."""
430
+ try:
431
+ out = subprocess.run(["ps", "-axo", "pid=,ppid="], capture_output=True, text=True, timeout=5).stdout
432
+ except (OSError, subprocess.TimeoutExpired):
433
+ return [pid]
434
+ children = {}
435
+ for line in out.splitlines():
436
+ parts = line.split()
437
+ if len(parts) == 2:
438
+ children.setdefault(parts[1], []).append(parts[0])
439
+ tree, frontier = {str(pid)}, [str(pid)]
440
+ while frontier:
441
+ for child in children.get(frontier.pop(), []):
442
+ if child not in tree:
443
+ tree.add(child)
444
+ frontier.append(child)
445
+ return sorted(int(p) for p in tree)
446
+
447
+
290
448
  def group_cpu_seconds(pgid):
291
449
  """(user, kernel) CPU seconds used so far by a process group, or None."""
292
450
  try:
tuieval/pta.py CHANGED
@@ -1,4 +1,4 @@
1
- """PTA index: parsimony (tokens), time and accuracy per model, a bar each (longer = better).
1
+ """PTA index: parsimony (tokens), time and accuracy per model, a bar each.
2
2
 
3
3
  P parsimony (tokens) the tokens (reasoning and answer) used on every question compared (each
4
4
  question at its median over repeats), shown as how many times the leanest
@@ -7,8 +7,10 @@
7
7
  model's ("28×").
8
8
  A accuracy the share of answers to those questions that passed (%).
9
9
 
10
- Behind the P and T bars is a 0-100 score: 100 for the best, POINTS_PER_DOUBLING points less for every
11
- doubling (0 at about 100 times more), so models far behind the best still get a visible bar.
10
+ The P and T bars are as long as the tokens and time used (the model that used the most fills its bar,
11
+ the others in proportion, at least one block), so shorter is better; the A bar: longer is better.
12
+ P and T also carry a 0-100 score (100 for the best, POINTS_PER_DOUBLING points less for every
13
+ doubling), used to order models with the same accuracy.
12
14
 
13
15
  Models are compared on the questions all of them answered, so one that skipped some never looks
14
16
  faster. Server and connection errors aren't answers. By default a model with fewer than half as many
@@ -93,9 +95,11 @@ def index(rows, models=None, memory=None):
93
95
  "most": most}
94
96
 
95
97
 
96
- # (letter, name, what the number beside the bar shows, colour); the bar itself is the 0-100 score
97
- LETTERS = (("P", "parsimony (tokens)", "tokens_x", "cyan"), ("T", "time", "time_x", "magenta"),
98
- ("A", "accuracy", "A", "green"))
98
+ # (letter, name, which way is better, what the bar measures, the number beside it, colour). P and T bars
99
+ # are the amount itself (tokens, time: shorter is better); the A bar is the share right (longer is better).
100
+ LETTERS = (("P", "parsimony (tokens)", "▼ shorter is better", "tokens", "tokens_x", "cyan"),
101
+ ("T", "time", "▼ shorter is better", "total_s", "time_x", "magenta"),
102
+ ("A", "accuracy", "▲ longer is better", "A", "A", "green"))
99
103
 
100
104
 
101
105
  def times(v):
@@ -103,26 +107,41 @@ def times(v):
103
107
  return "-" if v is None else f"{v:.1f}×" if v < 9.95 else f"{v:.0f}×"
104
108
 
105
109
 
110
+ def _blocks(width, v, most):
111
+ """How many of width blocks a bar fills: v as a share of most, at least one block when v > 0."""
112
+ if not v or not most:
113
+ return 0
114
+ return max(1, min(width, round(width * v / most)))
115
+
116
+
106
117
  def bars(result, width=20, markup=True):
107
- """Lines with a row per model and a bar per score (P, T, A), longer = better: the at-a-glance view.
108
- Beside P and T, how many times the leanest / fastest model's tokens / time; beside A, the percentage.
109
- markup=False gives plain text (the report)."""
118
+ """Lines with a row per model and a bar each for P, T and A: the at-a-glance view. The P and T bars
119
+ are proportional to tokens and time (the longest is the model that used most; shorter is better),
120
+ with how many times the leanest / fastest model's beside them; the A bar is the share of answers
121
+ right (longer is better, full only when every answer passed). markup=False gives plain text."""
110
122
  if not result["models"]:
111
123
  return []
112
124
  name_w = max(len(x["model"]) for x in result["models"])
113
- # each column: the bar, a space, "100%" or "9.8×" (5), then a gap; at least as wide as its heading
114
- cell_w = max(width + 9, *(len(f"{k} {name}") + 2 for k, name, _, _ in LETTERS))
115
- head = " " * (name_w + 2) + "".join(f"{f'{k} {name}':<{cell_w}}" for k, name, _, _ in LETTERS)
116
- lines = [f"[b]{head.rstrip()}[/b]" if markup else head.rstrip()]
125
+ # each column: the bar, a space, "100%" or "9.8×" (6), then a gap; at least as wide as its heading
126
+ cell_w = max(width + 9, *(len(t) + 2 for k, name, better, *_ in LETTERS for t in (f"{k} {name}", better)))
127
+ pad = " " * (name_w + 2)
128
+ head = pad + "".join(f"{f'{k} {name}':<{cell_w}}" for k, name, *_ in LETTERS)
129
+ sub = pad + "".join(f"{better:<{cell_w}}" for _, _, better, *_ in LETTERS)
130
+ lines = [f"[b]{head.rstrip()}[/b]" if markup else head.rstrip(), f"[dim]{sub.rstrip()}[/dim]" if markup else sub.rstrip()]
131
+ most = {m: max((x.get(m) or 0 for x in result["models"]), default=0) for _, _, _, m, _, _ in LETTERS}
117
132
  for x in result["models"]:
118
133
  cells = []
119
- for k, _, shown, color in LETTERS:
120
- v = x[k]
121
- full = 0 if v is None else round(width * max(0, min(100, v)) / 100)
122
- if v is not None and v < 100: # full only when perfect (accuracy) or the best (P, T)
123
- full = min(full, width - 1)
134
+ for k, _, _, measure, shown, color in LETTERS:
135
+ if k == "A":
136
+ v = x["A"]
137
+ full = 0 if v is None else round(width * max(0, min(100, v)) / 100)
138
+ if v is not None and v < 100: # full only when every answer passed
139
+ full = min(full, width - 1)
140
+ num = "-" if v is None else compare.pct(v / 100)
141
+ else:
142
+ full = _blocks(width, x.get(measure), most[measure])
143
+ num = times(x.get(shown))
124
144
  bar, rest = "█" * full, "░" * (width - full)
125
- num = (("-" if v is None else compare.pct(v / 100)) if shown == "A" else times(x.get(shown)))
126
145
  bar = f"[{color}]{bar}[/][grey37]{rest}[/]" if markup else bar + rest
127
146
  cells.append(f"{bar} {num:>6}" + " " * (cell_w - width - 7))
128
147
  name = f"{x['model']:<{name_w}}"
@@ -183,8 +202,9 @@ def scope_note(result, models):
183
202
  if not result["questions"]:
184
203
  return "These models have no question in common yet, so there's nothing to compare."
185
204
  return (f"Compared on the {result['questions']} questions all {len(result['models'])} model(s) answered. "
186
- "Longer bars are better. P parsimony (tokens) and T time: how many times the leanest / fastest "
187
- "model's (1.0×, ★ in the table). A accuracy: answers right.")
205
+ "P parsimony (tokens) and T time: bars as long as the tokens / time used (shorter is better), "
206
+ "and how many times the leanest / fastest model's (1.0×, ★ in the table). A accuracy: answers right "
207
+ "(longer is better).")
188
208
 
189
209
 
190
210
  def for_engine(e, labels=None, packs=None, results_dir=None):
tuieval/tui.py CHANGED
@@ -332,9 +332,10 @@ with the model's reasoning and answer as they stream, then recent results with t
332
332
  v with several models at a time: stream the next one (k skips the one streaming)""",
333
333
  "ResultsScreen": """[b]Results[/b]
334
334
 
335
- PTA index parsimony (tokens), time and accuracy per model, a bar each (longer = better;
336
- 2.4× = 2.4 times the best), with per-answer numbers, tok/s, TTFT and memory in
337
- the table. Results open here.
335
+ PTA index parsimony (tokens), time and accuracy per model, a bar each: tokens and time
336
+ as long as they took (shorter is better; 2.4× = 2.4 times the best), accuracy
337
+ longer is better. Per-answer numbers, tok/s, TTFT and memory in the table.
338
+ Results open here.
338
339
  Production readiness one verdict per model and use case; the table says why and what to run next
339
340
  Per question every question, model by model (filters: pack, level, Models disagree)
340
341
  Failures every wrong answer with the grader's reason; enter opens it in full
tuieval/tune.py CHANGED
@@ -60,6 +60,7 @@ SWAP_NOTABLE = 256 * 2**20 # swap worth a warning (bytes); rejecting for swap n
60
60
  ANSWER_TOKENS = 1024 # answer length the projected objective scores ([tune] answer_tokens)
61
61
  PRESSURE_CRITICAL = 4 # macOS memory pressure level that rejects a candidate
62
62
  PRESSURE_EVERY_S = 2
63
+ VRAM_MARGIN_GB = 0.25 # a discrete GPU this close to full could run out on a longer prompt
63
64
  GPU_MARGIN_GB = 0.75 # a candidate whose GPU allocation comes this close to the residency limit
64
65
  # is rejected even before it stalls: servers grow as requests arrive
65
66
  REQUEST_LIMIT_S = 600 # a tuning request taking longer fails the candidate ([tune] request_timeout_s)
@@ -556,6 +557,14 @@ def tune(eng, label, emit=lambda *a, **k: None, max_starts=16, min_gain=0.03, us
556
557
  r.facts["gpu_settled_gb"] = round(settled, 1)
557
558
  if info.get("kernel_share_max") is not None:
558
559
  r.facts["kernel_share"] = info["kernel_share_max"]
560
+ mc = eng.machine()
561
+ if mc.discrete: # VRAM is the limit there: its own memory, nothing else can use it
562
+ vram = machines.vram_used_gb()
563
+ if vram is not None:
564
+ r.facts["vram_used_gb"] = round(vram, 1)
565
+ if vram > mc.gpu_limit_gb - VRAM_MARGIN_GB and not r.error:
566
+ r.error = (f"VRAM nearly full: {vram:.1f} of {mc.gpu_limit_gb:.0f} GB in use "
567
+ "(a longer prompt could run out)")
559
568
  limit = eng.gpu_residency_gb()
560
569
  if settled and settled > limit - GPU_MARGIN_GB and not r.error:
561
570
  r.error = (f"GPU allocation settled at {settled:.1f} GB, within {GPU_MARGIN_GB} GB of the "
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: tuieval
3
- Version: 0.2.0.dev62
3
+ Version: 0.2.0.dev66
4
4
  Summary: Evaluate local and frontier LLMs on your own questions: accuracy, speed, tokens and PASS/FAIL verdicts, in the terminal.
5
5
  Project-URL: Homepage, https://github.com/ashe-wb/tuieval
6
6
  Project-URL: Issues, https://github.com/ashe-wb/tuieval/issues
@@ -51,7 +51,7 @@ Whatever runs your models, the first steps are short:
51
51
  | You have | Do this |
52
52
  |---|---|
53
53
  | **LM Studio, Ollama or vLLM** | Start its server and load a model, then `tuieval init my-evals`: it finds the model. Later: `tuieval add` lists new ones. |
54
- | **GGUF files** | Install llama.cpp (`brew install llama.cpp`), then `tuieval add ~/models/Some-Model-Q4_K_M.gguf`. tuieval starts `llama-server` for it, sized to your machine. |
54
+ | **GGUF files** | Install llama.cpp (`brew install llama.cpp`, or a CUDA/ROCm build on Linux), then `tuieval add ~/models/Some-Model-Q4_K_M.gguf`. tuieval starts `llama-server` for it, sized to your Mac's memory or your Nvidia/AMD card's VRAM. |
55
55
  | **An OpenRouter key** | `export OPENROUTER_API_KEY=…`, then `tuieval run --tier smoke --only openrouter:<model id>`. |
56
56
 
57
57
  Stuck? `tuieval doctor` checks servers, models, packs and keys, and says what to fix.
@@ -76,7 +76,7 @@ Afterwards, every answer keeps its reasoning. Enter on a result opens it with th
76
76
  - **Verdicts you can act on.** A pack passes only with zero critical failures over enough trials, and an accuracy whose 95% lower bound clears your bar. *INCONCLUSIVE* says what evidence is missing.
77
77
  - **Two tiers:** *Screen* a sample of every pack to drop weak models fast, then *Certify* finalists on every test with repeats. Certification reuses the screening answers.
78
78
  - **Honest numbers:** every request is a fresh single-turn conversation, with prompt caching off and repeat rounds in different orders. Each answer records what was sent, and the run warns about reused prompts or identical repeats.
79
- - **Per-machine speed.** A fit check picks the largest context that fits your Mac's GPU memory, `tuieval tune` finds the fastest speed-only server flags (with a guard that rejects flags that change answers), and readiness includes a *Fast enough?* table per machine, measured or projected.
79
+ - **Per-machine speed.** A fit check picks the largest context that fits your Mac's GPU memory or your Nvidia/AMD card's VRAM, `tuieval tune` finds the fastest speed-only server flags (with a guard that rejects flags that change answers), and readiness includes a *Fast enough?* table per machine, measured or projected.
80
80
  - **Tests that check themselves.** Every test carries a reference answer and known-wrong answers, and `tuieval selftest` checks the grader accepts the first and rejects the second, and that each gate is reachable at all.
81
81
  - **History.** Verdict changes are appended to `results/verdicts.jsonl`, and replaced results are moved to `history/`, never overwritten.
82
82
 
@@ -1,24 +1,24 @@
1
1
  tuieval/__init__.py,sha256=myVXVX7htbwezW6k3x_FuKgn1RSZ2WcTaDEMByGn6Wg,312
2
2
  tuieval/__main__.py,sha256=E6Gls0DNz8GQK2K-kOUIx8cYhgANW_CH54VKrfCfs14,52
3
- tuieval/_version.py,sha256=Q5t2lKtGGZuhOAPSq1URLDDN-gL2EG-f55AiFxUzLv0,535
3
+ tuieval/_version.py,sha256=3oGXG-ulb5H7C2aLJwOF-Gqqfw6csmjHt4syzml7C4M,535
4
4
  tuieval/builtin.toml,sha256=Kxw22RZCJhURUyu5Wz8tj5Y1nM85A8hFVRbA4ocoPUg,4293
5
5
  tuieval/cli.py,sha256=fn6z0cupM-aW3fY5fFgnS-HmOQmMzlDg-U76Y6LgL3o,4510
6
6
  tuieval/client.py,sha256=kpsyLEZKfxCsvIGBHBbBy83TpI97CvnGCDq-4AbJS4Y,9986
7
- tuieval/compare.py,sha256=V_K34LFnDvd7xhGDS4zZDCguaIMU05f5mCbPx0VpUOA,26944
8
- tuieval/doctor.py,sha256=y1C_ggjd8oikXTrovgTBf26wjThP8EoVkfTVeO_n5dQ,6070
9
- tuieval/engine.py,sha256=0PuHFus1k02qAY8nlsI6z5iQo7IT82bMwmHDZT6fGtU,114784
7
+ tuieval/compare.py,sha256=T6a_PC7z-jHEvw09KEceo2dxoLMi-9cHYPQs4L6Ctig,26997
8
+ tuieval/doctor.py,sha256=j2MdDORstsAGPnRmpsnxau1_fR6sTc_oEFGM5zugTJU,7246
9
+ tuieval/engine.py,sha256=SsXqR1ydn827qBX8NoawyT2roNuelmrZB-hOuyGSesY,116514
10
10
  tuieval/export.py,sha256=dbHQgL_ubWtIPM1sLzAew_gETnrDJyd0zgqVA5vkpXM,9657
11
- tuieval/machines.py,sha256=tdRrn3WNOmCHwfcxcWz1NuAuOJdI7WnJFR1y6xgF89c,13512
11
+ tuieval/machines.py,sha256=t9tu6CZeXZON4EtOVnEwP4VtaynpVLf9Cz8TNjf7jtY,20124
12
12
  tuieval/onboard.py,sha256=IYETVDWCCo9vF0Dtj4_rr9VanYeCky8PwP3-2g5A_l0,6215
13
13
  tuieval/packs.py,sha256=tiLmxsrX_M5EUMuR4Yvb7pLBLEI15wamHSjflD6wjoY,11299
14
14
  tuieval/profiles.py,sha256=soeLxjdB-l-OxSY8jZ4yjwfdSnsBV-QICcwKxRJS7nQ,3663
15
- tuieval/pta.py,sha256=6HwPMvTTJFoZjO-2ZurucJrp1itIzpDTKL1xvYP9W0w,10888
15
+ tuieval/pta.py,sha256=i5oPj-Pz3N9u7bzzuZwsQvMGdxWdAncww2nR15K6PHY,12108
16
16
  tuieval/remove.py,sha256=Vwh43nm9lVb9U9aN-h6CMYbkTwdR3UWfZObwweF72n0,5157
17
17
  tuieval/run_evals.py,sha256=1zNkCdFt744cqpebqiyj-sZrbOI22c6IYBcXk9koz20,46538
18
18
  tuieval/scaffold.py,sha256=YBOqniJpf_GtKKAFF3_OHxxMGbmTWdFjcClGcOnrrKE,12130
19
19
  tuieval/selftest.py,sha256=nExkrOidgymlmvkxImEBfrQG5iTUN5WuRMIKtqusCCs,9835
20
- tuieval/tui.py,sha256=lrIv4z21s9OG809706Z-lE2-TZ6gg8z0AjaJ_zW7zkw,161021
21
- tuieval/tune.py,sha256=jXwYuSjfdqbLCE3WonP2xaUHwk_FnhI67twB1BaHggI,38992
20
+ tuieval/tui.py,sha256=LPnUYbynZiHUBv_d7TNttd7smoTlphPHEa5yoGCvU6s,161108
21
+ tuieval/tune.py,sha256=azxxthgJeag8JyoQUgaRxq6oI1XvEgzb9vkszjJZH7w,39645
22
22
  tuieval/verdict.py,sha256=VB-0LTxR9y8bJHT9RicxtE9K7cUHBdCu40hOCrsbmA4,19150
23
23
  tuieval/watch_proxy.py,sha256=bnDO1i6n6yUs1hODoUWcMppJMGPavoQqs6aNYrIxpT8,11416
24
24
  tuieval/workspace.py,sha256=V_HhkaN1odr0OpjNsPYradRWLpzDldM7SwpvxohBL4U,895
@@ -46,8 +46,8 @@ tuieval/templates/packs/tool_call/pack.toml,sha256=n4bx0lGJHSmW41uVqhfIXJ2BWZpmT
46
46
  tuieval/templates/packs/tool_call/system.txt,sha256=mKxu-lB-0YjLHXdgeFJa8x2C180OvcNz5cHv2N5Bg3U,254
47
47
  tuieval/templates/packs/tool_call/tests.yaml,sha256=Nv7c4syrzJ9cU8EBKSK_1ZSFx9V02aCjW4-2TBCPT7s,1859
48
48
  tuieval/templates/packs/tool_call/tools.yaml,sha256=HgxCkh0On2VwbHSsjAGM8tNCK7ZtKLGrs7lMCn3Fprs,1048
49
- tuieval-0.2.0.dev62.dist-info/METADATA,sha256=X2v6zWEn3E0Lkm-W2x-pjAHgG6qjjzFw_BqeSvyyIxI,13898
50
- tuieval-0.2.0.dev62.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
51
- tuieval-0.2.0.dev62.dist-info/entry_points.txt,sha256=7eIhi1GpFxBP2OLJV02Nn8LwsNuO512eKOGt1IBbj04,45
52
- tuieval-0.2.0.dev62.dist-info/licenses/LICENSE,sha256=7wfRgGtBGH1aXhZkIn47oUznqKC18kEPMvUVgol7Ffc,1077
53
- tuieval-0.2.0.dev62.dist-info/RECORD,,
49
+ tuieval-0.2.0.dev66.dist-info/METADATA,sha256=3R7yYobJYnLLsMP_OHfy74PYErGtGBOf50xMtXpZSXA,13996
50
+ tuieval-0.2.0.dev66.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
51
+ tuieval-0.2.0.dev66.dist-info/entry_points.txt,sha256=7eIhi1GpFxBP2OLJV02Nn8LwsNuO512eKOGt1IBbj04,45
52
+ tuieval-0.2.0.dev66.dist-info/licenses/LICENSE,sha256=7wfRgGtBGH1aXhZkIn47oUznqKC18kEPMvUVgol7Ffc,1077
53
+ tuieval-0.2.0.dev66.dist-info/RECORD,,