"lib/vscode:/vscode.git/clone" did not exist on "065f466e70060c3c5ef5f7a0d1acede1f3a810b8"
workflow.py 2.75 KB
Newer Older
1
2
3
4
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

from pathlib import Path
5
from typing import Dict, List
6
7
8
9
10
11

from benchmarks.utils.genai import run_concurrency_sweep
from benchmarks.utils.plot import generate_plots


def print_concurrency_start(
12
    label: str, model: str, isl: int, osl: int, std: int
13
14
) -> None:
    """Print concurrency sweep start messages"""
15
    print(f"⚙️  Starting {label} concurrency sweep!", flush=True)
16
17
18
19
20
21
22
    print(
        "⏱️  This may take several minutes - running through multiple concurrency levels...",
        flush=True,
    )
    print(f"🎯 Model: {model} | ISL: {isl} | OSL: {osl} | StdDev: {std}")


23
def run_endpoint_benchmark(
24
25
26
27
28
29
    label: str,
    endpoint: str,
    model: str,
    isl: int,
    osl: int,
    std: int,
30
    output_dir: Path,
31
32
33
) -> None:
    """Run benchmark for an existing endpoint with custom label"""
    print(f"🚀 Starting benchmark of endpoint '{label}': {endpoint}")
34
35
36
37
38
    print(f"📁 Results will be saved to: {output_dir / label}")
    print_concurrency_start(label, model, isl, osl, std)

    # Create output directory
    (output_dir / label).mkdir(parents=True, exist_ok=True)
39
40
41
42
43
44
45

    run_concurrency_sweep(
        service_url=endpoint,
        model_name=model,
        isl=isl,
        osl=osl,
        stddev=std,
46
        output_dir=output_dir / label,
47
48
49
50
    )
    print("✅ Endpoint benchmark completed successfully!")


51
def print_final_summary(output_dir: Path, labels: List[str]) -> None:
52
53
    """Print final benchmark summary"""
    print("📊 Generating performance plots...")
54
55
56
    generate_plots(base_output_dir=output_dir, output_dir=output_dir / "plots")
    print(f"📈 Plots saved to: {output_dir / 'plots'}")
    print(f"📋 Summary saved to: {output_dir / 'plots' / 'SUMMARY.txt'}")
57
58
59
60
61

    print()
    print("🎉 Benchmark workflow completed successfully!")
    print(f"📁 All results available at: {output_dir}")

62
63
    if labels:
        print(f"🚀 Benchmarked: {', '.join(labels)}")
64

65
    print(f"📊 View plots at: {output_dir / 'plots'}")
66
67


68
def run_benchmark_workflow(
69
    inputs: Dict[str, str],
70
    isl: int = 2000,
71
    std: int = 10,
72
73
    osl: int = 256,
    model: str = "Qwen/Qwen3-0.6B",
74
75
    output_dir: str = "benchmarks/results",
) -> None:
76
77
78
    """Main benchmark workflow orchestrator for HTTP endpoints only"""
    output_dir_path = Path(output_dir)
    output_dir_path.mkdir(parents=True, exist_ok=True)
79
80

    # Run endpoint benchmarks
81
82
83
84
    benchmarked_labels = []
    for label, endpoint in inputs.items():
        run_endpoint_benchmark(label, endpoint, model, isl, osl, std, output_dir_path)
        benchmarked_labels.append(label)
85
86

    # Generate final summary
87
    print_final_summary(output_dir_path, benchmarked_labels)