tuieval 0.2.0.dev152__tar.gz → 0.2.0.dev154__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.
Files changed (83) hide show
  1. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/CHANGELOG.md +1 -0
  2. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/PKG-INFO +1 -1
  3. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/models.md +1 -1
  4. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/_version.py +2 -2
  5. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/ctxbench.py +46 -2
  6. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/tests/test_tuieval.py +33 -0
  7. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/.gitignore +0 -0
  8. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/LICENSE +0 -0
  9. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/README.md +0 -0
  10. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/RELEASING.md +0 -0
  11. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/agent-packs.md +0 -0
  12. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/brand/README.md +0 -0
  13. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/brand/favicon.ico +0 -0
  14. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/brand/readme-header.png +0 -0
  15. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/brand/social-preview.png +0 -0
  16. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/brand/tuieval-icon-1024.png +0 -0
  17. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/brand/tuieval-icon-128.png +0 -0
  18. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/brand/tuieval-icon-16.png +0 -0
  19. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/brand/tuieval-icon-16.svg +0 -0
  20. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/brand/tuieval-icon-256.png +0 -0
  21. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/brand/tuieval-icon-32.png +0 -0
  22. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/brand/tuieval-icon-48.png +0 -0
  23. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/brand/tuieval-icon-512.png +0 -0
  24. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/brand/tuieval-icon-64.png +0 -0
  25. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/brand/tuieval-icon-animated.svg +0 -0
  26. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/brand/tuieval-icon.svg +0 -0
  27. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/tui-answer-reasoning.png +0 -0
  28. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/tui-run-reasoning.png +0 -0
  29. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/images/tui-setup.png +0 -0
  30. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/docs/writing-packs.md +0 -0
  31. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/pyproject.toml +0 -0
  32. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/__init__.py +0 -0
  33. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/__main__.py +0 -0
  34. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/agents.py +0 -0
  35. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/builtin.toml +0 -0
  36. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/cli.py +0 -0
  37. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/client.py +0 -0
  38. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/compare.py +0 -0
  39. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/dates.py +0 -0
  40. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/doctor.py +0 -0
  41. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/engine.py +0 -0
  42. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/export.py +0 -0
  43. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/graders/__init__.py +0 -0
  44. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/graders/answer.py +0 -0
  45. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/graders/code.py +0 -0
  46. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/graders/rag.py +0 -0
  47. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/graders/reply.py +0 -0
  48. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/graders/tool_call.py +0 -0
  49. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/insights.py +0 -0
  50. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/logs.py +0 -0
  51. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/machines.py +0 -0
  52. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/onboard.py +0 -0
  53. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/packs.py +0 -0
  54. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/profiles.py +0 -0
  55. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/pta.py +0 -0
  56. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/remove.py +0 -0
  57. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/run_evals.py +0 -0
  58. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/scaffold.py +0 -0
  59. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/selftest.py +0 -0
  60. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/models.toml +0 -0
  61. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/packs/answer/pack.toml +0 -0
  62. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/packs/answer/system.txt +0 -0
  63. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/packs/answer/tests.yaml +0 -0
  64. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/packs/code/pack.toml +0 -0
  65. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/packs/code/system.txt +0 -0
  66. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/packs/code/tests.yaml +0 -0
  67. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/packs/rag/pack.toml +0 -0
  68. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/packs/rag/system.txt +0 -0
  69. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/packs/rag/tests.yaml +0 -0
  70. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/packs/reply/pack.toml +0 -0
  71. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/packs/reply/system.txt +0 -0
  72. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/packs/reply/tests.yaml +0 -0
  73. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/packs/tool_call/pack.toml +0 -0
  74. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/packs/tool_call/system.txt +0 -0
  75. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/packs/tool_call/tests.yaml +0 -0
  76. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/templates/packs/tool_call/tools.yaml +0 -0
  77. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/tui.py +0 -0
  78. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/tune.py +0 -0
  79. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/verdict.py +0 -0
  80. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/watch_proxy.py +0 -0
  81. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/workspace.py +0 -0
  82. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/src/tuieval/yamlout.py +0 -0
  83. {tuieval-0.2.0.dev152 → tuieval-0.2.0.dev154}/tests/mock_server.py +0 -0
@@ -2,6 +2,7 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - Fix: `tuieval tune --ctx` waits for the machine to recover after each try (memory pressure back to normal, memory given back). A try stopped for memory pressure could fail the next one within seconds, at a context that works.
5
6
  - `tuieval tune --ctx`: the measured context governs the caps in `models.toml` (`max_ctx`, a model's `ctx`, a context flag), not the other way around: the search runs up to the model's own limit, and runs use what was measured even above a cap. It starts at half the model's current context, and a try is also stopped while the server loads. Memory is measured as what the machine loses while the server runs (on a Mac from `vm_stat` page counts, not the rounded free percentage), so memory-mapped files a server reads on demand no longer count against it.
6
7
  - `tuieval tune <model> --ctx` measures the largest context a model can be served with on this machine, for any server tuieval starts: it fills each context it tries and checks the answer, the tokens the server read, memory pressure and swapping. Runs then use the measured context in place of the fit check's estimate (`tuning/<machine>/<model>.ctx.toml`; `tuieval machines` shows *measured*). See docs/models.md.
7
8
  - Results from more than one machine: a **Machine** dropdown in Results keeps only the answers that ran on one machine, in every tab (hosted models' answers count from any machine unless **Hosted from any machine** is unticked). `--ran-on <id>` (and `--ran-on-strict`) on `tuieval pta`, `compare`, `verdict`, `report` and `insights`.
@@ -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
@@ -153,7 +153,7 @@ The knobs are `[servers.<name>.tune]` in `models.toml`: each knob is a list of o
153
153
  The fit check estimates the context from the model file, and only for servers that use memory the way llama.cpp does. `tuieval tune <model> --ctx` measures it instead, the same way for any server tuieval starts:
154
154
 
155
155
  1. It starts the server with a context, sends a built-in document that fills it (sized from the token counts the server reports, so any tokenizer works) with one fact near the start, and asks for that fact.
156
- 2. The try passes when the answer is right, the server read the whole document (a server that cuts long prompts short fails here), and the machine stayed healthy: no macOS memory pressure, no swapping, memory left on Linux. A try is stopped the moment one of those turns bad, also while the server is still loading.
156
+ 2. The try passes when the answer is right, the server read the whole document (a server that cuts long prompts short fails here), and the machine stayed healthy: no macOS memory pressure, no swapping, memory left on Linux. A try is stopped the moment one of those turns bad, also while the server is still loading. The next try waits until the machine has recovered, so the pressure one try leaves behind can't fail the next.
157
157
  3. It starts at half the context the model runs with now (32768 when that isn't known) and doubles. Memory grows about linearly with the context, so two tries that passed predict the largest context that fits in the machine's memory (less `memory_headroom_gb`, and less whatever other apps hold now); no try goes above the prediction, and a failed try is bisected against the largest that passed.
158
158
 
159
159
  Expect 3 to 5 server starts; the largest ones take as long as the server needs to read that many tokens. It won't start when memory pressure is already elevated or the model is larger than the memory free now.
@@ -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
@@ -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)
@@ -4011,6 +4011,39 @@ class ContextBench(unittest.TestCase):
4011
4011
  self.assertEqual(best, 74752)
4012
4012
  self.assertTrue(why.startswith("memory:"), why)
4013
4013
 
4014
+ def test_search_keeps_what_passed_when_the_machine_doesnt_recover(self):
4015
+ from tuieval import ctxbench
4016
+
4017
+ def try_ctx(ctx):
4018
+ if ctx > 65536:
4019
+ raise ctxbench.Halt("macOS memory pressure stayed at level 2 for 120s after the last try")
4020
+ return ctxbench.Probe(ctx, ok=True)
4021
+ probes, why = ctxbench.search(try_ctx, start=32768, upper=262144)
4022
+ self.assertEqual([p.ctx for p in probes], [32768, 65536])
4023
+ self.assertIn("stayed at level 2", why)
4024
+
4025
+ def test_the_next_try_waits_for_the_machine_to_recover(self):
4026
+ from tuieval import ctxbench, machines
4027
+ eng = types.SimpleNamespace(_check=lambda: None, machine=lambda: types.SimpleNamespace(discrete=False))
4028
+ for name in ("memory_pressure_level", "available_memory_gb"):
4029
+ self.addCleanup(setattr, machines, name, getattr(machines, name))
4030
+ self.addCleanup(setattr, ctxbench, "SETTLE_POLL_S", ctxbench.SETTLE_POLL_S)
4031
+ ctxbench.SETTLE_POLL_S = 0.001
4032
+ levels, free, said = iter([2, 2, 1, 1, 1]), iter([70.0, 70.0, 70.0, 84.0, 84.0]), []
4033
+ machines.memory_pressure_level = lambda: next(levels)
4034
+ machines.available_memory_gb = lambda: next(free)
4035
+ ctxbench.settle(eng, 85.0, lambda kind, **d: said.append(d["message"]))
4036
+ self.assertEqual(next(levels), 1) # it read four times: pressure eased on the third, memory came back on the fourth
4037
+ self.assertEqual(len(said), 1)
4038
+ machines.memory_pressure_level = lambda: 2 # pressure that doesn't ease ends the search
4039
+ machines.available_memory_gb = lambda: 84.0
4040
+ with self.assertRaisesRegex(ctxbench.Halt, "stayed at level 2"):
4041
+ ctxbench.settle(eng, 85.0, limit_s=0.01)
4042
+ machines.memory_pressure_level = lambda: 1 # memory another app took doesn't
4043
+ machines.available_memory_gb = lambda: 60.0
4044
+ ctxbench.settle(eng, 85.0, lambda kind, **d: said.append(d["message"]), limit_s=0.01)
4045
+ self.assertIn("25.0 GB less memory is available", said[-1])
4046
+
4014
4047
  def test_search_halves_when_the_first_try_fails(self):
4015
4048
  best, tried, why = self._search(20000, start=65536, upper=131072)
4016
4049
  self.assertEqual(tried[:3], [65536, 32768, 16384])
File without changes
File without changes