File size: 8,761 Bytes
29658b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<template>
  <div class="chart-wrapper">
    <v-chart :option="chartOption" :autoresize="true" style="height: 100%; width: 100%" />
  </div>
</template>

<script setup>
import { computed } from 'vue';
import { removeSGLangPrefix } from '../utils/dataProcessor';
import { use } from 'echarts/core';
import { CanvasRenderer } from 'echarts/renderers';
import { BarChart, LineChart } from 'echarts/charts';
import {
  TitleComponent,
  TooltipComponent,
  LegendComponent,
  GridComponent,
  DataZoomComponent
} from 'echarts/components';
import VChart from 'vue-echarts';

use([
  CanvasRenderer,
  BarChart,
  LineChart,
  TitleComponent,
  TooltipComponent,
  LegendComponent,
  GridComponent,
  DataZoomComponent
]);

const props = defineProps({
  data: { type: Array, required: true },
  benchmark: { type: String, default: 'MTBench' },
  metric: { type: String, default: 'throughput' }
});

const chartOption = computed(() => {
  const isAllBenchmarks = props.benchmark === 'all';
  const benchmarksList = isAllBenchmarks ? ['gsm8k', 'math500', 'mtbench', 'humaneval', 'livecodebench', 'financeqa', 'gpqa'] : [props.benchmark];
  const metricKey = props.metric === 'accLen' ? 'accLen' : 'throughput';
  const metricLabel = props.metric === 'accLen' ? 'Acceptance Length' : 'Throughput (tokens/s)';
  const isSpeedup = props.metric === 'speedup';

  // Filter data that has at least one valid metric
  const validData = props.data.filter((d) => {
    return benchmarksList.some(b => d.metrics[b] && d.metrics[b][metricKey] != null);
  });

  // Extract parallel config for current target model(s)
  const parallelConfigs = [...new Set(validData.map(d => d.parallelConfig).filter(c => c && c !== '-' && c !== null))];
  const parallelConfigText = parallelConfigs.length > 0 ? ` (${parallelConfigs.join(', ')})` : '';

  // Calculate values
  const series = [];
  let xAxisData = [];

  // Helper to determine color based on draft model type
  const getColor = (draftModel) => {
    const draft = draftModel ? draftModel.toLowerCase() : '';
    if (draft.includes('specbundle')) {
        return {
          type: 'linear',
          x: 0, y: 0, x2: 0, y2: 1,
          colorStops: [{ offset: 0, color: '#4f46e5' }, { offset: 1, color: '#4338ca' }]
        };
    } else if (draft.includes('eagle')) {
        return '#10b981'; // Emerald
    } else if (draft === '-' || draft === 'none' || draft.includes('baseline')) {
        return '#94a3b8'; // Slate
    }
    return '#f59e0b'; // Amber
  };

  const getLabel = (d) => {
      const isBaseline = d.draftModel === '-' || d.draftModel === 'None' || d.draftModel.toLowerCase().includes('baseline');
      if (isBaseline) {
          return 'Baseline (No Draft Model)';
      }
      const cleanedModel = removeSGLangPrefix(d.draftModel);
      const modelName = cleanedModel.split('/').pop();
      const config = (d.config === '0-0-0' || !d.config || d.config === '-') ? '' : d.config;
      return config ? `${modelName}\n(${config})` : modelName;
  };

  if (isAllBenchmarks) {
    // PIVOTED VIEW: X-Axis = Benchmarks, Series = Configurations
    xAxisData = benchmarksList;

    // Palette for distinct series
    const palette = [
      '#06b6d4', // Cyan
      '#8b5cf6', // Violet
      '#ec4899', // Pink
      '#f59e0b', // Amber
      '#14b8a6', // Teal
      '#f43f5e', // Rose
      '#3b82f6', // Blue
      '#84cc16'  // Lime
    ];
    let colorIndex = 0;

    validData.forEach((d) => {
        const seriesName = getLabel(d).replace(/\n/g, ' '); // Flatten for legend

        // Determine Color
        const draft = d.draftModel ? d.draftModel.toLowerCase() : '';
        const isBaseline = draft === '-' || draft === 'none' || draft.includes('baseline');

        let itemStyleColor;

        if (draft.includes('specbundle')) {
           itemStyleColor = {
              type: 'linear',
              x: 0, y: 0, x2: 0, y2: 1,
              colorStops: [{ offset: 0, color: '#4f46e5' }, { offset: 1, color: '#4338ca' }]
           };
        } else if (isBaseline) {
           itemStyleColor = '#94a3b8'; // Slate
        } else {
           itemStyleColor = palette[colorIndex % palette.length];
           colorIndex++;
        }

        const data = benchmarksList.map(b => {
            const val = d.metrics[b]?.[metricKey];
            if (val == null) return 0;
            if (isSpeedup) {
                const baseline = d.baseline && d.baseline[b] ? d.baseline[b][metricKey] : null;
                return baseline ? parseFloat((val / baseline).toFixed(2)) : 0;
            }
            return typeof val === 'number' ? parseFloat(val.toFixed(2)) : val;
        });

        series.push({
            name: seriesName,
            type: 'bar',
            data: data,
            itemStyle: {
                borderRadius: [4, 4, 0, 0],
                color: itemStyleColor
            },
            label: {
                show: true,
                position: 'top',
                fontSize: 9,
                formatter: (params) => {
                    const val = params.value;
                    return typeof val === 'number' ? val.toFixed(2) : val;
                },
                distance: 2
            }
        });
    });

  } else {
    // SINGLE BENCHMARK VIEW: X-Axis = Models
    xAxisData = validData.map(getLabel);

    const values = validData.map((d) => {
      const val = d.metrics[benchmarksList[0]][metricKey];
      if (isSpeedup) {
        const baseline = d.baseline && d.baseline[benchmarksList[0]] ? d.baseline[benchmarksList[0]][metricKey] : null;
        return baseline ? parseFloat((val / baseline).toFixed(2)) : 0;
      }
      return typeof val === 'number' ? parseFloat(val.toFixed(2)) : val;
    });

    series.push({
      name: isSpeedup ? 'Speedup' : metricLabel,
      type: 'bar',
      data: values,
      barMaxWidth: 60,
      itemStyle: {
        borderRadius: [6, 6, 0, 0],
        color: function (params) {
          const dataIndex = params.dataIndex;
          return getColor(validData[dataIndex].draftModel);
        }
      },
      label: {
        show: xAxisData.length <= 15,
        position: 'top',
        formatter: (params) => {
            const val = params.value;
            return typeof val === 'number' ? val.toFixed(2) : val;
        },
        fontSize: 10,
        color: '#64748b'
      }
    });
  }

  const displayTitle = isAllBenchmarks
    ? `Hardware: H200 ${parallelConfigText} | Metric: Throughput (tokens/s)`
    : `${benchmarksList[0]} Performance`;


  return {
    textStyle: { fontFamily: 'Inter, sans-serif' },
    title: {
      text: displayTitle,
      left: 'left',
      textStyle: {
        fontSize: 16,
        fontWeight: 600,
        color: '#1e293b'
      }
    },
    tooltip: {
      trigger: 'axis',
      backgroundColor: 'rgba(255, 255, 255, 0.95)',
      borderColor: '#e2e8f0',
      textStyle: { color: '#334155', fontSize: 12 },
      axisPointer: { type: 'shadow' }
    },
    legend: {
      show: isAllBenchmarks,
      bottom: 0,
      left: 'center',
      width: '90%',
      itemGap: 15,
      textStyle: {
        fontSize: 11
      },
      data: isAllBenchmarks ? series.map(s => s.name) : []
    },
    grid: {
      left: 0,
      right: 10,
      bottom: 100, // Increased to fit 2 rows of legend + axis labels
      top: 60,
      containLabel: true
    },
    xAxis: {
      type: 'category',
      data: xAxisData,
      axisLine: { lineStyle: { color: '#e2e8f0' } },
      axisTick: { show: false },
      axisLabel: {
        interval: 0, // Force show all labels
        rotate: isAllBenchmarks ? 0 : 30, // Rotate 30 deg for single view
        fontSize: 10,
        color: '#64748b',
        // No truncation formatter
      }
    },
    yAxis: {
      type: 'value',
      name: isSpeedup ? 'x Baseline' : '',
      nameTextStyle: { align: 'right', color: '#94a3b8' },
      splitLine: { lineStyle: { type: 'dashed', color: '#f1f5f9' } },
      axisLabel: { color: '#64748b', fontSize: 11 }
    },
    dataZoom: [
      {
        type: 'slider',
        show: !isAllBenchmarks && xAxisData.length > 8,
        start: 0,
        end: isAllBenchmarks ? 100 : Math.min(100, (8 / xAxisData.length) * 100),
        bottom: 0,
        height: 16,
        borderColor: 'transparent',
        backgroundColor: '#f8fafc',
        fillerColor: 'rgba(79, 70, 229, 0.1)',
        handleSize: '100%',
        handleStyle: { color: '#818cf8' }
      },
      {
        type: 'inside',
        start: 0,
        end: 100,
        zoomOnMouseWheel: false,
        moveOnMouseMove: true,
        moveOnMouseWheel: true
      }
    ],
    series: series
  };
});
</script>

<style scoped>
.chart-wrapper {
  width: 100%;
  height: 100%;
}
</style>