(Drafted with AI assistance.)
When consuming tabbyAPI behind a metrics-aware proxy (e.g. llama-swap), per-request speed and cache stats don't surface, because the stats live only in the non-standard usage object while the standard places consumers look are empty.
Problem
- Speeds are only in
usage. UsageStats carries prompt_tokens_per_sec / completion_tokens_per_sec, but there is no top-level timings (llama.cpp-style) or metrics (vLLM-style) object. Consumers that read top-level timings/metrics for prompt/prediction speed show "unknown" even though token counts populate.
- Cached prompt tokens are dropped. The backend (exllamav3) finish chunk already reports
cached_tokens, but get_usage_stats discards it when building UsageStats, so the OpenAI-standard usage.prompt_tokens_details.cached_tokens is never emitted.
- Spec-decoding draft stats are dropped. The finish chunk carries
draft_accept / draft_reject, but they are not surfaced anywhere in the response.
- Prompt count/speed mismatch.
usage.prompt_tokens reports the total (including cached), while prompt_tokens_per_sec is computed over new tokens only — so the count and the speed disagree.
This is solvable and is working for us. We run a patched tabbyAPI image that exposes these fields, and the metrics populate correctly in our setup. We have a working patch set against v1.4.2 that we're happy to share for reference; we're not asking to own the implementation.
General direction for a fix
- Emit a top-level
timings object on /chat/completions and /completions (streaming + non-streaming) with llama.cpp-compatible keys: prompt_n, prompt_per_second, predicted_n, predicted_per_second, and draft_n / draft_n_accepted when spec-decoding is active.
- Add
prompt_tokens_details: {cached_tokens} to UsageStats, populated from the backend finish chunk's cached_tokens.
- Add
draft_tokens / draft_tokens_accepted to UsageStats from draft_accept / draft_reject.
- Decide on
prompt_tokens semantics: report new-only (total − cached) to match llama.cpp, or keep total and document it.
(Drafted with AI assistance.)
When consuming tabbyAPI behind a metrics-aware proxy (e.g. llama-swap), per-request speed and cache stats don't surface, because the stats live only in the non-standard
usageobject while the standard places consumers look are empty.Problem
usage.UsageStatscarriesprompt_tokens_per_sec/completion_tokens_per_sec, but there is no top-leveltimings(llama.cpp-style) ormetrics(vLLM-style) object. Consumers that read top-leveltimings/metricsfor prompt/prediction speed show "unknown" even though token counts populate.cached_tokens, butget_usage_statsdiscards it when buildingUsageStats, so the OpenAI-standardusage.prompt_tokens_details.cached_tokensis never emitted.draft_accept/draft_reject, but they are not surfaced anywhere in the response.usage.prompt_tokensreports the total (including cached), whileprompt_tokens_per_secis computed over new tokens only — so the count and the speed disagree.This is solvable and is working for us. We run a patched tabbyAPI image that exposes these fields, and the metrics populate correctly in our setup. We have a working patch set against v1.4.2 that we're happy to share for reference; we're not asking to own the implementation.
General direction for a fix
timingsobject on/chat/completionsand/completions(streaming + non-streaming) with llama.cpp-compatible keys:prompt_n,prompt_per_second,predicted_n,predicted_per_second, anddraft_n/draft_n_acceptedwhen spec-decoding is active.prompt_tokens_details: {cached_tokens}toUsageStats, populated from the backend finish chunk'scached_tokens.draft_tokens/draft_tokens_acceptedtoUsageStatsfromdraft_accept/draft_reject.prompt_tokenssemantics: report new-only (total − cached) to match llama.cpp, or keep total and document it.