Commit Graph
100 Commits
Author SHA1 Message Date
Andrej 9755682b98 Merge pull request #463 from goswamig/test1
Fixing eval path in README
2024-06-03 09:51:52 -07:00
Andrej 3ab86ce851 Merge branch 'master' into test1 2024-06-03 09:50:45 -07:00
Andrej 7c7e627108 Merge pull request #487 from jellehak/patch-1
Update README.md
2024-06-03 09:47:17 -07:00
Andrej 325be85d9b Merge pull request #420 from vinjn/fix-371-enc-is-not-defined
Move enc to gloabal namespace to fix #371
2024-02-27 09:27:01 -08:00
Andrej a022d02ee2 Merge pull request #429 from adambala/fixes
Open "shakespeare" data in UTF-8 in "prepare.py"
2024-02-27 09:05:44 -08:00
Andrej f68ac2200d Merge pull request #428 from kjslag/memmap-memory-leak
fix np.memmap memory leak
2024-02-27 08:41:24 -08:00
Andrej eba36e8464 Merge pull request #309 from ho2103/master
Fix AssertionError on macOS - need to check CUDA availability for bf16
2023-06-22 08:24:17 -07:00
Andrej 4eb7a96b07 Merge pull request #305 from okuvshynov/fix_osx_dataload
nanogpt: fix multiprocessing in load_dataset on os x
2023-06-17 20:26:35 -07:00
Andrej 41d7014f7d Merge pull request #301 from okuvshynov/master
[easy] allow multithreading in load_dataset
2023-06-16 18:30:03 -07:00
Andrej Karpathy 7339b904ef use WORLD_SIZE instead of device_count, supports both the case where the number of gpus we train on is smaller than gpus available, and also multinode training may be a bugfix 2023-06-14 23:33:07 +00:00
Andrej f08abb45bd Merge pull request #274 from apivovarov/gelu
Use nn.GELU - 1.27x faster training
2023-06-14 16:25:15 -07:00
Andrej 18ee6b62b6 Merge pull request #275 from apivovarov/rm_unsqueeze
Remove pos unsqueeze(0)
2023-06-14 15:38:45 -07:00
Andrej ed7887c888 Merge pull request #270 from LaihoE/master
fix np.sum overflows on windows
2023-06-14 15:36:26 -07:00
Andrej 8020bb582b Merge pull request #276 from apivovarov/gitign
Add more files to .gitignore
2023-06-14 15:30:39 -07:00
Andrej 0f06d9b889 Merge pull request #277 from apivovarov/is_bf16_supported
Use bf16 only if supported
2023-06-14 15:29:50 -07:00
Andrej cf4835ed6f Merge pull request #286 from ctjlewis/master
docs: simplify dependencies installation
2023-06-14 15:21:04 -07:00
Andrej Karpathy 7fe4a099ad simplify configure_optimizers by a lot 2023-05-06 14:40:28 +00:00
Andrej 196160b849 Merge pull request #247 from gnobre/macbook-run-instructions
Macbook run instructions
2023-04-17 20:16:31 -07:00
Andrej 21f9bff7e4 Merge pull request #225 from otaviogood/grad_accum
Fix for gradient_accumulation_steps training slow
2023-04-17 20:11:25 -07:00
Andrej a6a708c7f1 Merge branch 'master' into grad_accum 2023-04-17 20:11:00 -07:00
Andrej d9f4735f5e Merge pull request #10 from LaihoE/master
batch file write
2023-04-13 00:39:41 -07:00
Andrej b288f4cfb2 Merge pull request #146 from lutzroeder/master
Add .gitignore
2023-04-12 22:48:37 -07:00
Andrej 079df20748 Merge pull request #74 from venusatuluri/fix_decode
Small fix to decode fn in shakespeare_char/prepare.py
2023-04-12 22:45:01 -07:00
Andrej 01e48ec1ab Merge pull request #240 from YassineYousfi/master
don't dropout in eval mode
2023-04-12 22:43:59 -07:00
Andrej 7840a66859 Merge pull request #54 from MicroPanda123/luv
Give tqdm some love :)
2023-04-12 22:25:18 -07:00
Andrej 8abe215fba Merge pull request #128 from abrahamsangha/fix-typo
fix typo
2023-04-12 22:24:41 -07:00
Andrej ad62003d7a Merge pull request #142 from kovkev/patch-1
Fix the position of a comma
2023-04-12 22:24:06 -07:00
Andrej ea24604b29 Merge pull request #220 from python273/patch-1
Fix GPT.crop_block_size when flash attention is available
2023-04-12 22:13:01 -07:00
Andrej 8aeea6d970 Merge pull request #224 from SnehalRaj/patch-1
fix small typo
2023-04-12 22:12:26 -07:00
Andrej 2457471c9c Merge pull request #236 from ymurenko/master
fix "cuda out of memory" when resuming training
2023-04-12 22:09:42 -07:00
Andrej Karpathy 553f949f46 fix minor bug where we have to scale the loss to account for gradient accumulation, which sums before backprop. note that this is not a major bug because AdamW is scale invariant. however, this did affect gradient clipping 2023-04-13 04:59:11 +00:00
Andrej a82b33b525 Merge pull request #199 from ChristianOrr/patch-1
bugfix in decode function
2023-03-12 13:40:20 -07:00
Andrej 0d8fbd11ae Merge pull request #195 from drisspg/enable_sdpa_with_nonzero_dropout
Enable sdpa for nonzero dropout
2023-03-06 21:47:20 -08:00
Andrej ae3a8d5fdd Merge pull request #145 from otaviogood/gradAccumStability
fix for training stability on single GPU
2023-02-14 18:48:54 -08:00
Andrej Karpathy 55c5069696 fix misinformation in readme 2023-02-10 16:34:46 +00:00
Andrej Karpathy e58f0cfa94 oops i should not be needing or multiplying by world_size to calculate mfu 2023-02-07 21:38:39 +00:00
Andrej Karpathy 8b1e43209e small tweaks, make default WD be 0.1 as is often cited, and remove spurious init of LayerNorm, which is already initialized at 1,0 2023-02-06 23:07:25 +00:00
Andrej Karpathy ab21d6c15d bugfix we have to call the raw_model's estimate_mfu ty @jprobichaud for original PR 2023-02-06 19:55:35 +00:00
Andrej Karpathy f83dd034e1 also add a sampling/inference section 2023-02-05 21:02:30 +00:00
Andrej Karpathy 23a8e701d2 revamp the readme file to be a bit better and more accessible, i hope 2023-02-05 19:31:32 +00:00
Andrej Karpathy fce706cbe6 tune the hyperparams a bit, in configs 2023-02-05 19:31:18 +00:00
Andrej Karpathy ab0718a7dd add the estimation of model flops utilization (MFU), a very commonly looked at metric that estimates the token throughput in units of A100 bfloat16 peak flops (312 TFLOPS). this gives us a sense of the hardware utilization we're achieving 2023-02-05 00:48:58 +00:00
Andrej Karpathy 580902617c oops optimizer now demands to know device_type 2023-02-05 00:43:15 +00:00
Andrej Karpathy 34720df284 make more accurate the way in which we count parameters. previous count incorrectly included the positional encoding params, when typically only the number of weight parameters is reported for these models 2023-02-04 23:51:18 +00:00
Andrej Karpathy 3341b4cecc oops forgot to subtract embedding params, which don't enter the 6ND equation 2023-02-04 22:33:35 +00:00
Andrej Karpathy 5a162bc773 fix silly error, i don't want to confuse a future GPT training on this notebook in the future 2023-02-04 22:11:16 +00:00
Andrej Karpathy 0bb96d3fff add reference for 6ND to notebook too 2023-02-04 22:07:32 +00:00
Andrej Karpathy eae986c2d2 new notebook with a bunch of calculations related to flops and memory of Transformer 2023-02-04 22:02:53 +00:00
Andrej Karpathy a74e8363a2 clean up TODOs a bit, they are stale 2023-02-04 21:11:25 +00:00
Andrej Karpathy 25d95dbd65 mildly dramatic refactor for handing all these usage cases across all possible supported and unsupported devices for all the possible switches and flags 2023-02-04 21:06:17 +00:00
Andrej Karpathy e108ffb973 very slight refactor, bit cleaner 2023-02-04 19:34:24 +00:00
Andrej dc149891b6 Merge pull request #120 from nynyg/remove_cpu_pin_mem
Pin memory only when training on GPU
2023-02-04 11:28:08 -08:00
Andrej Karpathy 77e7e04c26 padding 50257 -> 50304 vocab_size, the nerest multiple of 64. the biggest deal smallest optimization i've made in recent past, about 25% faster. this is because the last layer is a major latency bottleneck consuming about 40% of latency due to the very high channel count. 2023-02-04 16:06:18 +00:00
Andrej Karpathy b3c17c6c6a slight tweak compressing LOC 2023-02-04 15:57:29 +00:00
Andrej 53d56b82f1 Merge pull request #116 from ramtingh/master
Minor change to allow using ddp with exclusive process mode
2023-02-04 07:42:32 -08:00
Andrej Karpathy 3fd4c0c5ef who needs a dataloader? overlap the prefetching of the next batch with GPU compute, ehiding the data loading latency entirely. this saves about 1ms lol 2023-02-04 02:52:48 +00:00
Andrej 46428d3142 Merge pull request #115 from akashmjn/akashmjn/fix-notebook-stats
add template .gitattributes that fixes language stats
2023-02-03 17:23:44 -08:00
Andrej Karpathy 3969860ff5 include launch command too. anyone should be able to do this now 2023-02-03 22:17:05 +00:00
Andrej Karpathy f9348f3f18 add gpt2 training config 2023-02-03 22:14:37 +00:00
Andrej Karpathy e170e40872 use the new fused AdamW from pytorch nightly, if available 2023-02-03 17:56:51 +00:00
Andrej 7d44bdf6b5 Merge pull request #106 from YassineYousfi/master
use the ``enabled`` arg in GradScaler
2023-02-02 17:23:22 -08:00
Andrej Karpathy 1e87509e47 if dropout > 0.0 disable Flash until pytorch fix. don't assert fail sigh 2023-02-02 23:22:56 +00:00
Andrej Karpathy d8b1a94519 change grad accum to default off because i think it just confuses everyone 2023-02-02 18:38:49 +00:00
Andrej Karpathy d01863ef01 small usability tweaks to bench 2023-02-02 17:23:46 +00:00
Andrej Karpathy d995c22128 fix bug with loading GPT-2 parameters, assert gets incorrectly tripped due to .bias missing since it is now optionally present depending on flash or not 2023-02-01 02:05:34 +00:00
Andrej Karpathy 038ce89438 rename iter to it, because iter is a concrete Python builtin 2023-01-31 23:34:02 +00:00
Andrej Karpathy d2705bd92a tune cited numbers and reproductions and more explicitly point out the problems w.r.t. the OWT vs WT domain gap 2023-01-31 21:57:07 +00:00
Andrej Karpathy 4386bce1f4 adjust teaser figure with a more tuned result 2023-01-31 21:43:30 +00:00
Andrej Karpathy 924a0873eb merge, make cleaner, careful with gradient clipping when using grad scaler fp16 training 2023-01-30 23:40:35 +00:00
Andrej Karpathy ae06d0b15a add flash attention support, resolving last few issues but for now seems to work ok 2023-01-30 23:18:26 +00:00
Andrej Karpathy 0e90ee9d48 based on my experiments these biases are indeed not needed. code runs faster, identical results. keeping the option just because it deviates from the gpt-2 setup 2023-01-30 08:07:58 +00:00
Andrej Karpathy 001c1e7be7 stay true to the README file and set grad accum to 5, so the default batch size is about 0.5M and is reproducing gpt2 2023-01-27 20:51:50 +00:00
Andrej Karpathy 79dbe0086d let me set bias=True until I validate it properly, but this should be ok to merge to master for now, is equivalent to previous functionality 2023-01-27 20:45:28 +00:00
Andrej Karpathy e808a67149 bunch of plumbing of bias all around. measuring bias=False to be about 6% faster 2023-01-27 20:41:17 +00:00
Andrej Karpathy cc5444e194 add the bias option to config, default it to True for now 2023-01-27 20:29:45 +00:00
Andrej Karpathy 2bf07a3fbf rewrite model class so layernorm has an optional bias= parameter 2023-01-27 20:17:32 +00:00
Andrej Karpathy 2892858ce7 attempt a non-biased model, per few papers that cite this as working well 2023-01-27 18:54:08 +00:00
Andrej Karpathy f29a9ff5bf ok i tried bringing back original init again and this time it makes a ton of difference and works much better than default. i'm not sure what was different with my earlier experiment where i saw a slight regression. may try to dissect commits later, for now merged the original mingpt init (following gpt-2 paper) as default. 2023-01-27 17:56:18 +00:00
Andrej Karpathy 23a0bfac20 try bring back mingpt init 2023-01-27 16:52:18 +00:00
Andrej Karpathy 3cb3fc059c grad clipping seems to slightly speed up training in the beginning but i can't see a big difference later in the training. it costs non-negligeable compute to clip. adding it for now because it is standard, and i think more necessary as the model becomes larger. practitioners may consider turning it off for minor efficiency gains 2023-01-27 16:45:09 +00:00
Andrej Karpathy e0c689cf38 allow the prompt to compe from a file 2023-01-25 01:12:43 +00:00
Andrej Karpathy 21675d7755 allow sample.py to init from a pretrained gpt2 checkpoints as well, in similar style to train.py 2023-01-25 00:55:29 +00:00
Andrej 6c40a08b41 Merge pull request #82 from danielgross/master
Missed two spots while relative pathing
2023-01-22 13:47:32 -08:00
Andrej 3611338959 Merge pull request #71 from cchan/patch-1
Zero-grad more aggressively to save memory
2023-01-20 14:38:10 -08:00
Andrej Karpathy 1f77d03024 make mentions of mps in docs. ty good people in issue #28 2023-01-20 21:28:20 +00:00
Andrej a6bffeee59 Merge pull request #73 from danielgross/master
Use relative paths
2023-01-20 12:21:33 -08:00
Andrej Karpathy 2c7806db6e for consistency with previous commit 2023-01-19 23:10:51 +00:00
Andrej c1c20a0311 Merge pull request #57 from ryouze/patch-1
Improve readability of huge numbers
2023-01-19 15:08:35 -08:00
Andrej 9e150b808e Merge pull request #66 from PWhiddy/patch-1
fix typo ( params -> tokens)
2023-01-18 22:29:51 -08:00
Andrej Karpathy 8dd2061e4d fix temperature comment, slightly wrong 2023-01-18 16:10:05 +00:00
Andrej Karpathy 2b083fbfde the badge is a bit ugly, move it down to troubleshooting section 2023-01-18 03:16:59 +00:00
Andrej Karpathy aa8e4c2546 screwed up the link, fix 2023-01-18 03:11:31 +00:00
Andrej Karpathy 6dab32c003 experimenting with badges, and discord link to start specifically. issues sometimes feel a little too heavy 2023-01-18 03:09:42 +00:00
Andrej Karpathy 7f74652843 add docs on multinode training to main README too 2023-01-16 17:11:02 +00:00
Andrej Karpathy 46ce9971df small tweaks to docs and variable names stylistically 2023-01-16 16:56:05 +00:00
Andrej Karpathy 684800dd87 clarify that these should be run on two separate machines 2023-01-16 06:02:46 +00:00
Andrej Karpathy 9352df23de docs for multinode ddp 2023-01-16 05:57:33 +00:00
Andrej Karpathy c3dddbff3d get rid of gpu_id, the world is more complicated than that when world_size > 8 2023-01-16 05:44:50 +00:00
Andrej Karpathy f5e6ac8b02 local rank -> rank 2023-01-16 05:13:13 +00:00
Andrej Karpathy cf99914886 add gradient accumulation support to simulate larger batch sizes. ty @VHellendoorn for original PR 2023-01-15 17:49:55 +00:00