Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BLS support to Optuna #902

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions model_analyzer/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from model_analyzer.config.generate.base_model_config_generator import (
BaseModelConfigGenerator,
)
from model_analyzer.config.generate.model_profile_spec import ModelProfileSpec
from model_analyzer.config.generate.search_parameters import SearchParameters
from model_analyzer.constants import LOGGER_NAME, PA_ERROR_LOG_FILENAME
from model_analyzer.state.analyzer_state_manager import AnalyzerStateManager
Expand Down Expand Up @@ -84,6 +85,7 @@ def __init__(
)

self._search_parameters: Dict[str, SearchParameters] = {}
self._composing_search_parameters: Dict[str, SearchParameters] = {}

def profile(
self, client: TritonClient, gpus: List[GPUDevice], mode: str, verbose: bool
Expand Down Expand Up @@ -118,7 +120,8 @@ def profile(

self._create_metrics_manager(client, gpus)
self._create_model_manager(client, gpus)
self._populate_search_parameters()
self._populate_search_parameters(client, gpus)
self._populate_composing_search_parameters(client, gpus)

if self._config.triton_launch_mode == "remote":
self._warn_if_other_models_loaded_on_remote_server(client)
Expand Down Expand Up @@ -205,6 +208,7 @@ def _create_model_manager(self, client, gpus):
state_manager=self._state_manager,
constraint_manager=self._constraint_manager,
search_parameters=self._search_parameters,
composing_search_parameters=self._composing_search_parameters,
)

def _get_server_only_metrics(self, client, gpus):
Expand Down Expand Up @@ -420,8 +424,20 @@ def _warn_if_other_models_loaded_on_remote_server(self, client):
"This could impact the profile results."
)

def _populate_search_parameters(self):
def _populate_search_parameters(self, client, gpus):
for model in self._config.profile_models:
model_profile_spec = ModelProfileSpec(model, self._config, client, gpus)
self._search_parameters[model.model_name()] = SearchParameters(
self._config, model.parameters(), model.model_config_parameters()
config=self._config,
model=model_profile_spec,
is_bls_model=bool(self._config.bls_composing_models),
)

def _populate_composing_search_parameters(self, client, gpus):
for model in self._config.bls_composing_models:
model_profile_spec = ModelProfileSpec(model, self._config, client, gpus)
self._composing_search_parameters[model.model_name()] = SearchParameters(
config=self._config,
model=model_profile_spec,
is_composing_model=True,
)
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ def __init__(
config: ConfigCommandProfile,
gpu_count: int,
models: List[ModelProfileSpec],
composing_models: List[ModelProfileSpec],
result_manager: ResultManager,
model_variant_name_manager: ModelVariantNameManager,
search_parameters: Dict[str, SearchParameters],
composing_search_parameters: Dict[str, SearchParameters],
):
"""
Parameters
Expand All @@ -62,19 +64,25 @@ def __init__(
gpu_count: Number of gpus in the system
models: List of ModelProfileSpec
List of models to profile
composing_models: List of ModelProfileSpec
List of composing models that exist inside of the supplied models
result_manager: ResultManager
The object that handles storing and sorting the results from the perf analyzer
model_variant_name_manager: ModelVariantNameManager
Maps model variants to config names
search_parameters: SearchParameters
The object that handles the users configuration search parameters
composing_search_parameters: SearchParameters
The object that handles the users configuration search parameters for composing models
"""
self._config = config
self._gpu_count = gpu_count
self._models = models
self._composing_models = composing_models
self._result_manager = result_manager
self._model_variant_name_manager = model_variant_name_manager
self._search_parameters = search_parameters
self._composing_search_parameters = composing_search_parameters

def set_last_results(
self, measurements: List[Optional[RunConfigMeasurement]]
Expand Down Expand Up @@ -117,8 +125,10 @@ def _create_optuna_run_config_generator(self) -> OptunaRunConfigGenerator:
config=self._config,
gpu_count=self._gpu_count,
models=self._models,
composing_models=self._composing_models,
model_variant_name_manager=self._model_variant_name_manager,
search_parameters=self._search_parameters,
composing_search_parameters=self._composing_search_parameters,
)

def _sweep_concurrency_over_top_results(self) -> Generator[RunConfig, None, None]:
Expand Down
Loading
Loading