Repository navigation
Fix prefill_throughput for prefix-cache hits - #203
Merged
Merged
Conversation
…erator N/ttft mismatched numerator and denominator whenever KV was reused. Shared prefill_metrics() helper in utils.py now divides new_input_tokens = N - K, and both LLM and VLM metric dicts report new_input_tokens, prefix_cache_hit_tokens and ovgenai_version so warm rows are attributable across nightly bumps. bench.py shows a cache_hit column; benchmark.py tracks prefix_cache_hit_tokens. SearchSavior#202
…s dicts The version stamp was only useful for us, not for the server response, so it stays out of the LLM and VLM metrics dicts.
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.
Closes issue #202.
prefill_throughput (tokens/s)was computed asinput_tokens / ttft. TTFT only covers the tokens the pipeline actually recomputed, so whenever KV is reused from an earlier request the numerator and the denominator describe different amounts of work, and warm runs are inflated by up to the full prompt length.What's new
src/engine/ov_genai/utils.py— newprefill_metrics(perf_metrics) -> tuple[float, int, int]returning(rate, new_tokens, hit), whererate = (N - K) / ttft. The accessor is feature-detected withgetattr, so a build without it leavesK = 0instead of raising.src/engine/ov_genai/llm.py,src/engine/ov_genai/vlm.py— the formula copy-pasted in bothcollect_metrics()bodies is replaced by one helper call; both metric dicts now emitnew_input_tokensandprefix_cache_hit_tokens.total_tokenreadsget_num_input_tokens()directly instead of a local that no longer exists.tests/unit/test_ov_genai_llm_unit.py,tests/unit/test_ov_genai_vlm_unit.py— addedDummyPerfMetricsCacheHit(accessor returns 20 / 8) andtest_collect_metrics_prefill_throughput_cache_hit, asserting20.0/5/20and10.0/4/8. The existingDummyPerfMetricsdeliberately keeps no accessor, so it still covers the fallback path and the old== 100.0/== 30.0assertions are unchanged.src/cli/groups/bench.py— newcache_hitcolumn afterprefill(t/s), so a warm row is visible rather than silently averaged with cold ones.src/cli/modules/benchmark.py—prefix_cache_hit_tokens INTEGER NOT NULL DEFAULT 0in the results table,_ensure_prefix_cache_column()following the existing_ensure_*ALTER pattern, and the INSERT extended.Behavior / caveats
hit=0, new=1639, ttft=1.15s; warmhit=1616, new=27, ttft=0.12s; exact repeathit=1632, new=11. Reproduced with a bareLLMPipeline+SchedulerConfig(cache_size=1, enable_prefix_caching=True), so the finding is independent of OpenArc.VLMPipelinereportshit = 0even when reuse should occur — Qwen3.5-9B, Ornith-1.0-9B, text-only and with a 256x256 image. This is an upstream gap, not an OpenArc one:vlm.py:413passes**scheduler_configtoVLMPipelineexactly asllm.py:289does toLLMPipeline, and the continuous-batching backend is demonstrably selected (m_batch_sizespopulated,VLMContinuousBatchingAdapterpresent in the wheel). VLMprefill_throughputis therefore still inflated today.hit == 0is not proof of a cold run. The SDPA backend rejectsscheduler_config(utils.py:77-79), so it never has a prefix cache, and older builds lack the accessor. That is why the count is surfaced in the metrics rather than used to suppress warm rows.setup.sh:16,setup.bat:16,.devops/openvino.Dockerfile:95all runuv pip install --pre -U openvino-genai), which is why the accessor is feature-detected instead of guaranteed by raising thepyproject.tomlfloor.Development environment