780d8bd012
initial version
Erik Schultheis
2024-04-14 03:48:56 +03:00
534b93a732
erase the old kernel to save LOC and do some renaming and adjust dev/cuda code to add the new largeC kernel as kernel 7
Andrej Karpathy
2024-04-13 22:02:31 +00:00
0554c7e414
Merge pull request #115 from ademeure/softmax_largeC
Andrej
2024-04-13 14:49:26 -07:00
fc3dce37ce
Add __ldcs to a few reads for which the memory will never be read again in the forward pass
ademeure
2024-04-13 22:38:12 +01:00
321b042657
New softmax for non-self-attention softmax case with large Cs
ademeure
2024-04-13 22:31:23 +01:00
c02bae2ebc
average iterates in code
Andrej Karpathy
2024-04-13 21:09:37 +00:00
c70fbd059b
refine comment on time
Andrej Karpathy
2024-04-13 21:09:25 +00:00
ca242a3d0b
get rid of spurious handle variable creation, remnant from before, and update README
Andrej Karpathy
2024-04-13 21:04:49 +00:00
c65d1d305b
Merge pull request #113 from ademeure/cublasTF32
Andrej
2024-04-13 13:56:13 -07:00
5ab44973b0
Fix cuBLAS calls to use pre-initialised handle with TF32 enabled (big perf gain)
ademeure
2024-04-13 20:35:53 +01:00
c5ee371564
make the tests own their cublas cublaslt handles and settings, instead of putting that stuff in common
Andrej Karpathy
2024-04-13 17:56:18 +00:00
82623518a4
fix comment block of gelu forward kernel
Andrej Karpathy
2024-04-13 17:48:53 +00:00
02b5b33c5f
remove unused variable C
Andrej Karpathy
2024-04-13 17:48:11 +00:00
84145411d3
fix crossentropy forward, loss requires probabilities so these floats must be 0..1 instead of -1..1 or we get nans
Andrej Karpathy
2024-04-13 17:47:19 +00:00
69f0385237
add comments and handling of kernels and their correctness
Andrej Karpathy
2024-04-13 17:44:31 +00:00
5364e0b853
change main train/test code to use new cublaslt functions. inference now causes segfault though, very strange have to fix before merge
Andrej Karpathy
2024-04-12 21:23:30 +00:00
8cf66fbb84
change workspace from 4mib to 32mib so we don't have to detect hopper. seems ok for now
Andrej Karpathy
2024-04-12 20:41:08 +00:00
bfd11ce5b6
use cublaslt and optionally tf32, which fuses bias and deprecates the need for add_bias kernel
Andrej Karpathy
2024-04-12 19:38:36 +00:00
8e87aac341
online softmax
Erik Schultheis
2024-04-12 12:47:48 +03:00
de98a9a44a
vector loads
Erik Schultheis
2024-04-12 11:24:56 +03:00
6396e393e3
add links to discussions
Andrej Karpathy
2024-04-12 01:11:29 +00:00
baba3cfa01
recalculate instead of memory round-trip
Erik Schultheis
2024-04-12 02:20:20 +03:00
69d0e5bac7
Include a parallel kernal of softmax_online
lancer
2024-04-11 15:30:36 -07:00
ca1e5ee04d
Include a parallel kernal of softmax_online
lancer
2024-04-11 15:24:41 -07:00
dec54904b4
one more simple clarifying comment
Andrej Karpathy
2024-04-11 22:24:38 +00:00
d680fbad25
one more comment on attention
Andrej Karpathy
2024-04-11 21:49:14 +00:00
9710163a60
did one pass of additional comments, potentially helpful, as i think a lot of people may be looking at this for the first time
Andrej Karpathy
2024-04-11 21:45:46 +00:00
5f99fb30d2
cooperative groups and fused scale kernel
Erik Schultheis
2024-04-11 22:11:28 +03:00
d6bcc129b9
Improve the efficiency
lancer
2024-04-11 12:16:20 -07:00
00010c7188
Improve the efficiency
lancer
2024-04-11 12:13:34 -07:00
2c81198101
make the new cooperative groups layernorm kernel the default. shaves off aonly bout 1ms of the total running time though
Andrej Karpathy
2024-04-11 18:23:46 +00:00
6f5ec063f0
Merge branch 'ngc92-layer-norm'
Andrej Karpathy
2024-04-11 18:22:40 +00:00
00b9fda4a1
ceildiv in layernorm
Andrej Karpathy
2024-04-11 18:21:34 +00:00
089cd5f1dd
make sure we also test correctness of mean and rstd and do it all block sizes
Andrej Karpathy
2024-04-11 18:12:26 +00:00
f28613e0b9
small edits to comments and variables
Andrej Karpathy
2024-04-11 18:09:54 +00:00
4e91362fa2
optionally generate mean and rstd
Erik Schultheis
2024-04-11 20:48:14 +03:00
f524a90de3
Include the online softmax CPU code (from the paper "Online normalizer calculation for softmax") and native port to GPU kernel. Both the CPU and GPU kernels' correctness are verified by executing the script.
lancer
2024-04-11 09:47:50 -07:00
79b8af4a9b
Merge pull request #56 from scotthaleen/omp-osx-intel
Andrej
2024-04-11 09:13:10 -07:00
21a250d372
Merge pull request #64 from krrishnarraj/master
Andrej
2024-04-11 09:12:07 -07:00
1751af1607
inline docs for sizes
Andrej Karpathy
2024-04-11 16:04:14 +00:00
bcd0dad6c8
Merge branch 'master' of github.com:karpathy/llm.c
Andrej Karpathy
2024-04-11 15:50:10 +00:00
f26cf00a61
make gelu constant be a #define, speeds up the kernel by 1% or so
Andrej Karpathy
2024-04-11 15:49:01 +00:00
f46d5b2e2a
Merge pull request #72 from Soldy/master
Andrej
2024-04-11 08:38:57 -07:00
3aaed922a3
-O3 cannot go with -Ofast
soldy
2024-04-11 16:27:59 +01:00
4542f8913a
[train_gpt2.py] synchronize based on device
Krishnaraj Bhat
2024-04-11 17:06:51 +05:30
47b2f9312c
fixed homebrew path for intel based macs
Scott Haleen
2024-04-10 23:01:07 -04:00
afddb1af5b
fixed block size and improved load op hint
Erik Schultheis
2024-04-11 03:47:38 +03:00
466723bb06
fully fused layer-norm kernel
Erik Schultheis
2024-04-11 00:36:48 +03:00
a08c11b60e
Merge pull request #48 from lancerts/fix_matmul
Andrej
2024-04-10 13:44:22 -07:00
68d2ce0601
fix error in small typos in matmul_forward.cu
lancer
2024-04-10 13:35:20 -07:00
ef7a4867b1
Merge branch 'master' of github.com:karpathy/llm.c
Andrej Karpathy
2024-04-10 19:25:13 +00:00
e1e0a08035
change fabs to fabsf
Andrej Karpathy
2024-04-10 19:23:18 +00:00
919b2200a0
Merge pull request #20 from varunlakkur/master
Andrej
2024-04-10 12:21:07 -07:00
9f5069d3b2
Merge pull request #38 from lancerts/fix_matmul
Andrej
2024-04-10 12:15:53 -07:00
c0d57b1c45
Merge pull request #47 from eltociear/patch-1
Andrej
2024-04-10 12:14:56 -07:00
add9e77daa
mention compilation issue that seems to be common. we may want to resolve this inside the Makefile though
Andrej Karpathy
2024-04-10 19:11:44 +00:00
fd8459d858
small gitignore for now. probably iterate on
Andrej Karpathy
2024-04-10 18:54:23 +00:00
15fad9bc96
Create LICENSE MIT
Andrej
2024-04-10 11:47:40 -07:00
80f52e5290
the full forward pass of GPT-2 in one file of pure CUDA
Andrej Karpathy
2024-04-10 18:15:55 +00:00
d8e2a36f15
ok crossentropy is fairly ez, just have to be careful with logs of negative numbers in debug tests. so this should be all the layers now
Andrej Karpathy
2024-04-10 01:13:20 +00:00
46ee0a3944
sorry there should be no mallocs inside these functions, have to pass in buffer memory from outside. getting tired
Andrej Karpathy
2024-04-10 00:55:14 +00:00
919ae1f27b
ok attention is now optimized too, by 20X, nice. actually this one was really painful, i had to make sure all the cuBLAS calls take all the right arguments and deal with the fact that cuBLAS is column major instead of row major. i go for nap now
Andrej Karpathy
2024-04-10 00:50:30 +00:00
fbd679adec
fix the consistency of the transpose notation
lancer
2024-04-09 15:19:55 -07:00
8386e5393c
intra-warp reductions and inter-warp shared memory reductions for B,T,C parallelism of softmax kernel nice
Andrej Karpathy
2024-04-09 20:08:11 +00:00
c29d70a9b3
add softmax forward, both a naive parallel over B,T version, and a more optimized parallel over B,T,C version using shared memory for reductions
Andrej Karpathy
2024-04-09 19:22:47 +00:00
327705d03f
mention ongoing cuda work in main readme
Andrej Karpathy
2024-04-09 18:29:24 +00:00
ea1fad0337
Merge pull request #33 from lancerts/fix_M_PI_undefined
Andrej
2024-04-09 11:25:23 -07:00
e3e0d73fbc
Merge pull request #34 from VinciGit00/patch-1
Andrej
2024-04-09 11:24:32 -07:00
bb4f04bdf8
add flash attention, but a naive implementation there of
Andrej Karpathy
2024-04-09 18:22:49 +00:00