Skip to content
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
6 changes: 5 additions & 1 deletion packages/app/src/components/inference/ui/ChartDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,11 @@ export default function ChartDisplay() {
const visibleData = graph.data.filter((d) =>
activeHwTypes.has(d.hwKey as string),
);
const { headers, rows } = inferenceChartToCsv(visibleData);
const { headers, rows } = inferenceChartToCsv(
visibleData,
graph.model,
graph.sequence,
);
exportToCsv(`chart-${graphIndex}-${Date.now()}`, headers, rows);
}}
/>
Expand Down
25 changes: 19 additions & 6 deletions packages/app/src/lib/csv-export-helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('inferenceChartToCsv', () => {

it('exports all raw benchmark fields', () => {
const data = [makePoint()];
const { headers, rows } = inferenceChartToCsv(data);
const { headers, rows } = inferenceChartToCsv(data, 'llama-3.1-405b', '1k/1k');

// Should have all metric columns
expect(headers).toContain('Throughput/GPU (tok/s)');
Expand All @@ -71,9 +71,22 @@ describe('inferenceChartToCsv', () => {
expect(rows).toHaveLength(1);
});

it('includes Model, ISL, and OSL columns from model and sequence', () => {
const data = [makePoint()];
const { headers, rows } = inferenceChartToCsv(data, 'llama-3.1-405b', '1k/8k');
const row = rows[0];

expect(headers[0]).toBe('Model');
expect(headers[1]).toBe('ISL');
expect(headers[2]).toBe('OSL');
expect(row[0]).toBe('llama-3.1-405b');
expect(row[1]).toBe(1024);
expect(row[2]).toBe(8192);
});

it('includes throughput and latency values in correct columns', () => {
const data = [makePoint()];
const { headers, rows } = inferenceChartToCsv(data);
const { headers, rows } = inferenceChartToCsv(data, 'llama-3.1-405b', '1k/1k');
const row = rows[0];

const tputIdx = headers.indexOf('Throughput/GPU (tok/s)');
Expand All @@ -88,13 +101,13 @@ describe('inferenceChartToCsv', () => {

it('filters out hidden data points', () => {
const data = [makePoint(), makePoint({ hidden: true })];
const { rows } = inferenceChartToCsv(data);
const { rows } = inferenceChartToCsv(data, 'llama-3.1-405b', '1k/1k');
expect(rows).toHaveLength(1);
});

it('includes disaggregated and parallelism fields', () => {
const data = [makePoint({ disagg: true, num_prefill_gpu: 2, num_decode_gpu: 6, ep: 4 })];
const { headers, rows } = inferenceChartToCsv(data);
const { headers, rows } = inferenceChartToCsv(data, 'llama-3.1-405b', '1k/1k');
const row = rows[0];

expect(row[headers.indexOf('Disaggregated')]).toBe(true);
Expand All @@ -104,7 +117,7 @@ describe('inferenceChartToCsv', () => {
});

it('handles empty data', () => {
const { rows } = inferenceChartToCsv([]);
const { rows } = inferenceChartToCsv([], 'llama-3.1-405b', '1k/1k');
expect(rows).toHaveLength(0);
});

Expand All @@ -129,7 +142,7 @@ describe('inferenceChartToCsv', () => {
costri: { y: 0, roof: false },
} as InferenceData,
];
const { headers, rows } = inferenceChartToCsv(data);
const { headers, rows } = inferenceChartToCsv(data, 'llama-3.1-405b', '1k/1k');
const row = rows[0];

// Missing optional fields should be ''
Expand Down
15 changes: 14 additions & 1 deletion packages/app/src/lib/csv-export-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import type { InferenceData, TrendDataPoint } from '@/components/inference/types';

import { sequenceToIslOsl } from '@semianalysisai/inferencex-constants';

interface CsvData {
headers: string[];
rows: (string | number | boolean | null | undefined)[][];
Expand All @@ -19,8 +21,16 @@ interface CsvData {
* Exports all raw benchmark metrics so the user gets a full data dump,
* regardless of which axes are currently plotted.
*/
export function inferenceChartToCsv(data: InferenceData[]): CsvData {
export function inferenceChartToCsv(
data: InferenceData[],
model: string,
sequence: string,
): CsvData {
const islOsl = sequenceToIslOsl(sequence);
const headers = [
'Model',
'ISL',
'OSL',
'Hardware',
'Hardware Key',
'Framework',
Expand Down Expand Up @@ -71,6 +81,9 @@ export function inferenceChartToCsv(data: InferenceData[]): CsvData {
const rows = data
.filter((d) => !d.hidden)
.map((d) => [
model,
islOsl?.isl ?? '',
islOsl?.osl ?? '',
d.hw ?? '',
d.hwKey,
d.framework ?? '',
Expand Down