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

Analyze: Print CSV reports #207

Merged
merged 4 commits into from
Dec 9, 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
37 changes: 37 additions & 0 deletions genai-perf/genai_perf/config/generate/perf_analyzer_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from argparse import Namespace
from copy import deepcopy
from dataclasses import dataclass
from enum import Enum, auto
from pathlib import Path
from typing import Any, Dict, List, Optional

Expand Down Expand Up @@ -88,6 +89,11 @@
]


class InferenceType(Enum):
CONCURRENCY = auto()
REQUEST_RATE = auto()


@dataclass
class PerfAnalyzerConfig:
"""
Expand Down Expand Up @@ -311,6 +317,37 @@ def get_obj_args(self) -> Namespace:

return obj_args

def get_inference_type(self) -> InferenceType:
"""
Returns the type of inferencing: concurrency or request-rate
"""
cmd = self.create_command()
if "--concurrency-range" in cmd:
return InferenceType.CONCURRENCY
elif "--request-rate-range" in cmd:
return InferenceType.REQUEST_RATE
else:
raise GenAIPerfException(
f"An inference type (either concurrency or request-rate) was not found."
)

def get_inference_value(self) -> int:
"""
Returns the value that we are inferencing
"""
infer_type = self.get_inference_type()
infer_cmd_option = (
"--concurrency-range"
if infer_type == InferenceType.CONCURRENCY
else "--request-rate-range"
)

cmd = self.create_command()
infer_value_index = cmd.index(infer_cmd_option) + 1
debermudez marked this conversation as resolved.
Show resolved Hide resolved
infer_value = int(cmd[infer_value_index])

return infer_value

###########################################################################
# CLI String Creation Methods
###########################################################################
Expand Down
5 changes: 5 additions & 0 deletions genai-perf/genai_perf/config/run/run_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ def get_all_gpu_metrics(self) -> GpuRecords:
def get_gpu_metric(self, name: str) -> Optional[GpuRecords]:
return self.measurement.get_gpu_metric(name)

def get_gpu_metric_value(
self, gpu_id: str, name: str, return_value: int = 0
) -> Any:
return self.measurement.get_gpu_metric_value(gpu_id, name, return_value)

def get_all_perf_metrics(self) -> Dict[ModelName, PerfRecords]:
return self.measurement.get_all_perf_metrics()

Expand Down
12 changes: 9 additions & 3 deletions genai-perf/genai_perf/export_data/data_exporter_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,24 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from typing import List
from typing import Any, List

from genai_perf.export_data.console_exporter import ConsoleExporter
from genai_perf.export_data.csv_exporter import CsvExporter
from genai_perf.export_data.exporter_config import ExporterConfig
from genai_perf.export_data.json_exporter import JsonExporter

DataExporterList = [ConsoleExporter, JsonExporter, CsvExporter]
ProfileDataExporterList = [ConsoleExporter, JsonExporter, CsvExporter]
AnalyzeDataExporterList = [CsvExporter]


class DataExporterFactory:
def create_data_exporters(self, config: ExporterConfig) -> List:
def create_data_exporters(self, config: ExporterConfig) -> List[Any]:
if config.args.subcommand == "analyze":
DataExporterList: List[Any] = AnalyzeDataExporterList
else:
DataExporterList = ProfileDataExporterList

data_exporters = []
for exporter in DataExporterList:
data_exporters.append(exporter(config))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def get_perf_metric(self, name: PerfMetricName) -> Optional[Record]:

def get_perf_metric_value(self, name: PerfMetricName, return_value: int = 0) -> Any:
metric = self.get_perf_metric(name)
return metric.value() if metric else return_value
return (
metric.value() / (10**metric.reduction_factor) if metric else return_value
)

def get_weighted_score(self, other: "ModelConfigMeasurement") -> float:
"""
Expand Down
20 changes: 20 additions & 0 deletions genai-perf/genai_perf/measurements/run_config_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,26 @@ def get_gpu_metric(self, name: str) -> Optional[GpuRecords]:

return gpu_metrics

def get_gpu_metric_value(
self,
gpu_id: str,
name: str,
return_value: int = 0,
) -> Any:
gpu_metrics = self.get_gpu_metric(name)

gpu_metric = None
if gpu_metrics:
if gpu_id in gpu_metrics:
if name in gpu_metrics[gpu_id]:
gpu_metric = gpu_metrics[gpu_id][name]

return (
gpu_metric.value() / (10**gpu_metric.reduction_factor)
if gpu_metric
else return_value
)

def get_model_config_measurements(self) -> ModelConfigMeasurements:
return self._model_config_measurements

