Skip to content

Commit 8c47241

Browse files
committed
add strategy label to tooltip
Signed-off-by: dalthecow <[email protected]>
1 parent 9e328cc commit 8c47241

File tree

5 files changed

+42
-17
lines changed

5 files changed

+42
-17
lines changed

src/guidellm/presentation/data_models.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from math import ceil
44
from typing import TYPE_CHECKING, Optional, Union
55

6+
from guidellm.scheduler.strategy import SchedulingStrategy
67
from pydantic import BaseModel, computed_field
78

89
if TYPE_CHECKING:
@@ -212,11 +213,26 @@ class BenchmarkDatum(BaseModel):
212213
ttft: TabularDistributionSummary
213214
throughput: TabularDistributionSummary
214215
time_per_request: TabularDistributionSummary
216+
strategy_display_str: str
217+
218+
def strategy_display_str(strategy: SchedulingStrategy):
219+
strategy_type = strategy if isinstance(strategy, str) else strategy.type_
220+
strategy_instance = strategy if isinstance(strategy, SchedulingStrategy) else None
221+
222+
if strategy_type == "concurrent":
223+
rate = f"@{strategy_instance.streams}" if strategy_instance else "@##" # type: ignore[attr-defined]
224+
elif strategy_type in ("constant", "poisson"):
225+
rate = f"@{strategy_instance.rate:.2f}" if strategy_instance else "@#.##" # type: ignore[attr-defined]
226+
else:
227+
rate = ""
228+
return f"{strategy_type}{rate}"
215229

