Skip to content

feat(server): export tracker metrics and scheduler queue telemetry - #513

Closed
Yumeio wants to merge 1 commit into
FlashML-org:mainfrom
Yumeio:codex/server-metrics
Closed

Yumeio wants to merge 1 commit into
FlashML-org:mainfrom
Yumeio:codex/server-metrics

Conversation

@Yumeio

@Yumeio Yumeio commented Sep 18, 2026 •

Copy link
Copy Markdown

Expose /metrics as a projection of the same StatsTracker used by /v1/stats. Token counters are read directly from existing admitted/sampled totals; timing histograms observe each shared-generation RequestRecord once. A new scheduler -> tokenizer -> frontend queue snapshot supplies real running/waiting counts, including zero after abort/idle transitions. Unknown queue/pool values are omitted rather than fabricated, and registries are per tracker.

Timing preserves existing desktop behavior: streaming records have TTFT, buffered records do not. E2E covers shared chat/Messages/Responses generation; TPOT is the per-completed-stream mean after the first output. Raw /generate and legacy text completions contribute engine counters but are excluded from timing histograms because their middleware records before a stream finishes. See docs/server-hardening/03-metrics.md for semantics and vLLM/SGLang/TensorRT-LLM comparisons.

Validation on Windows x86-64 / Python 3.13.5: 568 passed for tests/server plus scheduler queue metrics, scheduler status and cost-accounting tests. All 5 tests/scheduler/test_abort_inflight_prefill.py tests also passed. New metrics/queue tests cover real Prometheus parsing, counter equality, late aborted tokens, ring eviction, repeated scrapes, IPC codecs and frontend telemetry. Targeted Ruff E4/E7/E9/F and git diff --check passed.

Reproduce: PYTHONPATH=python pytest -q tests/server tests/scheduler/test_queue_metrics.py tests/scheduler/test_scheduler_status.py tests/scheduler/test_cost_accounting_core.py tests/scheduler/test_abort_inflight_prefill.py. The Windows native CPU radix build required ninja on PATH and CL=/std:c++20; initial missing-dependency/compiler failures were resolved without changing kernel code. CPU/fake-backend tests only: no live GPU, checkpoint, multi-rank IPC or performance validation is claimed.

Adds prometheus-client>=0.20,<1 and additive IPC message types; run workers/frontend from the same checkout. No linked issue was supplied. AI-assisted draft at the user's request; human review and real-server validation remain required before merge.

Combined review evidence

All seven independent changes were also merged on the integration branch. The combined server and targeted scheduler run passed 779 tests; the branch records the configuration/error-handler conflict resolutions and detailed validation scope.

Validation host: Windows/Python 3.13.5 with existing PyTorch 2.13.0+cu126, outside the project's pinned 2.11 range. Results are scoped CPU server/state-machine evidence; they do not establish compatibility with the pinned production environment or real GPU/model execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant