This is an open collection of methodologies, tools and step by step instructions to help with successful training 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.
Part 1. Insights
- The AI Battlefield Engineering - what you need to know in order to succeed
Part 2. Hardware
-
Compute - accelerators, CPUs, CPU memory.
-
Storage - local, distributed and shared file systems.
-
Network - intra- and inter-node networking.
Part 3. Orchestration
- SLURM - the main orchestration environment
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
I announce any significant updates on my twitter channel https://twitter.com/StasBekman.
Download the PDF version of the book.
I will try to rebuild it once a week or so, but if you want the latest, the instructions for building are here.
Thanks to HuggingFace for giving me permission to host my book's PDF at the HF hub.
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.
High end accelerators:
Networks:
Things that you are likely to need to find quickly and often.
Tools:
- all_reduce_bench.py - a much easier way to benchmark network throughput than nccl-tests.
- torch-distributed-gpu-test.py - a tool to quickly test your inter-node connectivity
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
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 to that opportunity to Aman and Douwe.
I'd also like to say thanks to the numerous contributors who have been making this text awesome and error-free.
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.
The content of this site is distributed under Attribution-ShareAlike 4.0 International.
@misc{bekman2024mlengineering,
author = {Bekman, Stas},
title = {Machine Learning Engineering Open Book},
year = {2023-2024},
publisher = {Stasosphere Online Inc.},
journal = {GitHub repository},
url = {https://github.com/stas00/ml-engineering}
}
✔ Machine Learning: ML Engineering Open Book | ML ways | Porting
✔ Guides: The Art of Debugging
✔ Applications: ipyexperiments
✔ Tools and Cheatsheets: bash | conda | git | jupyter-notebook | make | python | tensorboard | unix