[Bugfix][Profiler] Fix API server crash on double /stop_profile (#51678)
Signed-off-by: Alberto Massidda <amassidda@nvidia.com> Co-authored-by: Alberto Massidda <amassidda@nvidia.com>
This commit is contained in:
co-authored by
Alberto Massidda
parent
73723b707f
commit
55178f2d09
@@ -7,9 +7,7 @@ import time
|
||||
import warnings
|
||||
from collections.abc import AsyncGenerator, Iterable, Mapping
|
||||
from copy import copy
|
||||
from typing import Any
|
||||
|
||||
import torch
|
||||
from typing import Any, Optional
|
||||
|
||||
import vllm.envs as envs
|
||||
from vllm import TokensPrompt
|
||||
@@ -34,6 +32,7 @@ from vllm.lora.request import LoRARequest
|
||||
from vllm.multimodal import MULTIMODAL_REGISTRY, MultiModalRegistry
|
||||
from vllm.outputs import STREAM_FINISHED, PoolingRequestOutput, RequestOutput
|
||||
from vllm.pooling_params import PoolingParams
|
||||
from vllm.profiler.wrapper import TorchProfilerWrapper
|
||||
from vllm.renderers import renderer_from_config
|
||||
from vllm.renderers.inputs.preprocess import extract_prompt_components
|
||||
from vllm.sampling_params import RequestOutputKind, SamplingParams
|
||||
@@ -92,6 +91,7 @@ class AsyncLLM(EngineClient):
|
||||
client_addresses: dict[str, Any] | None = None,
|
||||
client_count: int = 1,
|
||||
client_index: int = 0,
|
||||
profiler: Optional[TorchProfilerWrapper] = None, # type: ignore # noqa
|
||||
) -> None:
|
||||
"""
|
||||
Create an AsyncLLM.
|
||||
@@ -195,19 +195,12 @@ class AsyncLLM(EngineClient):
|
||||
profiler_dir,
|
||||
)
|
||||
worker_name = f"{socket.gethostname()}_{os.getpid()}.async_llm"
|
||||
self.profiler = torch.profiler.profile(
|
||||
activities=[
|
||||
torch.profiler.ProfilerActivity.CPU,
|
||||
],
|
||||
with_stack=vllm_config.profiler_config.torch_profiler_with_stack,
|
||||
on_trace_ready=torch.profiler.tensorboard_trace_handler(
|
||||
profiler_dir,
|
||||
worker_name=worker_name,
|
||||
use_gzip=vllm_config.profiler_config.torch_profiler_use_gzip,
|
||||
),
|
||||
self.profiler = TorchProfilerWrapper(
|
||||
vllm_config.profiler_config,
|
||||
worker_name=worker_name,
|
||||
local_rank=0,
|
||||
activities=["CPU"],
|
||||
)
|
||||
else:
|
||||
self.profiler = None
|
||||
|
||||
@classmethod
|
||||
def from_vllm_config(
|
||||
|
||||
Reference in New Issue
Block a user