熱門話題
#
Bonk 生態迷因幣展現強韌勢頭
#
有消息稱 Pump.fun 計劃 40 億估值發幣,引發市場猜測
#
Solana 新代幣發射平臺 Boop.Fun 風頭正勁

Andrej Karpathy
建築@EurekaLabsAI。曾任 AI 總監 @ 特斯拉,創始團隊 @ OpenAI,CS231n/PhD @ 史丹佛大學。我喜歡訓練大型深層神經網路。
啟用了 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 的 GEMMs 大小不足以使開銷明顯值得,當然 - 在較低的精度下,每一步的質量較小。對於行級擴展配方,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!

261
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 天),當時的價格是每小時 $8/TPUv3,總成本約為 $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" 模型是第 1 項,耗時 3.04 小時。進一步迭代這個將會很有趣,我歡迎幫助!我希望 nanochat 能夠成長為一個非常好/乾淨且調整過的實驗 LLM 平台,用於原型設計、娛樂,當然還有學習。
那些能夠立即產生增益的最大改進是 1) Flash Attention 3 核心(更快,並允許 window_size kwarg 獲得交替注意模式)、Muon 優化器(我嘗試了大約 1 天刪除它並僅使用 AdamW,但我做不到)、由可學習標量控制的殘差路徑和跳過連接,以及值嵌入。還有許多其他較小的改進累積起來。
圖片:與當前 nanochat 模型迷你系列的縮放法則推導相關的半相關視覺效果,既美觀又令人滿意!

664
熱門
排行
收藏