216230
@classmethod
217231
def from_benchmark(cls, bm: "GenerativeBenchmark"):
232+
rps = bm.metrics.requests_per_second.successful.mean
218233
return cls(
219-
requests_per_second=bm.metrics.requests_per_second.successful.mean,
234+
strategy_display_str=cls.strategy_display_str(bm.args.strategy),
235+
requests_per_second=rps,
220236
tpot=TabularDistributionSummary.from_distribution_summary(
221237
bm.metrics.inter_token_latency_ms.successful
222238
),

src/ui/lib/components/Charts/MetricLine/MetricLine.component.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { Typography, useTheme } from '@mui/material';
2-
import { ResponsiveLine } from '@nivo/line';
2+
import { PointTooltipProps, ResponsiveLine } from '@nivo/line';
33
import { BasicTooltip } from '@nivo/tooltip';
44
import React, { FC } from 'react';
55

66
import { useColor } from '@/lib/hooks/useColor';
7-
import { formatNumber } from '@/lib/utils/helpers';
87

98
import { MetricLineProps } from '.';
109
import CustomAxes from './components/CustomAxes';
@@ -51,16 +50,12 @@ export const Component: FC<MetricLineProps> = ({
5150
reverse: false,
5251
};
5352
}
54-
55-
const getUnits = (seriesId: string) => {
56-
switch (seriesId) {
57-
case 'timePerRequest':
58-
return 's';
59-
case 'throughput':
60-
return 'tok/s';
61-
default:
62-
return 'ms';
63-
}
53+
type PointTooltipPropsWithLabel = PointTooltipProps & {
54+
point: {
55+
data: {
56+
label: string;
57+
};
58+
};
6459
};
6560

6661
return (
@@ -71,7 +66,7 @@ export const Component: FC<MetricLineProps> = ({
7166
<BasicTooltip
7267
id={
7368
<Typography variant="body2">
74-
{`${formatNumber(Number(point.point.data.x))} rps, ${formatNumber(Number(point.point.data.y))} ${getUnits(`${point.point.serieId}`)}`}
69+
{(point as PointTooltipPropsWithLabel).point.data.label}
7570
</Typography>
7671
}
7772
color={point.point.color}

src/ui/lib/store/benchmarksWindowData.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const benchmarksScript = `window.benchmarks = [
22
{
3+
strategyDisplayStr: "synchronous",
34
requestsPerSecond: 11.411616848282272,
45
tpot: {
56
mean: 8.758024845683707,
@@ -171,6 +172,7 @@ export const benchmarksScript = `window.benchmarks = [
171172
},
172173
},
173174
{
175+
strategyDisplayStr: "[email protected]",
174176
requestsPerSecond: 36.289181300710815,
175177
tpot: {
176178
mean: 588.0161376137819,
@@ -342,6 +344,7 @@ export const benchmarksScript = `window.benchmarks = [
342344
},
343345
},
344346
{
347+
strategyDisplayStr: "[email protected]",
345348
requestsPerSecond: 20.752070927855794,
346349
tpot: {
347350
mean: 116.28360712595156,
@@ -513,6 +516,7 @@ export const benchmarksScript = `window.benchmarks = [
513516
},
514517
},
515518
{
519+
strategyDisplayStr: "[email protected]",
516520
requestsPerSecond: 26.81917480361788,
517521
tpot: {
518522
mean: 299.7306064613554,
@@ -684,6 +688,7 @@ export const benchmarksScript = `window.benchmarks = [
684688
},
685689
},
686690
{
691+
strategyDisplayStr: "[email protected]",
687692
requestsPerSecond: 26.823988819498975,
688693
tpot: {
689694
mean: 683.8011571339198,
@@ -855,6 +860,7 @@ export const benchmarksScript = `window.benchmarks = [
855860
},
856861
},
857862
{
863+
strategyDisplayStr: "[email protected]",
858864
requestsPerSecond: 24.50047903792646,
859865
tpot: {
860866
mean: 742.9258901891964,
@@ -1026,6 +1032,7 @@ export const benchmarksScript = `window.benchmarks = [
10261032
},
10271033
},
10281034
{
1035+
strategyDisplayStr: "[email protected]",
10291036
requestsPerSecond: 25.617829792196602,
10301037
tpot: {
10311038
mean: 663.3098317044122,
@@ -1197,6 +1204,7 @@ export const benchmarksScript = `window.benchmarks = [
11971204
},
11981205
},
11991206
{
1207+
strategyDisplayStr: "[email protected]",
12001208
requestsPerSecond: 37.02892550982192,
12011209
tpot: {
12021210
mean: 606.4144710877113,
@@ -1368,6 +1376,7 @@ export const benchmarksScript = `window.benchmarks = [
13681376
},
13691377
},
13701378
{
1379+
strategyDisplayStr: "[email protected]",
13711380
requestsPerSecond: 37.29183354201869,
13721381
tpot: {
13731382
mean: 603.3237551205925,
@@ -1539,6 +1548,7 @@ export const benchmarksScript = `window.benchmarks = [
15391548
},
15401549
},
15411550
{
1551+
strategyDisplayStr: "throughput",
15421552
requestsPerSecond: 37.45318312972309,
15431553
tpot: {
15441554
mean: 600.7204526769262,

src/ui/lib/store/slices/benchmarks/benchmarks.interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface BenchmarkMetrics {
2727

2828
export interface Benchmark extends BenchmarkMetrics {
2929
requestsPerSecond: number;
30+
strategyDisplayStr: string;
3031
}
3132

3233
export type Benchmarks = Benchmark[];

src/ui/lib/store/slices/benchmarks/benchmarks.selectors.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ export const selectMetricsSummaryLineData = createSelector(
1818
?.slice()
1919
?.sort((bm1, bm2) => (bm1.requestsPerSecond > bm2.requestsPerSecond ? 1 : -1));
2020
const selectedPercentile = sloState.enforcedPercentile;
21-
22-
const lineData: { [K in keyof BenchmarkMetrics]: Point[] } = {
21+
interface PointWithLabel extends Point {
22+
label: string;
23+
}
24+
const lineData: { [K in keyof BenchmarkMetrics]: PointWithLabel[] } = {
2325
ttft: [],
2426
tpot: [],
2527
timePerRequest: [],
@@ -32,14 +34,15 @@ export const selectMetricsSummaryLineData = createSelector(
3234
'throughput',
3335
];
3436
metrics.forEach((metric) => {
35-
const data: Point[] = [];
37+
const data: PointWithLabel[] = [];
3638
sortedByRPS?.forEach((benchmark) => {
3739
const percentile = benchmark[metric].percentileRows.find(
3840
(p) => p.percentile === selectedPercentile
3941
);
4042
data.push({
4143
x: benchmark.requestsPerSecond,
4244
y: percentile?.value ?? 0,
45+
label: benchmark.strategyDisplayStr,
4346
});
4447
});
4548

0 commit comments

Comments
 (0)