Expand Down
20 changes: 20 additions & 0 deletions genai-perf/genai_perf/record/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@
import importlib
import os
from abc import ABCMeta, abstractmethod
from dataclasses import dataclass
from statistics import mean
from typing import Dict, Union

from genai_perf.exceptions import GenAIPerfException
from genai_perf.types import RecordValue


@dataclass(frozen=True)
class ReductionFactor:
NS_TO_MS = 6
NJ_TO_MJ = 6
B_TO_GB = 9
PERCENTAGE = -2
debermudez marked this conversation as resolved.
Show resolved Hide resolved
NONE = 0


class RecordType(ABCMeta):
"""
A metaclass that holds the instantiated Record types
Expand Down Expand Up @@ -147,6 +157,16 @@ def tag(self) -> str:
the name tag of the record type.
"""

@property
@abstractmethod
def reduction_factor(self) -> int:
"""
Returns
-------
int
the factor (of 10) that the value should be reduced by
"""

def create_checkpoint_object(self):
return (self.tag, self.__dict__)

Expand Down
2 changes: 2 additions & 0 deletions genai-perf/genai_perf/record/types/energy_consumption_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from functools import total_ordering

from genai_perf.record.gpu_record import DecreasingGPURecord
from genai_perf.record.record import ReductionFactor


@total_ordering
Expand All @@ -24,6 +25,7 @@ class GPUEnergyConsumptionBase(DecreasingGPURecord):
"""

base_tag = "energy_consumption"
reduction_factor = ReductionFactor.NJ_TO_MJ

def __init__(self, value, device_uuid=None, timestamp=0):
super().__init__(value, device_uuid, timestamp)
Expand Down
2 changes: 2 additions & 0 deletions genai-perf/genai_perf/record/types/gpu_memory_used_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from functools import total_ordering

from genai_perf.record.gpu_record import IncreasingGPURecord
from genai_perf.record.record import ReductionFactor


@total_ordering
Expand All @@ -24,6 +25,7 @@ class GPUMemoryUsedBase(IncreasingGPURecord):
"""

base_tag = "gpu_memory_used"
reduction_factor = ReductionFactor.B_TO_GB

def __init__(self, value, device_uuid=None, timestamp=0):
super().__init__(value, device_uuid, timestamp)
Expand Down
2 changes: 2 additions & 0 deletions genai-perf/genai_perf/record/types/gpu_power_limit_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from functools import total_ordering

from genai_perf.record.gpu_record import IncreasingGPURecord
from genai_perf.record.record import ReductionFactor


@total_ordering
Expand All @@ -24,6 +25,7 @@ class GPUPowerLimitBase(IncreasingGPURecord):
"""

base_tag = "gpu_power_limit"
reduction_factor = ReductionFactor.NONE
nv-braf marked this conversation as resolved.
Show resolved Hide resolved

def __init__(self, value, device_uuid=None, timestamp=0):
super().__init__(value, device_uuid, timestamp)
Expand Down
2 changes: 2 additions & 0 deletions genai-perf/genai_perf/record/types/gpu_power_usage_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from functools import total_ordering

from genai_perf.record.gpu_record import DecreasingGPURecord
from genai_perf.record.record import ReductionFactor


@total_ordering
Expand All @@ -24,6 +25,7 @@ class GPUPowerUsageBase(DecreasingGPURecord):
"""

base_tag = "gpu_power_usage"
reduction_factor = ReductionFactor.NONE

def __init__(self, value, device_uuid=None, timestamp=0):
super().__init__(value, device_uuid, timestamp)
Expand Down
2 changes: 2 additions & 0 deletions genai-perf/genai_perf/record/types/gpu_utilization_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from functools import total_ordering

from genai_perf.record.gpu_record import IncreasingGPURecord
from genai_perf.record.record import ReductionFactor


