-
Notifications
You must be signed in to change notification settings - Fork 103
feat(observability): report real prefix-cache query/hit counters in /metrics #953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,12 +27,16 @@ pub(crate) fn resolve_step( | |
| prompt_echoes: Vec::new(), | ||
| pending: Vec::new(), | ||
| decode: resolve_decode_outputs(executor, active, &result.requests), | ||
| prefix_queries: 0, | ||
| prefix_hits: 0, | ||
| }, | ||
| ExecutionArtifacts::SpeculativeDecode { verify } => StepEffects { | ||
| cached: Vec::new(), | ||
| prompt_echoes: Vec::new(), | ||
| pending: Vec::new(), | ||
| decode: resolve_speculative_outputs(executor, active, &verify.requests), | ||
| prefix_queries: 0, | ||
| prefix_hits: 0, | ||
| }, | ||
| ExecutionArtifacts::Unified { pending, result } => { | ||
| let mut effects = resolve_prefill_outputs(executor, pending, result.prefill_requests); | ||
|
|
@@ -107,6 +111,10 @@ fn resolve_prefill_outputs( | |
| request_id: req.request_id, | ||
| cached_tokens: result.cached_tokens, | ||
| }); | ||
| // One cache query per request (the cache is consulted once, on the | ||
| // first chunk); the cached prefix length is the hit count, in tokens. | ||
| effects.prefix_queries += 1; | ||
| effects.prefix_hits += result.cached_tokens as u64; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For any prompt longer than one token, this makes the query denominator request-granularity ( Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| if !result.completed { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Qwen3's stepped bridge,
SchedulerMetricscarries monotonic totals anddispatch_stepsendsscheduler_stats_from(&self.scheduler.metrics())on every output batch; vLLM's Prometheus logger incrementsprefix_cache_queries/hitsby the values in eachSchedulerStats. Once any cached request has run, every subsequent token batch re-adds the same cumulative totals, so/metricsovercounts prefix-cache traffic until the process restarts. Please compute per-send deltas here, like the existing spec-decode path does.Useful? React with 👍 / 👎.