-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add time-to-second-token metric (#217)
- Loading branch information
1 parent
5f1c7b3
commit 05b0949
Showing
26 changed files
with
471 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
genai-perf/genai_perf/record/types/time_to_second_token_avg.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2024, 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. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from functools import total_ordering | ||
|
||
from genai_perf.record.types.time_to_second_token_base import TimeToSecondTokenBase | ||
|
||
|
||
@total_ordering | ||
class TimeToSecondTokenAvg(TimeToSecondTokenBase): | ||
""" | ||
A record for avg Time to second token metric | ||
""" | ||
|
||
tag = TimeToSecondTokenBase.base_tag + "_avg" | ||
|
||
def __init__(self, value, timestamp=0): | ||
super().__init__(value, timestamp) | ||
|
||
@classmethod | ||
def header(cls, aggregation_tag=False) -> str: | ||
return "Avg Time To Second Token (ms)" |
56 changes: 56 additions & 0 deletions
56
genai-perf/genai_perf/record/types/time_to_second_token_base.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Copyright 2024, 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. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from functools import total_ordering | ||
|
||
from genai_perf.record.record import DecreasingRecord, ReductionFactor | ||
from genai_perf.types import RecordValue | ||
|
||
|
||
@total_ordering | ||
class TimeToSecondTokenBase(DecreasingRecord): | ||
""" | ||
A base class record for the time to second token metric | ||
""" | ||
|
||
base_tag = "time_to_second_token" | ||
reduction_factor = ReductionFactor.NS_TO_MS | ||
|
||
def __init__(self, value: RecordValue, timestamp: int = 0) -> None: | ||
super().__init__(value, timestamp) | ||
|
||
def __eq__(self, other: "TimeToSecondTokenBase") -> bool: # type: ignore | ||
return self.value() == other.value() | ||
|
||
def __lt__(self, other: "TimeToSecondTokenBase") -> bool: | ||
return self.value() > other.value() | ||
|
||
def __add__(self, other: "TimeToSecondTokenBase") -> "TimeToSecondTokenBase": | ||
""" | ||
Allows adding two records together | ||
to produce a brand new record. | ||
""" | ||
|
||
return self.__class__(value=(self.value() + other.value())) | ||
|
||
def __sub__(self, other: "TimeToSecondTokenBase") -> "TimeToSecondTokenBase": | ||
""" | ||
Allows subbing two records together | ||
to produce a brand new record. | ||
** Note this does reverse subtraction because | ||
of the inverted nature of latency (lower is better) | ||
""" | ||
|
||
return self.__class__(value=(other.value() - self.value())) |
33 changes: 33 additions & 0 deletions
33
genai-perf/genai_perf/record/types/time_to_second_token_max.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2024, 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. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from functools import total_ordering | ||
|
||
from genai_perf.record.types.time_to_second_token_base import TimeToSecondTokenBase | ||
|
||
|
||
@total_ordering | ||
class TimeToSecondTokenMax(TimeToSecondTokenBase): | ||
""" | ||
A record for max Time to second token metric | ||
""" | ||
|
||
tag = TimeToSecondTokenBase.base_tag + "_max" | ||
|
||
def __init__(self, value, timestamp=0): | ||
super().__init__(value, timestamp) | ||
|
||
@classmethod | ||
def header(cls, aggregation_tag=False) -> str: | ||
return "Max Time To Second Token (ms)" |
33 changes: 33 additions & 0 deletions
33
genai-perf/genai_perf/record/types/time_to_second_token_min.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2024, 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. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from functools import total_ordering | ||
|
||
from genai_perf.record.types.time_to_second_token_base import TimeToSecondTokenBase | ||
|
||
|
||
@total_ordering | ||
class TimeToSecondTokenMin(TimeToSecondTokenBase): | ||
""" | ||
A record for min Time to second token metric | ||
""" | ||
|
||
tag = TimeToSecondTokenBase.base_tag + "_min" | ||
|
||
def __init__(self, value, timestamp=0): | ||
super().__init__(value, timestamp) | ||
|
||
@classmethod | ||
def header(cls, aggregation_tag=False) -> str: | ||
return "Min Time To Second Token (ms)" |
33 changes: 33 additions & 0 deletions
33
genai-perf/genai_perf/record/types/time_to_second_token_p25.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2024, 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. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from functools import total_ordering | ||
|
||
from genai_perf.record.types.time_to_second_token_base import TimeToSecondTokenBase | ||
|
||
|
||
@total_ordering | ||
class TimeToSecondTokenP25(TimeToSecondTokenBase): | ||
""" | ||
A record for p25 Time to second token metric | ||
""" | ||
|
||
tag = TimeToSecondTokenBase.base_tag + "_p25" | ||
|
||
def __init__(self, value, timestamp=0): | ||
super().__init__(value, timestamp) | ||
|
||
@classmethod | ||
def header(cls, aggregation_tag=False) -> str: | ||
return "p25 Time To Second Token (ms)" |
33 changes: 33 additions & 0 deletions
33
genai-perf/genai_perf/record/types/time_to_second_token_p50.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2024, 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. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from functools import total_ordering | ||
|
||
from genai_perf.record.types.time_to_second_token_base import TimeToSecondTokenBase | ||
|
||
|
||
@total_ordering | ||
class TimeToSecondTokenP50(TimeToSecondTokenBase): | ||
""" | ||
A record for p50 Time to second token metric | ||
""" | ||
|
||
tag = TimeToSecondTokenBase.base_tag + "_p50" | ||
|
||
def __init__(self, value, timestamp=0): | ||
super().__init__(value, timestamp) | ||
|
||
@classmethod | ||
def header(cls, aggregation_tag=False) -> str: | ||
return "p50 Time To Second Token (ms)" |
Oops, something went wrong.