@total_ordering
Expand All @@ -24,6 +25,7 @@ class GPUUtilizationBase(IncreasingGPURecord):
"""

base_tag = "gpu_utilization"
reduction_factor = ReductionFactor.PERCENTAGE

def __init__(self, value, device_uuid=None, timestamp=0):
super().__init__(value, device_uuid, timestamp)
Expand Down
2 changes: 1 addition & 1 deletion genai-perf/genai_perf/record/types/gpu_utilization_p25.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def __init__(self, value, device_uuid=None, timestamp=0):

@classmethod
def header(cls, aggregation_tag=False) -> str:
return "p25 GPU Utilization (W)"
return "p25 GPU Utilization (%)"
2 changes: 1 addition & 1 deletion genai-perf/genai_perf/record/types/gpu_utilization_p50.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def __init__(self, value, device_uuid=None, timestamp=0):

@classmethod
def header(cls, aggregation_tag=False) -> str:
return "p50 GPU Utilization (W)"
return "p50 GPU Utilization (%)"
2 changes: 1 addition & 1 deletion genai-perf/genai_perf/record/types/gpu_utilization_p75.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def __init__(self, value, device_uuid=None, timestamp=0):

@classmethod
def header(cls, aggregation_tag=False) -> str:
return "p75 GPU Utilization (W)"
return "p75 GPU Utilization (%)"
2 changes: 1 addition & 1 deletion genai-perf/genai_perf/record/types/gpu_utilization_p90.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def __init__(self, value, device_uuid=None, timestamp=0):

@classmethod
def header(cls, aggregation_tag=False) -> str:
return "p90 GPU Utilization (W)"
return "p90 GPU Utilization (%)"
2 changes: 1 addition & 1 deletion genai-perf/genai_perf/record/types/gpu_utilization_p95.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def __init__(self, value, device_uuid=None, timestamp=0):

@classmethod
def header(cls, aggregation_tag=False) -> str:
return "p95 GPU Utilization (W)"
return "p95 GPU Utilization (%)"
2 changes: 1 addition & 1 deletion genai-perf/genai_perf/record/types/gpu_utilization_p99.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def __init__(self, value, device_uuid=None, timestamp=0):

@classmethod
def header(cls, aggregation_tag=False) -> str:
return "p99 GPU Utilization (W)"
return "p99 GPU Utilization (%)"
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from functools import total_ordering

from genai_perf.record.record import IncreasingRecord
from genai_perf.record.record import IncreasingRecord, ReductionFactor
from genai_perf.types import RecordValue


Expand All @@ -25,6 +25,7 @@ class InputSequenceLengthBase(IncreasingRecord):
"""

base_tag = "input_sequence_length"
reduction_factor = ReductionFactor.NONE

def __init__(self, value: RecordValue, timestamp: int = 0) -> None:
super().__init__(value, timestamp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from functools import total_ordering

from genai_perf.record.record import DecreasingRecord
from genai_perf.record.record import DecreasingRecord, ReductionFactor
from genai_perf.types import RecordValue


Expand All @@ -25,6 +25,7 @@ class InterTokenLatencyBase(DecreasingRecord):
"""

base_tag = "inter_token_latency"
reduction_factor = ReductionFactor.NS_TO_MS

def __init__(self, value: RecordValue, timestamp: int = 0) -> None:
super().__init__(value, timestamp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from functools import total_ordering

from genai_perf.record.record import IncreasingRecord
from genai_perf.record.record import IncreasingRecord, ReductionFactor
from genai_perf.types import RecordValue


Expand All @@ -25,6 +25,7 @@ class OutputSequenceLengthBase(IncreasingRecord):
"""

base_tag = "output_sequence_length"
reduction_factor = ReductionFactor.NONE

def __init__(self, value: RecordValue, timestamp: int = 0) -> None:
super().__init__(value, timestamp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from functools import total_ordering

from genai_perf.record.record import IncreasingRecord
from genai_perf.record.record import IncreasingRecord, ReductionFactor
from genai_perf.types import RecordValue


Expand All @@ -25,6 +25,7 @@ class OutputTokenThroughputAvg(IncreasingRecord):
"""

tag = "output_token_throughput_avg"
reduction_factor = ReductionFactor.NONE

def __init__(self, value: RecordValue, timestamp: int = 0) -> None:
super().__init__(value, timestamp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from functools import total_ordering

from genai_perf.record.record import IncreasingRecord
from genai_perf.record.record import IncreasingRecord, ReductionFactor
from genai_perf.types import RecordValue


Expand All @@ -25,6 +25,7 @@ class OutputTokenThroughputPerRequestBase(IncreasingRecord):
"""

base_tag = "output_token_throughput_per_request"
reduction_factor = ReductionFactor.NONE

def __init__(self, value: RecordValue, timestamp: int = 0) -> None:
super().__init__(value, timestamp)
Expand Down
3 changes: 2 additions & 1 deletion genai-perf/genai_perf/record/types/request_goodput_avg.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from functools import total_ordering

from genai_perf.record.record import IncreasingRecord
from genai_perf.record.record import IncreasingRecord, ReductionFactor


@total_ordering
Expand All @@ -24,6 +24,7 @@ class RequestGoodputAvg(IncreasingRecord):
"""

tag = "request_goodput_avg"
reduction_factor = ReductionFactor.NONE

def __init__(self, value, timestamp=0):
super().__init__(value, timestamp)
Expand Down
Loading
Loading