openai/openai-gemm

Open single and half precision gemm implementations

C

397

14 commits

updated Apr 2, 2023

See the code

README

Status: Archive (code is provided as-is, no updates expected)

openai-gemm

Open single and half precision gemm implementations. The main speedups over cublas are with small minibatch and in fp16 data formats.

Quick Install

The demonstration code currently depends on Nervana neon:

git clone [email protected]:NervanaSystems/neon.git
cd neon
make
. .venv/bin/activate

Clone and run this repo:

git clone [email protected]:openai/openai-gemm.git

Run the benchmark:
./benchmark.py

Run the unit test:
./test.py

DeepBench on Pascal TITAN X

( https://github.com/baidu-research/DeepBench )

MNKOpOpenAI_32cuBLAS_32ratio_32OpenAI_16cuBLAS_16ratio_16
1617601760NN255721951.2350734610.1
3217601760NN501011284.4681452613.0
6417601760NN648641121.6823528012.9
12817601760NN706869311.0940053071.8
700017601760NN996895841.01051598071.1
1620482048NN256915161.7361924215.0
3220482048NN503413563.7657660610.8
6420482048NN663628152.4828532412.6
12820482048NN731663731.1906653341.7
700020482048NN1008199001.01127599481.1
1625602560NN271813122.1431225117.2
3225602560NN537016603.2752574910.0
6425602560NN733126872.784369518.9
12825602560NN800752381.5927761231.5
700025602560NN10282101311.01102799741.1
1640964096NN269511102.4444226616.7
3240964096NN526622642.3772375810.2
6440964096NN694239221.8890410558.4
12840964096NN812756861.4971156811.7
700040964096NN10462100821.01115299911.1
1617601760NT171910951.626922909.3
3217601760NT331613122.5506844711.3
6417601760NT524719552.7762117974.2
12817601760NT672033932.0888633422.7
700017601760NT934185131.11008596351.0
1620482048NT244212312.0364129912.2
3220482048NT480112513.8584946812.5
6420482048NT631719673.2782531282.5
12820482048NT717650411.4861648431.8
700020482048NT997591731.11074195601.1
1625602560NT183412081.5315429710.6
3225602560NT361014362.554185849.3
6425602560NT608328152.2833110428.0
12825602560NT770232462.4885752591.7
700025602560NT925778291.21065995481.1
1640964096NT254612972.0416430913.5
3240964096NT499222902.2815677510.5
6440964096NT674641571.6842913816.1
12840964096NT784354251.4929855271.7
700040964096NT992568791.41063097841.1
713317601760TN9752101861.01051789121.2
713320482048TN10485103191.01067496081.1
713325602560TN10743110571.011195100591.1
713340964096TN10384102901.010980105581.0
912451241760NN992094801.01058097431.1
912451242048NN1000894151.11060297961.1
912451242560NN992594261.11058698501.1
912451244096NN998294891.11058094721.1
912451241760NT909334972.6930286921.1
912451242048NT950665121.5950688831.1
912451242560NT870433642.6985577331.3
912451244096NT973361091.61027887601.2
8457351760NN334310203.338417365.2
8457352048NN341919961.747828036.0
8457352560NN341510723.238687894.9
8457354096NN374320091.947418045.9
8457351760NT357419701.8417612433.4
8457352048NT456430691.5481812553.8
8457352560NT359820621.7359711353.2
8457354096NT431129901.4492713033.8
1676802560NN26837183.7444928915.4
3276802560NN530436601.478379798.0
6476802560NN731149791.5931012747.3
12876802560NN793161091.3939065911.4
1676802560NT188511911.6340129011.7
3276802560NT373118082.1637310046.3
6476802560NT627435091.8880916555.3
12876802560NT795729882.7924646952.0
1630721024NN227712951.8337328212.0
3230721024NN449417982.560118077.4
6430721024NN627230462.167909177.4
12830721024NN736454361.4776857491.4
1630721024NT228510772.1343924414.1
3230721024NT459715403.056456778.3
6430721024NT639229692.2755512046.3
12830721024NT746050581.5858655351.6
743530721024TN982988041.11012393651.1
548176802560TN944893091.0946693941.0

DeepBench on DGX1 (P100)

Note that the OpenAI kernels do not yet implement fp16x2 instructions. Even still it seems the current cublas hgemm implentation is only good for large dimensions. There are also accuracy considerations when accumulating large reductions in fp16.

MNKOpOpenAI_32cuBLAS_32ratio_32OpenAI_16cuBLAS_16ratio_16
1617601760NN259520481.329354636.3
3217601760NN49638645.757668956.4
6417601760NN756539091.9776017114.5
12817601760NN814060531.3842240892.1
700017601760NN965387221.19617161430.6
1620482048NN225517461.332115465.9
3220482048NN446710124.4453310194.4
6420482048NN661841981.6659120183.3
12820482048NN805959211.4793646671.7
700020482048NN976193461.09910187150.5
1625602560NN288321081.442106856.1
3225602560NN570112794.5582012974.5
6425602560NN810060541.3809925583.2
12825602560NN830867991.2879059011.5
700025602560NN974095381.09845184990.5
1640964096NN344913422.6429910694.0
3240964096NN686320453.4690721033.3
6440964096NN840440592.1824841832.0
12840964096NN822480391.0885386691.0
700040964096NN981895191.010011185880.5
1617601760NT257913241.927634286.4
3217601760NT50898785.853828576.3
6417601760NT750130172.5769516954.5
12817601760NT804354941.5819234262.4
700017601760NT947775711.39355161130.6
1620482048NT226712761.831715046.3
3220482048NT448410264.4448910094.4
6420482048NT656739861.6655120183.2
12820482048NT801958251.4796844961.8
700020482048NT962593731.09713178780.5
1625602560NT287014602.042566386.7
3225602560NT561412994.3570512714.5
6425602560NT801444021.8808525213.2
12825602560NT821956401.5824051371.6
700025602560NT953490911.09735180250.5
1640964096NT336615472.2435410474.2
3240964096NT671420553.3685920933.3
6440964096NT829734452.4828941782.0
12840964096NT833574501.1791179731.0
700040964096NT957892141.09877180730.5
713317601760TN970492671.09506156050.6
713320482048TN974798361.010012191100.5
713325602560TN974297481.09805191070.5
713340964096TN980797331.010122195590.5
912451241760NN932690761.09631174960.6
912451242048NN941490541.09602175230.5
912451242560NN935390411.09698173800.6
912451244096NN937090511.09689176170.5
912451241760NT912487461.09524167770.6
912451242048NT929488171.19641169350.6
912451242560NT922184991.19637168200.6
912451244096NT927089611.09568170800.6
8457351760NN330122331.5450531541.4
8457352048NN326530661.1450133351.3
8457352560NN312723001.4451631351.4
8457354096NN325732721.0472934851.4
8457351760NT456331421.5461229981.5
8457352048NT455432021.4460131091.5
8457352560NT456731441.5465430391.5
8457354096NT435334151.3445732571.4
1676802560NN366812003.1502012364.1
3276802560NN724533852.1751924653.1
6476802560NN844052101.6834949101.7
12876802560NN876548721.89131113490.8
1676802560NT322915152.1503211574.3
3276802560NT664027212.4681023073.0
6476802560NT828251131.6836244941.9
12876802560NT876346461.9861791590.9
1630721024NN292917171.733357504.4
3230721024NN580113994.1611614204.3
6430721024NN695843401.6692328142.5
12830721024NN804764921.2776963021.2
1630721024NT299010682.833847054.8
3230721024NT583414294.1602114114.3
6430721024NT692135002.0689328192.4
12830721024NT791860341.3787657601.4
743530721024TN936793911.09559172340.6
548176802560TN967295201.09967188320.5

openai/openai-gemm

Open single and half precision gemm implementations

C

397

14 commits

updated Apr 2, 2023

See the code

README

Status: Archive (code is provided as-is, no updates expected)

openai-gemm

Open single and half precision gemm implementations. The main speedups over cublas are with small minibatch and in fp16 data formats.

Quick Install

The demonstration code currently depends on Nervana neon:

git clone [email protected]:NervanaSystems/neon.git
cd neon
make
. .venv/bin/activate

Clone and run this repo:

git clone [email protected]:openai/openai-gemm.git

Run the benchmark:
./benchmark.py

Run the unit test:
./test.py

DeepBench on Pascal TITAN X

( https://github.com/baidu-research/DeepBench )

MNKOpOpenAI_32cuBLAS_32ratio_32OpenAI_16cuBLAS_16ratio_16
1617601760NN255721951.2350734610.1
3217601760NN501011284.4681452613.0
6417601760NN648641121.6823528012.9
12817601760NN706869311.0940053071.8
700017601760NN996895841.01051598071.1
1620482048NN256915161.7361924215.0
3220482048NN503413563.7657660610.8
6420482048NN663628152.4828532412.6
12820482048NN731663731.1906653341.7
700020482048NN1008199001.01127599481.1
1625602560NN271813122.1431225117.2
3225602560NN537016603.2752574910.0
6425602560NN733126872.784369518.9
12825602560NN800752381.5927761231.5
700025602560NN10282101311.01102799741.1
1640964096NN269511102.4444226616.7
3240964096NN526622642.3772375810.2
6440964096NN694239221.8890410558.4
12840964096NN812756861.4971156811.7
700040964096NN10462100821.01115299911.1
1617601760NT171910951.626922909.3
3217601760NT331613122.5506844711.3
6417601760NT524719552.7762117974.2
12817601760NT672033932.0888633422.7
700017601760NT934185131.11008596351.0
1620482048NT244212312.0364129912.2
3220482048NT480112513.8584946812.5
6420482048NT631719673.2782531282.5
12820482048NT717650411.4861648431.8
700020482048NT997591731.11074195601.1
1625602560NT183412081.5315429710.6
3225602560NT361014362.554185849.3
6425602560NT608328152.2833110428.0
12825602560NT770232462.4885752591.7
700025602560NT925778291.21065995481.1
1640964096NT254612972.0416430913.5
3240964096NT499222902.2815677510.5
6440964096NT674641571.6842913816.1
12840964096NT784354251.4929855271.7
700040964096NT992568791.41063097841.1
713317601760TN9752101861.01051789121.2
713320482048TN10485103191.01067496081.1
713325602560TN10743110571.011195100591.1
713340964096TN10384102901.010980105581.0
912451241760NN992094801.01058097431.1
912451242048NN1000894151.11060297961.1
912451242560NN992594261.11058698501.1
912451244096NN998294891.11058094721.1
912451241760NT909334972.6930286921.1
912451242048NT950665121.5950688831.1
912451242560NT870433642.6985577331.3
912451244096NT973361091.61027887601.2
8457351760NN334310203.338417365.2
8457352048NN341919961.747828036.0
8457352560NN341510723.238687894.9
8457354096NN374320091.947418045.9
8457351760NT357419701.8417612433.4
8457352048NT456430691.5481812553.8
8457352560NT359820621.7359711353.2
8457354096NT431129901.4492713033.8
1676802560NN26837183.7444928915.4
3276802560NN530436601.478379798.0
6476802560NN731149791.5931012747.3
12876802560NN793161091.3939065911.4
1676802560NT188511911.6340129011.7
3276802560NT373118082.1637310046.3
6476802560NT627435091.8880916555.3
12876802560NT795729882.7924646952.0
1630721024NN227712951.8337328212.0
3230721024NN449417982.560118077.4
6430721024NN627230462.167909177.4
12830721024NN736454361.4776857491.4
1630721024NT228510772.1343924414.1
3230721024NT459715403.056456778.3
6430721024NT639229692.2755512046.3
12830721024NT746050581.5858655351.6
743530721024TN982988041.11012393651.1
548176802560TN944893091.0946693941.0

DeepBench on DGX1 (P100)

Note that the OpenAI kernels do not yet implement fp16x2 instructions. Even still it seems the current cublas hgemm implentation is only good for large dimensions. There are also accuracy considerations when accumulating large reductions in fp16.

MNKOpOpenAI_32cuBLAS_32ratio_32OpenAI_16cuBLAS_16ratio_16
1617601760NN259520481.329354636.3
3217601760NN49638645.757668956.4
6417601760NN756539091.9776017114.5
12817601760NN814060531.3842240892.1
700017601760NN965387221.19617161430.6
1620482048NN225517461.332115465.9
3220482048NN446710124.4453310194.4
6420482048NN661841981.6659120183.3
12820482048NN805959211.4793646671.7
700020482048NN976193461.09910187150.5
1625602560NN288321081.442106856.1
3225602560NN570112794.5582012974.5
6425602560NN810060541.3809925583.2
12825602560NN830867991.2879059011.5
700025602560NN974095381.09845184990.5
1640964096NN344913422.6429910694.0
3240964096NN686320453.4690721033.3
6440964096NN840440592.1824841832.0
12840964096NN822480391.0885386691.0
700040964096NN981895191.010011185880.5
1617601760NT257913241.927634286.4
3217601760NT50898785.853828576.3
6417601760NT750130172.5769516954.5
12817601760NT804354941.5819234262.4
700017601760NT947775711.39355161130.6
1620482048NT226712761.831715046.3
3220482048NT448410264.4448910094.4
6420482048NT656739861.6655120183.2
12820482048NT801958251.4796844961.8
700020482048NT962593731.09713178780.5
1625602560NT287014602.042566386.7
3225602560NT561412994.3570512714.5
6425602560NT801444021.8808525213.2
12825602560NT821956401.5824051371.6
700025602560NT953490911.09735180250.5
1640964096NT336615472.2435410474.2
3240964096NT671420553.3685920933.3
6440964096NT829734452.4828941782.0
12840964096NT833574501.1791179731.0
700040964096NT957892141.09877180730.5
713317601760TN970492671.09506156050.6
713320482048TN974798361.010012191100.5
713325602560TN974297481.09805191070.5
713340964096TN980797331.010122195590.5
912451241760NN932690761.09631174960.6
912451242048NN941490541.09602175230.5
912451242560NN935390411.09698173800.6
912451244096NN937090511.09689176170.5
912451241760NT912487461.09524167770.6
912451242048NT929488171.19641169350.6
912451242560NT922184991.19637168200.6
912451244096NT927089611.09568170800.6
8457351760NN330122331.5450531541.4
8457352048NN326530661.1450133351.3
8457352560NN312723001.4451631351.4
8457354096NN325732721.0472934851.4
8457351760NT456331421.5461229981.5
8457352048NT455432021.4460131091.5
8457352560NT456731441.5465430391.5
8457354096NT435334151.3445732571.4
1676802560NN366812003.1502012364.1
3276802560NN724533852.1751924653.1
6476802560NN844052101.6834949101.7
12876802560NN876548721.89131113490.8
1676802560NT322915152.1503211574.3
3276802560NT664027212.4681023073.0
6476802560NT828251131.6836244941.9
12876802560NT876346461.9861791590.9
1630721024NN292917171.733357504.4
3230721024NN580113994.1611614204.3
6430721024NN695843401.6692328142.5
12830721024NN804764921.2776963021.2
1630721024NT299010682.833847054.8
3230721024NT583414294.1602114114.3
6430721024NT692135002.0689328192.4
12830721024NT791860341.3787657601.4
743530721024TN936793911.09559172340.6
548176802560TN967295201.09967188320.5

Significant stargazers

Valentin Churavy

674 followers · starred Apr 2017

Jerry Zhang

295 followers · starred May 2017

Yuxin Wu

4,004 followers · starred Nov 2016

Xiaoyu Zhang

2,858 followers · starred Jun 2021