[PR #472] [CLOSED] Fix inaccurate decode rate on parallel decode #549

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/472
Author: @asdacap
Created: 10/25/2026
Status: ❌ Closed

Base: main ← Head: fix-decode-tps-counting


📝 Commits (3)

  • d22fa08 Server: the live decode rate is per request (no ~1000 tok/s blips with --parallel or after a burst)
  • d8d4bf6 Monitor: with several requests running, the big decode number is their total (the graph's newest point)
  • 1cb32e0 Monitor: the label under the decode total counts the requests writing

📊 Changes

4 files changed (+161 additions, -47 deletions)

View changed files

📝 serve/server.py (+78 -37)
📝 serve/test_fair.py (+2 -2)
📝 serve/test_server.py (+77 -6)
📝 serve/web/app.js (+4 -2)

📄 Description

The Monitor's live decode number sometimes jumped to ~1000 tok/s, far above what the engine can do. This fixes how the server counts it, and makes the Monitor's big number follow all running requests under --parallel.

What was wrong

  • Concurrent requests shared one sample buffer. With --parallel (READY ... multi=<n>), every request wrote its (time, generated) samples into the one Service.rate deque, so the rate was taken between two different requests' counts. Example: 813 from one answer against 5 from another, half a second apart, reads as ~1600 tok/s. The order the other way round gave 0.
  • A burst after a quiet stretch. The window started at the first sample inside it. After a pause longer than the window, 300 tokens at once plus one 0.3 s later read as 300 / 0.3 s ≈ 1000 tok/s.
  • The done: line printed n / (now - first token), so a one-token answer read as thousands of tok/s. The setup TUI parses that line for its speed.
  • The big number looked stuck under overlapping requests. It followed the newest request alone. While that one read its prompt, it showed the last finished request's speed even though others were writing.

Changes

  1. Server: the live decode rate is per request. Each request has a RequestStat with its own samples and first token. Service.current_requests holds the ones writing, and latest_request is the one that last got the engine (it replaces the shared status["first_token"]). The live tok/s is the sum over current_requests. The window is measured from RequestStat.base, the last sample at or before its start, with no scan. The done: line uses the engine's decode clock (DONE's decode_ms), the same figure as the Monitor's history row.
  2. Monitor: with more than one request running, the big decode number is their total. It reads the newest point of history.tok_s, the series the graph already draws, so /metrics' live block is unchanged for that. With one or no request running, the number is the same as before.
  3. Monitor: the label under that total counts the requests writing. /metrics gains live.writing, the requests past their prompt. The label reads "decode · N writing" rather than counting a request that is still reading its prompt.

The badge and the header pill are unchanged.

Screenshot

image

Checks

  • tools/check_hip_compat.py: passes (no engine code touched).
  • serve tests: 368 run on Linux. 10 errors are in the Responses API tests and need a local openai 2.30 SDK. The same 10 fail on main at v1.1.27, and CI doesn't install openai, so they skip there.
  • tools tests: not run to completion here (one exits because this checkout isn't set up), and this PR doesn't touch tools/.
  • Not tested on V100s or in the browser by me.

🤖 Generated with Claude Code


🔄 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/472 **Author:** [@asdacap](https://github.com/asdacap) **Created:** 10/25/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-decode-tps-counting` --- ### 📝 Commits (3) - [`d22fa08`](https://github.com/mw00/project-maya/commit/d22fa08843e8b25c33aec4ef7a646f15b3ab6acd) Server: the live decode rate is per request (no ~1000 tok/s blips with --parallel or after a burst) - [`d8d4bf6`](https://github.com/mw00/project-maya/commit/d8d4bf66aa7c7af19c08a7fdc18d493eb8115626) Monitor: with several requests running, the big decode number is their total (the graph's newest point) - [`1cb32e0`](https://github.com/mw00/project-maya/commit/1cb32e099664ed862dfc32d3ea8760b6516a9331) Monitor: the label under the decode total counts the requests writing ### 📊 Changes **4 files changed** (+161 additions, -47 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+78 -37) 📝 `serve/test_fair.py` (+2 -2) 📝 `serve/test_server.py` (+77 -6) 📝 `serve/web/app.js` (+4 -2) </details> ### 📄 Description The Monitor's live decode number sometimes jumped to ~1000 tok/s, far above what the engine can do. This fixes how the server counts it, and makes the Monitor's big number follow all running requests under `--parallel`. ## What was wrong - **Concurrent requests shared one sample buffer.** With `--parallel` (`READY ... multi=<n>`), every request wrote its `(time, generated)` samples into the one `Service.rate` deque, so the rate was taken between two different requests' counts. Example: 813 from one answer against 5 from another, half a second apart, reads as ~1600 tok/s. The order the other way round gave 0. - **A burst after a quiet stretch.** The window started at the first sample *inside* it. After a pause longer than the window, 300 tokens at once plus one 0.3 s later read as 300 / 0.3 s ≈ 1000 tok/s. - **The `done:` line** printed `n / (now - first token)`, so a one-token answer read as thousands of tok/s. The setup TUI parses that line for its speed. - **The big number looked stuck under overlapping requests.** It followed the newest request alone. While that one read its prompt, it showed the last *finished* request's speed even though others were writing. ## Changes 1. **Server: the live decode rate is per request.** Each request has a `RequestStat` with its own samples and first token. `Service.current_requests` holds the ones writing, and `latest_request` is the one that last got the engine (it replaces the shared `status["first_token"]`). The live tok/s is the sum over `current_requests`. The window is measured from `RequestStat.base`, the last sample at or before its start, with no scan. The `done:` line uses the engine's decode clock (`DONE`'s `decode_ms`), the same figure as the Monitor's history row. 2. **Monitor: with more than one request running, the big decode number is their total.** It reads the newest point of `history.tok_s`, the series the graph already draws, so `/metrics`' `live` block is unchanged for that. With one or no request running, the number is the same as before. 3. **Monitor: the label under that total counts the requests writing.** `/metrics` gains `live.writing`, the requests past their prompt. The label reads "decode · N writing" rather than counting a request that is still reading its prompt. The badge and the header pill are unchanged. ## Screenshot <img width="2138" height="732" alt="image" src="https://github.com/user-attachments/assets/6e6d854d-4670-41d1-8fdf-7901578df4df" /> ## Checks - `tools/check_hip_compat.py`: passes (no engine code touched). - `serve` tests: 368 run on Linux. 10 errors are in the Responses API tests and need a local `openai` 2.30 SDK. The same 10 fail on `main` at v1.1.27, and CI doesn't install `openai`, so they skip there. - `tools` tests: not run to completion here (one exits because this checkout isn't set up), and this PR doesn't touch `tools/`. - Not tested on V100s or in the browser by me. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:26:43 +07:00
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#549
No description provided.