[PR #406] tools/agent_bench.py: a benchmark shaped like coding agents - several long conversations at once against a running server #514

Open
opened 2026-10-29 21:26:16 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/406
Author: @somnergy
Created: 10/23/2026
Status: 🔄 Open

Base: main ← Head: pr/agent-bench


📝 Commits (1)

  • 084249e tools/agent_bench.py: a benchmark shaped like coding agents, several conversations at once against a running server

📊 Changes

4 files changed (+842 additions, -2 deletions)

View changed files

📝 CONTRIBUTING.md (+5 -2)
➕ docs/AGENT_BENCH.md (+79 -0)
➕ tools/agent_bench.py (+518 -0)
➕ tools/test_agent_bench.py (+240 -0)

📄 Description

Summary

./maya.sh --bench answers "how fast is one request on this PC": three short questions and two cold prompt reads, one at a time. Coding agents load a server differently - several long conversations at once, each turn appending a tool result or a message to an ever longer history - and the settings that only matter under that load (--parallel, the expert tiers, the batched decode, reading a prompt between decode steps, a system prompt kept for the next conversation) show nothing in --bench.

This adds tools/agent_bench.py, a scripted agent workload against a running server, fixed by --seed so two settings, two builds or two machines get exactly the same requests:

  • --clients conversations at once (default 4) sharing a few long system prompts (30K / 8K / 4K tokens), then turns of new text (64 tokens to 64K, 80% under 2K) asking for 32-1024-token answers, with 2-20 s think time between an answer and the next turn;
  • short checks that send one long system prompt with a fresh question at a fixed rate (40/h), like an agent's permission or routing check;
  • two cold bursts where half the conversations start over (--burst-clients 0 for none), and compaction when a conversation outgrows --max-context;
  • the history is scripted (the model's answers are not fed back) and requests are greedy with the end tokens banned (--ban auto knows GLM-5.3-Flash by the served model's name), so every run writes the same tokens.

Requests are streamed and timed by the client, so it works against any OpenAI-compatible server. It reports aggregate output tokens/s, requests in flight, per-request decode (first token to last, what an agent sees), time to first token, latency (median and p90), decode by context length and reads by new tokens (the server's timings when it sends them). Against a Maya server it adds each request's VRAM hit and the expert tiers' readings from GET /metrics. compare prints mean +- sd per label and marks differences beyond twice their standard error.

Standard library only. docs/AGENT_BENCH.md describes the workload and how to read it; CONTRIBUTING.md points speed reports and pull requests for several conversations at it.

Example

One run, to show the output (not an A/B): 2x NVIDIA RTX PRO 5000 72GB Blackwell (PCIe 5.0 x8 each, no P2P), Intel Core Ultra 9 285K (24 cores), 96 GB DDR5, driver 615.71.09, CUDA 13.4; GLM-5.3-Flash Maya-L (IQ3_S / IQ4_XS experts, ~85% in VRAM, the rest pinned in RAM with the CPU lane), --parallel 8, --max-context 524288. python tools/agent_bench.py run --clients 4 --duration 600 --warmup 120 against a server that had already served other conversations for 35 minutes (so its caches were warm; an A/B starts a fresh server per run):

metric value
output tokens/s, all conversations 45.0
requests in flight (mean) 2.2
decode per request, median / p10 34.4 / 17.3 tok/s
decode by context: 0-32K / 32-64K / 64-128K 37.2 / 34.6 / 33.6 tok/s
latency of a turn, median / p90 12.8 / 26.2 s
time to first token, median / p90 2.3 / 11.0 s
reads by new tokens: 1-512 / 512-2K / 2-8K / 8-32K / 32K+ 548 / 941 / 1479 / 2356 / 2773 tok/s
VRAM hit per request (median) 97.2%
RAM-tier experts over PCIe a token / promotions a token 1.19 / 0.56

The p10 decode (half the median) is what a conversation gets while another one's prompt is being read; a one-request benchmark cannot show it. With the same workload on the same machine (the server-side replay from the closed #389, fresh server per run, no cold bursts), MTP drafting in the batched steps (#385's MAYA_GLM_MULTI_MTP=1, here with a local change that lends the draft layer's VRAM to the trunk while drafting is off) moved the per-request decode median by +4% at 4 conversations (drafting windows only at 2 or fewer running, MAYA_GLM_MULTI_MTP_MAX=2) and by -17% at 8 (the default MAYA_GLM_MULTI_MTP_MAX=4; one run each, run-to-run spread 2-3%) - a sign flip that only a multi-conversation run shows.

Tests

tools/test_agent_bench.py (picked up by the tools job): the plan is the same for a seed and differs for another; sizes and schedule; texts are fixed and a restart shares only the system prompt; compaction; the summary's window, rates, bins and in-flight count; server read times preferred over time to first token; errors counted, not measured; the comparison's marks; the end-token choice; and two short runs against a fake streaming server, with and without /metrics. 14 tests, ~7 s, no GPU.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mw00/project-maya/pull/406 **Author:** [@somnergy](https://github.com/somnergy) **Created:** 10/23/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/agent-bench` --- ### 📝 Commits (1) - [`084249e`](https://github.com/mw00/project-maya/commit/084249e5faf1b250a4a7a12849a9707c580c464f) tools/agent_bench.py: a benchmark shaped like coding agents, several conversations at once against a running server ### 📊 Changes **4 files changed** (+842 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `CONTRIBUTING.md` (+5 -2) ➕ `docs/AGENT_BENCH.md` (+79 -0) ➕ `tools/agent_bench.py` (+518 -0) ➕ `tools/test_agent_bench.py` (+240 -0) </details> ### 📄 Description ## Summary `./maya.sh --bench` answers "how fast is one request on this PC": three short questions and two cold prompt reads, one at a time. Coding agents load a server differently - several long conversations at once, each turn appending a tool result or a message to an ever longer history - and the settings that only matter under that load (`--parallel`, the expert tiers, the batched decode, reading a prompt between decode steps, a system prompt kept for the next conversation) show nothing in `--bench`. This adds **`tools/agent_bench.py`**, a scripted agent workload against a running server, fixed by `--seed` so two settings, two builds or two machines get exactly the same requests: - `--clients` conversations at once (default 4) sharing a few long system prompts (30K / 8K / 4K tokens), then turns of new text (64 tokens to 64K, 80% under 2K) asking for 32-1024-token answers, with 2-20 s think time between an answer and the next turn; - short checks that send one long system prompt with a fresh question at a fixed rate (40/h), like an agent's permission or routing check; - two cold bursts where half the conversations start over (`--burst-clients 0` for none), and compaction when a conversation outgrows `--max-context`; - the history is scripted (the model's answers are not fed back) and requests are greedy with the end tokens banned (`--ban auto` knows GLM-5.3-Flash by the served model's name), so every run writes the same tokens. Requests are streamed and timed by the client, so it works against any OpenAI-compatible server. It reports aggregate output tokens/s, requests in flight, per-request decode (first token to last, what an agent sees), time to first token, latency (median and p90), decode by context length and reads by new tokens (the server's `timings` when it sends them). Against a Maya server it adds each request's VRAM hit and the expert tiers' readings from `GET /metrics`. `compare` prints mean +- sd per label and marks differences beyond twice their standard error. Standard library only. `docs/AGENT_BENCH.md` describes the workload and how to read it; `CONTRIBUTING.md` points speed reports and pull requests for several conversations at it. ## Example One run, to show the output (not an A/B): 2x NVIDIA RTX PRO 5000 72GB Blackwell (PCIe 5.0 x8 each, no P2P), Intel Core Ultra 9 285K (24 cores), 96 GB DDR5, driver 615.71.09, CUDA 13.4; GLM-5.3-Flash Maya-L (IQ3_S / IQ4_XS experts, ~85% in VRAM, the rest pinned in RAM with the CPU lane), `--parallel 8`, `--max-context 524288`. `python tools/agent_bench.py run --clients 4 --duration 600 --warmup 120` against a server that had already served other conversations for 35 minutes (so its caches were warm; an A/B starts a fresh server per run): | metric | value | |---|---| | output tokens/s, all conversations | 45.0 | | requests in flight (mean) | 2.2 | | decode per request, median / p10 | 34.4 / 17.3 tok/s | | decode by context: 0-32K / 32-64K / 64-128K | 37.2 / 34.6 / 33.6 tok/s | | latency of a turn, median / p90 | 12.8 / 26.2 s | | time to first token, median / p90 | 2.3 / 11.0 s | | reads by new tokens: 1-512 / 512-2K / 2-8K / 8-32K / 32K+ | 548 / 941 / 1479 / 2356 / 2773 tok/s | | VRAM hit per request (median) | 97.2% | | RAM-tier experts over PCIe a token / promotions a token | 1.19 / 0.56 | The p10 decode (half the median) is what a conversation gets while another one's prompt is being read; a one-request benchmark cannot show it. With the same workload on the same machine (the server-side replay from the closed #389, fresh server per run, no cold bursts), MTP drafting in the batched steps (#385's `MAYA_GLM_MULTI_MTP=1`, here with a local change that lends the draft layer's VRAM to the trunk while drafting is off) moved the per-request decode median by +4% at 4 conversations (drafting windows only at 2 or fewer running, `MAYA_GLM_MULTI_MTP_MAX=2`) and by -17% at 8 (the default `MAYA_GLM_MULTI_MTP_MAX=4`; one run each, run-to-run spread 2-3%) - a sign flip that only a multi-conversation run shows. ## Tests `tools/test_agent_bench.py` (picked up by the tools job): the plan is the same for a seed and differs for another; sizes and schedule; texts are fixed and a restart shares only the system prompt; compaction; the summary's window, rates, bins and in-flight count; server read times preferred over time to first token; errors counted, not measured; the comparison's marks; the end-token choice; and two short runs against a fake streaming server, with and without `/metrics`. 14 tests, ~7 s, no GPU. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#514
No description provided.