Skip to content

5080deploy: merge upstream #504, per-request metrics under --enable-metrics - #62

Open
gdevenyi wants to merge 3 commits into
5080/23-retrieve-model-108from
5080/24-request-metrics-504
Open

gdevenyi wants to merge 3 commits into
5080/23-retrieve-model-108from
5080/24-request-metrics-504

Conversation

@gdevenyi

Copy link
Copy Markdown
Owner

Stacked on #61. Merges upstream FlashML-org#504 (head a76d9ec): opt-in per-request metrics (--enable-metrics): TTFT, prefill span, prefill/decode tok/s and the real prefix-cache hit, on chat, messages and responses. Off by default; the production launch script does not pass the flag.

Merge: conflicts with #47 (FlashML-org#393) and #57 in scheduler.py, generation.py, openai_api.py, all resolved as unions: the non-streaming chat response keeps #47's n > 1 choices, usage and reasoning-token count and gains the metrics block (taken from the first choice); the streaming usage chunk keeps #47's shape and gains metrics. Two follow-ups:

Testing (RTX 5080, production flags):

  • tests/server + tests/scheduler: 1004 passed after the follow-ups.
  • Live with the flag off (production): responses carry no metrics key and are otherwise unchanged.
  • pytest tests/ -m "not slow" at the top of this stack (77d8d5c): 2446 passed, 206 skipped; the 4 failures are the known environment-only ones (3x test_muse_glimmer_vision.py on transformers 5.15.1, test_async_pull_coalesced needing pytest-asyncio).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Bu6LgoxLR4wETqb7RPR2vt

FantasticCode2019 and others added 3 commits September 17, 2026 16:42
…ics-report

- the scheduler measures the prefill span itself (admission to the token sampled off the request's last prefill chunk) and ships it as a duration on that token's DetokenizeMsg: it is the one boundary a client timing SSE frames cannot see, and a duration keeps the wire free of any cross-process clock assumption
- the remaining timings come off the raw ack stream, not the emitted GenEvents: a reasoning or tool-call parser holds text back, sometimes to the end of the stream, so an event-timed TTFT runs long, and acks are the one path the streaming and buffered generators share
- cached_prompt_tokens reports the real prefix-cache hit whether or not --enable-cache-report is set; that flag governs the billing fields in usage, and gating the hit here would leave prefill_tokens_per_second computed over tokens that were never forwarded
- decode_tokens_per_second divides by decode_tokens - 1, as vLLM's and sglang's serving benchmarks do: the first token falls out of prefill and spans no decode interval
- served on /v1/chat/completions, /v1/messages and /v1/responses; /v1/completions does not go through the shared generation core and is left out

Closes FlashML-org#503
…ics under --enable-metrics

# Conflicts:
#	python/freetoken/scheduler/scheduler.py
#	python/freetoken/server/generation.py
#	python/freetoken/server/openai_api.py
…etrics timing reads

Upstream FlashML-org#504 times the prefill span in Scheduler._prefill_start; the stubs from FlashML-org#222 and
FlashML-org#505's tests build the scheduler without it.

Assisted-by: Claude Opus 5.5
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.

2 participants