Skip to content
Draft
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
1 change: 1 addition & 0 deletions docs/charts-csv-to-json/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
40 changes: 40 additions & 0 deletions docs/charts-csv-to-json/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# csv to json conversion module for benchmarks

## Application logic (draft)

The principle is to pre-generate the conversion of the benchmarks csv to json so that the client only has to consume the data.

### Client side

On the client side, we only fetch converted json data, hosted on the static github pages.

Note:
- In the case of a download failure, default json data, with a speed of 0, is generated to avoid any anomalies and display the problem.
- However, a real data json file, the last one generated, should always be present on the site and accessible through the fetch.

### Node module for converting csv to json

First it is necessary to copy the new benchmarks csv file into the `input` directory of the module.
The module reads and parses the `csv` file and generates a `benchmark.json` file in the `/javascripts` directory of the site, before it is generated into a static site and deployed.

If an error occurs during this process, no json file will be generated, only error logs.
The default json file, or the previously generated file, will be used. In the worst case, 0 data will be displayed by the client.

## Point of attention to solve

Beware, the integration of the module in the `/docs` directory generates some side effects.
Some `node_modules` files potentially conflict with the site build (`The following pages exist in the docs directory, but are not included in the "nav" configuration:`) and pollute the static site `sitemap.xml`.

A solution is to be found.

## To do

- Find a solution to not pollute the build and the sitemap.xml
- Integrate the conversion in the build and deployment chain
- Perform unit tests to convert csv to json
- Bonus: typescript integration with Vite.

## Node version used

`lts/hydrogen`

42 changes: 42 additions & 0 deletions docs/charts-csv-to-json/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import fs from 'fs';
import Papa from 'papaparse'

const filepath = 'input/data.csv'
const resultFilepath = '../javascripts/benchmark.json'
const header = 'engine,batch,sequence,speed'

function writeResult(result) {
try {
fs.writeFileSync(resultFilepath, result);
console.log('csv conversion has been saved!');
} catch (error) {
console.error(`an error occurred while writing the json file :\n
${error}`);
}
}

function convertCSVtoJSON (){
try {
const csv = fs.readFileSync(filepath, 'utf8');
const csvWithHeader = `${header}\n${csv.trim()}`;

Papa.parse(csvWithHeader, {
complete: function (json) {
console.log('csv conversion complete!');
writeResult(JSON.stringify(json.data))
},
error: function (error) {
console.error(`an error occurred while parsing the csv file :\n
${JSON.stringify(error)}`);
},
delimiter: ',',
header: true,
dynamicTyping: true,
})
} catch (error) {
console.error(`an error occurred while reading the csv file :\n
${JSON.stringify(error)}`);
}
}

