KellerJordan/modded-nanogpt

GitHub: KellerJordan/modded-nanogpt

一个以极致速度训练小型GPT语言模型为目标的竞争性研究项目,汇集社区力量不断刷新训练效率纪录。

Stars: 5182 | Forks: 735

# Modded-NanoGPT 本仓库托管了 *NanoGPT 速度挑战赛*,在此活动中,我们(以合作或竞争的方式)寻找最快的算法,使用 8 块 NVIDIA H100 GPU 训练一个语言模型,使其在 [FineWeb](https://huggingface.co/datasets/HuggingFaceFW/fineweb) 验证集上达到 3.28 的交叉熵损失。 该目标(在 FineWeb 上达到 3.28 验证损失)源于 Andrej Karpathy 的 [在 llm.c 中复现 GPT-2,该复现在运行 45 分钟后达到了该损失](https://github.com/karpathy/llm.c/discussions/481#:~:text=By%20the%20end%20of%20the%20optimization%20we%27ll%20get%20to%20about%203.29)。 速度挑战赛的代码同样源自 llm.c 的 [PyTorch 训练器](https://github.com/karpathy/llm.c/blob/master/train_gpt2.py),而后者又源自 NanoGPT,这也是本仓库得名的原因。 得益于众多贡献者的努力,本仓库现在包含了一种训练算法,该算法在以下条件下即可达到目标性能: * 在 8xH100 上不到 90 秒(llm.c 的 GPT-2 复现需要 45 分钟) * 在不到 4 亿 (400M) 个 token 上(llm.c 的 GPT-2 复现需要 100 亿 (10B) 个) 以下技术带来了训练速度的上述提升: * 现代化架构:Rotary embeddings、QK-Norm 和 ReLU² * Muon 优化器 [[介绍文章](https://kellerjordan.github.io/posts/muon/)] [[仓库](https://github.com/KellerJordan/Muon)] * 在 head 中使用 FP8 matmul,以及非对称缩放 和 softcap logits * 将投影层初始化为零(类似 muP) * 从 embedding 到每个 block 的跳跃连接,以及从 block 3 到 block 6 的跳跃连接 * 混合入注意力层 values 中的额外 embeddings(受 Zhou 等人 2024 年的论文启发) * Flash Attention 3 与长短滑动窗口注意力机制(受 Gemma 2 启发),以及使用 YaRN 的窗口大小预热 * 将训练批次的起始位置与 EoS 对齐,并设置最大文档长度 * 在更新参数前,为 embedding 和 lm_head 累积 2 步的梯度 * Backout,为最后 3 个注意力层提供单一激活输入 * 在 Muon 中的 Polar Express 实现 * 启用 1 个 token 回溯的 Smear 模块 * 稀疏注意力门 * NorMuon * 谨慎的权重衰减,其调度表与 LR 相关联 * 残差流的指数衰减 * 批大小调度表 * 最大序列长度调度表 * Partial Key Offset * Multi token prediction * 在训练进行到 2/3 时解开 embed 和 lm_head 的绑定 * 针对 value embeddings 和跳跃连接的额外门控 * Paired head attention * Bigram hash embedding 以及许多系统层面的优化。 贡献者名单(随着每一次新纪录的产生而不断增加):[@bozavlado](https://x.com/bozavlado); [@brendanh0gan](https://x.com/brendanh0gan); [@fernbear.bsky.social](https://bsky.app/profile/fernbear.bsky.social); [@Grad62304977](https://x.com/Grad62304977); [@jxbz](https://x.com/jxbz); [@kellerjordan0](https://x.com/kellerjordan0); [@KoszarskyB](https://x.com/KoszarskyB); [@leloykun](https://x.com/@leloykun); [@YouJiacheng](https://x.com/YouJiacheng); [@jadenj3o](https://x.com/jadenj3o); [@KonstantinWilleke](https://github.com/KonstantinWilleke), [@alexrgilbert](https://github.com/alexrgilbert), [@adricarda](https://github.com/adricarda), [@tuttyfrutyee](https://github.com/tuttyfrutyee), [@vdlad](https://github.com/vdlad); [@ryanyang0](https://x.com/ryanyang0), [@vagrawal](https://github.com/vagrawal), [@classiclarryd](https://x.com/classiclarryd), [@byronxu99](https://github.com/byronxu99), [@varunneal](https://x.com/varunneal), [@EmelyanenkoK](https://github.com/EmelyanenkoK), [@bernard24](https://github.com/bernard24)/https://www.hiverge.ai/, [@Gusarich](https://x.com/Gusarich), [@li_zichong](https://x.com/li_zichong), [@akash5474](https://github.com/akash5474), [@snimu](https://x.com/omouamoua), [@roeeshenberg](https://x.com/roeeshenberg), [@ChrisJMcCormick](https://x.com/ChrisJMcCormick), [@dominikkallusky](https://github.com/dominikkallusky), [@acutkosky](https://github.com/acutkosky), [@manikbhandari](https://github.com/manikbhandari), [@andrewbriand](https://x.com/andrewbriand8), [@jrauvola](https://x.com/Joshrav21), [@soren_dunn_](https://x.com/soren_dunn_), [@photon_mz](https://x.com/photon_mz), [@srashedll](https://x.com/srashedll), [@dhrvji](https://x.com/dhrvji), [@EmmettBicker](https://github.com/EmmettBicker), [@dualverse-ai](https://github.com/dualverse-ai), [@sisovicm](https://x.com/sisovicm), [@moof2x](https://github.com/moof2x), [@samacqua](https://github.com/samacqua) ## 运行当前纪录 要运行当前纪录,请执行以下命令。 ``` git clone https://github.com/KellerJordan/modded-nanogpt.git && cd modded-nanogpt pip install -r requirements.txt # 仅下载前 900M 训练 tokens 以节省时间 python data/cached_fineweb10B.py 9 ./run.sh ``` 如果 ./run.sh 提示 `torchrun: command not found` 错误,请将 torchrun 添加到环境变量 PATH 中。 **注意:首次运行代码时,torch.compile 会增加大约 7 分钟的延迟。** 官方纪录的计时均在来自 https://app.primeintellect.ai/ 的 8 块 NVIDIA H100 GPU 上进行。PrimeIntellect 慷慨赞助了近期的验证运行。 ## 替代方案:使用 Docker 运行(推荐用于精确计时) 如果 CUDA 或 NCCL 版本与您当前的系统设置不兼容,Docker 可能会是一个有用的替代方案。 这种方法标准化了 CUDA、NCCL、CUDNN 和 Python 的版本,减少了依赖问题并简化了设置过程。 注意:系统上必须已经安装了 NVIDIA 驱动程序(如果只有 NVIDIA 驱动程序和 Docker 可用,这将非常有用)。 ``` git clone https://github.com/KellerJordan/modded-nanogpt.git && cd modded-nanogpt sudo docker build -t modded-nanogpt . sudo docker run -it --rm --gpus all -v $(pwd):/modded-nanogpt modded-nanogpt python data/cached_fineweb10B.py 8 sudo docker run -it --rm --gpus all -v $(pwd):/modded-nanogpt modded-nanogpt sh run.sh ``` 要获取交互式的 docker 环境,您可以使用 ``` sudo docker run -it --rm --gpus all -v $(pwd):/modded-nanogpt modded-nanogpt bash ``` ## 世界纪录历史 以下是针对以下竞速任务的世界速度纪录的历史进展: 注意:选择 3.28 作为目标是与 [Andrej Karpathy 的 GPT-2 (small) 复现](https://github.com/karpathy/llm.c/discussions/481) 保持一致。 | # | 纪录时间 | 描述 | 日期 | 日志 | 贡献者 | | - | - | - | - | - | - | 1 | 45 分钟 | [llm.c baseline](https://github.com/karpathy/llm.c/discussions/481) | 05/28/24 | [log](records/track_1_short/2024-10-13_llmc/main.log) | @karpathy, llm.c contributors 2 | 31.4 分钟 | [调整了学习率并引入 rotary embeddings](https://x.com/kellerjordan0/status/1798863559243513937) | 06/06/24 | [log](records/track_1_short/2024-06-06_AdamW/f66d43d7-e449-4029-8adf-e8537bab49ea.log) | @kellerjordan0 3 | 24.9 分钟 | [引入了 Muon 优化器](https://x.com/kellerjordan0/status/1842300916864844014) | 10/04/24 | none | @kellerjordan0, @jxbz 4 | 22.3 分钟 | [Muon 的改进](https://x.com/kellerjordan0/status/1844820919061287009) | 10/11/24 | [log](records/track_1_short/2024-10-10_Muon/eb5659d0-fb6a-49e5-a311-f1f89412f726.txt) | @kellerjordan0, @bozavlado 5 | 15.2 分钟 | [填充 embeddings、ReLU²、零初始化投影、QK-norm](https://x.com/kellerjordan0/status/1845865698532450646) | 10/14/24 | [log](records/track_1_short/2024-10-14_ModernArch/dabaaddd-237c-4ec9-939d-6608a9ed5e27.txt) | @Grad62304977, @kellerjordan0 6 | 13.1 分钟 | [分散 Muon 的开销](https://x.com/kellerjordan0/status/1847291684016783746) | 10/18/24 | [log](records/track_1_short/2024-10-17_DistributedMuon/22d24867-eb5a-4fcc-ae2c-263d0277dfd1.txt) | @kellerjordan0 7 | 12.0 分钟 | [升级到 PyTorch 2.5.0](https://x.com/kellerjordan0/status/1847358578686152764) | 10/18/24 | [log](records/track_1_short/2024-10-18_PyTorch25/d4bfb25f-688d-4da5-8743-33926fad4842.txt) | @kellerjordan0 8 | 10.8 分钟 | [解绑 embedding 和 head](https://x.com/kellerjordan0/status/1853188916704387239) | 11/03/24 | [log](records/track_1_short/2024-11-03_UntieEmbed/d6b50d71-f419-4d26-bb39-a60d55ae7a04.txt) | @Grad62304977, @kellerjordan0 9 | 8.2 分钟 | [Value 和 embedding 跳跃连接、动量预热、logit softcap](https://x.com/kellerjordan0/status/1854296101303800108) | 11/06/24 | [log](records/track_1_short/2024-11-06_ShortcutsTweaks/dd7304a6-cc43-4d5e-adb8-c070111464a1.txt) | @Grad62304977, @kellerjordan0 10 | 7.8 分钟 | [Bfloat16 激活](https://x.com/kellerjordan0/status/1855267054774865980) | 11/08/24 | [log](records/track_1_short/2024-11-08_CastBf16/a833bed8-2fa8-4cfe-af05-58c1cc48bc30.txt) | @kellerjordan0 11 | 7.2 分钟 | [U-net 模式跳跃连接和双倍 lr](https://x.com/kellerjordan0/status/1856053121103093922) | 11/10/24 | [log](records/track_1_short/2024-11-10_UNetDoubleLr/c87bb826-797b-4f37-98c7-d3a5dad2de74.txt) | @brendanh0gan 12 | 5.03 分钟 | [1024-ctx 密集因果注意力 → 64K-ctx FlexAttention](https://x.com/kellerjordan0/status/1859331370268623321) | 11/19/24 | [log](records/track_1_short/2024-11-19_FlexAttention/8384493d-dba9-4991-b16b-8696953f5e6d.txt) | @KoszarskyB 13 | 4.66 分钟 | [注意力窗口预热](https://x.com/hi_tysam/status/1860851011797053450) | 11/24/24 | [log](records/track_1_short/2024-11-24_WindowWarmup/cf9e4571-c5fc-4323-abf3-a98d862ec6c8.txt) | @fernbear.bsky.social 14 | 4.41 分钟 | [Value Embeddings](https://x.com/KoszarskyB/status/1864746625572257852) | 12/04/24 | [log](records/track_1_short/2024-12-04_ValueEmbed) | @KoszarskyB 15 | 3.95 分钟 | [U-net 模式 value embeddings,各类代码优化](https://x.com/YouJiacheng/status/1865761473886347747) | 12/08/24 | [log](records/track_1_short/2024-12-08_UNetValueEmbedsTweaks) | @leloykun, @YouJiacheng 16 | 3.80 分钟 | [分割 value embeddings、分块滑动窗口、独立的 block mask](https://x.com/YouJiacheng/status/1866734331559071981) | 12/10/24 | [log](records/track_1_short/2024-12-10_MFUTweaks) | @YouJiacheng 17 | 3.57 分钟 | [稀疏化 value embeddings、改进 rotary embeddings、移除一个 attn 层](https://x.com/YouJiacheng/status/1868938024731787640) | 12/17/24 | [log](records/track_1_short/2024-12-17_SparsifyEmbeds) | @YouJiacheng 18 | 3.4 分钟 | [将 logit softcap 从 30 降低到 15](https://x.com/kellerjordan0/status/1876048851158880624) | 01/04/25 | [log](records/track_1_short/2025-01-04_SoftCap/31d6c427-f1f7-4d8a-91be-a67b5dcd13fd.txt) | @KoszarskyB 19 | 3.142 分钟 | [FP8 head,偏移 logits,lr 衰减至 0.1 而不是 0.0](https://x.com/YouJiacheng/status/1878827972519772241) | 01/13/25 | [log](records/track_1_short/2025-01-13_Fp8LmHead/c51969c2-d04c-40a7-bcea-c092c3c2d11a.txt) | @YouJiacheng 20 | 2.992 分钟 | [合并 QKV 权重、长短注意力、注意力缩放、降低 Adam epsilon、批量 Muon](https://x.com/leloykun/status/1880301753213809016) | 01/16/25 | [log](records/track_1_short/2025-01-16_Sub3Min/1d3bd93b-a69e-4118-aeb8-8184239d7566.txt) | @leloykun, @fernbear.bsky.social, @YouJiacheng, @brendanh0gan, @scottjmaddox, @Grad62304977 21 | 2.933 分钟 | [减少批大小](https://x.com/leloykun/status/1885640350368420160) | 01/26/25 | [log](records/track_1_short/2025-01-26_BatchSize/c44090cc-1b99-4c95-8624-38fb4b5834f9.txt) | @leloykun 21 | 2.997 分钟 | 使用新计时的第 21 项纪录 | 02/01/25 | [log](records/track_1_short/2025-02-01_RuleTweak/eff63a8c-2f7e-4fc5-97ce-7f600dae0bc7.txt) | 非新纪录,只是使用[更新后的规则](#timing-change-after-record-21)对 #21 重新计时 21 | 3.014 分钟 | 使用最新版 torch 的第 21 项纪录 | 05/24/25 | [log](records/track_1_short/2025-05-24_StableTorch/89d9f224-3b01-4581-966e-358d692335e0.txt) | 非新纪录,只是使用最新版 torch 对 #21 重新计时 22 | 2.990 分钟 | [更快的梯度 all-reduce](https://x.com/KonstantinWille/status/1927137223238909969) | 05/24/25 | [log](records/track_1_short/2025-05-24_FasterReduce/23f40b75-06fb-4c3f-87a8-743524769a35.txt) | @KonstantinWilleke, @alexrgilbert, @adricarda, @tuttyfrutyee, @vdlad; The Enigma 项目 23 | 2.979 分钟 | [重叠计算与梯度通信](https://x.com/kellerjordan0/status/1927460573098262616) | 05/25/25 | [log](records/track_1_short/2025-05-25_EvenFasterReduce/6ae86d05-5cb2-4e40-a512-63246fd08e45.txt) | @ryanyang0 24 | 2.966 分钟 | 用 reduce_scatter 替换梯度 all_reduce | 05/30/25 | [log]() | @vagrawal 25 | 2.896 分钟 | 将 PyTorch 升级到 2.9.0.dev20250713+cu126 | 07/13/25 | [log](records/track_1_short/2025-07-13_UpgradeTorch190/692f80e0-5e64-4819-97d4-0dc83b7106b9.txt) | @kellerjordan0 26 | 2.863 分钟 | 将训练批次起始点与 EoS 对齐,将 cooldown 分数提高到 .45 | 07/13/25 | [log](records/track_1_short/2025-07-12_BosAlign/c1fd8a38-bb9f-45c4-8af0-d37f70c993f3.txt) | @classiclarryd 27 | 2.817 分钟 | 转置其中一个 MLP 矩阵 + 为对称 matmul 添加 Triton 内核 | 07/18/25 | [log](records/track_1_short/2025-07-18_TritonMuon/record.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/109) | @byronxu99 28 | 2.812 分钟 | 稀疏注意力门 | 08/23/25 | [log](records/track_1_short/2025-08-23_SparseAttnGate/020630eb-2191-4ba2-9ee4-4cdc94316943.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/117) | @classiclarryd 29 | 2.731 分钟 | Flash Attention 3,2048 max_doc_len,更新 ws 调度表 | 09/03/25 | [log](records/track_1_short/2025-09-03_FA3/44fc1276-0510-4961-92c0-730c65e5feba.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/118) | @varunneal 30 | 2.717 分钟 | 移除第一个 MLP 层 | 09/05/25 | [log](records/track_1_short/2025-09-05_SkipMLPBlocks/07e7ae76-b7d0-4481-b149-01e7d81b5ad4.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/120) | @EmelyanenkoK 31 | 2.656 分钟 | 在训练和验证中动态引入 YaRN | 09/10/25 | [log](records/track_1_short/2025-09-10_Yarn/0ecdb695-510b-4c3b-b030-09861a162ce8.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/122) | @classiclarryd 32 | 2.625 分钟 | 优化分布式训练,改进跳跃连接门控,增强 bfloat16 的使用 | 09/11/25 | [log](records/track_1_short/2025-09-11_VectSigmoidBFloat16/0d0d9882-c34f-4d82-b961-a17d5659c988.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/125) | @bernard24 & AI 系统 [hiverge.ai](https://www.hiverge.ai/) 33 | 2.565 分钟 | 异步获取并索引数据批次,扩展验证时的最后一层注意力窗口 | 09/15/25 | [log](records/track_1_short/2025-09-15_AsyncDataLoadAttnFinalWindow/25db37c7-2bab-4ef4-ae63-d593590ef823.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/127) | @classiclarryd 34 | 2.547 分钟 | 将 token embeddings 向前平移 1 个位置 | 09/18/25 | [log](records/track_1_short/2025-09-18_Smear/18a1e5c7-947e-479d-bc3a-a57a61a98fc9.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/130) | @classiclarryd 35 | 2.527 分钟 | 移除第一个 attn 层,扩展所有用于验证的长窗口,更新调度表 | 09/21/25 | [log](records/track_1_short/2025-09-21_DropAttn/01fc4a96-f2a0-47a1-8a6a-c7d10bac99fe.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/131) | @classiclarryd 36 | 2.495 分钟 | MuonCustomSizing,在共享调用中执行 mlp 和 attn 的 reduce scatter | 09/23/25 | [log](records/track_1_short/2025-09-23_MuonCustomSizing/b067b4ac-72a6-4436-a6f8-ea51c1efeef3.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/132) | @classiclarryd 37 | 2.483 分钟 | 在训练期间以 BF16 计算交叉熵 | 09/27/25 | [log](records/track_1_short/2025-09-27_BF16CE/08c0770f-17fc-44cd-971d-734a7a28a3e3.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/133) | @Gusarich 38 | 2.476 分钟 | Polar Express,替代 Newton-Schulz | 09/29/25 | [log](records/track_1_short/2025-09-29_PolarExpress/0e3f0af5-ad08-47a6-813d-0c709b50d422.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/134) | @varunneal 39 | 2.447 分钟 | 仅每隔一步更新 Adam 参数,减少批大小 | 09/30/25 | [log](records/track_1_short/2025-09-30_CustomBatching/40b101b1-77ea-45ea-a089-1d3a647daa22.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/136) | @classiclarryd 40 | 2.358 分钟 | Backout,杂项超参数调优,优化 lambda 填充 | 10/04/25 | [log](records/track_1_short/2025-10-04_Backout/514e7581-fbd4-4338-a3e4-e556f9c958ce.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/140) | @classiclarryd 41 | 2.345 分钟 | [NorMuon](https://arxiv.org/pdf/2510.05491) | 10/24/25 | [log](records/track_1_short/2025-10-24_NorMuon/088a77ee-9b67-475a-bbb9-3e92e4698799.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/144) | @li_zichong 42 | 2.313 分钟 | 更新 NorMuon LR,步进逻辑 | 10/27/25 | [log](records/track_1_short/2025-10-27_FixMuonLR/14afd380-d3d9-48d7-ad23-4c13cb96754b.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/146) | @varunneal 43 | 2.284 分钟 | 谨慎的权重衰减及调度表 | 11/10/25 | [log](records/track_1_short/2025-11-10_CautiousWD/1aac0132-a891-4ed9-b358-0fd2abd1b019.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/154) | @varunneal 44 | 2.269 分钟 | Adam 上的反向钩子,[性能分析 101](https://blog.underfit.ai/profiling-101-nanogpt) | 11/16/25 | [log](records/track_1_short/2025-10-31_AdamSyncGradientHook/0c17cdfd-772c-4906-8d11-141b370599a0.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/149) | @akash5474 45 | 2.248 分钟 | 改进跳跃架构,更新指数衰减初始化| 11/18/25 | [log](records/track_1_short/2025-11-18_RefineSkip/00f4e1e6-0044-4a08-b88a-3b7ec0624081.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/159) | @classiclarryd 46 | 2.203 分钟 | [批大小调度表](https://x.com/classiclarryd/status/1998212158770065844) | 11/29/25 | [log](records/track_1_short/2025-11-29_BatchSizeSchedule/10e8f7c6-7175-4467-bdb0-a5de25d771a6.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/163) | @varunneal 47 | 2.193 分钟 | [用权重而不是数据乘以 attn lambda,修复预热](https://x.com/classiclarryd/status/1999630732814348451) | 12/10/25 | [log](records/track_1_short/2025-12-10_SALambdaOnWeights/15ef5eaf-56e1-40e1-9ddf-af010027c9dd.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/166) | @roeeshenberg 48 | 2.170 分钟 | [加速 Muon,额外的预乘 lambda,重塑矩阵,更新 lr,更新 NorMuon 轴](https://x.com/classiclarryd/status/2000272495644152317) | 12/11/25 | [log](records/track_1_short/2025-12-11_NorMuonOptimsAndFixes/82edf6be-f343-475d-b93a-47c32acf4de2.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/168) | @ChrisJMcCormick 49 | 2.146 分钟 | [Partial Key Offset](https://x.com/classiclarryd/status/2000841339299402142) | 12/14/25 | [log](records/track_1_short/2025-12-14_PartialKeyOffset/150d40bf-c20b-4568-aac9-26eb919e25fd.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/169) | @classiclarryd 50 | 2.128 分钟 | [将谨慎的权重衰减扩展到 Adam 参数](https://x.com/classiclarryd/status/2002482925741486381) | 12/18/25 | [log](records/track_1_short/2025-12-18_CautiousWDAdam/1981d492-bc65-4ba9-a0fa-2b30fc5c3eba.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/172) | @roeeshenberg 51 | 2.075 分钟 | [重新绑定 Embed 到 lm_head,重新调优 fp8 缩放](https://x.com/classiclarryd/status/2003167208483209668) | 12/19/25 | [log](records/track_1_short/2025-12-19_RetieLMHead/0828d309-ecfe-4442-9ee9-68fed3a4b599.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/175) | @varunneal 52 | 2.037 分钟 | [通过增加 beta 来平滑标量,降低 smear 门控 lr,在转换期间冻结标量,adam all reduce](https://x.com/classiclarryd/status/2003863282613190656) | 12/21/25 | [log](records/track_1_short/2025-12-21_SmoothedScalars/12-21-Smoothed-Scalars/0bc6e909-8ee8-4ae3-ac62-0070e151a808.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/177) | @ChrisJMcCormick 53 | 1.988 分钟 | [Multi-token prediction,在训练 2/3 时解绑 embed/lm_head,lr 更新,微调 CWD](https://x.com/classiclarryd/status/2004248941878296580) | 12/22/25 | [log](records/track_1_short/2025-12-22_MultiTokenPrediction/17aaf854-f338-4d0d-9767-a5db30fd7980.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/178) | @varunneal, feat. @classiclarryd 54 | 1.940 分钟 | [非对称 Logit 缩放](https://x.com/classiclarryd/status/2004791008098480232) | 12/26/25 | [log](records/track_1_short/2025-12-26_LogitRescale/03e41c2d-2951-4546-a599-24cd723247fc.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/181) | @classiclarryd 55 | 1.918 分钟 | [Value embeds 和跳跃连接上的门控](https://x.com/classiclarryd/status/2005659526960492638) | 12/29/25 | [log](records/track_1_short/2025-12-29_VeSkipGates/2851d7dc-d6a5-4e74-8623-57031425db16.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/186) | @classiclarryd 56 | 1.894 分钟 | [优化并编译 Adam,提高 Adam 缓冲区精度,将门控从 Muon 移至 Adam 参数库](https://x.com/classiclarryd/status/2007882371576873445) | 12/31/25 | [log](records/track_1_short/2025-12-31_GatesToCompiledAdam/12-31-gates-to-adam-20stps/219a5f2f-151e-4c56-ab91-3735ae4610b8.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/187) | @ChrisJMcCormick 57 | 1.878 分钟 | [Bfloat16 attn/mlp 权重,混合精度 Muon,交织 Adam/Muon,更细粒度的 Adam beta](https://x.com/classiclarryd/status/2008261904566022590) | 01/04/26 | [log](records/track_1_short/2026-01-04_MixedPrecisionInterweavedOptimizer/41f606b6-1b9c-46a3-b46e-2beff1521d18.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/190) | @classiclarryd, feat. @YouJiacheng, @ChrisJMcCormick 58 | 1.820 分钟 | [Paired Head Attention](https://x.com/classiclarryd/status/2008963501688324228) | 01/07/26 | [log](records/track_1_short/2026-01-07_PairedHeadAttention/2a5d5cde-db5f-4aab-a4a8-cc8e183ea671.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/191) | @classiclarryd 59 | 1.781 分钟 | [用于线性 relu 平方 MLP 步骤的融合 triton 内核](https://x.com/classiclarryd/status/2010545452832407943) | 01/10/26 | [log](records/track_1_short/2026-01-10_FusedLinearReLUSquare/3c47e63b-075e-4b5b-9c76-9dbe7bad9ad4.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/197) | @andrewbriand8, @Joshrav21 60 | 1.765 分钟 | [用于带 softcap 的 multi-token prediction 交叉熵步骤的融合 triton 内核](https://x.com/classiclarryd/status/2012927211448516796) | 01/16/26 | [log](records/track_1_short/2026-01-16_FusedSoftcappedEntropy/45beba56-93e2-4995-bc5b-caff3cb2c1b5.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/199) | @soren_dunn_ & AI 系统 [Locus](https://www.intology.ai/blog/previewing-locus) 61 | 1.748 分钟 | [统一优化器和转置 LM Head](https://x.com/classiclarryd/status/2013399457841160702) | 01/18/26 | [log](records/track_1_short/2026-01-18_UnifiedOptimizers/unified-optimizer/2fc79469-a527-4bde-8540-8426ed3352d1.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/200) | @ChrisJMcCormick 62 | 1.655 分钟 | [Bigram Hash Embedding](https://x.com/classiclarryd/status/2013520088297558274) | 01/19/26 | [log](records/track_1_short/2026-01-19_BigramHashEmbedding/40ec7bb6-14b3-46f8-90b7-bb5ed188faba.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/201) | @classiclarryd 63 | 1.650 分钟 | [解绑 Value Embeds](https://x.com/classiclarryd/status/2016968386476200301) | 01/26/26 | [log](records/track_1_short/2026-01-26-UntieValueEmbeddings/43955d93-6914-40cb-bdf8-786ace93784f.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/209) | @photon_mz 64 | 1.630 分钟 | [调优非零 Attn V 和 O 初始化](https://x.com/classiclarryd/status/2017735338601726357) | 01/30/26 | [log](records/track_1_short/2026-01-30_MimeticValueOutput/runs/0f262f64-20c4-4268-9ae7-d7440c810abd.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/214) | @srashedll 65 | 1.613 分钟 | [将 Value Embeds 分组为单一参数](https://x.com/classiclarryd/status/2018057653742920016) | 01/30/26 | [log](records/track_1_short/2026-01-30_VeFused/0ba09d92-4ef1-440f-85e3-9d2766294db4.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/215) | @varunneal 66 | 1.595 分钟 | Torch 2.10 | 01/31/26 | - | - 67 | 1.540 分钟 | [调优融合 softcap 内核并在 LM head 中融合 fp8 量化](https://x.com/classiclarryd/status/2021015642472869978) | 01/31/26 | [log](records/track_1_short/2026-01-24_ImprovedLMHead/record/73a071ac-522d-4ce0-a4d6-cf3955a376e4.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/207) | @andrewbriand8 68 | 1.535 分钟 | [将 bigram hash 移至 GPU](https://x.com/classiclarryd/status/2021450730117460439) | 01/31/26 | [log](records/track_1_short/2026-01-31-BigramHashH2D/112c686e-b0d6-4dc8-814a-1ad1f5d5b274.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/216) | @dhrvji 69 | 1.528 分钟 | [内核优化](https://x.com/classiclarryd/status/2023319358303510719) | 02/02/26 | [log](records/track_1_short/2026-02-02_KernelTuning/25afb73a-332f-4d69-b9ab-f6261497f2d8.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/217) | @EmmettBicker & AI 系统 [Aster](https://www.asterlab.ai/) 70 | 1.521 分钟 | [调优 value embed 布局和 ve_gates](https://x.com/classiclarryd/status/2023319358303510719) | 02/03/26 | [log](records/track_1_short/2026-02-03_VeTuned/42cbebac-0599-4a89-a00e-26d1c4cad140.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/218) | @photon_mz 71 | 1.516 分钟 | [稀疏 bigram 梯度通信和优化的 CPU 加载](https://x.com/classiclarryd/status/2023319358303510719) | 02/06/26 | [log](records/track_1_short/2026-02-06_SparseBigramGradient/02fee7bd-cd22-478b-9e8e-12e857ff3152.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/221) | @roeeshenberg 72 | 1.496 分钟 | [提高最小 lr 并添加 max_seq_len 调度表](https://x.com/classiclarryd/status/2023319358303510719) | 02/10/26 | [log](records/track_1_short/2026-02-10_ShortWindow/Short-Window_1_1.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/224) | @dualverse-ai & AI 系统 [Station](https://github.com/dualverse-ai/station) 73 | 1.485 分钟 | [分区超连接]() | 02/12/26 | [log](records/track_1_short/2026-02-12_ParallelResiduals/451050db-d471-49db-b19b-be824bb896d0.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/230) | @sisovicm 74 | 1.468 分钟 | [扁平化 GPT 前向传播,移除 post attention lambdas,添加转置内核](https://x.com/classiclarryd/status/2027228782483182059) | 02/16/26 | [log](records/track_1_short/2026-02-16_FlattenForward/pr233/2026-02-16_21-30-05_time-362_secs_F-inject-post-attn_9f12a3.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/233) | @ChrisJMcCormick 75 | 1.453 分钟 | [交叉熵内核优化](https://x.com/classiclarryd/status/2030087884854939947) | 02/23/26 | [log](records/track_1_short/2026-02-23_CrossEntropyKernel/1e51be6b-7dd4-41ab-b95d-e57da5814776.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/235) | @moof2x 76 | 1.446 分钟 | [重用并调优反向转置内核](https://x.com/classiclarryd/status/2030403421027852337) | 02/28/26 | [log](records/track_1_short/2026-02-28_TransposeCopyBackward/this_pr/14c9cefc-c840-493f-870e-61bb1d2b1d97.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/240) | @samacqua 77 | 1.435 分钟 | [用单一保存的激活替换分区超连接](https://x.com/classiclarryd/status/2030465730718908884) | 03/06/26 | [log](records/track_1_short/2026-03-06_SimplifyHC/0ab4a843-8c3a-4fb4-9fff-8e1d39852646.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/241) | @classiclarryd 78 | 1.426 分钟 | [收窄 fa3 max_num_docs 的边界以匹配 fineweb 分布](https://x.com/classiclarryd/status/2038077427180851240) | 03/22/26 | [log](records/track_1_short/2026-03-22_VarlenMaxDocs/combined/2026-03-22_20-07-32_time-186_secs_06-mbeta2-max-docs_227ce8.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/246) | @ChrisJMcCormick 79 | 1.411 分钟 | 融合交叉熵 前向/反向内核,以避免在 softcap sigmoid 上重新计算 | 04/04/26 | [log](records/track_1_short/2026-04-04_FuseCEFwdAndBwd/runs/19ad9161-37c0-4985-8dd4-6db4e27f34b4.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/251) | @andrewbriand8 80 | 1.406 分钟 | 在 Muon 中成对正交化 Q 和 K 矩阵,而不是在整个 6 head 矩阵上进行 | 04/08/26 | [log](records/track_1_short/2026-04-08_PairedHeadMuon/logs/split_qk0-1480.txt),[PR](https://github.com/KellerJordan/modded-nanogpt/pull/253) | samacqua ## 规则 新纪录必须满足: 1. 不得修改训练或验证的数据流水线。(您可以更改批大小、序列长度、注意力结构等;但不要更改底层的 token 流。) 2. 达到 ≤3.28 的平均验证损失。(由于运行间的差异,提交必须提供足够多的运行日志,以使其平均验证损失 ≤3.28 达到 p<0.01 的统计显著性水平。计算 p 值的示例代码可以在[这里](records/track_1_short/2025-01-04_SoftCap#softer-softcap)找到。对于通过优化系统性能来提高速度而不涉及 ML 的提交,此要求可免。) 3. 不使用任何额外的 `torch._inductor.config` 或 `torch.compile` 标志。(这些可以节省几秒钟,但也会使编译耗时超过 30 分钟。此规则是在第 21 项纪录之后引入的。) 4. 在相同硬件基准测试下,运行速度必须快于先前的纪录。 PR 可能不被接受的酌情原因: 1. 过度降低了代码库的可读性。用 200 行内核代码换取 300ms 的提升被认为是值得的。但为了 50ms 的提升而用 500 行代码把优化器的布局弄得错综复杂,很可能会被拒绝。 2. 当前的纪录有意将损失保持在比 3.28 低约 0.001-0.002 的水平,以简化验证过程。如果某个 PR 大量消耗了这个缓冲,那么在同等损失下测量时,其表现应当优于简单的步数减少。 除此之外,任何事情都是允许的! [进一步说明](https://github.com/KellerJordan/modded-nanogpt/discussions/23?sort=new#discussioncomment-12109560) ### 关于目标指标的说明 目标指标是 *FineWeb 验证集上的交叉熵损失*。用数学的话来说,这项速度挑战赛的目标是 *获得一个语言概率模型,该模型分配给 FineWeb 验证集前 10,485,760 个 token 的概率至少为 `math.exp(-3.28 * 10485760)`。因此,例如,我们允许在任何序列长度下进行评估,只要我们仍然拥有一个有效的语言概率模型。 ### 第 21 项纪录之后的计时更改 在第 21 项纪录之后,我们对计时进行了两项更改。首先,过去有一个初始的“宽限期”,包含 10 个不计时的步骤以允许内核预热。我们用一个显式的、不计时的、使用虚拟数据的内核预热部分代替了它。这导致额外的 10 个计时步骤增加了 850ms 的运行时间。 其次,我们禁止使用 `torch._inductor.config.coordinate_descent_tuning`。这节省了约 25 分钟的不计时预运行编译,但会导致约 3 秒的额外运行时间。