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

Output config.pbtxt when in remote mode #784

Merged
merged 1 commit into from
Nov 3, 2023
Merged
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
89 changes: 64 additions & 25 deletions model_analyzer/record/metrics_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,35 +347,74 @@ def _create_model_variant(
repository and fills directory with config
"""

variant_name = variant_config.variant_name
if self._config.triton_launch_mode != "remote":
model_repository = self._config.model_repository
self._create_non_remote_mode_model_variant(
original_name, variant_config, ignore_first_config_variant
tgerdesnv marked this conversation as resolved.
Show resolved Hide resolved
)
else:
self._create_remote_mode_model_variant(original_name, variant_config)

original_model_dir = os.path.join(model_repository, original_name)
new_model_dir = os.path.join(self._output_model_repo_path, variant_name)
try:
# Create the directory for the new model
os.makedirs(new_model_dir, exist_ok=True)
self._first_config_variant.setdefault(original_name, None)
def _create_non_remote_mode_model_variant(
self,
original_name: str,
variant_config: ModelConfigVariant,
ignore_first_config_variant: bool = False,
) -> None:
"""
Creates a directory for the model config variant in the output model
repository and fills directory with config
"""
variant_name = variant_config.variant_name
model_repository = self._config.model_repository

original_model_dir = os.path.join(model_repository, original_name)
new_model_dir = os.path.join(self._output_model_repo_path, variant_name)
try:
# Create the directory for the new model
os.makedirs(new_model_dir, exist_ok=True)
self._first_config_variant.setdefault(original_name, None)

if ignore_first_config_variant:
variant_config.model_config.write_config_to_file(
new_model_dir, original_model_dir, None
tgerdesnv marked this conversation as resolved.
Show resolved Hide resolved
)
else:
variant_config.model_config.write_config_to_file(
new_model_dir,
original_model_dir,
self._first_config_variant[original_name],
)

if ignore_first_config_variant:
variant_config.model_config.write_config_to_file(
new_model_dir, original_model_dir, None
)
else:
variant_config.model_config.write_config_to_file(
new_model_dir,
original_model_dir,
self._first_config_variant[original_name],
)
if self._first_config_variant[original_name] is None:
self._first_config_variant[original_name] = os.path.join(
self._output_model_repo_path, variant_name
)
except FileExistsError:
# Ignore if the file already exists
pass

if self._first_config_variant[original_name] is None:
self._first_config_variant[original_name] = os.path.join(
self._output_model_repo_path, variant_name
)
except FileExistsError:
# Ignore if the file already exists
pass
def _create_remote_mode_model_variant(
self,
original_name: str,
variant_config: ModelConfigVariant,
) -> None:
"""
Creates a directory for the model config variant in the output model
repository and fills directory with only the config.pbtxt
"""
variant_name = variant_config.variant_name
new_model_dir = os.path.join(self._output_model_repo_path, variant_name)
try:
os.makedirs(new_model_dir, exist_ok=False)
self._first_config_variant.setdefault(original_name, None)
variant_config.model_config.write_config_to_file(
model_path=new_model_dir,
src_model_path=new_model_dir,
first_variant_model_path=None,
)
except FileExistsError:
# Ignore if the dir already exists
pass

def _load_model_variants(self, run_config):
"""
Expand Down
Loading