Skip to content

Commit 4bff1eb

Browse files
committed
[MISC] rename interval to max_recent_queries
Signed-off-by: Andy Xie <[email protected]>
1 parent 7f0be2a commit 4bff1eb

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tests/v1/core/test_kv_cache_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def test_metrics():
288288
def stats(requests, queries, hits):
289289
return PrefixCacheStats(requests=requests, queries=queries, hits=hits)
290290

291-
metrics = PrefixCachingMetrics(interval=5)
291+
metrics = PrefixCachingMetrics(max_recent_requests=5)
292292
assert metrics.hit_rate == 0.0
293293

294294
metrics.observe(stats(1, 20, 9))

vllm/v1/core/kv_cache_utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ class BlockHashType(NamedTuple):
3131

3232

3333
class PrefixCachingMetrics:
34-
"""Metrics for prefix caching with a hit rate of the most recent N requests.
34+
"""Metrics for prefix caching with a hit rate of the max recent N requests.
3535
3636
Args:
37-
interval: The number of the most recent requests to aggregate.
37+
max_recent_requests: The number of the max recent requests to aggregate.
3838
Defaults to 1000.
3939
"""
4040

41-
def __init__(self, interval: int = 1000):
42-
self.interval = interval
41+
def __init__(self, max_recent_requests: int = 1000):
42+
self.max_recent_requests = max_recent_requests
4343
# The current aggregated values.
4444
self.aggregated_requests = 0
4545
self.aggregated_query_total = 0
@@ -54,7 +54,7 @@ def observe(self, stats: PrefixCacheStats):
5454
are being scheduled and are looking for computed blocks.
5555
5656
When there are more than `interval` requests, the oldest set of
57-
requestsare removed from the metrics.
57+
requests are removed from the metrics.
5858
5959
Args:
6060
stats: The prefix cache stats.
@@ -71,7 +71,7 @@ def observe(self, stats: PrefixCacheStats):
7171
self.aggregated_query_hit += stats.hits
7272

7373
# Remove the oldest stats if the number of requests exceeds.
74-
if self.aggregated_requests > self.interval:
74+
if self.aggregated_requests > self.max_recent_requests:
7575
old_requests, old_queries, old_hits = self.query_queue.popleft()
7676
self.aggregated_requests -= old_requests
7777
self.aggregated_query_total -= old_queries

0 commit comments

Comments
 (0)