rea-ci-tests-audit
MOmorluto/rea485k近 7 天新增 7,690 个 star
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, a loss spike/divergence, a NCCL/InfiniBand or multi-node hang, node/GPU failures, a straggler GPU slowing the whole job, communication that doesn't overlap with compute, checkpoint or preemption problems, storage/network bottlenecks, or needs to pick GPUs/cloud/file-systems or size inference latency/throughput. Distilled from "Machine Learning Engineering", the latest version of which can be found at https://github.com/stas00/ml-engineering The latest SKILL.md version can be found at https://github.com/stas00/ml-engineering/blob/master/skills/ml-engineering/SKILL.md
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.
Full chapter: Compute · Accelerators.
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.gpu-straggler-finder.py runs a training step on every GPU of every node at once and flags slow nodes, and slow or unsteady GPUs by UUID and serial, which don't change when node names get recycled. See Straggler finder and How to find a straggler GPU.Full chapter: Storage.
fio-scan on local NVMe and shared FS).Full chapter: Network.
torch-dist-bench.py (far simpler than nccl-tests). Mind the important nuances (e.g. unidirectional vs bidirectional, payload size, busbw vs algbw). Intra-node plus ≥4-node inter-node is part of How to evaluate the cluster.comm-compute-overlap-bench.py measures it on your hardware without setting up a framework and a model.all_gather and all_to_all under CTA policy zero with symmetric memory, which run on the copy engines. Lower a process group's limit with max_ctas or set cta_policy in its NCCL config; the NCCL_MAX_CTAS and NCCL_CTA_POLICY environment variables silently override every group's config. See CTA policy and the other performance-oriented NCCL environment variables. On bare metal with PCIe switches, disable Access Control Services: ACS sends GPU-to-NIC traffic up through the PCIe root complex, which slows NCCL down or hangs it.Full chapter: Orchestration · SLURM · Kubernetes.
torch-distributed-gpu-test.py across all nodes first.sbatch/srun/salloc, job arrays, dependencies, and inspecting the queue; keep the allocation and re-srun for fast debug iterations.Full chapter: Performance.
torch.compile, and tame automatic garbage collection jitter in synchronized runs.transformers>=5.17: gradient_checkpointing_kwargs={"offload": True}). It lowers the peak only if the peak is in forward, and it costs CPU memory and step time.Full chapter: Instabilities.
Full chapter: Fault tolerance · Checkpoints.
torchft does this for DDP and HSDP: the healthy groups keep training with a smaller global batch while the failed group restarts and fetches the state from a healthy group. A node that is failing but still works can be moved to a standby node even with a single replica, by capturing and restoring its processes together with their GPU memory (CRIU and cuda-checkpoint; research systems so far) while the whole job pauses. See Multi-Replica-based fault tolerance.Full chapter: Inference.
Full chapter: Debugging · PyTorch.
torch-distributed-gpu-test.py.py-spy; ranks stuck at different collectives reveal the desync. See diagnosing crashes, hangs and tracing execution and hanging solutions.NCCL_DEBUG=INFO; escalate to NCCL performance debug.CUDA_LAUNCH_BLOCKING=1 for a real traceback (CUDA is async). See The Art of Debugging - PyTorch.PYTORCH_ALLOC_CONF.nsys profile in front of each node's torchrun to get one timeline per node with every rank's kernels and streams; add --gpu-metrics-devices=all for the GPU clocks, which needs elevated permissions. Tracing slows host-bound steps, so take step times from an untraced run. See NVIDIA Nsight Systems.Full chapter: Testing.
| Need | Tool |
|---|---|
| Verify all GPUs/nodes can talk & allocate | torch-distributed-gpu-test.py |
| Real network throughput (all-reduce busbw) | torch-dist-bench.py |
| Actual achievable matmul FLOPS of an accelerator | mamf-finder.py |
| A GPU or node slower than its peers | gpu-straggler-finder.py |
| How much communication a parallelism pattern leaves exposed | comm-compute-overlap-bench.py |
| Tiny models/tokenizers/datasets for fast iteration | make-tiny guide |
Better trace for distributed hangs | NicerTrace |
| Symptom | Reach for |
|---|---|
| Low TFLOPS / MFU, "GPUs feel idle" | Find the bottleneck: mamf-finder, performance checklist, DataLoader, NUMA, dim divisibility |
| Training OOM | Memory anatomy → activation checkpointing/offload/parallelism; profile; PYTORCH_ALLOC_CONF |
| Slow steps but GPUs busy on comms | Benchmark network (torch-dist-bench), check intra/inter-node, NCCL settings; measure the exposed communication (comm-compute-overlap-bench, nsys) |
| Whole job slower than its GPUs should be, nothing errors | gpu-straggler-finder.py on all nodes at once; confirm a flagged GPU with --repeat 3 (on 1-2 nodes, compare with --baseline); leave its node out (--hostfile-to-sort), and record and report the GPU by UUID and serial |
| Slow dataloading / GPU starvation | DataLoader, local NVMe, prefetch/workers |
| Loss spike / divergence / NaN | Logbooks, init/STD, underflow-overflow detection, tensor scans |
| Multi-node/GPU hang or deadlock | torch-distributed-gpu-test.py → py-spy all ranks → NCCL_DEBUG=INFO |
| Node/GPU dies mid-run | Spare nodes, frequent checkpoints, auto-restart, kill/save switch; with ≥2 data-parallel replicas, recovery from a healthy replica or torchft |
| Job keeps getting preempted | forced preemption, queue chained jobs |
| Checkpoint save/load is slow | Benchmark storage, choose FS, local vs shared |
| Choosing GPUs / cloud / storage | Comparison tables, MAMF, choose a cloud provider |
| Inference too slow / won't fit | Metrics (TTFT/TPOT), KV-cache memory, framework choice, model-load speedups |
MOmorluto/rea485k近 7 天新增 7,690 个 star
MOmorluto/rea485k近 7 天新增 7,690 个 star
MAmattpocock/skills336k近 7 天新增 4,217 个 star
MAmattpocock/skills336k近 7 天新增 4,217 个 star
MAmattpocock/skills336k近 7 天新增 4,217 个 star