Skip to content

Commit 6e5169a

Browse files
committed
add Model, ISL, OSL columns to inference CSV export
1 parent 93398ec commit 6e5169a

3 files changed

Lines changed: 38 additions & 8 deletions

File tree

packages/app/src/components/inference/ui/ChartDisplay.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,11 @@ export default function ChartDisplay() {
268268
const visibleData = graph.data.filter((d) =>
269269
activeHwTypes.has(d.hwKey as string),
270270
);
271-
const { headers, rows } = inferenceChartToCsv(visibleData);
271+
const { headers, rows } = inferenceChartToCsv(
272+
visibleData,
273+
graph.model,
274+
graph.sequence,
275+
);
272276
exportToCsv(`chart-${graphIndex}-${Date.now()}`, headers, rows);
273277
}}
274278
/>

packages/app/src/lib/csv-export-helpers.test.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('inferenceChartToCsv', () => {
5757

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

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

74+
it('includes Model, ISL, and OSL columns from model and sequence', () => {
75+
const data = [makePoint()];
76+
const { headers, rows } = inferenceChartToCsv(data, 'llama-3.1-405b', '1k/8k');
77+
const row = rows[0];
78+
79+
expect(headers[0]).toBe('Model');
80+
expect(headers[1]).toBe('ISL');
81+
expect(headers[2]).toBe('OSL');
82+
expect(row[0]).toBe('llama-3.1-405b');
83+
expect(row[1]).toBe(1024);
84+
expect(row[2]).toBe(8192);
85+
});
86+
7487
it('includes throughput and latency values in correct columns', () => {
7588
const data = [makePoint()];
76-
const { headers, rows } = inferenceChartToCsv(data);
89+
const { headers, rows } = inferenceChartToCsv(data, 'llama-3.1-405b', '1k/1k');
7790
const row = rows[0];
7891

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

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

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

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

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

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

135148
// Missing optional fields should be ''

packages/app/src/lib/csv-export-helpers.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

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

12+
import { sequenceToIslOsl } from '@semianalysisai/inferencex-constants';
13+
1214
interface CsvData {
1315
headers: string[];
1416
rows: (string | number | boolean | null | undefined)[][];
@@ -19,8 +21,16 @@ interface CsvData {
1921
* Exports all raw benchmark metrics so the user gets a full data dump,
2022
* regardless of which axes are currently plotted.
2123
*/
22-
export function inferenceChartToCsv(data: InferenceData[]): CsvData {
24+
export function inferenceChartToCsv(
25+
data: InferenceData[],
26+
model: string,
27+
sequence: string,
28+
): CsvData {
29+
const islOsl = sequenceToIslOsl(sequence);
2330
const headers = [
31+
'Model',
32+
'ISL',
33+
'OSL',
2434
'Hardware',
2535
'Hardware Key',
2636
'Framework',
@@ -71,6 +81,9 @@ export function inferenceChartToCsv(data: InferenceData[]): CsvData {
7181
const rows = data
7282
.filter((d) => !d.hidden)
7383
.map((d) => [
84+
model,
85+
islOsl?.isl ?? '',
86+
islOsl?.osl ?? '',
7487
d.hw ?? '',
7588
d.hwKey,
7689
d.framework ?? '',

0 commit comments

Comments
 (0)