run-on-slurm

Launch distributed Megatron-LM training jobs on SLURM with torch.distributed.run.

17.4k|4.3k|Updated Mar 21, 2019
One-click install
npx skills add https://github.com/NVIDIA/Megatron-LM --skill run-on-slurm-nvidia
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: run-on-slurm
Source: https://github.com/NVIDIA/Megatron-LM/tree/main/skills/run-on-slurm
Command: npx skills add https://github.com/NVIDIA/Megatron-LM --skill run-on-slurm-nvidia

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the problem of reliably running multi-node, multi-GPU Megatron-LM (via torch.distributed.run) on SLURM without misconfigured environment variables, inconsistent filesystem paths, or hardware/parallelism-related runtime failures.

Core Features & Use Cases

  • Minimal SLURM sbatch skeleton for distributed training: sets MASTER_ADDR, MASTER_PORT, NNODES, WORLD_SIZE, and launches a unified srun+distributed run across nodes.
  • Hardware- and strategy-aware CUDA_DEVICE_MAX_CONNECTIONS guidance: prevents assertion failures and avoids incorrect settings for FSDP vs non-FSDP modes and Blackwell behavior.
  • Operational readiness for real clusters: covers shared filesystem conventions, container execution considerations, monitoring/collection with squeue+sacct, and systematic per-rank failure diagnosis (OOM, shape errors, import errors, NCCL issues).

Quick Start

Write an sbatch script that exports MASTER_ADDR and MASTER_PORT, computes WORLD_SIZE from SLURM_NNODES and GPUs per node, and starts pretrain_gpt.py using uv run python -m torch.distributed.run with matching master address/port and node-rank across all ranks.

Frequently Asked Questions about run-on-slurm

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I launch Megatron-LM distributed training on SLURM across multiple nodes?

To launch Megatron-LM distributed training on SLURM, write an sbatch script that exports MASTER_ADDR and MASTER_PORT, computes WORLD_SIZE from SLURM_NNODES and GPUs per node, and starts pretrain_gpt.py using torch.distributed.run with matching master address and node-rank across all ranks.

What should torchrun parameters be for multi-node Megatron-LM rendezvous on SLURM?

Correct torch.distributed.run parameters for multi-node rendezvous require matching nnodes, nproc-per-node, node-rank, master-addr, and master-port across all ranks to ensure successful distributed initialization.

Why does NCCL fail during multi-node SLURM training and how do I debug it?

NCCL failures during multi-node SLURM training often stem from misconfigured environment variables or inconsistent shared filesystem paths; systematic per-rank failure diagnosis helps identify specific OOM, shape, or import errors causing the issue.

Do I need to set CUDA_DEVICE_MAX_CONNECTIONS for Megatron-LM on Blackwell GPUs?

CUDA_DEVICE_MAX_CONNECTIONS handling depends on hardware and parallelism mode, requiring conditional settings to prevent assertion failures and avoid incorrect configurations for FSDP versus non-FSDP modes and specific Blackwell behavior.

Can I use srun and torchrun together in a single SLURM sbatch script for distributed training?

Yes, a minimal SLURM sbatch skeleton can launch a unified srun and torch.distributed.run across nodes by setting MASTER_ADDR, MASTER_PORT, NNODES, and WORLD_SIZE correctly within the script.

What shared filesystem conventions are required for multi-node SLURM training jobs?

Multi-node SLURM training jobs require consistent shared filesystem paths across all nodes to prevent runtime failures and ensure correct distributed rendezvous configuration.