ml-engineering
它能做什么
提供训练和部署大型 AI 模型的实用方法与方案,从选择硬件到从故障中恢复。它适用于需要大型训练任务按时、按预算完成的机器学习工程师。
适用场景
- ✓当你需要为训练大型模型选择硬件和存储的时候。
- ✓当训练任务运行缓慢、内存耗尽或产生 NaN 值的时候。
- ✓当你需要为长时间训练任务制定检查点和恢复方案的时候。
技能链接
https://github.com/stas00/ml-engineering/blob/master/skills/ml-engineering/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我们的大型模型训练任务一直产生 NaN 损失。请帮我找出原因,以及如何恢复。”
每周 5 个新技能,1 分钟读完。
工作原理
该技能是一份从长篇开放参考资料中提炼出的精简指南,涵盖基准测试、任务调度、内存与吞吐量调优以及训练稳定性。它会针对每个问题指向相关章节,并在有的地方提供脚本和基准。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Machine Learning Engineering
Distilled from Machine Learning Engineering Open Book by Stas Bekman - source: https://github.com/stas00/ml-engineering (CC BY-SA 4.0). Know-how from training BLOOM-176B, IDEFICS-80B and production RAG and RL training and inference systems. This skill is a condensed index; each section links back to the full chapter for depth, scripts, and benchmarks.
A field-tested, end-to-end guide to training and serving large models (LLMs, VLMs, multi-modal, RAG) on real hardware at scale - distilled from actually training BLOOM-176B and IDEFICS-80B and building production inference/RAG systems. It is a practitioner's brain dump: opinionated guidance backed by copy-paste scripts, benchmark tools, and comparison tables, written for the engineers and operators who have to make expensive clusters actually deliver a finished model.
It spans the entire stack that decides whether a run succeeds and how much it costs: selecting and benchmarking accelerators, storage, and network so the fast compute is never starved; orchestrating jobs with SLURM/Kubernetes; maximizing throughput (MFU) and fitting models in memory via parallelism (DP/TP/PP/ZeRO), activation recomputation, and offload; keeping training numerically stable through loss spikes and NaN/Inf; and surviving the inevitable hardware and job failures with frequent checkpointing, spare capacity, and automatic restarts. On the serving side it covers inference latency/throughput/cost trade-offs, KV-cache and memory sizing, and framework selection - plus diagnosing multi-node/multi-GPU hangs and testing the whole thing.
Use it as an operator's runbook: figure out which resource is actually the bottleneck (compute? memory? network? storage? dataloader?), then jump to the targeted recipe. For pure debugging technique (gdb/strace/py-spy/CUDA), pair this with The Art of Debugging.
Core principles
- Measure, don't assume. Vendor/theoretical TFLOPS are marketing; benchmark your hardware and software stack before optimizing or buying. Track MFU/throughput, not vibes.
- Find the actual bottleneck. A training step is gated by the slowest of: accelerator compute, memory bandwidth/capacity, inter/intra-node network, storage IO, or CPU dataloading. Optimizing anything else is wasted effort.
- At scale, failure is the steady state. With hundreds/thousands of accelerators, hardware will fail mid-run. Design for frequent checkpoints, automatic restarts, spare nodes, and kill/save switches from day one.
- Reproduce small and fast. Debug on a tiny model / few layers / one node before burning cluster time - see The Art of Debugging.
- Watch the logbooks. Others have already hit your instability; training chronicles document the loss spikes and the fixes. See LLM/VLM chronicles.
Compute / accelerators
Full chapter: Compute · Accelerators.
- The number that matters is achievable, not theoretical. Real matmul FLOPS are well below spec. Measure Maximum Achievable Matmul FLOPS with
mamf-finder.py; compute MFU (model FLOPS utilization) to compare setups. See the most important thing to understand and what accelerator characteristics we care for. For a full trial-node loop (compute + network + storage → markdown report) see How to evaluate the cluster and the evaluate-cluster skill. - Memory capacity + bandwidth often bind before FLOPS. Check the [accelerator memory size and speed table](https://github.com/stas00/ml-engineering/blob/master/compute/accelera
常见问题
它是一本完整的训练手册吗?
不是。它是一份精简索引,每个部分都会链接回更完整的章节以获得更多细节。
它也涵盖模型部署吗?
涵盖。它涵盖大型模型的训练和部署,包括检索与推理系统。
指导内容来自哪里?
来自 Stas Bekman 的一本开放书籍,基于训练大型模型的经验。
详情
作者的原始描述
Field-tested methodology and concrete recipes for training and operating large-scale LLM/VLM/multi-modal models end to end - choosing and benchmarking accelerators, storage and network; SLURM/Kubernetes orchestration; maximizing training throughput and fitting models in memory; diagnosing and surviving training instabilities, NaN/Inf, and hardware/job failures; checkpointing and fault tolerance; inference performance and memory; debugging multi-node/ multi-GPU hangs; and writing/running tests. Use when the user is training or fine-tuning large models, hits low TFLOPS/MFU, OOM, slow dataloading
repo: stas00/ml-engineering
热度
- GitHub 星标
- 20k
- 排名
- #10479
- 许可证
- CC-BY-SA-4.0
- 更新时间
- 2026/11/1
评论
- …