热门话题
#
Bonk 生态迷因币展现强韧势头
#
有消息称 Pump.fun 计划 40 亿估值发币,引发市场猜测
#
Solana 新代币发射平台 Boop.Fun 风头正劲

Andrej Karpathy
建筑@EurekaLabsAI。曾任人工智能总监@特斯拉,创始团队@OpenAI,CS231n/博士@斯坦福大学。我喜欢训练大型深度神经网络。
启用了 fp8 训练,使得 "时间到 GPT-2" 提升了 +4.3%,现在降至 2.91 小时。值得注意的是,如果使用 8XH100 的现货实例价格,这个 GPT-2 重现的成本实际上仅为 ~$20。这真令人兴奋 -
GPT-2(7年前):太危险,无法发布。
GPT-2(今天):新的 MNIST!:)
这肯定可以低于 1 小时。
关于 fp8 再多说几句,它比我预期的要复杂一些,我花了一些时间才接触到它,即使现在我也不完全确定这是否是个好主意,因为对它的整体支持较少。从理论上讲,H100 上的 fp8 是 2 倍的 FLOPS,但在实践中要少得多。我们在实际训练过程中并不是 100% 受计算限制,增加的规模转换带来了额外的开销,GPT-2 规模的 GEMM 不够大,无法使开销显得明显值得,当然 - 在较低精度下,每一步的质量较小。对于行级缩放配方,fp8 与 bf16 的损失曲线非常接近,但速度略慢。对于张量级缩放,损失曲线分离得更多(即每一步的质量更差),但至少我们现在获得了约 7.3% 的加速。你可以通过增加训练范围(你训练更多步骤,但每一步更快)来天真地恢复性能,并希望最终能有所收获。在这种情况下,总体而言,稍微调整这些配方和训练范围后,我最终得到了约 5% 的加速。torchao 在他们的论文中报告 Llama3-8B fp8 训练加速为 25%(相比我的 ~7.3%,未考虑能力),这更接近我最初的期望,尽管 Llama3-8B 是一个更大的模型。这可能不是 fp8 传奇的结束。通过精确选择应用它的层,并在整个网络中更仔细地处理数值,应该可以改善情况。

Andrej Karpathy2月1日 04:55
nanochat can now train GPT-2 grade LLM for <<$100 (~$73, 3 hours on a single 8XH100 node).
GPT-2 is just my favorite LLM because it's the first time the LLM stack comes together in a recognizably modern form. So it has become a bit of a weird & lasting obsession of mine to train a model to GPT-2 capability but for much cheaper, with the benefit of ~7 years of progress. In particular, I suspected it should be possible today to train one for <<$100.
Originally in 2019, GPT-2 was trained by OpenAI on 32 TPU v3 chips for 168 hours (7 days), with $8/hour/TPUv3 back then, for a total cost of approx. $43K. It achieves 0.256525 CORE score, which is an ensemble metric introduced in the DCLM paper over 22 evaluations like ARC/MMLU/etc.
As of the last few improvements merged into nanochat (many of them originating in modded-nanogpt repo), I can now reach a higher CORE score in 3.04 hours (~$73) on a single 8XH100 node. This is a 600X cost reduction over 7 years, i.e. the cost to train GPT-2 is falling approximately 2.5X every year. I think this is likely an underestimate because I am still finding more improvements relatively regularly and I have a backlog of more ideas to try.
A longer post with a lot of the detail of the optimizations involved and pointers on how to reproduce are here:
Inspired by modded-nanogpt, I also created a leaderboard for "time to GPT-2", where this first "Jan29" model is entry #1 at 3.04 hours. It will be fun to iterate on this further and I welcome help! My hope is that nanochat can grow to become a very nice/clean and tuned experimental LLM harness for prototyping ideas, for having fun, and ofc for learning.
The biggest improvements of things that worked out of the box and simply produced gains right away were 1) Flash Attention 3 kernels (faster, and allows window_size kwarg to get alternating attention patterns), Muon optimizer (I tried for ~1 day to delete it and only use AdamW and I couldn't), residual pathways and skip connections gated by learnable scalars, and value embeddings. There were many other smaller things that stack up.
Image: semi-related eye candy of deriving the scaling laws for the current nanochat model miniseries, pretty and satisfying!

258
nanochat 现在可以以 <<$100 (~$73,单个 8XH100 节点上 3 小时) 的价格训练 GPT-2 级别的 LLM。
GPT-2 是我最喜欢的 LLM,因为这是 LLM 堆栈首次以可识别的现代形式结合在一起。因此,我对以更便宜的价格训练一个具有 GPT-2 能力的模型产生了一种奇怪而持久的痴迷,受益于大约 7 年的进展。特别是,我怀疑今天应该可以以 <<$100 的价格训练一个。
最初在 2019 年,GPT-2 是由 OpenAI 在 32 个 TPU v3 芯片上训练的,持续了 168 小时(7 天),当时的费用为每个 TPUv3 $8/小时,总成本约为 $43K。它达到了 0.256525 的 CORE 分数,这是在 DCLM 论文中引入的一个集成指标,经过 22 次评估,如 ARC/MMLU 等。
截至最近合并到 nanochat 的一些改进(其中许多源自 modded-nanogpt 仓库),我现在可以在单个 8XH100 节点上以 3.04 小时 (~$73) 达到更高的 CORE 分数。这是 7 年间成本降低了 600 倍,即训练 GPT-2 的成本每年大约下降 2.5 倍。我认为这可能是一个低估,因为我仍然相对定期地发现更多的改进,并且我还有一堆想法待尝试。
有关优化细节和如何重现的更多信息,请查看更长的帖子:
受到 modded-nanogpt 的启发,我还创建了一个“时间到 GPT-2”的排行榜,其中第一个“Jan29”模型以 3.04 小时成为第 1 条目。进一步迭代这个将会很有趣,我欢迎任何帮助!我希望 nanochat 能够发展成为一个非常不错/干净且经过调优的实验 LLM 平台,用于原型设计、娱乐,当然还有学习。
那些开箱即用并立即产生收益的最大改进包括 1) Flash Attention 3 内核(更快,并允许 window_size kwarg 获取交替注意模式),Muon 优化器(我尝试了大约 1 天删除它,只使用 AdamW,但我做不到),由可学习标量控制的残差路径和跳过连接,以及值嵌入。还有许多其他较小的改进也在不断累积。
图片:与当前 nanochat 模型迷你系列的缩放法则推导相关的半相关眼花缭乱的内容,既美观又令人满意!

660
热门
排行
收藏
