Add cache_config_info metric. (#17273)
This commit is contained in:
@@ -607,6 +607,11 @@ class Scheduler(
|
||||
f"{'available_cpu_mem' if self.device == 'cpu' else 'available_gpu_mem'}={avail_mem:.2f} GB"
|
||||
)
|
||||
|
||||
if self.enable_metrics and hasattr(self, "metrics_collector"):
|
||||
self.metrics_collector.emit_cache_config_info(
|
||||
self.page_size, self.max_total_num_tokens // self.page_size
|
||||
)
|
||||
|
||||
def init_cache_with_memory_pool(self):
|
||||
server_args = self.server_args
|
||||
|
||||
|
||||
@@ -849,6 +849,16 @@ class SchedulerMetricsCollector:
|
||||
],
|
||||
)
|
||||
|
||||
# This is a work-around Info metric since Info metrics are not supported in Prometheus.
|
||||
# Similar to vLLM, https://github.com/vllm-project/vllm/blob/main/vllm/v1/metrics/loggers.py
|
||||
# If more Info metrics are needed, we can create a common _log_info function.
|
||||
self.cache_config_info = Gauge(
|
||||
name="sglang:cache_config_info",
|
||||
documentation="Cache configuration information.",
|
||||
labelnames=["page_size", "num_pages"],
|
||||
multiprocess_mode="mostrecent",
|
||||
)
|
||||
|
||||
def _log_gauge(self, gauge, data: Union[int, float]) -> None:
|
||||
# Convenience function for logging to gauge.
|
||||
gauge.labels(**self.labels).set(data)
|
||||
@@ -1066,6 +1076,9 @@ class SchedulerMetricsCollector:
|
||||
)
|
||||
self.num_grammar_total.labels(**self.labels).inc(1)
|
||||
|
||||
def emit_cache_config_info(self, page_size: int, num_pages: int) -> None:
|
||||
self.cache_config_info.labels(page_size=page_size, num_pages=num_pages).set(1)
|
||||
|
||||
|
||||
class TokenizerMetricsCollector:
|
||||
def __init__(
|
||||
|
||||
Reference in New Issue
Block a user