tuieval 0.2.0.dev152__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 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.dev152'
22
- __version_tuple__ = version_tuple = (0, 2, 0, 'dev152')
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
@@ -22,7 +22,8 @@ the measurement replaces those. Memory grows about linearly with the context, so
22
22
  passed predict the largest context that fits under the machine's limit; no probe goes above that
23
23
  prediction, and a failed probe is bisected against the largest that passed. A probe is stopped at
24
24
  once, while the server loads or works, when memory pressure rises, the machine starts swapping,
25
- or memory runs out. Typically 3 to 5 server starts.
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.
26
27
 
27
28
  Memory is read off the machine, not the server's processes: available memory before the server
28
29
  starts less the lowest it falls to. Resident memory would count files a server maps and reads on
@@ -35,6 +36,7 @@ model declares (max_context): one probe, nothing saved.
35
36
  import dataclasses
36
37
  import os
37
38
  import threading
39
+ import time
38
40
 
39
41
  from . import engine as engine_mod
40
42
  from . import machines
@@ -52,6 +54,9 @@ REQUEST_LIMIT_S = 3600 # reading a few hundred thousand tokens takes a while
52
54
  PRESSURE_WARNING = 2 # macOS memory pressure level that stops a probe (1 is normal)
53
55
  SWAP_STOP_MB = 512 # swapped out while a probe ran: stop it
54
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
55
60
  TOO_LITTLE = 0.5 # a reading under this share of the model's size on disk can't be right for a server
56
61
  # that holds the model in memory: its resident memory is used instead
57
62
  SAMPLE_CHARS = 12000 # the request that measures the server's characters per token
@@ -234,6 +239,37 @@ def probe(eng, m, ctx, emit=lambda *a, **k: None, limit=REQUEST_LIMIT_S):
234
239
  return out
235
240
 
236
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
+
237
273
  # ------------------------------------------------------------------ the search
238
274
  def memory_gb(eng, m, info, guard):
239
275
  """What the server took with its context full: VRAM on a discrete GPU, else how much less memory
@@ -276,7 +312,12 @@ def search(try_ctx, start, upper, limit_gb=None, step=STEP, floor=FLOOR, max_sta
276
312
  why = f"{max_starts} server starts used"
277
313
  while len(tried) < max_starts:
278
314
  emit("tune_step", message=f"[{len(tried) + 1}] context {c:,}", start=len(tried) + 1, max_starts=max_starts)
279
- r = try_ctx(c)
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
280
321
  tried.append(r)
281
322
  emit("tune_result", message=" " + r.summary(), result=r)
282
323
  if r.ok:
@@ -394,8 +435,11 @@ def bench(eng, label, emit=lambda *a, **k: None, max_ctx=None, start=None, step=
394
435
  emit("tune_step", message=f"largest context up to {upper:,} ({source})"
395
436
  + (f"; {room:.1f} GB of memory to work with" if room is not None else ""))
396
437
 
438
+ baseline = None if sv.machine.discrete else machines.available_memory_gb()
439
+
397
440
  def try_ctx(ctx):
398
441
  eng._check()
442
+ settle(eng, baseline, emit)
399
443
  return probe(eng, m, ctx, emit, limit_s)
400
444
 
401
445
  tried, why = search(try_ctx, first, upper, room, step, min(FLOOR, first), max_starts, emit)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: tuieval
3
- Version: 0.2.0.dev152
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,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=SBk0ZLvvAsL0b3FMt7eym0iNTparGaT68nwzhJvZqA4,537
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=5JKm6QOpHN2hK3bmexC6aqyEBunOzw-hyI95msMS_yg,21634
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
12
  tuieval/engine.py,sha256=OfAQx4s9A7PfaPJDr5U_MBp69kS3-tI99aPnrCYZ8mU,141469
@@ -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.dev152.dist-info/METADATA,sha256=3D1IrWsNYPAEKTdD9PbTs1vFgPGIhvrGGIzD1YyxoSU,15306
55
- tuieval-0.2.0.dev152.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
56
- tuieval-0.2.0.dev152.dist-info/entry_points.txt,sha256=7eIhi1GpFxBP2OLJV02Nn8LwsNuO512eKOGt1IBbj04,45
57
- tuieval-0.2.0.dev152.dist-info/licenses/LICENSE,sha256=7wfRgGtBGH1aXhZkIn47oUznqKC18kEPMvUVgol7Ffc,1077
58
- tuieval-0.2.0.dev152.dist-info/RECORD,,
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,,