run-on-slurm

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

Updated May 23, 2026
One-click install
npx skills add https://github.com/yo-steven/skills-exploration-20260522 --skill run-on-slurm
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: run-on-slurm
Source: https://github.com/yo-steven/skills-exploration-20260522/tree/main/skills/Megatron-Core/run-on-slurm
Command: npx skills add https://github.com/yo-steven/skills-exploration-20260522 --skill run-on-slurm

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill solves the problem of reliably running distributed Megatron-LM training across multiple GPUs and nodes on a SLURM cluster without misconfigured environment variables, device connectivity, or logging/diagnostics.

Core Features & Use Cases

  • SLURM job skeleton for multi-node training: Provides a minimal sbatch pattern that computes MASTER_ADDR, WORLD_SIZE, and uses srun with one task per node.
  • Correct torch.distributed.run wiring: Sets nnodes, nproc-per-node, node-rank, master-addr, and master-port so ranks rendezvous correctly.
  • CUDA_DEVICE_MAX_CONNECTIONS rules by hardware/parallelism: Prevents known failures by advising when to set it to 1, when to avoid it, and when to use 32 for MoE comm overlap.
  • Failure diagnosis guidance: Instructs how to inspect rank-by-rank stderr and classify OOM, shape/divisibility, import errors, and NCCL failures.

Quick Start

Submit the job by saving the provided sbatch skeleton as run_megatron.slurm, then run sbatch --parsable run_megatron.slurm from the shared Megatron worktree.

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 multi-node training on a SLURM cluster?

To launch Megatron-LM multi-node training on a SLURM cluster, use an sbatch skeleton that runs torch.distributed.run with correct MASTER_ADDR, MASTER_PORT, WORLD_SIZE, and node-rank settings for proper rank rendezvous.

How do I configure CUDA_DEVICE_MAX_CONNECTIONS for multi-node training?

Configure CUDA_DEVICE_MAX_CONNECTIONS based on GPU hardware and parallelism mode, setting it to 1 for certain cases, avoiding it in others, or using 32 for MoE communication overlap to prevent known failures.

Why does my SLURM multi-node training job fail with NCCL errors?

SLURM multi-node training jobs fail with NCCL errors due to device connectivity issues or misconfigured environment variables; diagnose by inspecting rank-by-rank stderr to classify NCCL failures alongside OOM and import errors.

Does torch.distributed.run work with SLURM for distributed training?

Yes, torch.distributed.run works with SLURM by configuring nnodes, nproc-per-node, node-rank, master-addr, and master-port correctly so ranks rendezvous across multiple nodes using shared filesystems.

What is the best way to debug rank failures in SLURM distributed training?

The best way to debug rank failures in SLURM distributed training is inspecting rank-by-rank stderr to classify OOM, shape divisibility errors, import errors, and NCCL connectivity issues.

Do I need a shared filesystem for SLURM multi-node training configurations?

Yes, you need a shared filesystem for SLURM multi-node training configurations to ensure container or venv visibility and access to the shared Megatron worktree across all allocated nodes.