@wendellresearch-ai/benchwarmers 0.2.0 → 0.2.2
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.
- package/AGENTS.md +152 -147
- package/BENCHMARKS.md +262 -262
- package/GATEWAY.md +415 -272
- package/NOTICE +28 -28
- package/PRIVACY.md +46 -46
- package/README.md +408 -314
- package/SECURITY.md +83 -83
- package/TERMS.md +22 -22
- package/USAGE.md +186 -163
- package/VERSION +1 -1
- package/bin/benchwarmers.js +16 -74
- package/cli.py +674 -0
- package/examples/config/gateway.json +5 -5
- package/examples/config/model-roles.json +11 -11
- package/gateway.py +939 -755
- package/launcher.py +120 -0
- package/mcp_server.py +266 -266
- package/metrics/alerts.py +116 -116
- package/metrics/aliases.py +41 -41
- package/metrics/bench_collections.py +141 -141
- package/metrics/catalog.py +304 -295
- package/metrics/client.py +804 -394
- package/metrics/cliproxy.py +191 -191
- package/metrics/connect.py +691 -691
- package/metrics/cost.py +171 -152
- package/metrics/decide.py +227 -227
- package/metrics/discover.py +318 -318
- package/metrics/endpoints.py +436 -436
- package/metrics/formats.py +1021 -0
- package/metrics/guard.py +647 -592
- package/metrics/learn.py +234 -221
- package/metrics/ledger.py +148 -0
- package/metrics/litellm_hub.py +206 -206
- package/metrics/model_roles.py +94 -84
- package/metrics/offload.py +166 -166
- package/metrics/owui.py +205 -205
- package/metrics/pacing.py +248 -0
- package/metrics/paths.py +60 -60
- package/metrics/quota.py +383 -0
- package/metrics/route.py +581 -579
- package/metrics/scheduler.py +275 -275
- package/metrics/sources.py +167 -167
- package/metrics/wrong.py +144 -144
- package/package.json +69 -65
- package/perf/README.md +89 -89
- package/perf/run.py +284 -261
- package/scripts/auto_retire.py +367 -367
- package/scripts/check.py +113 -106
- package/scripts/check_deprecations.py +378 -378
- package/scripts/check_themes.py +103 -103
- package/scripts/init.py +124 -124
- package/scripts/list_served.py +78 -78
- package/scripts/notice.py +78 -78
- package/scripts/onboard.py +410 -331
- package/scripts/provider_tags.py +129 -129
- package/scripts/reprefix.py +136 -136
- package/scripts/sync_config.py +105 -105
- package/scripts/test_auth.py +255 -255
- package/scripts/test_cli.py +189 -0
- package/scripts/test_client.py +277 -233
- package/scripts/test_connect.py +222 -222
- package/scripts/test_first_run.py +180 -180
- package/scripts/test_formats.py +549 -0
- package/scripts/test_hubs.py +328 -328
- package/scripts/test_launcher.py +67 -0
- package/scripts/test_llm_log.py +85 -81
- package/scripts/test_mcp.py +178 -178
- package/scripts/test_merged.py +215 -214
- package/scripts/test_no_owui.py +291 -291
- package/scripts/test_owui.py +90 -90
- package/scripts/test_quota.py +334 -0
- package/scripts/test_serve_edit.py +453 -438
- package/scripts/test_server_json.py +79 -0
- package/scripts/test_verdict.py +102 -98
- package/scripts/test_vision.py +231 -228
- package/serve.py +3972 -3764
- package/suite/mine.py +154 -154
- package/suite/pace.py +145 -145
- package/suite/run.py +1046 -1042
- package/suite/seed.py +421 -421
- package/suite/tasks/claim-alias-unbound/fixtures/onboard.py +286 -286
- package/suite/tasks/claim-error-text-string/fixtures/decide.py +187 -187
- package/suite/tasks/claim-list-body/fixtures/gateway.py +235 -235
- package/suite/tasks/claim-member-nominated-twice/fixtures/gateway.py +284 -284
- package/suite/tasks/claim-nominee-uses-slot/fixtures/gateway.py +284 -284
- package/suite/tasks/claim-silent-exit/fixtures/gateway.py +235 -235
- package/suite/tasks/claim-sse-hang/fixtures/gateway.py +235 -235
- package/suite/tasks/claim-unknown-nominee-crash/fixtures/gateway.py +284 -284
- package/suite/tasks/rebench-matchms-809-bug/task.json +23 -23
- package/suite/tasks/rebench-matchms-809-control/task.json +27 -27
- package/suite/tasks/rebench-more-itertools-1028-bug/task.json +23 -23
- package/suite/tasks/rebench-more-itertools-1028-control/task.json +27 -27
- package/suite/tasks/rebench-narwhals-2864-bug/task.json +23 -23
- package/suite/tasks/rebench-narwhals-2864-control/task.json +27 -27
- package/suite/tasks/rebench-quantecon-py-769-bug/task.json +23 -23
- package/suite/tasks/rebench-quantecon-py-769-control/task.json +27 -27
- package/suite/tasks/rebench-scrapy-6867-bug/task.json +23 -23
- package/suite/tasks/rebench-scrapy-6867-control/task.json +27 -27
- package/ui/bench.css +430 -425
- package/ui/bench.js +1757 -1576
- package/ui/themes/dark.css +35 -35
- package/ui/themes/hardwood.css +52 -52
- package/ui/themes/rainforest.css +32 -32
package/metrics/cost.py
CHANGED
|
@@ -1,152 +1,171 @@
|
|
|
1
|
-
"""What each model actually costs us, from the `llm` CLI's
|
|
2
|
-
|
|
3
|
-
python metrics/cost.py
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
import
|
|
29
|
-
|
|
30
|
-
import
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
"
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
1
|
+
"""What each model actually costs us, from the bench's usage ledger and the `llm` CLI's log.
|
|
2
|
+
|
|
3
|
+
python metrics/cost.py
|
|
4
|
+
|
|
5
|
+
TWO SOURCES, NO CALL IN BOTH. The built-in client writes a line for every
|
|
6
|
+
call to the usage ledger (metrics/ledger.py, RELEASE-PLAN Phase 2b); calls
|
|
7
|
+
made through the `llm` backend, and every call before the switch, are in
|
|
8
|
+
llm's own logs.db, which it has kept all along (382 turns with token counts
|
|
9
|
+
were on disk before this file existed). The built-in client never writes
|
|
10
|
+
logs.db and `llm` never writes the ledger, so the two are added up.
|
|
11
|
+
|
|
12
|
+
WHY REASONING TOKENS MATTER SEPARATELY
|
|
13
|
+
--------------------------------------
|
|
14
|
+
They are billed like output and are invisible in the answer. One
|
|
15
|
+
`gemini-3.8-flash-high` call spent **6,524** of them on a prompt whose reply
|
|
16
|
+
was a few lines; a trivial one spent 123 of 134 total tokens thinking. A model
|
|
17
|
+
that answers correctly at four times the token cost of another is a different
|
|
18
|
+
proposition for bulk work, and nothing else in this repo could see that.
|
|
19
|
+
|
|
20
|
+
WHAT THIS IS NOT
|
|
21
|
+
----------------
|
|
22
|
+
Money. Most of what we call is free or flat-rate, and inventing a price per
|
|
23
|
+
model would be a number nobody could check. Tokens are the honest unit: they
|
|
24
|
+
are what we spend, they are what a provider meters, and a rate can be applied
|
|
25
|
+
later by whoever knows it.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
from __future__ import annotations
|
|
29
|
+
|
|
30
|
+
import collections
|
|
31
|
+
import json
|
|
32
|
+
import pathlib
|
|
33
|
+
import sqlite3
|
|
34
|
+
|
|
35
|
+
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
|
36
|
+
from paths import DATA # noqa: E402 -- the install's data folder (metrics/paths.py)
|
|
37
|
+
from endpoints import LLM_DIR # noqa: E402
|
|
38
|
+
LOGS = LLM_DIR / "logs.db"
|
|
39
|
+
OUT = DATA / "metrics" / "cost.json"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def alias_history() -> dict[str, str]:
|
|
43
|
+
path = DATA / "config" / "alias-history.json"
|
|
44
|
+
if not path.exists():
|
|
45
|
+
return {}
|
|
46
|
+
return json.loads(path.read_text(encoding="utf-8"))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
LEDGER = DATA / "metrics" / "benchmark-calls.json"
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def note_benchmark_calls(model: str, calls: int) -> None:
|
|
53
|
+
"""Record that N of a model's logged calls were a BENCHMARK, not work.
|
|
54
|
+
|
|
55
|
+
Without this the call counter measures how much a model was BENCHMARKED
|
|
56
|
+
rather than how much it was relied on, and says the opposite of what it
|
|
57
|
+
appears to. `deepseek-v4-pro-0813` shows 214 calls, of which roughly 200
|
|
58
|
+
are floor runs that failed — it looks like the most-used model here and it
|
|
59
|
+
is nothing of the sort.
|
|
60
|
+
|
|
61
|
+
Each runner reports its own total, because each runner is the only thing
|
|
62
|
+
that knows. Offload calls are then the remainder.
|
|
63
|
+
"""
|
|
64
|
+
try:
|
|
65
|
+
data = json.loads(LEDGER.read_text(encoding="utf-8")) if LEDGER.exists() else {}
|
|
66
|
+
except ValueError:
|
|
67
|
+
data = {}
|
|
68
|
+
data[model] = data.get(model, 0) + calls
|
|
69
|
+
LEDGER.parent.mkdir(parents=True, exist_ok=True)
|
|
70
|
+
LEDGER.write_text(json.dumps(data, indent=2, sort_keys=True) + "\n",
|
|
71
|
+
encoding="utf-8")
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def benchmark_calls() -> dict[str, int]:
|
|
75
|
+
if not LEDGER.exists():
|
|
76
|
+
return {}
|
|
77
|
+
try:
|
|
78
|
+
return json.loads(LEDGER.read_text(encoding="utf-8"))
|
|
79
|
+
except ValueError:
|
|
80
|
+
return {}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _llm_turns():
|
|
84
|
+
"""(model, input, output, reasoning or None, duration_ms) per turn in llm's log."""
|
|
85
|
+
if not LOGS.exists():
|
|
86
|
+
return
|
|
87
|
+
db = sqlite3.connect(f"file:{LOGS}?mode=ro", uri=True)
|
|
88
|
+
db.row_factory = sqlite3.Row
|
|
89
|
+
for row in db.execute(
|
|
90
|
+
"SELECT model, input_tokens, output_tokens, token_details,"
|
|
91
|
+
" duration_ms FROM turns"):
|
|
92
|
+
try:
|
|
93
|
+
details = json.loads(row["token_details"] or "{}") or {}
|
|
94
|
+
except ValueError:
|
|
95
|
+
details = {}
|
|
96
|
+
reasoning = ((details.get("completion_tokens_details") or {})
|
|
97
|
+
.get("reasoning_tokens"))
|
|
98
|
+
yield (row["model"], row["input_tokens"], row["output_tokens"], reasoning,
|
|
99
|
+
row["duration_ms"])
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _ledger_calls():
|
|
103
|
+
"""The same, per answered call in the usage ledger. Refused and failed
|
|
104
|
+
calls spent nothing, as llm's log (which keeps only answers) counts."""
|
|
105
|
+
import ledger
|
|
106
|
+
for row in ledger.rows():
|
|
107
|
+
if row.get("status") in ("ok", "empty"):
|
|
108
|
+
yield (row.get("alias") or "?", row.get("tokens_in"), row.get("tokens_out"),
|
|
109
|
+
row.get("reasoning"), round((row.get("seconds") or 0) * 1000))
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def collect() -> dict:
|
|
113
|
+
"""Per-model totals, with old aliases folded into their current name."""
|
|
114
|
+
rename = alias_history()
|
|
115
|
+
agg: dict[str, dict] = collections.defaultdict(
|
|
116
|
+
lambda: {"calls": 0, "input": 0, "output": 0, "reasoning": 0,
|
|
117
|
+
"duration_ms": 0, "with_reasoning_data": 0})
|
|
118
|
+
for name, tokens_in, tokens_out, reasoning, ms in (*_llm_turns(), *_ledger_calls()):
|
|
119
|
+
# Turns predating the versioned rename carry the old alias.
|
|
120
|
+
model = rename.get(name, name)
|
|
121
|
+
a = agg[model]
|
|
122
|
+
a["calls"] += 1
|
|
123
|
+
a["input"] += tokens_in or 0
|
|
124
|
+
a["output"] += tokens_out or 0
|
|
125
|
+
a["duration_ms"] += ms or 0
|
|
126
|
+
if reasoning is not None:
|
|
127
|
+
a["reasoning"] += reasoning
|
|
128
|
+
a["with_reasoning_data"] += 1
|
|
129
|
+
|
|
130
|
+
bench = benchmark_calls()
|
|
131
|
+
out = {}
|
|
132
|
+
for model, a in agg.items():
|
|
133
|
+
billed = a["output"] + a["reasoning"]
|
|
134
|
+
out[model] = {
|
|
135
|
+
**a,
|
|
136
|
+
# The number that decides bulk work: how much of what we pay for
|
|
137
|
+
# never appears in the answer.
|
|
138
|
+
"reasoning_share": (round(a["reasoning"] / billed, 3)
|
|
139
|
+
if billed else None),
|
|
140
|
+
"tokens_per_call": (round((a["input"] + billed) / a["calls"])
|
|
141
|
+
if a["calls"] else 0),
|
|
142
|
+
# Benchmark calls ONLY. There was an `offload_calls` here too,
|
|
143
|
+
# derived as calls minus benchmarks, and it was wrong in both
|
|
144
|
+
# directions: the ledger began the day it was written, so every
|
|
145
|
+
# earlier suite run counted as work. Real offloads are recorded
|
|
146
|
+
# deliberately in metrics/offload.py, because subtracting one
|
|
147
|
+
# imperfect number from another gives a third nobody can check.
|
|
148
|
+
"benchmark_calls": bench.get(model, 0),
|
|
149
|
+
}
|
|
150
|
+
return out
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def main() -> None:
|
|
154
|
+
data = collect()
|
|
155
|
+
OUT.write_text(json.dumps(data, indent=2, sort_keys=True) + "\n",
|
|
156
|
+
encoding="utf-8")
|
|
157
|
+
rows = sorted(data.items(), key=lambda kv: -kv[1]["tokens_per_call"])
|
|
158
|
+
print(f"{'model':<30} {'calls':>5} {'tok/call':>9} {'reasoning share':>16}")
|
|
159
|
+
for model, a in rows:
|
|
160
|
+
share = ("—" if a["reasoning_share"] is None
|
|
161
|
+
else f"{a['reasoning_share']:.1%}")
|
|
162
|
+
note = "" if a["with_reasoning_data"] else " (no reasoning data)"
|
|
163
|
+
print(f"{model:<30} {a['calls']:>5} {a['tokens_per_call']:>9,} "
|
|
164
|
+
f"{share:>16}{note}")
|
|
165
|
+
print(f"\nwrote {OUT}")
|
|
166
|
+
print("Tokens, not money: most of what we call is free or flat-rate, and "
|
|
167
|
+
"a made-up price is a number nobody can check.")
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
if __name__ == "__main__":
|
|
171
|
+
main()
|