| export async function loadAllData() { |
| try { |
| const response = await fetch('./raw_data/data.json'); |
| const jsonData = await response.json(); |
| return jsonData; |
| } catch (error) { |
| console.error('Error loading JSON data:', error); |
| return {}; |
| } |
| } |
|
|
| export function calculateSpeedup(specValue, baselineValue) { |
| if (!specValue || !baselineValue || baselineValue === 0) return null; |
| return (specValue / baselineValue).toFixed(2); |
| } |
|
|
| export function processModelData(modelData, targetModelName) { |
| if (!modelData || !targetModelName) return []; |
|
|
| |
| const entriesMap = new Map(); |
|
|
| |
| Object.entries(modelData).forEach(([, benchmarkData]) => { |
| const benchmarkName = benchmarkData.benchmark_name; |
| const results = benchmarkData.results || []; |
|
|
| results.forEach(result => { |
| const { batch_size, steps, topk, num_draft_tokens, metrics } = result; |
|
|
| |
| const baselineMetric = metrics.find(m => m.Name === 'Wihtout EAGLE3'); |
|
|
| |
| metrics.forEach(metric => { |
| const isBaseline = metric.Name === 'Wihtout EAGLE3'; |
| const config = isBaseline ? 'baseline' : `${batch_size}-${steps}-${topk}-${num_draft_tokens}`; |
|
|
| |
| const draftModel = isBaseline ? 'None' : metric.Name; |
|
|
| |
| |
| const key = `${draftModel}|${config}`; |
|
|
| |
| if (!entriesMap.has(key)) { |
| entriesMap.set(key, { |
| targetModel: targetModelName, |
| draftModel: draftModel, |
| config, |
| batch_size, |
| steps, |
| topk, |
| num_draft_tokens, |
| metrics: {}, |
| baseline: {} |
| }); |
| } |
|
|
| const entry = entriesMap.get(key); |
|
|
| |
| entry.metrics[benchmarkName] = { |
| throughput: metric.output_throughput, |
| accLen: metric.accept_length |
| }; |
|
|
| |
| if (baselineMetric) { |
| entry.baseline[benchmarkName] = { |
| throughput: baselineMetric.output_throughput, |
| accLen: baselineMetric.accept_length |
| }; |
| } |
| }); |
| }); |
| }); |
|
|
| return Array.from(entriesMap.values()); |
| } |
|
|
| export function getTargetModels(allData) { |
| return Object.keys(allData); |
| } |
|
|
| export function extractUniqueTargetModels(processedData) { |
| return [...new Set(processedData.map(d => d.targetModel).filter(Boolean))]; |
| } |
|
|
| export function removeSGLangPrefix(modelName) { |
| if (!modelName) return modelName; |
| |
| |
| |
| |
| let cleaned = String(modelName); |
|
|
| |
| cleaned = cleaned.replace(/(^|\/)SGLang-EAGLE3-/gi, '$1'); |
|
|
| |
| cleaned = cleaned.replace(/(^|\/)SGLang-EAGLE3\//gi, '$1'); |
|
|
| |
| cleaned = cleaned.replace(/^SGLang-EAGLE3(?![-\/])/gi, ''); |
|
|
| |
| cleaned = cleaned.replace(/\/+/g, '/'); |
|
|
| |
| if (cleaned.length > 1) { |
| cleaned = cleaned.replace(/^\//, ''); |
| } |
|
|
| return cleaned || modelName; |
| } |
|
|