本书是文档型仓库,不是可安装的软件包,无需 pip 安装;部分脚本需自行准备 PyTorch 与多机环境才能运行;电子书版本由作者定期重建,可能不是最新内容
README 未提供安装命令,内容以文档和脚本为主,可直接克隆仓库阅读README 未说明具体硬件要求,内容涉及加速器、CPU、内存、网络与存储的选型与基准测试,但未给出运行本书所需的最低配置
一本面向 LLM/VLM 训练工程师的开源实战手册,汇集大规模模型训练与推理的方法、脚本和可复制命令
一本面向大模型工程实践的开源手册,系统讲解 GPU 训练、推理、调试、网络与扩展性等落地问题,帮工程师把模型真正跑起来。
核心能力
- 提供可直接复制粘贴的脚本与命令解决训练运维问题
- 覆盖硬件、网络、存储、编排、训练、推理全链路
- 附 torch-dist-bench.py 等网络与 GPU 基准测试工具
- 提供 GPU 集群验收评估与调试排障指南
- 可下载 PDF/EPUB 电子书版本离线阅读
容易踩的坑
暂无 release 数据(可能没有发版,或尚未同步)。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Machine Learning Engineering Open Book
This is an open collection of methodologies, tools and step by step instructions to help with successful training and fine-tuning of large language models and multi-modal models and their inference.
This is a technical material suitable for LLM/VLM training engineers and operators. That is the content here contains lots of scripts and copy-n-paste commands to enable you to quickly address your needs.
This repo is an ongoing brain dump of my experiences training Large Language Models (LLM) (and VLMs); a lot of the know-how I acquired while training the open-source BLOOM-176B model in 2022 and IDEFICS-80B multi-modal model in 2023, and RAG models at Contextual.AI in 2024.
I've been compiling this information mostly for myself so that I could quickly find solutions I have already researched in the past and which have worked, but as usual I'm happy to share these notes with the wider ML community.
Table of Contents
Part 1. Insights
-
The AI Battlefield Engineering - what you need to know in order to succeed.
-
How to Choose a Cloud Provider - these questions will empower you to have a successful compute cloud experience.
-
When Is It Worth Upgrading GPUs? - a practical framework for deciding whether a GPU generation upgrade is worth its cost, worked through on a real H200 → B200 benchmark.
Part 2. Hardware
-
Compute - accelerators, CPUs, CPU memory.
-
Storage - local, distributed and shared file systems.
-
Network - intra- and inter-node networking.
Part 3. Orchestration
- Orchestration Systems - managing containers and resources
- SLURM - Simple Linux Utility for Resource Management
Part 4. Training
- Training - model training-related guides
Part 5. Inference
- Inference - model inference insights
Part 6. Development
-
Debugging and Troubleshooting - how to debug easy and difficult issues
-
Testing - numerous tips and tools to make test writing enjoyable
Part 7. Miscellaneous
- Resources - LLM/VLM chronicles
Updates
I announce any significant updates on my twitter channel https://twitter.com/StasBekman.
Ebook versions of the book
You can download various ebook formats of this book:
I will try to rebuild these once in a few weeks or so, but if you want the latest ebook versions, the instructions for building are here.
Thanks to HuggingFace for giving me permission to host my book's ebook formats at the HF hub.
Skills for AI agents
I maintain two SKILL.md files that you can use to teach your AI agent:
- Machine Learning Engineering — train and operate large-scale ML models.
- Evaluate a GPU cluster — trial-node / acceptance loop: compute, network, and storage, then a markdown report.
See also the companion skills: The Art of Debugging and Stas' Python Cookbook.
Courses
- Lessons Learned from Training LLMs - provides a very different way of reading my open books, by going over the terse learned insights and allowing you to quickly dive deeper when you need to.
Lectures/Talks
- Building resilient ML Engineering skills given on 2026-01-10 for the GPU Mode community. Only had time to discuss performance reality of accelerators, network and storage and how each of them can be crucial to the ensemble's performance. Thanks to Mark Saroufim for organizing and providing an awesome support during the talk.
Discussions
If you want to discuss something related to ML engineering this repo has the community discussions available - so please don't hesitate to share your experience or start a new discussion about something you're passionate about.
Key comparison tables
High end accelerators:
Networks:
Shortcuts
Things that you are likely to need to find quickly and often.
Tools:
- torch-dist-bench.py - a much easier way to benchmark network throughput than nccl-tests (used to be called
all_reduce_bench.py). - torch-distributed-gpu-test.py - a tool to quickly test your inter-node connectivity
- mamf-finder.py - what is the actual TFLOPS measurement you can get from your accelerator.
Guides:
- debugging pytorch applications - quick copy-n-paste solutions to resolve hanging or breaking pytorch applications
- slurm for users - a slurm cheatsheet and tricks
- make tiny models/datasets/tokenizers
- LLM/VLM chronicles collection
Gratitude
None of this would have been possible without me being entrusted with doing the specific LLM/VLM trainings I have learned the initial know-how from. This is a privilege that only a few enjoy due to the prohibitively expensive cost of renting huge ML compute clusters. So hopefully the rest of the ML community will vicariously learn from these notes.
Special thanks go to Thom Wolf who proposed that I lead the BLOOM-176B training back when I didn't know anything about large scale training. This was the project that catapulted me into the intense learning process. And, of course, HuggingFace for giving me the opportunity to work full time on BLOOM-176B and later on IDEFICS-80B trainings.
Recently, I continued expanding my knowledge and experience while training models and building scalable training/inference systems at Contextual.AI and I'm grateful for that opportunity to Aman and Douwe.
I'd also like to thank the numerous contributors who have been making this text awesome and error-free.
Contributing
If you found a bug, typo or would like to propose an improvement please don't hesitate to open an Issue or contribute a PR.
Related Open Books
- The Art of Debugging Open Book — methodologies and recipes for debugging Unix, Python and PyTorch programs.
- Stas' Python Cookbook — everyday Python and standard-library recipes.
License
The content of this site is distributed under Attribution-ShareAlike 4.0 International.
Citation
@misc{bekman2024mlengineering,
author = {Bekman, Stas},
title = {Machine Learning Engineering Open Book},
year = {2023-2026},
publisher = {Stasosphere Online Inc.},
journal = {GitHub repository},
url = {https://github.com/stas00/ml-engineering}
}
My repositories map
✔ Books: Machine Learning Engineering | The Art of Debugging | Stas' Python Cookbook
✔ Applications: ipyexperiments
✔ Tools and Cheatsheets: bash | conda | git | jupyter-notebook | make | python | tensorboard | unix