tuieval 0.2.0.dev79__tar.gz → 0.2.0.dev81__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.
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/CHANGELOG.md +1 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/PKG-INFO +1 -1
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/models.md +3 -1
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/_version.py +2 -2
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/engine.py +99 -39
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/run_evals.py +9 -2
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/tui.py +3 -4
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/tests/test_tuieval.py +66 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/.gitignore +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/LICENSE +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/README.md +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/RELEASING.md +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/brand/README.md +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/brand/favicon.ico +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/brand/readme-header.png +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/brand/social-preview.png +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/brand/tuieval-icon-1024.png +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/brand/tuieval-icon-128.png +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/brand/tuieval-icon-16.png +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/brand/tuieval-icon-16.svg +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/brand/tuieval-icon-256.png +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/brand/tuieval-icon-32.png +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/brand/tuieval-icon-48.png +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/brand/tuieval-icon-512.png +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/brand/tuieval-icon-64.png +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/brand/tuieval-icon-animated.svg +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/brand/tuieval-icon.svg +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/tui-answer-reasoning.png +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/tui-run-reasoning.png +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/images/tui-setup.png +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/docs/writing-packs.md +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/pyproject.toml +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/__init__.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/__main__.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/builtin.toml +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/cli.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/client.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/compare.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/doctor.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/export.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/graders/__init__.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/graders/answer.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/graders/code.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/graders/rag.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/graders/reply.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/graders/tool_call.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/logs.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/machines.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/onboard.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/packs.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/profiles.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/pta.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/remove.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/scaffold.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/selftest.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/models.toml +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/answer/pack.toml +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/answer/system.txt +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/answer/tests.yaml +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/code/pack.toml +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/code/system.txt +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/code/tests.yaml +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/rag/pack.toml +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/rag/system.txt +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/rag/tests.yaml +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/reply/pack.toml +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/reply/system.txt +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/reply/tests.yaml +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/tool_call/pack.toml +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/tool_call/system.txt +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/tool_call/tests.yaml +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/tool_call/tools.yaml +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/tune.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/verdict.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/watch_proxy.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/workspace.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/yamlout.py +0 -0
- {tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/tests/mock_server.py +0 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- Hosted models (OpenRouter and other APIs) run beside local ones instead of waiting for a slot: up to `parallel_hosted` at a time (default 4, `--parallel-hosted N`). Local models can be added to a hosted-only run.
|
|
5
6
|
- Early stop: `tuieval run --stop-early`, **Stop a pack once it fails** in Setup, or `stop_early = true` in a pack.toml ends a pack once its FAIL is certain (a critical failure, or an accuracy or truncation bar out of reach), asking first the questions models fail most. Verdicts also say FAIL when a partial run can no longer pass.
|
|
6
7
|
- `tuieval compare --reference <model>`: every other model paired against one on the questions both answered, per pack and overall: the difference with a 95% CI, better/tie/worse, critical failures and tokens vs the reference. `--packs` limits any compare to some packs.
|
|
7
8
|
- Fix: a question description or grader reason containing `[` no longer crashes the run screen.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: tuieval
|
|
3
|
-
Version: 0.2.0.
|
|
3
|
+
Version: 0.2.0.dev81
|
|
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
|
|
@@ -71,7 +71,7 @@ The best server flags differ per model and per machine, so tuieval splits them b
|
|
|
71
71
|
|
|
72
72
|
- **Machine id** is detected automatically (e.g. `m3max-64gb`, `m2-16gb`, or `rtx4090-128gb` on a Linux machine with a discrete GPU; set `EVALS_MACHINE` to rename it). Every result records the machine, the server version and the exact speed flags used. `tuieval machines` lists this machine and every other machine that has run the evals (they record themselves in `tuning/`).
|
|
73
73
|
- **Fit check (llama):** before starting a GGUF, tuieval reads its header (layers, KV heads, hybrid attention layers) and picks the largest context that fits this machine's GPU memory (a Mac's unified memory, or a discrete GPU's VRAM), capped at `max_ctx`. A model that can't fit at 8k context is skipped with *doesn't fit on <machine>* instead of swapping. Packs that need more context than fits are skipped. It never quantizes the KV cache on its own, since that changes answers. Servers that size their own memory (their `cmd` doesn't take `{ctx}`) are left alone: their context is the model's `max_context`; `fit_check` on the server changes that.
|
|
74
|
-
- **Per-machine settings** go under `[machines.<id>]`: `memory_headroom_gb` (GPU memory kept free: default 4 on a Mac, 1.5 in a discrete GPU's VRAM), `gpu_memory_gb` (the GPU memory to size models against, when detection gets it wrong or you want to hold some back), `gpu_residency_gb` (see the stall guard) and `
|
|
74
|
+
- **Per-machine settings** go under `[machines.<id>]`: `memory_headroom_gb` (GPU memory kept free: default 4 on a Mac, 1.5 in a discrete GPU's VRAM), `gpu_memory_gb` (the GPU memory to size models against, when detection gets it wrong or you want to hold some back), `gpu_residency_gb` (see the stall guard), `parallel_models` and `parallel_hosted` (see below).
|
|
75
75
|
|
|
76
76
|
### Discrete GPUs (Linux: Nvidia, AMD)
|
|
77
77
|
|
|
@@ -89,6 +89,7 @@ Windows isn't supported (WSL2 works like Linux).
|
|
|
89
89
|
|
|
90
90
|
By default a run serves one model at a time. On a machine with room for more, set `parallel_models = 2` (or more) under `[machines.<id>]`, type a number in **Models at a time** on the TUI's setup screen (blank uses the machine's setting), or pass `tuieval run --parallel N`.
|
|
91
91
|
|
|
92
|
+
- **Hosted models** (OpenRouter and other APIs) don't use this machine, so they don't count against this: up to `parallel_hosted` of them (default 4, under `[machines.<id>]`, or `tuieval run --parallel-hosted N`) run beside the local ones, and one never waits for a local model to finish. A server is hosted when tuieval doesn't start it and its url isn't this machine; set `hosted = true` (or `false`) on a server to say otherwise. A hosted-only run doesn't hold the machine; if local models are added to it, it takes the machine when the first of them starts.
|
|
92
93
|
- Models start in queue order, each in its own lane. The next one waits while its fit-check memory estimate wouldn't fit next to the ones running (without one, e.g. a server that sizes its own memory, the setting decides). Contexts are never shrunk to make room.
|
|
93
94
|
- A second model on the same server gets a free port, so a server's `cmd` must take `{port}`.
|
|
94
95
|
- A server with `before_start` (which may stop other servers) always runs on its own. Tuning is always one model at a time.
|
|
@@ -291,5 +292,6 @@ Optional sections:
|
|
|
291
292
|
# memory_headroom_gb = 3 # GPU memory kept free for macOS and other apps (default 4)
|
|
292
293
|
# gpu_residency_gb = 12 # GPU memory the driver keeps resident before churning (default: half of RAM)
|
|
293
294
|
# parallel_models = 2 # models a run serves at a time (default 1)
|
|
295
|
+
# parallel_hosted = 4 # hosted models (APIs) a run serves beside them (default 4)
|
|
294
296
|
```
|
|
295
297
|
|
|
@@ -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.dev81'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 2, 0, 'dev81')
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -47,6 +47,7 @@ import subprocess
|
|
|
47
47
|
import threading
|
|
48
48
|
import time
|
|
49
49
|
import tomllib
|
|
50
|
+
import urllib.parse
|
|
50
51
|
import urllib.request
|
|
51
52
|
|
|
52
53
|
from . import client
|
|
@@ -703,6 +704,7 @@ class Engine:
|
|
|
703
704
|
self._procs = []
|
|
704
705
|
self._stop_lock = threading.Lock()
|
|
705
706
|
self._run_lock = threading.Lock()
|
|
707
|
+
self._machine_take = threading.Lock() # one lane takes the machine lock for a hosted-only run
|
|
706
708
|
self._run = None # the run going: {"jobs", "pending", "open", "machine", "cond"} (add_jobs)
|
|
707
709
|
self._header_cache = {}
|
|
708
710
|
self._serving = {}
|
|
@@ -1258,6 +1260,36 @@ class Engine:
|
|
|
1258
1260
|
except (TypeError, ValueError):
|
|
1259
1261
|
return 1
|
|
1260
1262
|
|
|
1263
|
+
def parallel_hosted(self):
|
|
1264
|
+
"""How many hosted models (APIs) a run serves at a time, besides the local ones: models.toml
|
|
1265
|
+
[machines.<id>] parallel_hosted (default 4). They don't use this machine's GPU or memory."""
|
|
1266
|
+
try:
|
|
1267
|
+
return max(1, int(self.machine_settings().get("parallel_hosted", 4)))
|
|
1268
|
+
except (TypeError, ValueError):
|
|
1269
|
+
return 4
|
|
1270
|
+
|
|
1271
|
+
def models_at_once(self, labels, parallel=None, parallel_hosted=None):
|
|
1272
|
+
"""How many of these models run at the same time: local ones up to parallel (parallel_models),
|
|
1273
|
+
hosted ones beside them up to parallel_hosted."""
|
|
1274
|
+
labels = set(labels)
|
|
1275
|
+
hosted = sum(self.hosted(self.model(l)) for l in labels)
|
|
1276
|
+
return (min(parallel or self.parallel_models(), len(labels) - hosted)
|
|
1277
|
+
+ min(parallel_hosted or self.parallel_hosted(), hosted))
|
|
1278
|
+
|
|
1279
|
+
def hosted(self, m):
|
|
1280
|
+
"""A model served by an API elsewhere: tuieval doesn't start its server and its url isn't this
|
|
1281
|
+
machine (or its server sets hosted = true). A server you started yourself on localhost still
|
|
1282
|
+
counts as local (it uses the GPU)."""
|
|
1283
|
+
if m.get("remote"):
|
|
1284
|
+
return True
|
|
1285
|
+
server = self.cfg["servers"][m["server"]]
|
|
1286
|
+
if "hosted" in server: # say so for a server the url doesn't give away (e.g. a local proxy to an API)
|
|
1287
|
+
return bool(server["hosted"])
|
|
1288
|
+
if server.get("cmd"):
|
|
1289
|
+
return False
|
|
1290
|
+
host = urllib.parse.urlparse(server.get("url") or "").hostname or ""
|
|
1291
|
+
return bool(host) and host not in ("localhost", "127.0.0.1", "::1", "0.0.0.0")
|
|
1292
|
+
|
|
1261
1293
|
def memory_need_gb(self, m):
|
|
1262
1294
|
"""GPU memory a model takes while served here: 0 for one we don't start (a hosted API or a
|
|
1263
1295
|
server already running), the fit check's estimate for a local GGUF, else None (unknown)."""
|
|
@@ -1616,17 +1648,17 @@ class Engine:
|
|
|
1616
1648
|
return any(self.cfg["servers"][j.model["server"]].get("cmd") for j in jobs if j.status == "waiting")
|
|
1617
1649
|
|
|
1618
1650
|
# ---- running
|
|
1619
|
-
def run(self, jobs, parallel=None):
|
|
1651
|
+
def run(self, jobs, parallel=None, parallel_hosted=None):
|
|
1620
1652
|
"""Run the jobs (blocking). Jobs of the same model share one server start. parallel: how many
|
|
1621
|
-
models are served at a time (default: parallel_models for this machine)
|
|
1622
|
-
|
|
1653
|
+
local models are served at a time (default: parallel_models for this machine); hosted models
|
|
1654
|
+
(APIs) run beside them, up to parallel_hosted at a time (default: parallel_hosted). add_jobs()
|
|
1655
|
+
can add more while it runs; they run after the ones before them."""
|
|
1623
1656
|
self._cancel.clear()
|
|
1624
1657
|
self.emit("queue_started", jobs=jobs)
|
|
1625
1658
|
models = sorted({j.label for j in jobs if j.status == "waiting"})
|
|
1626
1659
|
machine = bool(jobs) and self.needs_machine(jobs)
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
if machine else contextlib.nullcontext())
|
|
1660
|
+
what = f"{jobs[0].tier} run: {', '.join(models[:3])}" + (f" +{len(models) - 3}" if len(models) > 3 else "")
|
|
1661
|
+
stack = contextlib.ExitStack() # holds the machine lock; a hosted-only run takes it if local models are added
|
|
1630
1662
|
order = []
|
|
1631
1663
|
for j in jobs:
|
|
1632
1664
|
if j.label not in order:
|
|
@@ -1634,10 +1666,13 @@ class Engine:
|
|
|
1634
1666
|
groups = [(label, [j for j in jobs if j.label == label and j.status == "waiting"]) for label in order]
|
|
1635
1667
|
with self._run_lock:
|
|
1636
1668
|
self._run = {"jobs": jobs, "pending": [g for g in groups if g[1]], "open": True, "machine": machine,
|
|
1637
|
-
"cond": threading.Condition(self._run_lock)}
|
|
1669
|
+
"cond": threading.Condition(self._run_lock), "stack": stack, "what": what}
|
|
1638
1670
|
try:
|
|
1639
|
-
with
|
|
1640
|
-
|
|
1671
|
+
with stack:
|
|
1672
|
+
if machine:
|
|
1673
|
+
stack.enter_context(self.machine_lock(what))
|
|
1674
|
+
self._run_lanes(max(1, int(parallel or self.parallel_models())),
|
|
1675
|
+
max(1, int(parallel_hosted or self.parallel_hosted())))
|
|
1641
1676
|
if self._cancel.is_set():
|
|
1642
1677
|
raise Cancelled()
|
|
1643
1678
|
except Cancelled:
|
|
@@ -1664,14 +1699,13 @@ class Engine:
|
|
|
1664
1699
|
def add_jobs(self, new):
|
|
1665
1700
|
"""Add planned jobs to the run going on, after its other jobs. Returns (added, why not): a
|
|
1666
1701
|
pack already waiting or running in it isn't added twice, and nothing is added once the run is
|
|
1667
|
-
finishing or cancelled
|
|
1702
|
+
finishing or cancelled. Local models added to a hosted-only run take the machine lock when the
|
|
1703
|
+
first of them starts.
|
|
1668
1704
|
Runs on the caller's thread, so the caller shows what was added (no event)."""
|
|
1669
1705
|
with self._run_lock:
|
|
1670
1706
|
r = self._run
|
|
1671
1707
|
if not r or not r["open"] or self._cancel.is_set():
|
|
1672
1708
|
return [], "the run is finishing"
|
|
1673
|
-
if not r["machine"] and self.needs_machine(new):
|
|
1674
|
-
return [], "the run going uses only hosted models, and these need this machine"
|
|
1675
1709
|
busy = {j.key for j in r["jobs"] if j.status in ("waiting", "loading", "running")}
|
|
1676
1710
|
added = [j for j in new if j.status == "waiting" and j.key not in busy]
|
|
1677
1711
|
r["jobs"].extend(added)
|
|
@@ -1684,33 +1718,51 @@ class Engine:
|
|
|
1684
1718
|
r["cond"].notify_all()
|
|
1685
1719
|
return added, None if added else "everything picked is already in the run"
|
|
1686
1720
|
|
|
1687
|
-
def _run_lanes(self, parallel):
|
|
1688
|
-
"""Run each model's jobs in its own lane
|
|
1689
|
-
|
|
1690
|
-
next to the ones running (memory_need_gb; an unknown need is left to the setting)
|
|
1691
|
-
|
|
1721
|
+
def _run_lanes(self, parallel, parallel_hosted=4):
|
|
1722
|
+
"""Run each model's jobs in its own lane: up to `parallel` local models at a time, in order (the
|
|
1723
|
+
next one starts once a lane is free, nothing running stops it (runs_alone), and its memory fits
|
|
1724
|
+
next to the ones running (memory_need_gb; an unknown need is left to the setting)), and beside
|
|
1725
|
+
them up to `parallel_hosted` hosted models, which need none of this machine. Lanes wait for jobs
|
|
1726
|
+
added meanwhile (add_jobs) until every model is done."""
|
|
1692
1727
|
pending, running, told = self._run["pending"], {}, set()
|
|
1693
1728
|
cond = self._run["cond"]
|
|
1729
|
+
hosted = {}
|
|
1730
|
+
|
|
1731
|
+
def is_hosted(label):
|
|
1732
|
+
if label not in hosted:
|
|
1733
|
+
hosted[label] = self.hosted(self.model(label))
|
|
1734
|
+
return hosted[label]
|
|
1694
1735
|
|
|
1695
1736
|
def blocked(label):
|
|
1696
1737
|
"""Why the next model can't start now (None: it can)."""
|
|
1697
|
-
if
|
|
1738
|
+
if is_hosted(label):
|
|
1739
|
+
return "" if sum(map(is_hosted, running)) >= parallel_hosted else None
|
|
1740
|
+
local = [l for l in running if not is_hosted(l)]
|
|
1741
|
+
if not local:
|
|
1698
1742
|
return None
|
|
1699
|
-
if len(
|
|
1743
|
+
if len(local) >= parallel:
|
|
1700
1744
|
return ""
|
|
1701
1745
|
m = self.model(label)
|
|
1702
|
-
if self.runs_alone(m) or any(self.runs_alone(self.model(l)) for l in
|
|
1703
|
-
alone = label if self.runs_alone(m) else next(l for l in
|
|
1746
|
+
if self.runs_alone(m) or any(self.runs_alone(self.model(l)) for l in local):
|
|
1747
|
+
alone = label if self.runs_alone(m) else next(l for l in local if self.runs_alone(self.model(l)))
|
|
1704
1748
|
return (f"{alone}'s server runs a before_start step that may stop other servers, so it runs "
|
|
1705
1749
|
"on its own")
|
|
1706
1750
|
need = self.memory_need_gb(m)
|
|
1707
|
-
used = sum(
|
|
1751
|
+
used = sum(running[l] or 0 for l in local)
|
|
1708
1752
|
room = self.memory_available_gb()
|
|
1709
1753
|
if need and used + need > room:
|
|
1710
|
-
return (f"needs ~{need:.0f} GB; {', '.join(
|
|
1754
|
+
return (f"needs ~{need:.0f} GB; {', '.join(local)} take ~{used:.0f} of {room:.0f} GB, so it "
|
|
1711
1755
|
"starts when there's room")
|
|
1712
1756
|
return None
|
|
1713
1757
|
|
|
1758
|
+
def take_machine():
|
|
1759
|
+
"""A hosted-only run that was given local models takes the machine lock before the first
|
|
1760
|
+
of them starts (it may wait for another tuieval window, like any run)."""
|
|
1761
|
+
with self._machine_take:
|
|
1762
|
+
if not self._run["machine"]:
|
|
1763
|
+
self._run["stack"].enter_context(self.machine_lock(self._run["what"]))
|
|
1764
|
+
self._run["machine"] = True
|
|
1765
|
+
|
|
1714
1766
|
def lane():
|
|
1715
1767
|
while True:
|
|
1716
1768
|
mine, note = None, None
|
|
@@ -1720,33 +1772,41 @@ class Engine:
|
|
|
1720
1772
|
cond.notify_all()
|
|
1721
1773
|
return
|
|
1722
1774
|
# in order, except that a model added again while it runs waits for itself to end
|
|
1723
|
-
# without holding up the ones behind it
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1775
|
+
# without holding up the ones behind it; the first waiting hosted model doesn't wait
|
|
1776
|
+
# for local ones (and the first local one doesn't wait for hosted ones)
|
|
1777
|
+
waiting = [i for i, g in enumerate(pending) if g[0] not in running]
|
|
1778
|
+
first = {}
|
|
1779
|
+
for i in waiting:
|
|
1780
|
+
first.setdefault(is_hosted(pending[i][0]), i)
|
|
1781
|
+
why, label = "", None
|
|
1782
|
+
for i in sorted(first.values()):
|
|
1783
|
+
why = blocked(pending[i][0])
|
|
1784
|
+
if why is None:
|
|
1785
|
+
label, mine = pending.pop(i)
|
|
1786
|
+
running[label] = self.memory_need_gb(self.model(label))
|
|
1787
|
+
break
|
|
1788
|
+
if mine is None:
|
|
1789
|
+
label = pending[min(first.values())][0] if first else None
|
|
1790
|
+
if why and label and label not in told:
|
|
1791
|
+
told.add(label)
|
|
1792
|
+
note = f"{label} waits: {why}"
|
|
1793
|
+
else:
|
|
1794
|
+
cond.wait(1.0)
|
|
1735
1795
|
if note:
|
|
1736
1796
|
self.emit("model_waiting", label=label, message=note)
|
|
1737
1797
|
if mine is None:
|
|
1738
1798
|
continue
|
|
1739
1799
|
try:
|
|
1800
|
+
if not is_hosted(label) and self.cfg["servers"][mine[0].model["server"]].get("cmd"):
|
|
1801
|
+
take_machine()
|
|
1740
1802
|
self._run_lane(label, mine)
|
|
1741
1803
|
finally:
|
|
1742
1804
|
with cond:
|
|
1743
1805
|
running.pop(label, None)
|
|
1744
1806
|
cond.notify_all()
|
|
1745
1807
|
|
|
1746
|
-
if
|
|
1747
|
-
|
|
1748
|
-
return
|
|
1749
|
-
threads = [threading.Thread(target=lane, name=f"lane-{i + 1}") for i in range(parallel)]
|
|
1808
|
+
# lanes for hosted models too, even if none is queued yet: add_jobs may bring some
|
|
1809
|
+
threads = [threading.Thread(target=lane, name=f"lane-{i + 1}") for i in range(parallel + parallel_hosted)]
|
|
1750
1810
|
for t in threads:
|
|
1751
1811
|
t.start()
|
|
1752
1812
|
for t in threads:
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
tuieval run --tier smoke --only openrouter:qwen/qwen3-32b # any OpenRouter model, no models.toml edit
|
|
18
18
|
tuieval run --dry-run # print the plan and server commands only
|
|
19
19
|
tuieval run --parallel 2 # serve two models at a time (parallel_models in models.toml)
|
|
20
|
+
tuieval run --parallel-hosted 6 # hosted models at a time beside them (default 4)
|
|
20
21
|
tuieval add ~/models/New-Model-Q4_K_M.gguf # register a model (--vision/--mmproj, --no-think, --tags)
|
|
21
22
|
tuieval scan # GGUFs in model_dirs that aren't registered yet
|
|
22
23
|
tuieval list # the models tuieval knows; hidden ones listed separately
|
|
@@ -755,6 +756,9 @@ def main(argv=None):
|
|
|
755
756
|
p.add_argument("--smoke", action="store_const", const="smoke", dest="tier", help="same as --tier smoke")
|
|
756
757
|
p.add_argument("--parallel", type=int, metavar="N",
|
|
757
758
|
help="models served at a time (default: parallel_models for this machine in models.toml, else 1)")
|
|
759
|
+
p.add_argument("--parallel-hosted", type=int, metavar="N",
|
|
760
|
+
help="hosted models (APIs) served at a time beside the local ones (default: parallel_hosted "
|
|
761
|
+
"in models.toml, else 4)")
|
|
758
762
|
p.add_argument("--dry-run", action="store_true", help="print the plan and commands without running")
|
|
759
763
|
p.add_argument("--brief", action="store_true", help="end with one line per model instead of the scorecards")
|
|
760
764
|
p.add_argument("--models", default=None, help="default: the workspace's models.toml")
|
|
@@ -769,6 +773,9 @@ def main(argv=None):
|
|
|
769
773
|
if args.parallel is not None and args.parallel < 1:
|
|
770
774
|
sys.exit("--parallel must be 1 or more")
|
|
771
775
|
parallel = args.parallel or e.parallel_models()
|
|
776
|
+
if args.parallel_hosted is not None and args.parallel_hosted < 1:
|
|
777
|
+
sys.exit("--parallel-hosted must be 1 or more")
|
|
778
|
+
parallel_hosted = args.parallel_hosted or e.parallel_hosted()
|
|
772
779
|
models = e.cfg["models"]
|
|
773
780
|
labels = [m["label"] for m in models if not m.get("remote")] # hosted APIs cost money: only by name
|
|
774
781
|
if args.only:
|
|
@@ -837,12 +844,12 @@ def main(argv=None):
|
|
|
837
844
|
|
|
838
845
|
signal.signal(signal.SIGINT, stop)
|
|
839
846
|
signal.signal(signal.SIGTERM, stop)
|
|
840
|
-
side_by_side =
|
|
847
|
+
side_by_side = e.models_at_once({j.label for j in jobs if j.status == "waiting"}, parallel, parallel_hosted)
|
|
841
848
|
if side_by_side > 1:
|
|
842
849
|
printer.side_by_side = True
|
|
843
850
|
say(f"up to {side_by_side} models at a time: one line per answer; each answer notes the models "
|
|
844
851
|
"it ran alongside, since they share this machine's speed")
|
|
845
|
-
worker = threading.Thread(target=e.run, args=(jobs, parallel))
|
|
852
|
+
worker = threading.Thread(target=e.run, args=(jobs, parallel, parallel_hosted))
|
|
846
853
|
worker.start()
|
|
847
854
|
while worker.is_alive():
|
|
848
855
|
worker.join(0.5)
|
|
@@ -975,7 +975,7 @@ class SetupScreen(Screen):
|
|
|
975
975
|
resumed = [j for j in run if "done earlier" in j.note]
|
|
976
976
|
if resumed:
|
|
977
977
|
text += f" [yellow]{len(resumed)} pack(s) continue from earlier results[/yellow]"
|
|
978
|
-
at_once =
|
|
978
|
+
at_once = e.models_at_once({j.label for j in run}, self.parallel())
|
|
979
979
|
if at_once > 1:
|
|
980
980
|
text += (f"\n[cyan]Up to {at_once} models at a time[/cyan][dim] (the time above assumes one at a "
|
|
981
981
|
"time). Answers note the models they ran alongside, since those share the machine's "
|
|
@@ -2130,8 +2130,7 @@ class RunScreen(Screen):
|
|
|
2130
2130
|
@property
|
|
2131
2131
|
def side_by_side(self):
|
|
2132
2132
|
"""Several models run at a time in this run."""
|
|
2133
|
-
return
|
|
2134
|
-
len({j.label for j in self.jobs if j.status != "skipped"})) > 1
|
|
2133
|
+
return self.app.engine.models_at_once({j.label for j in self.jobs if j.status != "skipped"}, self.parallel) > 1
|
|
2135
2134
|
|
|
2136
2135
|
def active(self):
|
|
2137
2136
|
"""Models being loaded or run now, in queue order."""
|
|
@@ -2446,7 +2445,7 @@ class RunScreen(Screen):
|
|
|
2446
2445
|
rough |= j.key in self.rough
|
|
2447
2446
|
left += (j.total - j.done) * spr
|
|
2448
2447
|
models.add(j.label)
|
|
2449
|
-
lanes = max(1,
|
|
2448
|
+
lanes = max(1, self.app.engine.models_at_once(models, self.parallel))
|
|
2450
2449
|
return left / lanes, rough
|
|
2451
2450
|
|
|
2452
2451
|
def update_overall(self):
|
|
@@ -15,6 +15,7 @@ import threading
|
|
|
15
15
|
import types
|
|
16
16
|
import time
|
|
17
17
|
import unittest
|
|
18
|
+
import unittest.mock
|
|
18
19
|
import urllib.request
|
|
19
20
|
|
|
20
21
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
@@ -283,6 +284,11 @@ class Units(unittest.TestCase):
|
|
|
283
284
|
job = lambda key, label, total, done=0, status="waiting": types.SimpleNamespace(
|
|
284
285
|
key=key, label=label, total=total, done=done, status=status)
|
|
285
286
|
run = RunScreen.__new__(RunScreen)
|
|
287
|
+
eng = types.SimpleNamespace(models_at_once=lambda labels, parallel: min(parallel, len(labels)))
|
|
288
|
+
patch = unittest.mock.patch.object(RunScreen, "app", new_callable=unittest.mock.PropertyMock,
|
|
289
|
+
return_value=types.SimpleNamespace(engine=eng))
|
|
290
|
+
patch.start()
|
|
291
|
+
self.addCleanup(patch.stop)
|
|
286
292
|
run.parallel, run.rough = 1, {"local/new"}
|
|
287
293
|
run.jobs = [job("hosted/a", "hosted", 100, 100, "done"), job("local/a", "local", 200, 4, "running"),
|
|
288
294
|
job("local/new", "local", 50)]
|
|
@@ -854,6 +860,66 @@ class MarkupInText(unittest.TestCase):
|
|
|
854
860
|
self.assertEqual(json.loads(p.stdout.strip().splitlines()[-1]), [["m/br", "done", 2]], p.stderr[-2000:])
|
|
855
861
|
|
|
856
862
|
|
|
863
|
+
class HostedBeside(unittest.TestCase):
|
|
864
|
+
"""Hosted models (APIs) don't use this machine: they run beside local ones whatever parallel_models
|
|
865
|
+
says, and local models can join a hosted-only run."""
|
|
866
|
+
|
|
867
|
+
def setUp(self):
|
|
868
|
+
self.tmp = tempfile.TemporaryDirectory()
|
|
869
|
+
self.ws = os.path.join(self.tmp.name, "ws")
|
|
870
|
+
tuieval(self.tmp.name, "init", self.ws)
|
|
871
|
+
d = os.path.join(self.ws, "packs", "apps")
|
|
872
|
+
os.makedirs(d)
|
|
873
|
+
write(os.path.join(d, "pack.toml"), 'label = "apps"\n[certify]\nrepeat = 1\n[gate]\nmin_accuracy = 0.1\n')
|
|
874
|
+
write(os.path.join(d, "tests.yaml"), "".join(
|
|
875
|
+
f"- {{id: {t}, input: question {t}, expected: 1, reference: 'ANSWER: 1', difficulty: easy}}\n" for t in "abcd"))
|
|
876
|
+
local = [sys.executable, os.path.join(HERE, "mock_server.py"), "--port", "{port}", "--packs",
|
|
877
|
+
os.path.join(self.ws, "packs"), "--model", "{served_name}", "--delay", "0.5"]
|
|
878
|
+
self.api = Mock(os.path.join(self.ws, "packs"), "oracle", delay=0.5)
|
|
879
|
+
with open(os.path.join(self.ws, "models.toml"), "a") as f:
|
|
880
|
+
f.write(f'\n[servers.mk]\ncmd = {json.dumps(local)}\nport = {free_port()}\n'
|
|
881
|
+
f'\n[servers.api]\nurl = "http://127.0.0.1:{self.api.port}"\nhosted = true\n'
|
|
882
|
+
'\n[[models]]\nlabel = "loc"\nserver = "mk"\nmodel = "loc"\n')
|
|
883
|
+
for label in ("h1", "h2"):
|
|
884
|
+
f.write(f'\n[[models]]\nlabel = "{label}"\nserver = "api"\nmodel = "mock"\n')
|
|
885
|
+
|
|
886
|
+
def tearDown(self):
|
|
887
|
+
self.api.stop()
|
|
888
|
+
self.tmp.cleanup()
|
|
889
|
+
|
|
890
|
+
def results(self, label):
|
|
891
|
+
return json.loads(read(os.path.join(self.ws, "results", label, "apps.json")))["results"]
|
|
892
|
+
|
|
893
|
+
def test_hosted_run_beside_local_with_one_slot(self):
|
|
894
|
+
from tuieval import engine
|
|
895
|
+
e = engine.Engine(lambda kind, **d: None, root=self.ws)
|
|
896
|
+
self.assertEqual([e.hosted(e.model(l)) for l in ("loc", "h1", "h2")], [False, True, True])
|
|
897
|
+
self.assertEqual(e.models_at_once({"loc", "h1", "h2"}, 1, 4), 3)
|
|
898
|
+
jobs = e.plan(["loc", "h1", "h2"], ["apps"], None, "certify", False, {})
|
|
899
|
+
e.run(jobs, parallel=1)
|
|
900
|
+
self.assertEqual([j.status for j in jobs], ["done"] * 3, [(j.key, j.note) for j in jobs])
|
|
901
|
+
seen = {l: set().union(*(r.get("ran_alongside", []) for r in self.results(l))) for l in ("loc", "h1", "h2")}
|
|
902
|
+
self.assertEqual(seen["loc"], {"h1", "h2"}) # neither hosted model waited for the local one
|
|
903
|
+
self.assertIn("h2", seen["h1"])
|
|
904
|
+
|
|
905
|
+
def test_local_model_joins_a_hosted_only_run(self):
|
|
906
|
+
from tuieval import engine
|
|
907
|
+
events = []
|
|
908
|
+
e = engine.Engine(lambda kind, **d: events.append(kind), root=self.ws)
|
|
909
|
+
jobs = e.plan(["h1"], ["apps"], None, "certify", False, {})
|
|
910
|
+
t = threading.Thread(target=e.run, args=(jobs,))
|
|
911
|
+
t.start()
|
|
912
|
+
deadline = time.time() + 120
|
|
913
|
+
while "request_done" not in events and time.time() < deadline:
|
|
914
|
+
time.sleep(0.05)
|
|
915
|
+
added, why = e.add_jobs(e.plan(["loc"], ["apps"], None, "certify", False, {}))
|
|
916
|
+
self.assertEqual(([j.key for j in added], why), (["loc/apps"], None))
|
|
917
|
+
t.join(300)
|
|
918
|
+
self.assertFalse(t.is_alive())
|
|
919
|
+
self.assertEqual(len(self.results("loc")), 4)
|
|
920
|
+
self.assertIsNone(e.machine_holder()) # the lock it took is released again
|
|
921
|
+
|
|
922
|
+
|
|
857
923
|
class AddToRun(unittest.TestCase):
|
|
858
924
|
"""More evals while a run is going: added to it (they run after its other jobs) or queued after it."""
|
|
859
925
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/tool_call/system.txt
RENAMED
|
File without changes
|
{tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/tool_call/tests.yaml
RENAMED
|
File without changes
|
{tuieval-0.2.0.dev79 → tuieval-0.2.0.dev81}/src/tuieval/templates/packs/tool_call/tools.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|