convertCSVtoJSON();
141 changes: 141 additions & 0 deletions docs/charts-csv-to-json/input/data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
Inductor,1,16,0.0018
Inductor,1,32,0.0020
Inductor,1,64,0.0020
Inductor,1,128,0.0025
Inductor,1,256,0.0030
Inductor,1,384,0.0036
Inductor,1,512,0.0048
Inductor,8,16,0.0023
Inductor,8,32,0.0027
Inductor,8,64,0.0039
Inductor,8,128,0.0065
Inductor,8,256,0.0117
Inductor,8,384,0.0156
Inductor,8,512,0.0212
Inductor,32,16,0.0039
Inductor,32,32,0.0062
Inductor,32,64,0.0108
Inductor,32,128,0.0177
Inductor,32,256,0.0357
AITemplate,1,16,0.0012
AITemplate,1,32,0.0012
AITemplate,1,64,0.0013
AITemplate,1,128,0.0015
AITemplate,1,256,0.0020
AITemplate,1,384,0.0022
AITemplate,1,512,0.0031
AITemplate,8,16,0.0013
AITemplate,8,32,0.0017
AITemplate,8,64,0.0026
AITemplate,8,128,0.0043
AITemplate,8,256,0.0076
AITemplate,8,384,0.0115
AITemplate,8,512,0.0149
AITemplate,32,16,0.0026
AITemplate,32,32,0.0043
AITemplate,32,64,0.0073
AITemplate,32,128,0.0127
AITemplate,32,256,0.0242
TensorRT,1,16,0.0010
TensorRT,1,32,0.0010
TensorRT,1,64,0.0011
TensorRT,1,128,0.0013
TensorRT,1,256,0.0016
TensorRT,1,384,0.0026
TensorRT,1,512,0.0026
TensorRT,8,16,0.0011
TensorRT,8,32,0.0015
TensorRT,8,64,0.0019
TensorRT,8,128,0.0036
TensorRT,8,256,0.0064
TensorRT,8,384,0.0139
TensorRT,8,512,0.0139
TensorRT,32,16,0.0020
TensorRT,32,32,0.0031
TensorRT,32,64,0.0054
TensorRT,32,128,0.0103
TensorRT,32,256,0.0210
DeepSpeed,1,16,0.0009
DeepSpeed,1,32,0.0008
DeepSpeed,1,64,0.0009
DeepSpeed,1,128,0.0012
DeepSpeed,1,256,0.0019
DeepSpeed,1,384,0.0023
DeepSpeed,1,512,0.0032
DeepSpeed,8,16,0.0011
DeepSpeed,8,32,0.0016
DeepSpeed,8,64,0.0025
DeepSpeed,8,128,0.0051
DeepSpeed,8,256,0.0106
DeepSpeed,8,384,0.0161
DeepSpeed,8,512,0.0219
DeepSpeed,32,16,0.0025
DeepSpeed,32,32,0.0050
DeepSpeed,32,64,0.0097
DeepSpeed,32,128,0.0176
DeepSpeed,32,256,0.0374
Baseline,1,16,0.00795173406600952
Cuda graphs,1,16,0.00106519103050232
Nvfuser,1,16,0.00355699706077576
Kernl,1,16,0.000644994974136352
ONNX Runtime,1,16,0.00239814496040344
Baseline,1,128,0.00808307266235352
Cuda graphs,1,128,0.00161654901504517
Nvfuser,1,128,0.00363480401039124
Kernl,1,128,0.00145257699489594
ONNX Runtime,1,128,0.00245641589164734
Baseline,1,256,0.00817633533477783
Cuda graphs,1,256,0.00291786408424377
Nvfuser,1,256,0.00357921099662781
Kernl,1,256,0.00198752295970917
ONNX Runtime,1,256,0.00270905590057373
Baseline,1,384,0.00817633533477783
Cuda graphs,1,384,0.00291786408424377
Nvfuser,1,384,0.00357921099662781
Kernl,1,384,0.00198752295970917
ONNX Runtime,1,384,0.00270905590057373
Baseline,1,512,0.00850767040252686
Cuda graphs,1,512,0.00442398595809937
Nvfuser,1,512,0.00375320100784302
Kernl,1,512,0.00254801301956177
ONNX Runtime,1,512,0.003773845911026
Baseline,8,16,0.00851109409332275
Cuda graphs,8,16,0.00164371204376221
Nvfuser,8,16,0.00403249311447144
Kernl,8,16,0.00136490595340729
ONNX Runtime,8,16,0.0024571259021759
Baseline,8,128,0.00816122531890869
Cuda graphs,8,128,0.00626455688476562
Nvfuser,8,128,0.00544208192825317
Kernl,8,128,0.00442465305328369
ONNX Runtime,8,128,0.00574171686172485
Baseline,8,256,0.0135426902770996
Cuda graphs,8,256,0.0131534404754639
Nvfuser,8,256,0.0103799543380737
Kernl,8,256,0.00705874919891357
ONNX Runtime,8,256,0.0111610059738159
Baseline,8,384,0.0192422294616699
Cuda graphs,8,384,0.0189292831420898
Nvfuser,8,384,0.0148918361663818
Kernl,8,384,0.0105360803604126
ONNX Runtime,8,384,0.0155409851074219
Baseline,8,512,0.0277956104278564
Cuda graphs,8,512,0.0273300457000732
Nvfuser,8,512,0.0203310241699219
Kernl,8,512,0.0137086231231689
ONNX Runtime,8,512,0.0207632541656494
Baseline,32,16,0.00819225311279297
Cuda graphs,32,16,0.00312871694564819
Nvfuser,32,16,0.00410407495498657
Kernl,32,16,0.00239948511123657
ONNX Runtime,32,16,0.00305436611175537
Baseline,32,128,0.019238655090332
Cuda graphs,32,128,0.0191719589233398
Nvfuser,32,128,0.0172065410614014
Kernl,32,128,0.0130825481414795
ONNX Runtime,32,128,0.017692741394043
Baseline,32,256,0.0431598892211914
Cuda graphs,32,256,0.042514949798584
Nvfuser,32,256,0.0349777145385742
Kernl,32,256,0.025843318939209
ONNX Runtime,32,256,0.0348241157531738
Loading