tuieval 0.2.0.dev156__py3-none-any.whl → 0.2.0.dev160__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 +52 -14
- tuieval/run_evals.py +3 -0
- {tuieval-0.2.0.dev156.dist-info → tuieval-0.2.0.dev160.dist-info}/METADATA +1 -1
- {tuieval-0.2.0.dev156.dist-info → tuieval-0.2.0.dev160.dist-info}/RECORD +8 -8
- {tuieval-0.2.0.dev156.dist-info → tuieval-0.2.0.dev160.dist-info}/WHEEL +0 -0
- {tuieval-0.2.0.dev156.dist-info → tuieval-0.2.0.dev160.dist-info}/entry_points.txt +0 -0
- {tuieval-0.2.0.dev156.dist-info → tuieval-0.2.0.dev160.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.dev160'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 2, 0, 'dev160')
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
tuieval/ctxbench.py
CHANGED
|
@@ -20,9 +20,13 @@ The search starts at half the context the model runs with now and doubles, up to
|
|
|
20
20
|
limit: what models.toml caps the context at (max_ctx, ctx, a context flag) doesn't bound it, since
|
|
21
21
|
the measurement replaces those. Memory grows about linearly with the context, so two probes that
|
|
22
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
|
|
23
|
+
prediction, and a failed probe is bisected against the largest that passed. (A server that already
|
|
24
|
+
takes more than that limit at the smallest context, and passes, sizes its own memory: the
|
|
25
|
+
prediction doesn't cap it, and the probes and their guard decide.) A probe is stopped at
|
|
24
26
|
once, while the server loads or works, when memory pressure rises, the machine starts swapping,
|
|
25
|
-
or memory runs out.
|
|
27
|
+
or memory runs out. (A server that reaches the warning level at the smallest context, with nothing
|
|
28
|
+
swapped, fills memory to a budget of its own: for it only critical pressure counts, besides
|
|
29
|
+
swapping and memory running out.) The next probe waits until the machine has recovered (pressure back to normal,
|
|
26
30
|
the memory given back), so one probe's pressure can't fail the next. Typically 3 to 5 server starts.
|
|
27
31
|
|
|
28
32
|
Memory is read off the machine, not the server's processes: available memory before the server
|
|
@@ -52,6 +56,7 @@ APART = 0.8 # memory per token is read off two probes at least th
|
|
|
52
56
|
MAX_STARTS = 8
|
|
53
57
|
REQUEST_LIMIT_S = 3600 # reading a few hundred thousand tokens takes a while ([tune] ctx_request_timeout_s)
|
|
54
58
|
PRESSURE_WARNING = 2 # macOS memory pressure level that stops a probe (1 is normal)
|
|
59
|
+
PRESSURE_CRITICAL = 4 # the level that stops one for a server whose normal state is the warning level
|
|
55
60
|
SWAP_STOP_MB = 512 # swapped out while a probe ran: stop it
|
|
56
61
|
AVAILABLE_STOP_GB = 1.0 # memory available under this stops a probe
|
|
57
62
|
SETTLE_S = 120 # how long the machine may take to recover after a probe before the next one
|
|
@@ -79,6 +84,8 @@ class Probe:
|
|
|
79
84
|
total_s: float | None = None
|
|
80
85
|
load_s: float | None = None
|
|
81
86
|
filled: bool = False # the server's token count confirms the context was full
|
|
87
|
+
pressure: int | None = None # highest macOS memory pressure level while it ran
|
|
88
|
+
stopped_for: str = "" # "pressure" when memory pressure alone stopped it (nothing was swapped)
|
|
82
89
|
|
|
83
90
|
def summary(self):
|
|
84
91
|
if not self.ok:
|
|
@@ -139,8 +146,9 @@ class Guard:
|
|
|
139
146
|
"""Watches the machine while a probe's server loads and works. When it gets unhealthy, the
|
|
140
147
|
server is stopped: a load is abandoned and a request is cut off."""
|
|
141
148
|
|
|
142
|
-
def __init__(self, eng, every_s=2.0):
|
|
143
|
-
self.eng, self.every_s, self.reason = eng, every_s, ""
|
|
149
|
+
def __init__(self, eng, every_s=2.0, stop_level=PRESSURE_WARNING):
|
|
150
|
+
self.eng, self.every_s, self.reason, self.stop_level = eng, every_s, "", stop_level
|
|
151
|
+
self.pressure_only = False # stopped for memory pressure, with nothing swapped out
|
|
144
152
|
self.pressure, self._stop = machines.memory_pressure_level(), threading.Event()
|
|
145
153
|
self._swap0 = machines.swapped_out_bytes()
|
|
146
154
|
self._own_memory = eng.machine().discrete # VRAM: the machine's memory isn't what runs out
|
|
@@ -155,7 +163,9 @@ class Guard:
|
|
|
155
163
|
lvl = machines.memory_pressure_level()
|
|
156
164
|
if lvl is not None:
|
|
157
165
|
self.pressure = max(self.pressure or 0, lvl)
|
|
158
|
-
if lvl >=
|
|
166
|
+
if lvl >= self.stop_level:
|
|
167
|
+
swap = machines.swapped_out_bytes()
|
|
168
|
+
self.pressure_only = None in (swap, self._swap0) or swap - self._swap0 < 2**20
|
|
159
169
|
return f"macOS memory pressure rose to level {lvl}"
|
|
160
170
|
swap = machines.swapped_out_bytes()
|
|
161
171
|
if None not in (swap, self._swap0) and (swap - self._swap0) / 2**20 > SWAP_STOP_MB:
|
|
@@ -191,8 +201,9 @@ class Guard:
|
|
|
191
201
|
self.eng._stall = None
|
|
192
202
|
|
|
193
203
|
|
|
194
|
-
def probe(eng, m, ctx, emit=lambda *a, **k: None, limit=REQUEST_LIMIT_S):
|
|
195
|
-
"""Serve the model with this context, fill it and ask for the fact. Returns a Probe.
|
|
204
|
+
def probe(eng, m, ctx, emit=lambda *a, **k: None, limit=REQUEST_LIMIT_S, stop_level=PRESSURE_WARNING):
|
|
205
|
+
"""Serve the model with this context, fill it and ask for the fact. Returns a Probe.
|
|
206
|
+
stop_level: the macOS memory pressure level that stops it."""
|
|
196
207
|
from . import client
|
|
197
208
|
out = Probe(ctx)
|
|
198
209
|
reserve = ANSWER_TOKENS + max(256, ctx // 50)
|
|
@@ -200,7 +211,7 @@ def probe(eng, m, ctx, emit=lambda *a, **k: None, limit=REQUEST_LIMIT_S):
|
|
|
200
211
|
if target < 1024:
|
|
201
212
|
out.error = f"a context of {ctx:,} is too small to test"
|
|
202
213
|
return out
|
|
203
|
-
guard = Guard(eng)
|
|
214
|
+
guard = Guard(eng, stop_level=stop_level)
|
|
204
215
|
try:
|
|
205
216
|
with guard, eng.serve(m, log_name=f"{m['label']}.ctx", ctx=ctx) as (url, info):
|
|
206
217
|
out.load_s = round(info["load_s"], 1) if info.get("load_s") else None
|
|
@@ -215,8 +226,8 @@ def probe(eng, m, ctx, emit=lambda *a, **k: None, limit=REQUEST_LIMIT_S):
|
|
|
215
226
|
met = client.metrics(res) if not res.get("error") else {}
|
|
216
227
|
out.prompt_tokens, out.pp_tps, out.tg_tps = met.get("prompt_tokens"), met.get("prompt_tps"), met.get("gen_tps")
|
|
217
228
|
out.total_s = round(res["total_s"], 1) if res.get("total_s") else None
|
|
218
|
-
guard.check()
|
|
219
|
-
out.mem_gb = memory_gb(eng, m, info, guard)
|
|
229
|
+
guard.reason = guard.reason or guard.check() # with the server still up: a short probe may end
|
|
230
|
+
out.mem_gb = memory_gb(eng, m, info, guard) # between the guard's own readings
|
|
220
231
|
text = (res.get("answer") or "") + (res.get("reasoning") or "")
|
|
221
232
|
if res.get("error"):
|
|
222
233
|
out.error = res["error"]
|
|
@@ -234,8 +245,10 @@ def probe(eng, m, ctx, emit=lambda *a, **k: None, limit=REQUEST_LIMIT_S):
|
|
|
234
245
|
out.error = str(e).splitlines()[0]
|
|
235
246
|
if not guard.reason and any(w in out.error for w in NOT_ABOUT_CONTEXT):
|
|
236
247
|
raise # a smaller context wouldn't help
|
|
248
|
+
out.pressure = guard.pressure
|
|
237
249
|
if guard.reason: # the machine got unhealthy: that is why, whatever the server said as it was stopped
|
|
238
250
|
out.ok, out.error = False, guard.reason
|
|
251
|
+
out.stopped_for = "pressure" if guard.pressure_only else ""
|
|
239
252
|
return out
|
|
240
253
|
|
|
241
254
|
|
|
@@ -310,6 +323,7 @@ def search(try_ctx, start, upper, limit_gb=None, step=STEP, floor=FLOOR, max_sta
|
|
|
310
323
|
Returns (probes in the order tried, why it stopped)."""
|
|
311
324
|
tried, lo, hi, c = [], None, None, min(start, upper)
|
|
312
325
|
why = f"{max_starts} server starts used"
|
|
326
|
+
budget = limit_gb # None once the tries show it doesn't describe this server
|
|
313
327
|
while len(tried) < max_starts:
|
|
314
328
|
emit("tune_step", message=f"[{len(tried) + 1}] context {c:,}", start=len(tried) + 1, max_starts=max_starts)
|
|
315
329
|
try:
|
|
@@ -336,12 +350,20 @@ def search(try_ctx, start, upper, limit_gb=None, step=STEP, floor=FLOOR, max_sta
|
|
|
336
350
|
if hi is not None and hi - lo <= step:
|
|
337
351
|
why = f"{hi:,} failed: {next(p.error for p in tried if p.ctx == hi)}"
|
|
338
352
|
break
|
|
339
|
-
|
|
353
|
+
smallest = min((p for p in tried if p.ok and p.mem_gb), key=lambda p: p.ctx, default=None)
|
|
354
|
+
if budget is not None and smallest and smallest.mem_gb >= budget:
|
|
355
|
+
# Over the budget at the smallest context that passed: the context isn't what takes the
|
|
356
|
+
# memory. The server fills memory to a budget of its own, so the prediction can't cap it.
|
|
357
|
+
emit("tune_step", message=f" it took {smallest.mem_gb:.1f} GB at {smallest.ctx:,} already, more than the "
|
|
358
|
+
f"{budget:.1f} GB set aside, and passed: this server sizes its own memory, so "
|
|
359
|
+
"the search goes by the tries, not by predicted memory")
|
|
360
|
+
budget = None
|
|
361
|
+
_, per, fit = predict([p for p in tried if p.ok], budget)
|
|
340
362
|
nxt = min(upper, lo * 2) if hi is None else lo + _grid((hi - lo) / 2)
|
|
341
363
|
if fit is not None and fit < nxt:
|
|
342
364
|
if _grid(fit) - lo < min(step, upper - lo):
|
|
343
365
|
at = min(upper, lo + step)
|
|
344
|
-
why = (f"memory: {at:,} is predicted to need more than the {
|
|
366
|
+
why = (f"memory: {at:,} is predicted to need more than the {budget:.1f} GB this machine has "
|
|
345
367
|
f"for it ({per * 1000:.3f} GB per 1,000 tokens)")
|
|
346
368
|
break
|
|
347
369
|
nxt = _grid(fit)
|
|
@@ -443,10 +465,24 @@ def bench(eng, label, emit=lambda *a, **k: None, max_ctx=None, start=None, step=
|
|
|
443
465
|
|
|
444
466
|
baseline = None if sv.machine.discrete else machines.available_memory_gb()
|
|
445
467
|
|
|
468
|
+
rule = {"level": PRESSURE_WARNING, "passed": False}
|
|
469
|
+
|
|
446
470
|
def try_ctx(ctx):
|
|
447
471
|
eng._check()
|
|
448
472
|
settle(eng, baseline, emit)
|
|
449
|
-
|
|
473
|
+
r = probe(eng, m, ctx, emit, limit_s, rule["level"])
|
|
474
|
+
if r.stopped_for == "pressure" and not rule["passed"] and rule["level"] < PRESSURE_CRITICAL:
|
|
475
|
+
# Before anything has passed, at the smallest contexts: this isn't the context being too
|
|
476
|
+
# large. The server fills memory to a budget of its own and runs at the warning level.
|
|
477
|
+
rule["level"] = PRESSURE_CRITICAL
|
|
478
|
+
emit("tune_result", message=" " + r.summary())
|
|
479
|
+
emit("tune_step", message=f" memory pressure reaches the warning level at {ctx:,} already, with nothing "
|
|
480
|
+
"swapped: that is how this server runs. From here a try is stopped for swapping, "
|
|
481
|
+
"memory running out or critical pressure only; trying this context again")
|
|
482
|
+
settle(eng, baseline, emit)
|
|
483
|
+
r = probe(eng, m, ctx, emit, limit_s, rule["level"])
|
|
484
|
+
rule["passed"] = rule["passed"] or r.ok
|
|
485
|
+
return r
|
|
450
486
|
|
|
451
487
|
tried, why = search(try_ctx, first, upper, room, step, min(FLOOR, first), max_starts, emit)
|
|
452
488
|
passed = [p for p in tried if p.ok]
|
|
@@ -465,7 +501,9 @@ def bench(eng, label, emit=lambda *a, **k: None, max_ctx=None, start=None, step=
|
|
|
465
501
|
"meta": {"date": profiles.now(), "machine": sv.machine.summary, "server_version": eng.server_version(m),
|
|
466
502
|
"model_file": os.path.basename(str(m.get("model", ""))), "model_bytes": sv.identity.get("model_bytes"),
|
|
467
503
|
"kv_type": sv.kv_type, "upper_bound": upper, "upper_bound_from": source,
|
|
468
|
-
"fill_confirmed": best.filled, "server_starts": len(tried)
|
|
504
|
+
"fill_confirmed": best.filled, "server_starts": len(tried),
|
|
505
|
+
"stops_at_pressure": "critical" if rule["level"] >= PRESSURE_CRITICAL else "warning",
|
|
506
|
+
"pressure_seen": max((p.pressure or 0 for p in passed), default=0) or None},
|
|
469
507
|
}
|
|
470
508
|
path = profiles.save_context(sv.machine.id, label, measured, eng.tuning_dir)
|
|
471
509
|
eng._serving.clear()
|
tuieval/run_evals.py
CHANGED
|
@@ -650,6 +650,9 @@ def context_report(e, label, got):
|
|
|
650
650
|
per = f", {at['gb_per_1k_tokens']} GB per 1,000 tokens" if at.get("gb_per_1k_tokens") else ""
|
|
651
651
|
say(f"{label}: largest context {got['max_ctx']:,}{mem}{per}", GREEN)
|
|
652
652
|
say(f"{label}: stopped there because: {at['stopped']}")
|
|
653
|
+
if got["meta"].get("stops_at_pressure") == "critical":
|
|
654
|
+
say(f"{label}: this server runs with memory pressure at the warning level, so tries were judged by swapping, "
|
|
655
|
+
"memory running out and critical pressure", YELLOW)
|
|
653
656
|
if not got["meta"].get("fill_confirmed"):
|
|
654
657
|
say(f"{label}: the server reports no token counts, so how full the context was isn't confirmed", YELLOW)
|
|
655
658
|
if sv.ctx_source == "measured":
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: tuieval
|
|
3
|
-
Version: 0.2.0.
|
|
3
|
+
Version: 0.2.0.dev160
|
|
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,12 +1,12 @@
|
|
|
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=B1XJa-pJPRDLsbVv960aMwhTigHTPIseY-06NHfWpIY,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=Xahl_o-r25Aq9LFaZXlZMzLhARIayT8gpsAQxYwuUYA,27898
|
|
10
10
|
tuieval/dates.py,sha256=CVazlwNjCRhD__D12zXLdeqF2ySt15X3xLUQeE-o6PY,6293
|
|
11
11
|
tuieval/doctor.py,sha256=j2MdDORstsAGPnRmpsnxau1_fR6sTc_oEFGM5zugTJU,7246
|
|
12
12
|
tuieval/engine.py,sha256=OfAQx4s9A7PfaPJDr5U_MBp69kS3-tI99aPnrCYZ8mU,141469
|
|
@@ -19,7 +19,7 @@ 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=OwS4HGkCOlU0cGcToqJKxFpL8GQdMFW5PB6SitSAfrE,56337
|
|
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.dev160.dist-info/METADATA,sha256=EdoEUbKXI7YGTzGLkvdth2NXmZk9GXQM1kSuY5VCRPY,15306
|
|
55
|
+
tuieval-0.2.0.dev160.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
56
|
+
tuieval-0.2.0.dev160.dist-info/entry_points.txt,sha256=7eIhi1GpFxBP2OLJV02Nn8LwsNuO512eKOGt1IBbj04,45
|
|
57
|
+
tuieval-0.2.0.dev160.dist-info/licenses/LICENSE,sha256=7wfRgGtBGH1aXhZkIn47oUznqKC18kEPMvUVgol7Ffc,1077
|
|
58
|
+
tuieval-0.2.0.dev160.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|