[MISC] Add prefix cache hit rate to metrics (#7606)
This commit is contained in:
@@ -47,7 +47,7 @@ from vllm.transformers_utils.tokenizer_group import (
|
||||
AnyTokenizer, BaseTokenizerGroup, init_tokenizer_from_configs)
|
||||
from vllm.usage.usage_lib import (UsageContext, is_usage_stats_enabled,
|
||||
usage_message)
|
||||
from vllm.utils import Counter
|
||||
from vllm.utils import Counter, Device
|
||||
from vllm.version import __version__ as VLLM_VERSION
|
||||
|
||||
logger = init_logger(__name__)
|
||||
@@ -1390,6 +1390,13 @@ class LLMEngine:
|
||||
for scheduler in self.scheduler)
|
||||
cpu_cache_usage_sys = 1.0 - (num_free_cpu / num_total_cpu)
|
||||
|
||||
# Prefix Cache Hit Rate. Note that we always use
|
||||
# the cache hit rate of the first virtual engine.
|
||||
cpu_prefix_cache_hit_rate = self.scheduler[
|
||||
0].get_prefix_cache_hit_rate(Device.CPU)
|
||||
gpu_prefix_cache_hit_rate = self.scheduler[
|
||||
0].get_prefix_cache_hit_rate(Device.GPU)
|
||||
|
||||
# Iteration stats
|
||||
num_prompt_tokens_iter = 0
|
||||
num_generation_tokens_iter = 0
|
||||
@@ -1498,6 +1505,9 @@ class LLMEngine:
|
||||
# KV Cache Usage in %
|
||||
gpu_cache_usage_sys=gpu_cache_usage_sys,
|
||||
cpu_cache_usage_sys=cpu_cache_usage_sys,
|
||||
# Prefix Cache Hit Rate
|
||||
cpu_prefix_cache_hit_rate=cpu_prefix_cache_hit_rate,
|
||||
gpu_prefix_cache_hit_rate=gpu_prefix_cache_hit_rate,
|
||||
|
||||
# Iteration stats
|
||||
num_prompt_tokens_iter=num_prompt_tokens_iter,
|
||||
|
||||
Reference in New Issue
Block a user