Skip to content

Commit

Permalink
Replace Argparse with ConfigCommand (#266)
Browse files Browse the repository at this point in the history
* Ported over logic infer logic from parser

* Added unit testing for inferred input/endpoint logic

* Completed porting of all inferred and checked fields from parser

* Adding missing goodput parsing

* Initial changes to get profile working

* CLI unit tests passing

* Fixing CLI tests that I missed

* Telemetry tests passing

* Test artifacts passing

* Telemetry data collector tests passing

* Passing common unit tests

* Fixing console exporter unit tests

* Fixing CSV exporter unit tests

* Partial for for JSON exporter unit tests

* Adding library function to convert BaseConfig into a JSON readable dictionary

* JSON Exporter unit tests passing

* Fixing Tokenizer unit tests

* PA Config unit tests passing

* Fixing Results and RunConfig unit tests

* All unit tests passing

* Fixing codeql issues

* Moving generation of artifact directory into PA Config generator class

* Fixing exporters to use PA config

* Progress on analyze. Need to add checkpoint support to base config class.

* Fixed GAP config generator. All unit tests passing

* Getting analyze working with CLI

* Analyze working with config file

* fixing codeql

* Fixed PA config to work with multiple sweep parameters

* Fixing message when config found in checkpoint

* Refactoring path method

* Removing commented out lines

* Fixing issue around specifing url/server metrics url

* Changes based on Elias' PR

* Fixing codeql issue

* Missing check for None
  • Loading branch information
nv-braf authored Feb 12, 2025
1 parent 275a9e5 commit 58efd02
Show file tree
Hide file tree
Showing 60 changed files with 1,881 additions and 1,396 deletions.
59 changes: 33 additions & 26 deletions genai-perf/genai_perf/config/generate/genai_perf_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,23 +33,48 @@ def __init__(
self,
config: ConfigCommand,
model_objective_parameters: ModelObjectiveParameters,
args: Namespace = Namespace(),
):
self._args = deepcopy(args)

self._set_parameters_based_on_objective(model_objective_parameters)
self._parameters = self._set_parameters_based_on_config(config)
self._parameters |= self._set_parameters_based_on_objective(
model_objective_parameters
)

###########################################################################
# Set Options Methods
###########################################################################
def _set_parameters_based_on_config(self, config: ConfigCommand) -> Parameters:
"""
Store values set in the config that should be checked when
determining if a previously checkpointed run can be used
"""
parameters: Parameters = {}

# ENDPOINT
parameters["endpoint"] = config.endpoint.to_json_dict()

# Remove any fields that have no bearing on the
# values of metrics being measured
del parameters["endpoint"]["server_metrics_urls"]
del parameters["endpoint"]["url"]

# INPUT
parameters["input"] = config.input.to_json_dict()

# TOKENIZER
parameters["tokenizer"] = config.tokenizer.to_json_dict()

return parameters

def _set_parameters_based_on_objective(
self, model_objective_parameters: ModelObjectiveParameters
) -> None:
self._parameters: Parameters = {}
) -> Parameters:
parameters: Parameters = {}
for objective in model_objective_parameters.values():
for name, parameter in objective.items():
if parameter.usage == SearchUsage.RUNTIME_GAP:
self._parameters[name] = parameter.get_value_based_on_category()
parameters[name] = parameter.get_value_based_on_category()

return parameters

###########################################################################
# Get Accessor Methods
Expand All @@ -60,21 +85,6 @@ def get_parameters(self) -> Parameters:
"""
return self._parameters

def get_obj_args(self) -> Namespace:
"""
Returns args that can be used by the existing CLI based methods in GAP
These will include any objectives that are set via parameters
"""
obj_args = deepcopy(self._args)
if "input_sequence_length" in self._parameters:
obj_args.synthetic_input_tokens_mean = self._parameters[
"input_sequence_length"
]
if "num_dataset_entries" in self._parameters:
obj_args.num_dataset_entries = self._parameters["num_dataset_entries"]

return obj_args

###########################################################################
# Representation Methods
###########################################################################
Expand All @@ -97,9 +107,6 @@ def create_checkpoint_object(self) -> CheckpointObject:
"""
genai_perf_config_dict = deepcopy(self.__dict__)

# Values set on the CLI and parameters are not kept (they can vary from run to run)
del genai_perf_config_dict["_args"]

return genai_perf_config_dict

@classmethod
Expand Down
Loading

0 comments on commit 58efd02

Please sign in to comment.