[PR #652] serve: keep final statistics when a reply ends or is cancelled #651

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/652
Author: @LostVector
Created: 10/29/2026
Status: 🔄 Open

Base: main ← Head: upstream/serve-drain-stats


📝 Commits (1)

  • d84955a serve: retain final STAT snapshots when draining a stopped consumer

📊 Changes

2 files changed (+41 additions, -0 deletions)

View changed files

📝 serve/server.py (+3 -0)
📝 serve/test_server.py (+38 -0)

📄 Description

When a reply ends, the engine sends its final statistics just after the last token. The server was throwing that snapshot away while finishing an EOS, token-budget stop, or cancellation. This keeps it, so the dashboard and /metrics show the completed reply instead of stale or missing counters. We found this on a three-token reply whose metrics were still None after completion.

The serial StrataEngine.generate() drain now parses STAT lines before continuing to DONE. This preserves the last timing, expert-cache/read counters, and any other native statistic through the same parser used during generation. It adds no model calls or device synchronization.

The regression test uses a fake native process that sends an intermediate snapshot, a token, then a final snapshot and DONE. It fails on current main because closing the token consumer leaves the intermediate values, and passes with this fix. It also checks that the next request reads its own tokens rather than a stale completion.

Validation on f031a23: 465 server tests pass (11 skipped), 585 tools tests pass (31 skipped), and HIP compatibility check passes. The same regression also passes against a backport onto our pinned private API source. No inference speedup is claimed; this fixes reporting needed for reliable measurements.


🔄 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/652 **Author:** [@LostVector](https://github.com/LostVector) **Created:** 10/29/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `upstream/serve-drain-stats` --- ### 📝 Commits (1) - [`d84955a`](https://github.com/mw00/project-maya/commit/d84955a22030666d48ab387d8fc2a389e15ab9a0) serve: retain final STAT snapshots when draining a stopped consumer ### 📊 Changes **2 files changed** (+41 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+3 -0) 📝 `serve/test_server.py` (+38 -0) </details> ### 📄 Description When a reply ends, the engine sends its final statistics just after the last token. The server was throwing that snapshot away while finishing an EOS, token-budget stop, or cancellation. This keeps it, so the dashboard and `/metrics` show the completed reply instead of stale or missing counters. We found this on a three-token reply whose metrics were still `None` after completion. The serial `StrataEngine.generate()` drain now parses `STAT` lines before continuing to `DONE`. This preserves the last timing, expert-cache/read counters, and any other native statistic through the same parser used during generation. It adds no model calls or device synchronization. The regression test uses a fake native process that sends an intermediate snapshot, a token, then a final snapshot and `DONE`. It fails on current main because closing the token consumer leaves the intermediate values, and passes with this fix. It also checks that the next request reads its own tokens rather than a stale completion. Validation on `f031a23`: 465 server tests pass (11 skipped), 585 tools tests pass (31 skipped), and HIP compatibility check passes. The same regression also passes against a backport onto our pinned private API source. No inference speedup is claimed; this fixes reporting needed for reliable measurements. --- <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#651
No description provided.