test_profile_sla_aiconfigurator.py 5.71 KB
Newer Older
1
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# SPDX-License-Identifier: Apache-2.0

"""
Test suite for profile_sla aiconfigurator functionality.

profile_sla should be able to use aiconfigurator functionality
even without access to any GPU system.
"""

import sys
from pathlib import Path

import pytest

# Add the project root to sys.path to enable imports
project_root = Path(__file__).parent.parent.parent
sys.path.insert(0, str(project_root))

20
21
from dynamo.profiler.profile_sla import run_profile  # noqa: E402
from dynamo.profiler.utils.model_info import ModelInfo  # noqa: E402
22

23
24
25
26
pytestmark = [
    pytest.mark.aiconfigurator,
]

27
28
29
30
31
32
33
34
35
36
37

# Override the logger fixture from conftest.py to prevent directory creation
@pytest.fixture(autouse=True)
def logger(request):
    """Override the logger fixture to prevent test directory creation.

    This replaces the logger fixture from tests/conftest.py that creates
    directories named after each test.
    """
    # Simply do nothing - no directories created, no file handlers added
    yield
38
39
40
41
42
43


class TestProfileSlaAiconfigurator:
    """Test class for profile_sla aiconfigurator functionality."""

    @pytest.fixture
44
    def llm_args(self, request):
45
        class Args:
46
            def __init__(self):
47
48
                self.model = ""
                self.dgd_image = ""
49
                self.backend = "trtllm"
50
                self.config = "examples/backends/trtllm/deploy/disagg.yaml"
51
52
53
                # Use unique output directory per test for parallel execution
                self.output_dir = f"/tmp/test_profiling_results_{request.node.name}"
                self.namespace = f"test-namespace-{request.node.name}"
54
55
56
57
58
59
60
61
62
63
64
65
66
67
                self.min_num_gpus_per_engine = 1
                self.max_num_gpus_per_engine = 8
                self.skip_existing_results = False
                self.force_rerun = False
                self.isl = 3000
                self.osl = 500
                self.ttft = 50
                self.itl = 10
                self.prefill_interpolation_granularity = 16
                self.decode_interpolation_granularity = 6
                self.service_name = ""
                self.dry_run = False
                self.use_ai_configurator = True
                self.aic_system = "h200_sxm"
68
                self.aic_hf_id = "Qwen/Qwen3-32B"
69
                self.aic_backend = ""
70
                self.aic_backend_version = None
71
                self.num_gpus_per_node = 8
72
                self.deploy_after_profile = False
73
                self.pick_with_webui = False
74
75
76
77
78
79
80
                # Provide minimal model_info to avoid HF queries
                self.model_info = ModelInfo(
                    model_size=16384.0,
                    architecture="TestArchitecture",
                    is_moe=False,
                    max_context_length=16384,
                )
81
82
83
84

        return Args()

    @pytest.mark.pre_merge
85
86
    @pytest.mark.gpu_0
    @pytest.mark.performance
87
    @pytest.mark.parallel
88
    @pytest.mark.asyncio
89
    @pytest.mark.parametrize("missing_arg", ["aic_system", "aic_hf_id"])
90
    async def test_aiconfigurator_missing_args(self, llm_args, missing_arg):
91
        # Check that validation error happens when a required arg is missing.
92
        # Note: aic_backend_version is optional - when None, auto-detects latest version
93
        setattr(llm_args, missing_arg, None)
94
        with pytest.raises(ValueError):
95
            await run_profile(llm_args)
96
97

    @pytest.mark.pre_merge
98
99
    @pytest.mark.gpu_0
    @pytest.mark.performance
100
    @pytest.mark.parallel
101
102
103
104
105
106
    @pytest.mark.asyncio
    @pytest.mark.parametrize(
        "arg_name, bad_value",
        [
            # these values don't exist in the aiconfigurator database.
            ("aic_system", "fake_gpu_system"),
107
            ("aic_backend_version", "0.1.0"),
108
109
        ],
    )
110
    async def test_aiconfigurator_no_data(self, llm_args, arg_name, bad_value):
111
112
        # Check that an appropriate error is raised when the system/model/backend
        # is not found in the aiconfigurator database.
113
        setattr(llm_args, arg_name, bad_value)
114
        with pytest.raises(ValueError, match="Database not found"):
115
            await run_profile(llm_args)
116

117
    @pytest.mark.trtllm
118
    @pytest.mark.pre_merge
119
    @pytest.mark.parallel
120
    @pytest.mark.asyncio
121
    @pytest.mark.gpu_0
122
    @pytest.mark.integration
123
124
125
    async def test_trtllm_aiconfigurator_single_model(self, llm_args):
        # Test that profile_sla works with the model & backend in the llm_args fixture.
        await run_profile(llm_args)
126

127
    @pytest.mark.parallel
128
    @pytest.mark.asyncio
129
    @pytest.mark.gpu_1
130
    @pytest.mark.integration
131
    @pytest.mark.nightly
132
    # fmt: off
133
    @pytest.mark.parametrize(
134
        "backend, aic_backend_version",
135
        [
136
137
138
139
140
141
            pytest.param("trtllm", None,          marks=pytest.mark.trtllm),
            pytest.param("trtllm", "1.2.0rc5",    marks=pytest.mark.trtllm),
            pytest.param("vllm",   None,          marks=pytest.mark.vllm),
            pytest.param("vllm",   "0.12.0",      marks=pytest.mark.vllm),
            pytest.param("sglang", None,          marks=pytest.mark.sglang),
            pytest.param("sglang", "0.5.6.post2", marks=pytest.mark.sglang),
142
143
        ],
    )
144
    # fmt: on
145
146
147
148
149
150
151
    @pytest.mark.parametrize(
        "hf_model_id",
        [
            "Qwen/Qwen3-32B",
            "meta-llama/Llama-3.1-405B",
        ],
    )
152
153
    async def test_aiconfigurator_dense_models(
        self, llm_args, hf_model_id, backend, aic_backend_version
154
155
    ):
        # Test that profile_sla works with a variety of backend versions and model names.
156
157
158
159
        llm_args.aic_hf_id = hf_model_id
        llm_args.backend = backend
        llm_args.aic_backend_version = aic_backend_version
        await run_profile(llm_args)