[PR #4947] [CLOSED] Monitor: --monitor-aggregate shows speed and prefill summed over every stream #5260

Closed
opened 2026-11-07 16:33:53 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4947
Author: @elight
Created: 11/1/2026
Status: ❌ Closed

Base: main ← Head: monitor-aggregate-rates


📝 Commits (4)

  • 3b05cfe Monitor: --monitor-aggregate shows speed and prefill summed over every stream
  • fad477b Monitor: STRATA_MONITOR_AGGREGATE=1 turns the aggregate rates on too
  • c5351f1 Monitor: aggregate rates hold their last value until really 0
  • 256ee45 Monitor: aggregate rates are the last second, not the gap between samples

📊 Changes

4 files changed (+263 additions, -9 deletions)

View changed files

📝 serve/runconfig.py (+1 -0)
📝 serve/server.py (+91 -2)
➕ serve/test_monitor_aggregate.py (+157 -0)
📝 serve/web/app.js (+14 -7)

📄 Description

What

A new opt-in flag, --monitor-aggregate (or "monitor_aggregate": true in the run config). With it, the Monitor's Speed and Prefill cards and their sparklines show tokens per second summed over every running stream, measured second by second. With one stream it is that stream's rate. With several running at once in a given second, it is their sum.

Without the flag nothing changes.

Why

With "parallel": N, the cards show one request's rate, so you can't see at a glance what the box as a whole is doing.

How

  • Decode: a server-wide counter goes up in _note by each request's new tokens. A count that restarts from zero, like a retry, never subtracts.
  • Prefill: a per-engine counter of fresh prompt tokens comes from PP lines. It uses ms × fresh tok/s, which is position − pp_from, so a reused cached prefix is never counted. A new prompt is spotted by a smaller ms, and the counter also resets at request start and slot admission. Replicas add up across engines.
  • The telemetry sampler records each second's counter differences, divided by the real interval, into the existing tok_s and prefill_tok_s_mean series. /metrics live gains rates: "aggregate", agg_tok_s and agg_prefill_tok_s.

Tests

serve/test_monitor_aggregate.py (11 tests) covers:

  • one stream and parallel streams adding up;
  • no negative counts;
  • the real-interval division;
  • fresh prefill only, with the reused prefix excluded;
  • a new prompt starting from zero;
  • bad PP lines;
  • summing across engines;
  • off by default.

test_server, test_monitor, test_prometheus, test_draft_layer, test_admit_order and test_lifecycle all pass.

🤖 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/Niko1221/Strata/pull/4947 **Author:** [@elight](https://github.com/elight) **Created:** 11/1/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `monitor-aggregate-rates` --- ### 📝 Commits (4) - [`3b05cfe`](https://github.com/Niko1221/Strata/commit/3b05cfe848a28b6bb5e31ed8a20b97f3711bfdbf) Monitor: --monitor-aggregate shows speed and prefill summed over every stream - [`fad477b`](https://github.com/Niko1221/Strata/commit/fad477bba7d13095aa3881ea54dd6567ee3e3d75) Monitor: STRATA_MONITOR_AGGREGATE=1 turns the aggregate rates on too - [`c5351f1`](https://github.com/Niko1221/Strata/commit/c5351f13da4631e79b5d339bed78da665c77aefc) Monitor: aggregate rates hold their last value until really 0 - [`256ee45`](https://github.com/Niko1221/Strata/commit/256ee45b0f4ac05cd55701ce10d091c696bd095d) Monitor: aggregate rates are the last second, not the gap between samples ### 📊 Changes **4 files changed** (+263 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `serve/runconfig.py` (+1 -0) 📝 `serve/server.py` (+91 -2) ➕ `serve/test_monitor_aggregate.py` (+157 -0) 📝 `serve/web/app.js` (+14 -7) </details> ### 📄 Description ## What A new opt-in flag, `--monitor-aggregate` (or `"monitor_aggregate": true` in the run config). With it, the Monitor's **Speed** and **Prefill** cards and their sparklines show tokens per second **summed over every running stream**, measured second by second. With one stream it is that stream's rate. With several running at once in a given second, it is their sum. Without the flag nothing changes. ## Why With `"parallel": N`, the cards show one request's rate, so you can't see at a glance what the box as a whole is doing. ## How - **Decode:** a server-wide counter goes up in `_note` by each request's new tokens. A count that restarts from zero, like a retry, never subtracts. - **Prefill:** a per-engine counter of fresh prompt tokens comes from PP lines. It uses `ms × fresh tok/s`, which is `position − pp_from`, so a reused cached prefix is never counted. A new prompt is spotted by a smaller `ms`, and the counter also resets at request start and slot admission. Replicas add up across engines. - The telemetry sampler records each second's counter differences, divided by the real interval, into the existing `tok_s` and `prefill_tok_s_mean` series. `/metrics` `live` gains `rates: "aggregate"`, `agg_tok_s` and `agg_prefill_tok_s`. ## Tests `serve/test_monitor_aggregate.py` (11 tests) covers: - one stream and parallel streams adding up; - no negative counts; - the real-interval division; - fresh prefill only, with the reused prefix excluded; - a new prompt starting from zero; - bad PP lines; - summing across engines; - off by default. `test_server`, `test_monitor`, `test_prometheus`, `test_draft_layer`, `test_admit_order` and `test_lifecycle` all pass. 🤖 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-11-07 16:33:53 +07:00
Sign in to join this conversation.
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
Niko1221/Strata#5260
No description provided.