Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
norm
vllm
Commits
9289e577
Unverified
Commit
9289e577
authored
Feb 29, 2024
by
Allen.Dou
Committed by
GitHub
Feb 29, 2024
Browse files
add cache_config's info to prometheus metrics. (#3100)
parent
a6d471c7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
1 deletion
+14
-1
vllm/config.py
vllm/config.py
+4
-0
vllm/engine/llm_engine.py
vllm/engine/llm_engine.py
+1
-0
vllm/engine/metrics.py
vllm/engine/metrics.py
+9
-1
No files found.
vllm/config.py
View file @
9289e577
...
@@ -308,6 +308,10 @@ class CacheConfig:
...
@@ -308,6 +308,10 @@ class CacheConfig:
self
.
num_gpu_blocks
=
None
self
.
num_gpu_blocks
=
None
self
.
num_cpu_blocks
=
None
self
.
num_cpu_blocks
=
None
def
metrics_info
(
self
):
# convert cache_config to dict(key: str, value:str) for prometheus metrics info
return
{
key
:
str
(
value
)
for
key
,
value
in
self
.
__dict__
.
items
()}
def
_verify_args
(
self
)
->
None
:
def
_verify_args
(
self
)
->
None
:
if
self
.
gpu_memory_utilization
>
1.0
:
if
self
.
gpu_memory_utilization
>
1.0
:
raise
ValueError
(
raise
ValueError
(
...
...
vllm/engine/llm_engine.py
View file @
9289e577
...
@@ -138,6 +138,7 @@ class LLMEngine:
...
@@ -138,6 +138,7 @@ class LLMEngine:
self
.
stat_logger
=
StatLogger
(
self
.
stat_logger
=
StatLogger
(
local_interval
=
_LOCAL_LOGGING_INTERVAL_SEC
,
local_interval
=
_LOCAL_LOGGING_INTERVAL_SEC
,
labels
=
dict
(
model_name
=
model_config
.
model
))
labels
=
dict
(
model_name
=
model_config
.
model
))
self
.
stat_logger
.
info
(
"cache_config"
,
self
.
cache_config
)
self
.
forward_dag
=
None
self
.
forward_dag
=
None
if
USE_RAY_COMPILED_DAG
:
if
USE_RAY_COMPILED_DAG
:
...
...
vllm/engine/metrics.py
View file @
9289e577
from
vllm.logger
import
init_logger
from
vllm.logger
import
init_logger
from
prometheus_client
import
Counter
,
Gauge
,
Histogram
,
REGISTRY
,
disable_created_metrics
from
prometheus_client
import
Counter
,
Gauge
,
Histogram
,
Info
,
REGISTRY
,
disable_created_metrics
import
time
import
time
import
numpy
as
np
import
numpy
as
np
...
@@ -23,6 +23,10 @@ class Metrics:
...
@@ -23,6 +23,10 @@ class Metrics:
if
hasattr
(
collector
,
"_name"
)
and
"vllm"
in
collector
.
_name
:
if
hasattr
(
collector
,
"_name"
)
and
"vllm"
in
collector
.
_name
:
REGISTRY
.
unregister
(
collector
)
REGISTRY
.
unregister
(
collector
)
self
.
info_cache_config
=
Info
(
name
=
'vllm:cache_config'
,
documentation
=
'information of cache_config'
)
# System stats
# System stats
self
.
gauge_scheduler_running
=
Gauge
(
self
.
gauge_scheduler_running
=
Gauge
(
name
=
"vllm:num_requests_running"
,
name
=
"vllm:num_requests_running"
,
...
@@ -128,6 +132,10 @@ class StatLogger:
...
@@ -128,6 +132,10 @@ class StatLogger:
self
.
labels
=
labels
self
.
labels
=
labels
self
.
metrics
=
Metrics
(
labelnames
=
list
(
labels
.
keys
()))
self
.
metrics
=
Metrics
(
labelnames
=
list
(
labels
.
keys
()))
def
info
(
self
,
type
:
str
,
obj
:
object
)
->
None
:
if
type
==
"cache_config"
:
self
.
metrics
.
info_cache_config
.
info
(
obj
.
metrics_info
())
def
_get_throughput
(
self
,
tracked_stats
:
List
[
int
],
now
:
float
)
->
float
:
def
_get_throughput
(
self
,
tracked_stats
:
List
[
int
],
now
:
float
)
->
float
:
return
float
(
np
.
sum
(
tracked_stats
)
/
(
now
-
self
.
last_local_log
))
return
float
(
np
.
sum
(
tracked_stats
)
/
(
now
-
self
.
last_local_log
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment