[KV Offloading] Add basic offloading metrics (#45958)
Signed-off-by: srinivas_oo7 <sklinkedin0120@gmail.com> Signed-off-by: Srinivas Krovvidi <194645829+Srinivasoo7@users.noreply.github.com> Co-authored-by: srinivas_oo7 <sklinkedin0120@gmail.com> Co-authored-by: Or Ozeri <or@ozery.com> Co-authored-by: Or Ozeri <oro@il.ibm.com>
This commit is contained in:
co-authored by
srinivas_oo7
Or Ozeri
Or Ozeri
parent
dd5c299fbe
commit
e040899a00
@@ -8,6 +8,7 @@ from vllm.v1.kv_offload.base import BlockIDsLoadStoreSpec
|
||||
class CPUOffloadingMetrics:
|
||||
STORES_SKIPPED = "vllm:kv_offload_stores_skipped"
|
||||
CPU_CACHE_USAGE_PERC = "vllm:kv_offload_cpu_cache_usage_perc"
|
||||
CPU_ALLOCATION_SIZE = "vllm:kv_offload_cpu_allocation_size"
|
||||
|
||||
|
||||
class CPULoadStoreSpec(BlockIDsLoadStoreSpec):
|
||||
|
||||
@@ -69,6 +69,7 @@ class CPUOffloadingManager(OffloadingManager):
|
||||
self.store_threshold: int = store_threshold
|
||||
self.max_tracker_size: int = max_tracker_size
|
||||
self.stores_skipped_in_current_batch: int = 0
|
||||
self.allocation_sizes_in_current_batch: list[int] = []
|
||||
|
||||
# Number of block references. It is ordered so can evict the LRU entry in O(1).
|
||||
self.counts: OrderedDict[OffloadKey, int] | None = (
|
||||
@@ -185,6 +186,7 @@ class CPUOffloadingManager(OffloadingManager):
|
||||
evicted_keys=[],
|
||||
)
|
||||
|
||||
self.allocation_sizes_in_current_batch.append(len(keys_to_store))
|
||||
num_blocks_to_evict = len(keys_to_store) - self._get_num_free_blocks()
|
||||
|
||||
to_evict: list[OffloadKey] = []
|
||||
@@ -300,10 +302,17 @@ class CPUOffloadingManager(OffloadingManager):
|
||||
usage = num_used / self._num_blocks if self._num_blocks > 0 else 0.0
|
||||
stats.set_gauge(CPUOffloadingMetrics.CPU_CACHE_USAGE_PERC, usage)
|
||||
|
||||
for allocation_size in self.allocation_sizes_in_current_batch:
|
||||
stats.observe_histogram(
|
||||
CPUOffloadingMetrics.CPU_ALLOCATION_SIZE, allocation_size
|
||||
)
|
||||
self.allocation_sizes_in_current_batch.clear()
|
||||
|
||||
if self.store_threshold >= 2:
|
||||
stats.increase_counter(
|
||||
CPUOffloadingMetrics.STORES_SKIPPED,
|
||||
self.stores_skipped_in_current_batch,
|
||||
)
|
||||
self.stores_skipped_in_current_batch = 0
|
||||
|
||||
return stats
|
||||
|
||||
@@ -12,6 +12,7 @@ from vllm.v1.kv_offload.base import (
|
||||
CanonicalKVCaches,
|
||||
OffloadingCounterMetadata,
|
||||
OffloadingGaugeMetadata,
|
||||
OffloadingHistogramMetadata,
|
||||
OffloadingManager,
|
||||
OffloadingMetricMetadata,
|
||||
OffloadingSpec,
|
||||
@@ -37,7 +38,14 @@ class CPUOffloadingSpec(OffloadingSpec):
|
||||
"values indicate transfers (stores or promotions) may be "
|
||||
"dropped due to insufficient capacity."
|
||||
),
|
||||
)
|
||||
),
|
||||
CPUOffloadingMetrics.CPU_ALLOCATION_SIZE: OffloadingHistogramMetadata(
|
||||
documentation=(
|
||||
"Histogram of the number of CPU blocks requested by each "
|
||||
"KV offload prepare_store call."
|
||||
),
|
||||
buckets=(1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144),
|
||||
),
|
||||
}
|
||||
store_threshold = int(extra_config.get("store_threshold", 0))
|
||||
if store_threshold >= 2:
|
||||
|
||||
Reference in New Issue
Block a user