tuieval 0.2.0.dev149__py3-none-any.whl → 0.2.0.dev154__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 +2 -2
- tuieval/ctxbench.py +128 -50
- tuieval/engine.py +4 -4
- tuieval/machines.py +18 -2
- tuieval/run_evals.py +4 -6
- {tuieval-0.2.0.dev149.dist-info → tuieval-0.2.0.dev154.dist-info}/METADATA +1 -1
- {tuieval-0.2.0.dev149.dist-info → tuieval-0.2.0.dev154.dist-info}/RECORD +10 -10
- {tuieval-0.2.0.dev149.dist-info → tuieval-0.2.0.dev154.dist-info}/WHEEL +0 -0
- {tuieval-0.2.0.dev149.dist-info → tuieval-0.2.0.dev154.dist-info}/entry_points.txt +0 -0
- {tuieval-0.2.0.dev149.dist-info → tuieval-0.2.0.dev154.dist-info}/licenses/LICENSE +0 -0
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.
|
|
22
|
-
__version_tuple__ = version_tuple = (0, 2, 0, '
|
|
21
|
+
__version__ = version = '0.2.0.dev154'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 2, 0, 'dev154')
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
tuieval/ctxbench.py
CHANGED
|
@@ -7,8 +7,8 @@ It works the same for every server tuieval starts, because it only uses what the
|
|
|
7
7
|
|
|
8
8
|
the context set through {ctx} in the server's cmd, or its ctx_flag
|
|
9
9
|
the API one chat request per try, and the token counts the server reports
|
|
10
|
-
the machine the server
|
|
11
|
-
macOS memory pressure and swapping
|
|
10
|
+
the machine the memory the server takes (how much less is available while it runs; VRAM on
|
|
11
|
+
discrete GPUs), macOS memory pressure and swapping
|
|
12
12
|
|
|
13
13
|
One try ("probe") at a context: start the server with it, send a document that fills it (sized
|
|
14
14
|
from the server's own token counts, so any tokenizer works) with one fact near the start, and ask
|
|
@@ -16,11 +16,19 @@ for that fact. The probe passes when the answer is right, the server read the wh
|
|
|
16
16
|
server that cuts long prompts short reports fewer tokens, or loses the fact), and the machine
|
|
17
17
|
stayed healthy. Filling matters: some servers only take memory as the context fills.
|
|
18
18
|
|
|
19
|
-
The search starts
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
The search starts at half the context the model runs with now and doubles, up to the model's own
|
|
20
|
+
limit: what models.toml caps the context at (max_ctx, ctx, a context flag) doesn't bound it, since
|
|
21
|
+
the measurement replaces those. Memory grows about linearly with the context, so two probes that
|
|
22
|
+
passed predict the largest context that fits under the machine's limit; no probe goes above that
|
|
23
|
+
prediction, and a failed probe is bisected against the largest that passed. A probe is stopped at
|
|
24
|
+
once, while the server loads or works, when memory pressure rises, the machine starts swapping,
|
|
25
|
+
or memory runs out. The next probe waits until the machine has recovered (pressure back to normal,
|
|
26
|
+
the memory given back), so one probe's pressure can't fail the next. Typically 3 to 5 server starts.
|
|
27
|
+
|
|
28
|
+
Memory is read off the machine, not the server's processes: available memory before the server
|
|
29
|
+
starts less the lowest it falls to. Resident memory would count files a server maps and reads on
|
|
30
|
+
demand, which the system can drop again, and that reading is what is compared with the memory
|
|
31
|
+
available, so both are in the same terms.
|
|
24
32
|
|
|
25
33
|
A server tuieval doesn't start, or can't set the context of, is only verified at the context its
|
|
26
34
|
model declares (max_context): one probe, nothing saved.
|
|
@@ -28,6 +36,7 @@ model declares (max_context): one probe, nothing saved.
|
|
|
28
36
|
import dataclasses
|
|
29
37
|
import os
|
|
30
38
|
import threading
|
|
39
|
+
import time
|
|
31
40
|
|
|
32
41
|
from . import engine as engine_mod
|
|
33
42
|
from . import machines
|
|
@@ -37,11 +46,19 @@ from . import tune
|
|
|
37
46
|
ANSWER_TOKENS = 1024 # room for the answer (and any thinking) in a probe
|
|
38
47
|
STEP = 8192 # how close to the true maximum the search gets
|
|
39
48
|
FLOOR = machines.MIN_CTX # the smallest context tried
|
|
49
|
+
FIRST = 32768 # the first context tried for a model whose usual context isn't known
|
|
50
|
+
APART = 0.8 # memory per token is read off two probes at least this far apart (the lower one
|
|
51
|
+
# at most this share of the higher): closer ones differ by less than the noise
|
|
40
52
|
MAX_STARTS = 8
|
|
41
53
|
REQUEST_LIMIT_S = 3600 # reading a few hundred thousand tokens takes a while ([tune] ctx_request_timeout_s)
|
|
42
54
|
PRESSURE_WARNING = 2 # macOS memory pressure level that stops a probe (1 is normal)
|
|
43
55
|
SWAP_STOP_MB = 512 # swapped out while a probe ran: stop it
|
|
44
|
-
AVAILABLE_STOP_GB = 1.0 #
|
|
56
|
+
AVAILABLE_STOP_GB = 1.0 # memory available under this stops a probe
|
|
57
|
+
SETTLE_S = 120 # how long the machine may take to recover after a probe before the next one
|
|
58
|
+
SETTLE_POLL_S = 1.0
|
|
59
|
+
SETTLE_GB = 2.0 # recovered: available memory back within this of what it was before the first probe
|
|
60
|
+
TOO_LITTLE = 0.5 # a reading under this share of the model's size on disk can't be right for a server
|
|
61
|
+
# that holds the model in memory: its resident memory is used instead
|
|
45
62
|
SAMPLE_CHARS = 12000 # the request that measures the server's characters per token
|
|
46
63
|
UNKNOWN_CHARS_PER_TOKEN = 3.0 # for a server that reports no token counts: short of full rather than over
|
|
47
64
|
NOT_ABOUT_CONTEXT = ("already in use", "isn't installed", "not found", "is not set", "skipped by user")
|
|
@@ -119,13 +136,15 @@ def too_long(error):
|
|
|
119
136
|
|
|
120
137
|
|
|
121
138
|
class Guard:
|
|
122
|
-
"""Watches the machine while a probe
|
|
139
|
+
"""Watches the machine while a probe's server loads and works. When it gets unhealthy, the
|
|
140
|
+
server is stopped: a load is abandoned and a request is cut off."""
|
|
123
141
|
|
|
124
142
|
def __init__(self, eng, every_s=2.0):
|
|
125
143
|
self.eng, self.every_s, self.reason = eng, every_s, ""
|
|
126
144
|
self.pressure, self._stop = machines.memory_pressure_level(), threading.Event()
|
|
127
145
|
self._swap0 = machines.swapped_out_bytes()
|
|
128
|
-
self.
|
|
146
|
+
self._own_memory = eng.machine().discrete # VRAM: the machine's memory isn't what runs out
|
|
147
|
+
self.available0 = self.lowest = None if self._own_memory else machines.available_memory_gb()
|
|
129
148
|
|
|
130
149
|
def __enter__(self):
|
|
131
150
|
self._thread = threading.Thread(target=self._run, daemon=True)
|
|
@@ -141,16 +160,25 @@ class Guard:
|
|
|
141
160
|
swap = machines.swapped_out_bytes()
|
|
142
161
|
if None not in (swap, self._swap0) and (swap - self._swap0) / 2**20 > SWAP_STOP_MB:
|
|
143
162
|
return f"the machine swapped out {(swap - self._swap0) / 2**20:.0f} MB"
|
|
144
|
-
if self.
|
|
163
|
+
if not self._own_memory:
|
|
145
164
|
free = machines.available_memory_gb()
|
|
146
|
-
if free is not None
|
|
147
|
-
|
|
165
|
+
if free is not None:
|
|
166
|
+
self.lowest = free if self.lowest is None else min(self.lowest, free)
|
|
167
|
+
if free < AVAILABLE_STOP_GB:
|
|
168
|
+
return f"only {free:.1f} GB of memory was left"
|
|
148
169
|
return ""
|
|
149
170
|
|
|
171
|
+
def taken_gb(self):
|
|
172
|
+
"""Memory the machine lost while the block ran (None where it can't be read)."""
|
|
173
|
+
if None in (self.available0, self.lowest):
|
|
174
|
+
return None
|
|
175
|
+
return max(self.available0 - self.lowest, 0.0)
|
|
176
|
+
|
|
150
177
|
def _run(self):
|
|
151
178
|
while not self._stop.wait(self.every_s):
|
|
152
179
|
self.reason = self.reason or self.check()
|
|
153
180
|
if self.reason:
|
|
181
|
+
self.eng._stall = self.reason # ends the wait for a server that is still loading
|
|
154
182
|
stream = getattr(self.eng, "_stream", None)
|
|
155
183
|
if stream is not None:
|
|
156
184
|
stream.close()
|
|
@@ -160,6 +188,7 @@ class Guard:
|
|
|
160
188
|
self._stop.set()
|
|
161
189
|
self._thread.join(self.every_s + 1)
|
|
162
190
|
self.reason = self.reason or self.check()
|
|
191
|
+
self.eng._stall = None
|
|
163
192
|
|
|
164
193
|
|
|
165
194
|
def probe(eng, m, ctx, emit=lambda *a, **k: None, limit=REQUEST_LIMIT_S):
|
|
@@ -171,28 +200,25 @@ def probe(eng, m, ctx, emit=lambda *a, **k: None, limit=REQUEST_LIMIT_S):
|
|
|
171
200
|
if target < 1024:
|
|
172
201
|
out.error = f"a context of {ctx:,} is too small to test"
|
|
173
202
|
return out
|
|
203
|
+
guard = Guard(eng)
|
|
174
204
|
try:
|
|
175
|
-
with eng.serve(m, log_name=f"{m['label']}.ctx", ctx=ctx) as (url, info):
|
|
205
|
+
with guard, eng.serve(m, log_name=f"{m['label']}.ctx", ctx=ctx) as (url, info):
|
|
176
206
|
out.load_s = round(info["load_s"], 1) if info.get("load_s") else None
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
res = _ask(eng, m, url, int(chars * 0.93), ANSWER_TOKENS, "fill", emit, limit)
|
|
207
|
+
ratio = chars_per_token(eng, m, url, emit, limit)
|
|
208
|
+
chars = int(target * (ratio or UNKNOWN_CHARS_PER_TOKEN) * 0.98)
|
|
209
|
+
emit("tune_progress", message=f" filling the context: ~{target:,} tokens, {chars:,} characters"
|
|
210
|
+
+ ("" if ratio else " (the server reports no token counts)"))
|
|
211
|
+
res = _ask(eng, m, url, chars, ANSWER_TOKENS, "fill", emit, limit)
|
|
212
|
+
if too_long(res.get("error")) and not guard.reason:
|
|
213
|
+
emit("tune_progress", message=" the server found that too long; trying 7% shorter")
|
|
214
|
+
res = _ask(eng, m, url, int(chars * 0.93), ANSWER_TOKENS, "fill", emit, limit)
|
|
186
215
|
met = client.metrics(res) if not res.get("error") else {}
|
|
187
216
|
out.prompt_tokens, out.pp_tps, out.tg_tps = met.get("prompt_tokens"), met.get("prompt_tps"), met.get("gen_tps")
|
|
188
217
|
out.total_s = round(res["total_s"], 1) if res.get("total_s") else None
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
out.mem_gb = round(peak, 2) if peak else None
|
|
218
|
+
guard.check()
|
|
219
|
+
out.mem_gb = memory_gb(eng, m, info, guard)
|
|
192
220
|
text = (res.get("answer") or "") + (res.get("reasoning") or "")
|
|
193
|
-
if
|
|
194
|
-
out.error = guard.reason
|
|
195
|
-
elif res.get("error"):
|
|
221
|
+
if res.get("error"):
|
|
196
222
|
out.error = res["error"]
|
|
197
223
|
elif not info["alive"]():
|
|
198
224
|
out.error = "the server stopped"
|
|
@@ -206,20 +232,67 @@ def probe(eng, m, ctx, emit=lambda *a, **k: None, limit=REQUEST_LIMIT_S):
|
|
|
206
232
|
out.filled = bool(ratio and out.prompt_tokens and out.prompt_tokens >= 0.85 * target)
|
|
207
233
|
except engine_mod.ModelFailed as e:
|
|
208
234
|
out.error = str(e).splitlines()[0]
|
|
209
|
-
if any(w in out.error for w in NOT_ABOUT_CONTEXT):
|
|
235
|
+
if not guard.reason and any(w in out.error for w in NOT_ABOUT_CONTEXT):
|
|
210
236
|
raise # a smaller context wouldn't help
|
|
237
|
+
if guard.reason: # the machine got unhealthy: that is why, whatever the server said as it was stopped
|
|
238
|
+
out.ok, out.error = False, guard.reason
|
|
211
239
|
return out
|
|
212
240
|
|
|
213
241
|
|
|
242
|
+
class Halt(Exception):
|
|
243
|
+
"""The search can't go on (the machine didn't recover); what passed so far stands."""
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def settle(eng, baseline_gb=None, emit=lambda *a, **k: None, limit_s=None):
|
|
247
|
+
"""Wait until the machine has recovered from the last probe: memory pressure back to normal,
|
|
248
|
+
and the memory its server held given back. Without this, pressure a stopped server left behind
|
|
249
|
+
would fail the next probe within seconds, at a context that may well work. Raises Halt if
|
|
250
|
+
pressure stays elevated; memory that stays taken (another app grew) is only noted."""
|
|
251
|
+
limit_s = SETTLE_S if limit_s is None else limit_s
|
|
252
|
+
end, told = time.time() + limit_s, False
|
|
253
|
+
while True:
|
|
254
|
+
eng._check()
|
|
255
|
+
level = machines.memory_pressure_level()
|
|
256
|
+
free = None if baseline_gb is None or eng.machine().discrete else machines.available_memory_gb()
|
|
257
|
+
calm = level is None or level < PRESSURE_WARNING
|
|
258
|
+
back = free is None or free >= baseline_gb - SETTLE_GB
|
|
259
|
+
if calm and back:
|
|
260
|
+
return
|
|
261
|
+
if time.time() >= end:
|
|
262
|
+
if not calm:
|
|
263
|
+
raise Halt(f"macOS memory pressure stayed at level {level} for {limit_s:.0f}s after the last try")
|
|
264
|
+
emit("tune_progress", message=f" {baseline_gb - free:.1f} GB less memory is available than at the start "
|
|
265
|
+
"(another app grew?); going on")
|
|
266
|
+
return
|
|
267
|
+
if not told:
|
|
268
|
+
told = True
|
|
269
|
+
emit("tune_progress", message=" waiting for the machine to recover from the last try…")
|
|
270
|
+
time.sleep(SETTLE_POLL_S)
|
|
271
|
+
|
|
272
|
+
|
|
214
273
|
# ------------------------------------------------------------------ the search
|
|
274
|
+
def memory_gb(eng, m, info, guard):
|
|
275
|
+
"""What the server took with its context full: VRAM on a discrete GPU, else how much less memory
|
|
276
|
+
the machine had available, else (where that can't be read, or reads implausibly low for a model
|
|
277
|
+
of this size) the resident memory of the server's processes."""
|
|
278
|
+
if eng.machine().discrete:
|
|
279
|
+
return round(info["vram_peak_gb"], 2) if info.get("vram_peak_gb") else None
|
|
280
|
+
taken, size = guard.taken_gb(), model_gb(m)
|
|
281
|
+
resident = (info["peak_mb"]() or 0) / 1024 if info.get("peak_mb") else 0
|
|
282
|
+
if not taken or (size and taken < TOO_LITTLE * size <= resident):
|
|
283
|
+
taken = resident
|
|
284
|
+
return round(taken, 2) if taken else None
|
|
285
|
+
|
|
286
|
+
|
|
215
287
|
def predict(passed, limit_gb):
|
|
216
|
-
"""(base_gb, gb_per_token, largest context predicted to fit) from the
|
|
217
|
-
passed with a memory reading. The third is None when
|
|
218
|
-
(nothing to predict) or there aren't two readings."""
|
|
288
|
+
"""(base_gb, gb_per_token, largest context predicted to fit) from the largest context that
|
|
289
|
+
passed with a memory reading and the nearest one well below it (APART). The third is None when
|
|
290
|
+
memory doesn't grow with the context (nothing to predict) or there aren't two such readings."""
|
|
219
291
|
pts = sorted((p.ctx, p.mem_gb) for p in passed if p.mem_gb)
|
|
220
292
|
if len(pts) < 2:
|
|
221
293
|
return None, None, None
|
|
222
|
-
|
|
294
|
+
c2, g2 = pts[-1]
|
|
295
|
+
c1, g1 = next(((c, g) for c, g in reversed(pts[:-1]) if c <= APART * c2), pts[0])
|
|
223
296
|
per = (g2 - g1) / (c2 - c1)
|
|
224
297
|
base = g2 - per * c2
|
|
225
298
|
if per <= 0 or limit_gb is None:
|
|
@@ -239,7 +312,12 @@ def search(try_ctx, start, upper, limit_gb=None, step=STEP, floor=FLOOR, max_sta
|
|
|
239
312
|
why = f"{max_starts} server starts used"
|
|
240
313
|
while len(tried) < max_starts:
|
|
241
314
|
emit("tune_step", message=f"[{len(tried) + 1}] context {c:,}", start=len(tried) + 1, max_starts=max_starts)
|
|
242
|
-
|
|
315
|
+
try:
|
|
316
|
+
r = try_ctx(c)
|
|
317
|
+
except Halt as e:
|
|
318
|
+
why = str(e)
|
|
319
|
+
emit("tune_result", message=f" not tried: {why}")
|
|
320
|
+
break
|
|
243
321
|
tried.append(r)
|
|
244
322
|
emit("tune_result", message=" " + r.summary(), result=r)
|
|
245
323
|
if r.ok:
|
|
@@ -303,20 +381,12 @@ def room_gb(eng):
|
|
|
303
381
|
return (limit if free is None else min(limit, free - headroom)), ""
|
|
304
382
|
|
|
305
383
|
|
|
306
|
-
def upper_bound(
|
|
307
|
-
"""(the largest context worth trying, where that number comes from).
|
|
384
|
+
def upper_bound(m, asked=None):
|
|
385
|
+
"""(the largest context worth trying, where that number comes from): the model's own limit.
|
|
386
|
+
What models.toml caps the context at (max_ctx, ctx, a context flag) isn't one: the measurement
|
|
387
|
+
replaces those."""
|
|
308
388
|
if asked:
|
|
309
389
|
return asked, "--max"
|
|
310
|
-
caps = [(server.get("max_ctx"), f"max_ctx in [servers.{m['server']}]"), (m.get("ctx"), "the model's ctx"),
|
|
311
|
-
(m.get("max_context"), "the model's max_context")]
|
|
312
|
-
caps = [(v, src) for v, src in caps if v]
|
|
313
|
-
if how == "flag":
|
|
314
|
-
sv = eng.serving(m)
|
|
315
|
-
written = engine_mod.read_context(list(m.get("server_args", [])) + list(sv.perf_args), server["ctx_flag"])
|
|
316
|
-
if written:
|
|
317
|
-
caps.append((written, f"{server['ctx_flag']} in models.toml"))
|
|
318
|
-
if caps:
|
|
319
|
-
return min(caps)
|
|
320
390
|
path = engine_mod.expand(str(m.get("model", "")))
|
|
321
391
|
if os.path.isfile(path):
|
|
322
392
|
try:
|
|
@@ -325,7 +395,9 @@ def upper_bound(eng, m, server, how, asked=None):
|
|
|
325
395
|
return n, "the model file"
|
|
326
396
|
except (OSError, ValueError):
|
|
327
397
|
pass
|
|
328
|
-
|
|
398
|
+
if m.get("max_context"):
|
|
399
|
+
return m["max_context"], "the model's max_context"
|
|
400
|
+
raise engine_mod.ModelFailed("the model's own context limit isn't known: pass --max N")
|
|
329
401
|
|
|
330
402
|
|
|
331
403
|
def bench(eng, label, emit=lambda *a, **k: None, max_ctx=None, start=None, step=STEP, max_starts=MAX_STARTS):
|
|
@@ -347,7 +419,7 @@ def bench(eng, label, emit=lambda *a, **k: None, max_ctx=None, start=None, step=
|
|
|
347
419
|
r = probe(eng, m, ctx, emit, limit_s)
|
|
348
420
|
emit("tune_result", message=" " + r.summary(), result=r)
|
|
349
421
|
return {"verified": r.ok, "ctx": ctx, "probe": r}
|
|
350
|
-
upper, source = upper_bound(
|
|
422
|
+
upper, source = upper_bound(m, max_ctx)
|
|
351
423
|
upper = max(upper, FLOOR)
|
|
352
424
|
room, refuse = room_gb(eng)
|
|
353
425
|
if refuse:
|
|
@@ -356,12 +428,18 @@ def bench(eng, label, emit=lambda *a, **k: None, max_ctx=None, start=None, step=
|
|
|
356
428
|
if room is not None and size is not None and size > room:
|
|
357
429
|
raise engine_mod.ModelFailed(f"the model is {size:.1f} GB and {room:.1f} GB is free for it now: another "
|
|
358
430
|
"model or app is holding memory")
|
|
359
|
-
|
|
431
|
+
# Half of what it runs with now, so the second probe is a context expected to work and the two
|
|
432
|
+
# give the memory per token before anything larger is tried.
|
|
433
|
+
usual = sv.ctx if sv.fits and sv.ctx else None
|
|
434
|
+
first = min(upper, max(FLOOR, _grid(start or (usual // 2 if usual else FIRST))))
|
|
360
435
|
emit("tune_step", message=f"largest context up to {upper:,} ({source})"
|
|
361
436
|
+ (f"; {room:.1f} GB of memory to work with" if room is not None else ""))
|
|
362
437
|
|
|
438
|
+
baseline = None if sv.machine.discrete else machines.available_memory_gb()
|
|
439
|
+
|
|
363
440
|
def try_ctx(ctx):
|
|
364
441
|
eng._check()
|
|
442
|
+
settle(eng, baseline, emit)
|
|
365
443
|
return probe(eng, m, ctx, emit, limit_s)
|
|
366
444
|
|
|
367
445
|
tried, why = search(try_ctx, first, upper, room, step, min(FLOOR, first), max_starts, emit)
|
tuieval/engine.py
CHANGED
|
@@ -1475,8 +1475,9 @@ class Engine:
|
|
|
1475
1475
|
flag = server.get("ctx_flag") # e.g. --max-context-tokens, when the server takes one
|
|
1476
1476
|
if flag and ctx is None:
|
|
1477
1477
|
ctx = read_context(list(m.get("server_args", [])) + perf, flag)
|
|
1478
|
-
# The largest context measured here (tuieval tune --ctx)
|
|
1479
|
-
# (max_ctx, ctx, max_context, a context flag
|
|
1478
|
+
# The largest context measured here (tuieval tune --ctx) is the context: it replaces the estimate
|
|
1479
|
+
# and whatever models.toml caps it at (max_ctx, ctx, max_context, a context flag), which were
|
|
1480
|
+
# written without knowing it.
|
|
1480
1481
|
how, source, ctx_note = takes_context(server), "", ""
|
|
1481
1482
|
measured = profiles.load_context(mc.id, m["label"], self.tuning_dir) if how else None
|
|
1482
1483
|
if measured:
|
|
@@ -1486,8 +1487,7 @@ class Engine:
|
|
|
1486
1487
|
elif meta.get("kv_type") and kv and meta["kv_type"] != kv:
|
|
1487
1488
|
ctx_note = f"its context was measured with {meta['kv_type']} KV, not {kv}; run tuieval tune --ctx again"
|
|
1488
1489
|
else:
|
|
1489
|
-
|
|
1490
|
-
ctx, fits, source = min(cap, measured["max_ctx"]) if cap else measured["max_ctx"], True, "measured"
|
|
1490
|
+
ctx, fits, source = measured["max_ctx"], True, "measured"
|
|
1491
1491
|
note = f"measured on {mc.id}: up to {measured['max_ctx'] // 1024}k context"
|
|
1492
1492
|
at = measured.get("measured", {})
|
|
1493
1493
|
if at.get("base_gb") is not None and at.get("gb_per_1k_tokens") is not None:
|
tuieval/machines.py
CHANGED
|
@@ -356,15 +356,31 @@ def swapped_out_bytes():
|
|
|
356
356
|
return int(page.group(1)) * int(swaps.group(1)) if page and swaps else None
|
|
357
357
|
|
|
358
358
|
|
|
359
|
+
def vm_stat_available_gb(text, ram_bytes):
|
|
360
|
+
"""Memory available on a Mac from vm_stat's page counts: RAM less what is held and can't be
|
|
361
|
+
given back (anonymous pages, wired pages, the compressor's own pages). File cache and
|
|
362
|
+
memory-mapped files the system can drop count as available. None if the counts aren't there."""
|
|
363
|
+
page = re.search(r"page size of (\d+)", text)
|
|
364
|
+
held = [re.search(name + r":\s+(\d+)", text) for name in
|
|
365
|
+
("Anonymous pages", "Pages wired down", "Pages occupied by compressor")]
|
|
366
|
+
if not page or not all(held) or not ram_bytes:
|
|
367
|
+
return None
|
|
368
|
+
return (ram_bytes - int(page.group(1)) * sum(int(h.group(1)) for h in held)) / GB
|
|
369
|
+
|
|
370
|
+
|
|
359
371
|
def available_memory_gb():
|
|
360
372
|
"""Memory a new process could take now without pushing anything to swap: free plus what the
|
|
361
|
-
system gives back on demand (file cache). macOS: `memory_pressure`'s
|
|
373
|
+
system gives back on demand (file cache). macOS: from vm_stat's page counts (`memory_pressure`'s
|
|
374
|
+
free percentage, which is rounded to 1% of RAM and reads higher, only if they are missing);
|
|
362
375
|
Linux: MemAvailable. None where unknown."""
|
|
363
376
|
try:
|
|
364
377
|
if platform.system() == "Darwin":
|
|
378
|
+
ram = int(_sysctl("hw.memsize") or 0)
|
|
379
|
+
got = vm_stat_available_gb(subprocess.run(["vm_stat"], capture_output=True, text=True, timeout=5).stdout, ram)
|
|
380
|
+
if got is not None:
|
|
381
|
+
return got
|
|
365
382
|
out = subprocess.run(["memory_pressure"], capture_output=True, text=True, timeout=10).stdout
|
|
366
383
|
pct = re.search(r"free percentage:\s*(\d+)%", out)
|
|
367
|
-
ram = int(_sysctl("hw.memsize") or 0)
|
|
368
384
|
return int(pct.group(1)) / 100 * ram / GB if pct and ram else None
|
|
369
385
|
with open("/proc/meminfo") as f:
|
|
370
386
|
kb = re.search(r"MemAvailable:\s+(\d+) kB", f.read())
|
tuieval/run_evals.py
CHANGED
|
@@ -652,10 +652,8 @@ def context_report(e, label, got):
|
|
|
652
652
|
say(f"{label}: stopped there because: {at['stopped']}")
|
|
653
653
|
if not got["meta"].get("fill_confirmed"):
|
|
654
654
|
say(f"{label}: the server reports no token counts, so how full the context was isn't confirmed", YELLOW)
|
|
655
|
-
if sv.
|
|
656
|
-
say(f"{label}: runs use {sv.ctx:,}
|
|
657
|
-
elif sv.ctx_source == "measured":
|
|
658
|
-
say(f"{label}: runs use {sv.ctx:,} from now on")
|
|
655
|
+
if sv.ctx_source == "measured":
|
|
656
|
+
say(f"{label}: runs use {sv.ctx:,} from now on, whatever models.toml caps it at")
|
|
659
657
|
return True
|
|
660
658
|
|
|
661
659
|
|
|
@@ -704,9 +702,9 @@ def cmd_tune(argv):
|
|
|
704
702
|
"machine (ctxbench.py): a few server starts, each filling the context it tries. Runs then "
|
|
705
703
|
"use it in place of the estimate")
|
|
706
704
|
p.add_argument("--max", type=int, default=None, metavar="N",
|
|
707
|
-
help="with --ctx: the largest context to try (default: the model's
|
|
705
|
+
help="with --ctx: the largest context to try (default: the model's own limit)")
|
|
708
706
|
p.add_argument("--start", type=int, default=None, metavar="N",
|
|
709
|
-
help="with --ctx: the first context to try (default:
|
|
707
|
+
help="with --ctx: the first context to try (default: half of what the model runs with now)")
|
|
710
708
|
p.add_argument("--step", type=int, default=None, metavar="N",
|
|
711
709
|
help="with --ctx: how close to the true maximum to get (default 8192)")
|
|
712
710
|
p.add_argument("--models", default=None, help="default: the workspace's models.toml")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: tuieval
|
|
3
|
-
Version: 0.2.0.
|
|
3
|
+
Version: 0.2.0.dev154
|
|
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
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
tuieval/__init__.py,sha256=myVXVX7htbwezW6k3x_FuKgn1RSZ2WcTaDEMByGn6Wg,312
|
|
2
2
|
tuieval/__main__.py,sha256=E6Gls0DNz8GQK2K-kOUIx8cYhgANW_CH54VKrfCfs14,52
|
|
3
|
-
tuieval/_version.py,sha256=
|
|
3
|
+
tuieval/_version.py,sha256=FsjuEXknIwtuSkmdWC9Fkff3xFhnhGysFK8jcDcy2CU,537
|
|
4
4
|
tuieval/agents.py,sha256=XmY4d4PAnC7BQcs_6KO9WTuIdpnwYVAdyhqItybWdAM,15408
|
|
5
5
|
tuieval/builtin.toml,sha256=QLQP1nh577RW6x0Z38JKNES-MPTSmlZAcxD5Javbk4Q,4768
|
|
6
6
|
tuieval/cli.py,sha256=Q9-b9sg6LSAfNq6o-c3J3hiOIoINgvH_Fe_U1x-0W4U,4915
|
|
7
7
|
tuieval/client.py,sha256=O77uftaxqgQ8b8rMnpR5822kmYFfr574w1pZlaSOFEE,14304
|
|
8
8
|
tuieval/compare.py,sha256=T5MDIkNzPGTFUvYr1EzxVGGlCdvTlO1v5De3gN0Eocw,39654
|
|
9
|
-
tuieval/ctxbench.py,sha256
|
|
9
|
+
tuieval/ctxbench.py,sha256=70NWkhhgYEuWzlTPYfK3-g2Kh6CM1OqoYx_ETIo9paw,23896
|
|
10
10
|
tuieval/dates.py,sha256=CVazlwNjCRhD__D12zXLdeqF2ySt15X3xLUQeE-o6PY,6293
|
|
11
11
|
tuieval/doctor.py,sha256=j2MdDORstsAGPnRmpsnxau1_fR6sTc_oEFGM5zugTJU,7246
|
|
12
|
-
tuieval/engine.py,sha256=
|
|
12
|
+
tuieval/engine.py,sha256=OfAQx4s9A7PfaPJDr5U_MBp69kS3-tI99aPnrCYZ8mU,141469
|
|
13
13
|
tuieval/export.py,sha256=dbHQgL_ubWtIPM1sLzAew_gETnrDJyd0zgqVA5vkpXM,9657
|
|
14
14
|
tuieval/insights.py,sha256=hIJp1n0eZeoo9QCyS5-OChv70ItSqV8jSsInoh4Stm0,29591
|
|
15
15
|
tuieval/logs.py,sha256=01gZK6tf53dIThaIrs1bEsz9eqKYVlcxpyaLnSPTVxo,8127
|
|
16
|
-
tuieval/machines.py,sha256=
|
|
16
|
+
tuieval/machines.py,sha256=KEZ7tJWdGdlIjNDfd8sgXMyV-GclcdQLoubNimz5tbs,21956
|
|
17
17
|
tuieval/onboard.py,sha256=IYETVDWCCo9vF0Dtj4_rr9VanYeCky8PwP3-2g5A_l0,6215
|
|
18
18
|
tuieval/packs.py,sha256=KOj0BkwsB2124aslGyauZonyyGqtSrCJ-WAozEntmqE,17466
|
|
19
19
|
tuieval/profiles.py,sha256=3GribubCOCRTi_rClLxVynBeX2SBYTig0XObAlS8lzg,5300
|
|
20
20
|
tuieval/pta.py,sha256=MBn2EkDysayv8XOqiTKp5zomuUmZnZTuQ5jGBR2-Z4s,19281
|
|
21
21
|
tuieval/remove.py,sha256=ckep4iZUkuWE2JTcZFovCy7snNd_WLkJ6b602eGKZws,5339
|
|
22
|
-
tuieval/run_evals.py,sha256=
|
|
22
|
+
tuieval/run_evals.py,sha256=kLnQDZB_XoqdBFDk3paPYGvl0u_IXfSDuZS0Sp69Rgc,56095
|
|
23
23
|
tuieval/scaffold.py,sha256=YBOqniJpf_GtKKAFF3_OHxxMGbmTWdFjcClGcOnrrKE,12130
|
|
24
24
|
tuieval/selftest.py,sha256=cIGSDCrCK-QISAXjKSJDB4sD-WwS32bn3Gn4Y0oGoF8,11502
|
|
25
25
|
tuieval/tui.py,sha256=5BtqHoEtqBHRCrh0qPn2Vmg-4hSjjtlfPQ5qoysHlb0,211349
|
|
@@ -51,8 +51,8 @@ tuieval/templates/packs/tool_call/pack.toml,sha256=n4bx0lGJHSmW41uVqhfIXJ2BWZpmT
|
|
|
51
51
|
tuieval/templates/packs/tool_call/system.txt,sha256=mKxu-lB-0YjLHXdgeFJa8x2C180OvcNz5cHv2N5Bg3U,254
|
|
52
52
|
tuieval/templates/packs/tool_call/tests.yaml,sha256=Nv7c4syrzJ9cU8EBKSK_1ZSFx9V02aCjW4-2TBCPT7s,1859
|
|
53
53
|
tuieval/templates/packs/tool_call/tools.yaml,sha256=HgxCkh0On2VwbHSsjAGM8tNCK7ZtKLGrs7lMCn3Fprs,1048
|
|
54
|
-
tuieval-0.2.0.
|
|
55
|
-
tuieval-0.2.0.
|
|
56
|
-
tuieval-0.2.0.
|
|
57
|
-
tuieval-0.2.0.
|
|
58
|
-
tuieval-0.2.0.
|
|
54
|
+
tuieval-0.2.0.dev154.dist-info/METADATA,sha256=H5DmG2b3U3AQ61kr-6XFRhC3AmHv1RBSXte94y2YdxE,15306
|
|
55
|
+
tuieval-0.2.0.dev154.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
56
|
+
tuieval-0.2.0.dev154.dist-info/entry_points.txt,sha256=7eIhi1GpFxBP2OLJV02Nn8LwsNuO512eKOGt1IBbj04,45
|
|
57
|
+
tuieval-0.2.0.dev154.dist-info/licenses/LICENSE,sha256=7wfRgGtBGH1aXhZkIn47oUznqKC18kEPMvUVgol7Ffc,1077
|
|
58
|
+
tuieval-0.2.0.dev154.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|