Skip to content

Instantly share code, notes, and snippets.

@msaroufim
Created April 10, 2024 03:40
Show Gist options
  • Save msaroufim/5defcd59aed4364846d034ac01eb6cfd to your computer and use it in GitHub Desktop.
Save msaroufim/5defcd59aed4364846d034ac01eb6cfd to your computer and use it in GitHub Desktop.
~ nvcc -O3 --use_fast_math attention_forward.cu -o attention_forward -lcublas
⚡ ~ ./attention_forward 1
Using kernel 1
-0.529510 -0.529510
0.889394 0.889394
0.881674 0.881674
0.651789 0.651789
-0.483486 -0.483486
Results match!
block_size 32 | time 7618.906250 ms
block_size 64 | time 11382.442383 ms
block_size 128 | time 11235.234375 ms
block_size 256 | time 11093.875977 ms
block_size 512 | time 10809.315430 ms
⚡ ~ ./attention_forward 2
Using kernel 2
-0.529510 -0.529510
0.889394 0.889394
0.881674 0.881674
0.651789 0.651789
-0.483486 -0.483486
Results match!
block_size 32 | time 3552.755859 ms
block_size 64 | time 3552.081543 ms
block_size 128 | time 3551.476074 ms
block_size 256 | time 3551.784668 ms
block_size 512 | time 3551.921875 ms
⚡ ~ ./attention_forward 3
Using kernel 3
-0.529510 -0.529510
0.889394 0.889394
0.881674 0.881674
0.651789 0.651789
-0.483486 -0.483486
Results match!
block_size 32 | time 80.599907 ms
block_size 64 | time 65.582977 ms
block_size 128 | time 63.635326 ms
block_size 256 | time 63.573471 ms
block_size 512 | time 63.550114 ms
⚡ ~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment