Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d97bc28c68 | ||
|
|
ff806fd4b3 |
No files matched your search
@@ -21,6 +21,7 @@ from vllm.multimodal.media.audio import load_audio
|
|||||||
from vllm.sampling_params import SamplingParams
|
from vllm.sampling_params import SamplingParams
|
||||||
|
|
||||||
from vllm_omni.entrypoints.omni import Omni
|
from vllm_omni.entrypoints.omni import Omni
|
||||||
|
from vllm_omni.utils.profiler import add_profiler_config_arg
|
||||||
from vllm_omni.utils.tracking_parser import TrackingArgumentParser
|
from vllm_omni.utils.tracking_parser import TrackingArgumentParser
|
||||||
|
|
||||||
SEED = 42
|
SEED = 42
|
||||||
@@ -325,6 +326,7 @@ def main(args):
|
|||||||
else:
|
else:
|
||||||
query_result = query_func()
|
query_result = query_func()
|
||||||
args.quantization_config = quantization_config
|
args.quantization_config = quantization_config
|
||||||
|
# ``vars(args)`` below forwards profiler_config to Omni.
|
||||||
omni_kwargs = vars(args).copy()
|
omni_kwargs = vars(args).copy()
|
||||||
# Override CLI --model with the derived model_name.
|
# Override CLI --model with the derived model_name.
|
||||||
omni_kwargs["model"] = model_name
|
omni_kwargs["model"] = model_name
|
||||||
@@ -378,11 +380,11 @@ def main(args):
|
|||||||
for i, prompt in enumerate(prompts):
|
for i, prompt in enumerate(prompts):
|
||||||
prompt["modalities"] = output_modalities
|
prompt["modalities"] = output_modalities
|
||||||
|
|
||||||
profiler_enabled = bool(os.getenv("VLLM_TORCH_PROFILER_DIR"))
|
profiler_enabled = args.profiler_config is not None
|
||||||
if profiler_enabled and hasattr(omni, "start_profile"):
|
if profiler_enabled and hasattr(omni, "start_profile"):
|
||||||
omni.start_profile(stages=[0])
|
omni.start_profile(stages=[0])
|
||||||
elif profiler_enabled:
|
elif profiler_enabled:
|
||||||
print("[Warn] VLLM_TORCH_PROFILER_DIR is set, but current engine does not support profiler controls.")
|
print("[Warn] --profiler-config was provided, but current engine does not support profiler controls.")
|
||||||
omni_generator = omni.generate(prompts, sampling_params_list, py_generator=args.py_generator)
|
omni_generator = omni.generate(prompts, sampling_params_list, py_generator=args.py_generator)
|
||||||
|
|
||||||
# Determine output directory: prefer --output-dir; fallback to --output-wav
|
# Determine output directory: prefer --output-dir; fallback to --output-wav
|
||||||
@@ -458,6 +460,7 @@ def parse_args():
|
|||||||
default=False,
|
default=False,
|
||||||
help="Enable writing detailed statistics (default: disabled)",
|
help="Enable writing detailed statistics (default: disabled)",
|
||||||
)
|
)
|
||||||
|
add_profiler_config_arg(parser)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--stage-init-timeout",
|
"--stage-init-timeout",
|
||||||
type=int,
|
type=int,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ from vllm_omni.entrypoints.omni import Omni
|
|||||||
from vllm_omni.model_executor.models.cosyvoice3.tokenizer import get_qwen_tokenizer
|
from vllm_omni.model_executor.models.cosyvoice3.tokenizer import get_qwen_tokenizer
|
||||||
from vllm_omni.model_executor.models.cosyvoice3.utils import extract_text_token
|
from vllm_omni.model_executor.models.cosyvoice3.utils import extract_text_token
|
||||||
from vllm_omni.transformers_utils.configs.cosyvoice3 import CosyVoice3Config
|
from vllm_omni.transformers_utils.configs.cosyvoice3 import CosyVoice3Config
|
||||||
|
from vllm_omni.utils.profiler import add_profiler_config_arg
|
||||||
|
|
||||||
# Upstream zero-shot reference clip
|
# Upstream zero-shot reference clip
|
||||||
ZERO_SHOT_PROMPT_URL = "https://raw.githubusercontent.com/FunAudioLLM/CosyVoice/main/asset/zero_shot_prompt.wav"
|
ZERO_SHOT_PROMPT_URL = "https://raw.githubusercontent.com/FunAudioLLM/CosyVoice/main/asset/zero_shot_prompt.wav"
|
||||||
@@ -45,6 +46,7 @@ def run_e2e():
|
|||||||
help="Override the deploy config path. If unset, auto-loads "
|
help="Override the deploy config path. If unset, auto-loads "
|
||||||
"vllm_omni/deploy/cosyvoice3.yaml based on the HF model_type.",
|
"vllm_omni/deploy/cosyvoice3.yaml based on the HF model_type.",
|
||||||
)
|
)
|
||||||
|
add_profiler_config_arg(parser)
|
||||||
parser.add_argument("--text", type=str, default="Hello, this is a test of the CosyVoice system capability.")
|
parser.add_argument("--text", type=str, default="Hello, this is a test of the CosyVoice system capability.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--prompt-text",
|
"--prompt-text",
|
||||||
@@ -79,6 +81,7 @@ def run_e2e():
|
|||||||
deploy_config=args.deploy_config,
|
deploy_config=args.deploy_config,
|
||||||
tokenizer=args.tokenizer,
|
tokenizer=args.tokenizer,
|
||||||
log_stats=True,
|
log_stats=True,
|
||||||
|
profiler_config=args.profiler_config,
|
||||||
)
|
)
|
||||||
|
|
||||||
sampling_cfg = {"top_p": 0.8, "top_k": 25, "eos_token_id": 6561 + 1}
|
sampling_cfg = {"top_p": 0.8, "top_k": 25, "eos_token_id": 6561 + 1}
|
||||||
@@ -149,8 +152,8 @@ def run_e2e():
|
|||||||
|
|
||||||
sampling_params_list = [gpt_sampling, s2mel_sampling]
|
sampling_params_list = [gpt_sampling, s2mel_sampling]
|
||||||
|
|
||||||
# Start profiling (requires VLLM_TORCH_PROFILER_DIR env var)
|
profiler_enabled = args.profiler_config is not None
|
||||||
if os.environ.get("VLLM_TORCH_PROFILER_DIR"):
|
if profiler_enabled:
|
||||||
print("Starting profiler...")
|
print("Starting profiler...")
|
||||||
omni.start_profile()
|
omni.start_profile()
|
||||||
|
|
||||||
@@ -158,7 +161,7 @@ def run_e2e():
|
|||||||
outputs = list(omni.generate(prompts, sampling_params_list=sampling_params_list[:2]))
|
outputs = list(omni.generate(prompts, sampling_params_list=sampling_params_list[:2]))
|
||||||
|
|
||||||
# Stop profiling and get results
|
# Stop profiling and get results
|
||||||
if os.environ.get("VLLM_TORCH_PROFILER_DIR"):
|
if profiler_enabled:
|
||||||
print("Stopping profiler...")
|
print("Stopping profiler...")
|
||||||
profile_results = omni.stop_profile()
|
profile_results = omni.stop_profile()
|
||||||
print(f"Profile traces saved to: {profile_results}")
|
print(f"Profile traces saved to: {profile_results}")
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||||
|
|
||||||
|
_REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||||
|
_EXAMPLES = (
|
||||||
|
"examples/offline_inference/text_to_speech/cosyvoice3/end2end.py",
|
||||||
|
"examples/offline_inference/qwen2_5_omni/end2end.py",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("relative_path", _EXAMPLES)
|
||||||
|
def test_offline_examples_use_typed_profiler_config(relative_path: str):
|
||||||
|
source = (_REPO_ROOT / relative_path).read_text(encoding="utf-8")
|
||||||
|
|
||||||
|
assert "add_profiler_config_arg(parser)" in source
|
||||||
|
assert "profiler_enabled = args.profiler_config is not None" in source
|
||||||
|
assert "VLLM_TORCH_PROFILER_DIR" not in source
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
|
def parse_json_object(value: str, flag_name: str = "argument") -> dict[str, Any]:
|
||||||
|
"""Parse a CLI value as a JSON object, attributing errors to ``flag_name``."""
|
||||||
|
try:
|
||||||
|
config = json.loads(value)
|
||||||
|
except json.JSONDecodeError as e:
|
||||||
|
raise argparse.ArgumentTypeError(f"{flag_name} must be valid JSON: {e}") from e
|
||||||
|
if not isinstance(config, dict):
|
||||||
|
raise argparse.ArgumentTypeError(f"{flag_name} must be a JSON object")
|
||||||
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
def parse_profiler_config(value: str) -> dict[str, Any]:
|
||||||
|
"""Parse the JSON object passed to ``--profiler-config``."""
|
||||||
|
return parse_json_object(value, flag_name="--profiler-config")
|
||||||
|
|
||||||
|
|
||||||
|
def add_profiler_config_arg(parser: argparse.ArgumentParser) -> None:
|
||||||
|
"""Add the shared JSON profiler configuration option to ``parser``."""
|
||||||
|
parser.add_argument(
|
||||||
|
"--profiler-config",
|
||||||
|
type=parse_profiler_config,
|
||||||
|
default=None,
|
||||||
|
help=(
|
||||||
|
"JSON profiler config for torch/cuda profiling, e.g. "
|
||||||
|
'\'{"profiler":"torch","torch_profiler_dir":"./perf"}\'.'
|
||||||
|
),
|
||||||
|
)
|
||||||
Reference in new issue
Block a user