2026-09-10 15:03:21 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
|
|
|
|
"""Utilities for Omni profile control routes."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _should_enable_profiler_endpoints(stage_configs: list | None) -> bool:
|
2026-09-17 12:47:38 +09:00
|
|
|
"""Check whether any typed or legacy stage enables a profiler."""
|
2026-09-10 15:03:21 +08:00
|
|
|
if not stage_configs:
|
|
|
|
|
return False
|
|
|
|
|
for stage in stage_configs:
|
|
|
|
|
profiler_config = (
|
2026-09-17 12:47:38 +09:00
|
|
|
stage.get("profiler_config") if isinstance(stage, dict) else getattr(stage, "profiler_config", None)
|
2026-09-10 15:03:21 +08:00
|
|
|
)
|
2026-09-17 12:47:38 +09:00
|
|
|
if profiler_config is None:
|
|
|
|
|
engine_args = stage.get("engine_args") if isinstance(stage, dict) else getattr(stage, "engine_args", None)
|
|
|
|
|
profiler_config = (
|
|
|
|
|
engine_args.get("profiler_config")
|
|
|
|
|
if isinstance(engine_args, dict)
|
|
|
|
|
else getattr(engine_args, "profiler_config", None)
|
|
|
|
|
)
|
2026-09-10 15:03:21 +08:00
|
|
|
if profiler_config is not None:
|
|
|
|
|
profiler = (
|
|
|
|
|
profiler_config.get("profiler")
|
|
|
|
|
if isinstance(profiler_config, dict)
|
|
|
|
|
else getattr(profiler_config, "profiler", None)
|
|
|
|
|
)
|
|
|
|
|
if profiler is not None:
|
|
|
|
|
return True
|
|
|
|
|
return False
|