[Profiler] Add per-session profiling controls to Python and Rust frontends (#57875)

Signed-off-by: czhu <conway.zhu@cohere.com>
Signed-off-by: Conway Zhu <conway.zhu@cohere.com>
Co-authored-by: aoshen02 <aoshen@inferact.ai>
This commit is contained in:
czhu-cohere
2026-10-06 05:21:19 +00:00
committed by GitHub
co-authored by aoshen02
parent 9a1f6fd4cb
commit 6fddc9b21e
25 changed files with 1497 additions and 164 deletions
+33
View File
@@ -7,6 +7,7 @@ from unittest.mock import MagicMock, call
import pytest
from vllm import LLM
from vllm.exceptions import ProfilerAlreadyActiveError
from vllm.sampling_params import SamplingParams, StructuredOutputsParams
from vllm.v1.engine.llm_engine import LLMEngine
from vllm.v1.metrics.reader import Counter, Gauge, Histogram, Metric, Vector
@@ -52,6 +53,38 @@ def test_step_invalidates_mm_processor_cache_misses():
]
def test_duplicate_profile_start_rejected_before_engine_core_dispatch():
engine = object.__new__(LLMEngine)
engine.engine_core = MagicMock()
engine._profile_session_active = False
engine.start_profile("first")
with pytest.raises(ProfilerAlreadyActiveError):
engine.start_profile("duplicate")
engine.engine_core.profile.assert_called_once_with(True, "first", None, None)
@pytest.mark.parametrize(
"kwargs",
[
{"profile_prefix": "../trace"},
{"delay_iterations": -1},
{"max_iterations": -1},
],
)
def test_invalid_profile_controls_rejected_before_engine_core_dispatch(kwargs):
engine = object.__new__(LLMEngine)
engine.engine_core = MagicMock()
engine._profile_session_active = False
with pytest.raises(ValueError):
engine.start_profile(**kwargs)
engine.engine_core.profile.assert_not_called()
def _vllm_model(
apc: bool,
vllm_runner: type[VllmRunner],