Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run metrics async #6

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions vllm/engine/async_llm_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@ def has_new_requests(self):
class _AsyncLLMEngine(LLMEngine):
"""Extension of LLMEngine to add async methods."""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.logging_task = asyncio.create_task(self.run_logging_loop())
self.logging_queue = asyncio.Queue()

async def run_logging_loop(self):
while True:
data = await self.logging_queue.get()
self.do_log_stats(data[0], data[1])

async def step_async(
self, virtual_engine: int
) -> List[Union[RequestOutput, EmbeddingRequestOutput]]:
Expand Down Expand Up @@ -288,8 +298,9 @@ async def step_async(
output, scheduler_outputs.scheduled_seq_groups,
scheduler_outputs.ignored_seq_groups, seq_group_metadata_list)

# Log stats.
self.do_log_stats(scheduler_outputs, output)
self.logging_queue.put_nowait((
scheduler_outputs, output
))

# Tracing
self.do_tracing(scheduler_outputs)
Expand Down
Loading