npx skills add nvidia/skills --skill nemo-mbridge-resiliency
promptingcompany/nv-skills
nemo-mbridge-resiliency
Resiliency features in Megatron Bridge including fault tolerance, straggler detection, in-process restart, preemption, and re-run state machine.
Installation
npx skills add promptingcompany/nv-skills --skill nemo-mbridge-resiliency
Similar popular skills
Related neighbors and high-traction skills in the same topics — useful to compare before installing.
Resiliency features in Megatron Bridge including fault tolerance, straggler detection, in-proce…
1.8K installsExpert knowledge for Azure Resiliency development including security, configuration, and deploy…
128 installsAlso in this package
Other skills from promptingcompany/nv-skills · top by installs.
npx skills add promptingcompany/nv-skills
More details
Agent compatibility
Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.
Also listed on
Alternate registries and mirrors of this skill.
Repository health
main
Skill metadata
Parsed from SKILL.md frontmatter.
Package contents
Files included with this skill beyond the listing page.
-
skill md
SKILL.md11,324 B -
docs
SUMMARY.md175 B
History
- First seen on skills.sh
- First recorded snapshot · 39 installs
SKILL.md
Resiliency
Stable docs: @docs/training/resiliency.md, @docs/training/checkpointing.md Card: @skills/nemo-mbridge-resiliency/card.yaml
Enablement
Fault tolerance (Slurm only)
Option 1: NeMo Run plugin (recommended)
from megatron.bridge.recipes.run_plugins import FaultTolerancePlugin
import nemo_run as run
task = run.Script(...)
run_plugins = [
FaultTolerancePlugin(
enable_ft_package=True,
calc_ft_timeouts=True,
num_in_job_restarts=3,
num_job_retries_on_failure=2,
initial_rank_heartbeat_timeout=1800,
rank_heartbeat_timeout=300,
)
]
run.run(task, plugins=run_plugins, executor=executor)
| Plugin parameter | Default | Description |
|---|---|---|
numinjob_restarts |
3 | Max restarts within same job |
numjobretriesonfailure |
2 | Max new job launches on failure |
initialrankheartbeat_timeout |
1800 | First heartbeat timeout (seconds) |
rankheartbeattimeout |
300 | Subsequent heartbeat timeout (seconds) |
Option 2: Direct config + ft_launcher
from megatron.bridge.training.config import FaultToleranceConfig
cfg.ft = FaultToleranceConfig(
enable_ft_package=True,
calc_ft_timeouts=True,
simulate_fault=False,
simulated_fault_type="random",
)
Launch with ft_launcher (not torchrun):
export GROUP_RANK=0 # required for non-Slurm
ft_launcher \
--rdzv_backend=c10d --rdzv_endpoint=${MASTER_ADDR}:${MASTER_PORT} \
--nnodes=${NUM_NODES} --nproc-per-node=${NUM_GPUS_PER_NODE} \
--ft-rank_section_timeouts=setup:600,step:180,checkpointing:420 \
--ft-rank_out_of_section_timeout=300 \
your_training_script.py
| Config parameter | Default | Description |
|---|---|---|
enableftpackage |
False | Enable fault tolerance |
calcfttimeouts |
False | Auto-compute optimal timeouts |
simulate_fault |
False | Enable fault simulation for testing |
simulatedfaulttype |
"random" |
"rankhung", "rankkilled", or "random" |
simulatedfaultrank |
None | Specific rank to fault (random if None) |
simulatedfaultbase_delay |
0 | Base delay before simulating fault |
Section-based timeout monitoring covers setup, training steps, checkpointing, and out-of-section time independently. Timeouts are saved to ftstate.json for subsequent runs when calcft_timeouts=True.
NVRx straggler detection
from megatron.bridge.training.config import NVRxStragglerDetectionConfig
cfg.nvrx_straggler = NVRxStragglerDetectionConfig(
enabled=True,
report_time_interval=300.0,
calc_relative_gpu_perf=True,
calc_individual_gpu_perf=True,
num_gpu_perf_scores_to_print=5,
gpu_relative_perf_threshold=0.7,
gpu_individual_perf_threshold=0.7,
stop_if_detected=False,
enable_logging=True,
)
| Parameter | Default | Description |
|---|---|---|
enabled |
False | Enable straggler detection |
reporttimeinterval |
300.0 | Seconds between straggler checks |
calcrelativegpu_perf |
True | Compare ranks against each other |
calcindividualgpu_perf |
True | Track per-rank degradation over time |
gpurelativeperf_threshold |
0.7 | Threshold for relative performance (0-1) |
gpuindividualperf_threshold |
0.7 | Threshold for individual performance (0-1) |
stopifdetected |
False | Terminate training on straggler |
numgpuperfscoresto_print |
5 | Number of best/worst scores to print |
profiling_interval |
1 | Profiling interval for detector |
Preemption
Plugin (Slurm)
from megatron.bridge.recipes.run_plugins import PreemptionPlugin
plugins = [
PreemptionPlugin(
preempt_time=60,
enable_exit_handler=True,
enable_exit_handler_for_data_loader=False,
)
]
| Plugin parameter | Default | Description |
|---|---|---|
preempt_time |
60 | Seconds before job limit to send signal |
enableexithandler |
True | Enable signal handler in training |
enableexithandlerfordata_loader |
False | Enable for dataloader workers |
Direct config
import signal
cfg.train.exit_signal_handler = True
cfg.train.exit_signal = signal.SIGTERM
cfg.train.exit_signal_handler_for_dataloader = False
Re-run state machine (experimental)
from megatron.bridge.training.config import RerunStateMachineConfig
cfg.rerun_state_machine = RerunStateMachineConfig(
rerun_mode="validate_results",
check_for_nan_in_loss=True,
check_for_spiky_loss=False,
spiky_loss_factor=10.0,
)
| Parameter | Default | Description |
|---|---|---|
rerun_mode |
"disabled" |
"disabled", "validateresults", "reportdeterminism_stats" |
checkfornaninloss |
True | Check for NaN in loss |
checkforspiky_loss |
False | Check for unexpectedly large loss |
spikylossfactor |
10.0 | Loss flagged if > factor * max observed (increase for large models) |
Exit codes: 16 = resume to disambiguate, 17 = failed validation.
In-process restart (experimental)
from megatron.bridge.training.config import InProcessRestartConfig
cfg.inprocess_restart = InProcessRestartConfig(
enabled=True,
granularity="node",
soft_timeout=60.0,
hard_timeout=90.0,
)
| Parameter | Default | Description |
|---|---|---|
enabled |
False | Enable in-process restart |
activeworldsize |
None | Ranks executing workload (rest are warm reserves) |
granularity |
"node" |
"node" or "rank" restart granularity |
max_iterations |
None | Max restart attempts (None = unlimited) |
soft_timeout |
60.0 | Detect GIL-released hangs (seconds) |
hard_timeout |
90.0 | Force-terminate hung ranks (seconds) |
heartbeat_interval |
30.0 | Heartbeat interval (seconds) |
heartbeat_timeout |
60.0 | Missing heartbeat timeout (seconds) |
barrier_timeout |
120.0 | Distributed barrier timeout (seconds) |
completion_timeout |
120.0 | Completion barrier timeout (seconds) |
emptycudacache |
True | Clear CUDA cache during restart |
maxrankfaults |
None | Max rank faults before terminating |
monitorprocesslogdir |
None | Directory for monitor logs |
Required environment variables:
export TORCH_CPP_LOG_LEVEL=error
export TORCH_NCCL_RETHROW_CUDA_ERRORS=0
export NCCL_NVLS_ENABLE=0
The PyTorch NCCL watchdog timeout must exceed hard_timeout. NeMo-Run's Slurm Executor is not supported; launch directly with srun --kill-on-bad-exit=0.
Async checkpoint save
cfg.checkpoint.async_save = True
cfg.checkpoint.ckpt_format = "torch_dist"
Local checkpointing (NVRx)
cfg.checkpoint.non_persistent_local_ckpt_dir = "/local/scratch/ckpt"
cfg.checkpoint.non_persistent_local_ckpt_algo = "fully_parallel"
Code Anchors
Fault tolerance
- Config:
src/megatron/bridge/training/config.py—FaultToleranceConfig - Runtime:
src/megatron/bridge/training/fault_tolerance.py - Plugin:
src/megatron/bridge/recipes/run_plugins.py—FaultTolerancePlugin - Perf plugin:
scripts/performance/nemo-mbridge-resiliency_plugins.py - Tests:
tests/unittests/training/testfault_tolerance.py - Example:
examples/trainingfeatures/nemo-mbridge-resiliency/faulttolerance/
Straggler detection
- Config:
src/megatron/bridge/training/config.py—NVRxStragglerDetectionConfig - Runtime:
src/megatron/bridge/training/nvrx_straggler.py - Train loop:
src/megatron/bridge/training/train.py—checknvrxstraggler_detection - Tests:
tests/unittests/training/testnvrxstraggler.py,tests/functionaltests/training/testnvrxstraggler.py - Example:
examples/trainingfeatures/nemo-mbridge-resiliency/stragglerdetection/
In-process restart
- Config:
src/megatron/bridge/training/config.py—InProcessRestartConfig - Runtime:
src/megatron/bridge/training/inprocess_restart.py - Entry point:
src/megatron/bridge/training/pretrain.py—maybewrapforinprocessrestart - Tests:
tests/unittests/training/testinprocessrestart.py,tests/functionaltests/training/testinprocessrestart.py
Preemption
- Plugin:
src/megatron/bridge/recipes/run_plugins.py—PreemptionPlugin - Signal handler:
src/megatron/bridge/training/utils/sig_utils.py - Tests:
tests/unittests/recipes/testrun_plugins.py
Re-run state machine
- Config:
src/megatron/bridge/training/config.py—RerunStateMachineConfig - Init:
src/megatron/bridge/training/initialize.py—initrerunstate
Checkpointing
- Async save:
src/megatron/bridge/training/checkpointing.py—scheduleasyncsave - Local ckpt:
src/megatron/bridge/training/checkpointing.py—LocalCheckpointManager - Tests:
tests/functionaltests/training/testlocal_checkpointing.py
Pitfalls
- ft_launcher, not torchrun: Direct
FaultToleranceConfigrequires
ftlauncher. Using torchrun silently disables FT. For non-Slurm, set GROUPRANK=0.
- Async save requires torchdist:
asyncsave=Trueonly works with
ckptformat="torchdist". Other formats silently fail or error.
- IPR + NeMo-Run: In-process restart is not compatible with NeMo-Run
or Slurm preemption plugins. Requires specific PyTorch/NCCL versions and env vars.
- NVRx vs legacy straggler: Two detectors exist. Use NVRx
(nvrx_straggler); do not enable both.
- stopifdetected default: NVRx logs but does not stop training by
default. Set stopifdetected=True for automatic termination.
- NCCL watchdog vs hard_timeout: For IPR, NCCL watchdog timeout must
exceed hard_timeout or PyTorch kills the process before recovery.
- Rerun state machine is alpha: Use
checkfornaninloss=Truefor
NaN detection, but don't rely on full rerun workflows yet.
Verification
Fault tolerance
./examples/training_features/nemo-mbridge-resiliency/fault_tolerance/run_fault_tolerance.sh
./examples/training_features/nemo-mbridge-resiliency/fault_tolerance/run_fault_tolerance.sh --simulate-fault
Look for [FaultTolerance] / [RankMonitorServer] log lines with section timeouts. Simulated fault should trigger restart from checkpoint.
Straggler detection
uv run python -m torch.distributed.run --nproc_per_node=2 \
examples/training_features/nemo-mbridge-resiliency/straggler_detection/straggler_detection_example.py
Look for GPU relative performance and GPU individual performance reports with per-rank scores.
Async checkpoint
Look for Scheduling async checkpoint save in logs. Training iterations should continue while checkpoint files are being written.
In-process restart
pytest tests/functional_tests/training/test_inprocess_restart.py -v
Requires compatible PyTorch/NCCL versions.