Repository navigation
Conversation
…model Add a "KV cache hit (request-observed)" section to the AIGateway dashboard. It reads the gateway's aigateway_prompt_tokens_observed_total and aigateway_cached_tokens_reports_total, which count the cached_tokens that each final engine response reported. The hit ratio uses the engine's own prompt token count as its denominator, and a coverage panel shows how much traffic reported at all. A model with no reports shows 0% coverage instead of disappearing. hack/dashboards/verify_aigateway_kv_cache_hit.py runs the panel queries against fake gateways and a local Prometheus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lykmj8mm4YfRenW75U6Jvu
…anels Describe the new dashboard section and separate the three signals that are all called a cache hit rate: the request-observed ratio, the engine's own aggregate gauge, and the scheduler's predicted rate at routing time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lykmj8mm4YfRenW75U6Jvu
The gateway never runs its post-stream bookkeeping for a request that the client cancels mid-stream, so neither aigateway_requests_total nor the two cache counters see it. The gateway test a_client_cancel_leaves_no_trace_in_either_cache_counter asserts this. The panel description and the docs said such a request counts as absent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lykmj8mm4YfRenW75U6Jvu
…tails flag MoAI Engine returns cached_tokens for every request and ignores --enable-prompt-tokens-details, like SGLang. Only a vLLM worker started without the flag leaves coverage below 100%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lykmj8mm4YfRenW75U6Jvu
… histograms The gateway now exports aigateway_engine_input_tokens, aigateway_engine_cached_tokens and aigateway_predicted_cached_tokens as per-request histograms. The four panels read them: - KV cache hit ratio by model: measured and predicted - Cached-token coverage by model: engine and prediction coverage - Engine input, cached and predicted tokens/sec by model - Cached tokens per request p50/p95 by model Measured series fall back per pod to the older counters, so gateways that still export them keep their values during a rolling update. The check script now models that mixed rollout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lykmj8mm4YfRenW75U6Jvu
…anels Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lykmj8mm4YfRenW75U6Jvu
Member
Author
|
The dashboard was removed in #191 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JIRA: MAF-21239
Artifact: MAF-21239 KV cache hit dashboard panels
Summary
This PR adds a "KV cache hit (request-observed)" row to the
mif-aigatewaydashboard. It shows, per model, how many input tokens the engines served from their KV cache, how much of the traffic that number covers, and how close the gateway's KV index prediction came. The panels read the per-request histograms that the Heimdall AI Gateway exports from its next release, and fall back to the older counters on gateways from v0.15.0 to v0.17.0.Metrics used
aigateway_engine_input_tokensaigateway_engine_cached_tokenscached_tokensaigateway_predicted_cached_tokensAll three are histograms with only the
modellabel, so the row has no per-endpoint breakdown.Panels
engine_cached_sum / engine_input_sum, predictedpredicted_sum / engine_input_sumengine_cached_count / engine_input_count, predictionpredicted_count / engine_cached_count_sumrateshistogram_quantileoverengine_cached_tokens_bucketThe measured hit ratio is a lower bound that is exact at 100% engine coverage, because a request without
cached_tokensstill adds its input tokens. The panel descriptions and the website docs say how to read the ratio with its coverage, and how it differs from the engine's own aggregate gauge.During a rolling update, each gateway pod exports either the histograms or the older counters. The measured series take whichever set a pod has with
orbefore summing by model. The predicted series and the per-request distribution need the histograms, and the predicted ratio divides only by newer pods' input tokens.The Tokenizer cache and Odin InferenceService rows move down by 17 grid units. #188 changes only panels 77 to 79, so the two PRs do not overlap.
Test plan (head
41081e9)hack/dashboards/verify_aigateway_kv_cache_hit.pyscrapes four fake gateways (two on the histograms, two on the older counters) with a local Prometheus 3.15 and runs all nine panel targets. Every target returns the expected value.or 0term from the engine coverage also fails it, because a model whose older gateway never sawcached_tokensdisappears instead of showing 0%.make helm-lintandhelm templatepass, and the rendered ConfigMap contains the new queries.npm run buildinwebsitepasses.cached_tokensin the final responses.🤖 Generated with Claude Code