Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 3.test_cases/megatron/nemo/kubernetes/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0

# Build the AWS-optimized NeMo container for P4 and P5 instances
# This script builds the Docker image with EFA support optimizations
Expand Down
3 changes: 3 additions & 0 deletions 3.test_cases/megatron/nemo/kubernetes/custom_data_module.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0

import json
import shutil
import numpy as np
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0

# Deploy NeMo Data Processing Pod
# This script helps deploy and manage the data processing pod
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0

from datasets import load_dataset
import json
import os
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0

import nemo_run as run
import json
import argparse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0

import signal
import nemo_run as run
import json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0

import signal
import nemo_run as run
import json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0

import signal
import nemo_run as run
import json
Expand Down
2 changes: 2 additions & 0 deletions 3.test_cases/megatron/nemo/kubernetes/push.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0

# Push the AWS-optimized NeMo container to Amazon ECR
# This script creates the ECR repository, logs in, tags, and pushes the image
Expand Down
23 changes: 23 additions & 0 deletions 3.test_cases/megatron/nemo/qwen3-8b-pretraining/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM nvcr.io/nvidia/nemo:26.04

RUN apt-get update && apt-get install -y --no-install-recommends \
libevent-core-2.1-7 libevent-pthreads-2.1-7 \
ethtool iproute2 pciutils curl \
&& cd /tmp \
&& curl -O https://efa-installer.amazonaws.com/aws-efa-installer-1.47.0.tar.gz \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update to 1.48.0

&& tar -xf aws-efa-installer-1.47.0.tar.gz \
&& cd aws-efa-installer \
&& ./efa_installer.sh -y --skip-kmod --skip-limit-conf --no-verify \
&& cd /tmp \
&& git clone -b v2.5.1 --depth 1 https://github.com/NVIDIA/gdrcopy.git \
&& cd gdrcopy && make -j$(nproc) lib lib_install \
&& cd / && rm -rf /tmp/* /var/lib/apt/lists/*

# Environment
ENV LD_LIBRARY_PATH="/opt/amazon/ofi-nccl/lib:/opt/amazon/efa/lib:${LD_LIBRARY_PATH}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to set LD_LIBRARY_PATH or NCCL_TUNER_PLUGIN, EFA Installer 1.4.8.0 detect which NGC containers it is and update accordingly.
This NGC /etc/shinit_v2 detect it runs on EFA and set the TUNER and NET plugin accordingly.

We should stop using LD_LIBRARY_PATH,NCCL_TUNER_PLUGIN and NCCL_NET_PLUGIN unless we need the OMPI provided by the EFA installer and we should only set LD_LIBRARY_PATH to there.

ENV NCCL_TUNER_PLUGIN="/opt/amazon/ofi-nccl/lib/libnccl-tuner-aws-ofi.so"
ENV FI_PROVIDER=efa
ENV TORCH_COMPILE_DISABLE=1
ENV NCCL_PROTO=simple

WORKDIR /workspace
170 changes: 170 additions & 0 deletions 3.test_cases/megatron/nemo/qwen3-8b-pretraining/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# Qwen3-8B Pre-Training: H200 vs B300 (NeMo/Megatron)

Pre-training **Qwen3-8B** (8.2B dense parameters) on 1T tokens comparing two GPU generations — p5en.48xlarge (H200) and p6-b300.48xlarge (B300) — using NeMo/Megatron on 2-node / 16-GPU topologies with EFA GDRDMA interconnect.

## Results

| Metric | H200 (p5en) | B300 (p6-b300) | Ratio |
|--------|-------------|----------------|-------|
| **TFLOP/s per GPU** | 497 | **976** | 1.96× |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

H200 performance numbers weren't re-measured after the architecture + memory-config change (blocking)

The H200 path changed in two ways that both shift throughput, yet every compute figure in this table is byte-identical to round 1:

  1. FFN 14336 → 12288. The recipe now builds the real Qwen3-8B (~17% smaller MLP, fewer FLOPs/step). The old 497 TFLOP/s and 162K tok/s were measured on a larger, non-Qwen3 model.
  2. Gradient checkpointing removed on H200. The config table flipped Full recompute → None and Key Finding Update versions for Megatron-LM #4 was rewritten to "no checkpointing needed" (peak memory updated 138 → 114 GB). Dropping full recompute removes a forward pass per step — that materially changes step time and tok/s.

After both, the H200 column still showing identical 3.23s / 497 / 162K / MFU 0.50 means those were carried over, not re-run — they describe a configuration the PR no longer contains. Could you re-run the H200 benchmark on the corrected recipe (no-recompute) config and update TFLOP/s, throughput, step time, time-to-1T, and MFU — plus the derived 1.96×/1.97× ratios? (Worth re-confirming the B300 column too, though its recipe didn't change, so it's lower-risk.)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The results table hasn't been re-measured, and now contradicts the code

Every compute figure (497/976 TFLOP/s, 162K/318K tok/s, 3.23s/1.65s, MFU 0.50, ~114 GB) is byte-identical to the original submission, across four rounds of materially different configs (FFN 14336→12288, recompute strategy described three different ways, mock→real data, two images→one, NeMo 26.02→26.04). Two consequences:

  • The numbers can't be from the current code: the B300 path doesn't run (Batch 2), and the H200 config has changed since the figures were taken.
  • The recompute claim contradicts the code: the README ("Best Configuration" + Key Finding Update versions for Megatron-LM #4) attributes the ~114/~173 GB peaks and 0.50 MFU to "selective (core_attn) gradient checkpointing on both clusters," but both train.py docstrings say "no gradient checkpointing needed" and neither script sets any recompute_* config — so the headline memory/MFU is attributed to a setting the code doesn't enable.

Could you re-run both columns on the current committed config and update the table (and the 1.96×/1.97× ratios), and either enable the recompute config you describe or drop the claim so the doc matches the code? Stating the scale actually run (and distinguishing smoke-test from research-scale) would help too.

| **Throughput** | 162K tok/s | **318K tok/s** | 1.96× |
| **Time to 1T tokens** | ~71 days | **~36 days** | 1.97× |
| Step time (100 iters) | 3.23s | 1.65s | 1.96× |
| Peak memory/GPU | ~114 GB / 141 GB | ~173 GB / 288 GB | — |
| MFU | 0.50 | 0.50 | — |

Both clusters are compute-saturated with perfect communication overlap. AllReduce and AllGather are fully hidden behind compute.

## Prerequisites

- **Slurm** workload manager with **PyXis + Enroot** container runtime
- **EFA networking** with GDRDMA support (for multi-node communication)
- **FSx for Lustre** shared filesystem mounted at `/fsx/`
- **Docker** (for building container images)

> **Don't have a cluster?** Deploy a fully functional HPC cluster in under 1 hour using [Amazon SageMaker HyperPod](https://awslabs.github.io/ai-on-sagemaker-hyperpod/). The guide walks you through deploying a ready-to-use cluster with Slurm, EFA, PyXis/Enroot, and FSx for Lustre pre-configured.

## Quick Start

> **Disk space:** The container build requires ~50 GB of disk space in TMPDIR.
> `enroot import` needs `sudo` and TMPDIR pointing to FSx or another file system (not `/tmp`, which is too small).

### Clone this repo and change it its directory
```bash
git clone https://github.com/awslabs/awsome-distributed-ai.git
cd awsome-distribued-ai

@KeitaW KeitaW Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README clone typo

The clone above produces awsome-distributed-ai; this cd (missing a "t") won't match.

Suggested change
cd awsome-distribued-ai
cd awsome-distributed-ai

```

### Prepare datasets (allenai/c4/en)
```bash
# export your Hugging Face token, if you have one
export HF_TOKEN=<your token>

# Prepare the dataset
sbatch preprocessing/preprocess.sh
```
Without your Hugging Face token, the download will be throttled. The script requires a token.
Datasets are tokenized and transformed into binary mmap accessible files to avoid streaming data (`.idx` and `.bin` files).

### Build the container
```bash
# Build container
docker build -t qwen3-8b-pretraining:latest .

# Setup directories to run
mkdir -p /fsx/tmp && mkdir -p /fsx/ubuntu/qwen3-8b-pretraining/containers/

# Create the squash file with Enroot
sudo TMPDIR=/fsx/tmp ENROOT_TEMP_PATH=/fsx/tmp enroot import --output /fsx/ubuntu/qwen3-8b-pretraining/containers/nemo-efa-26.04.sqsh dockerd://qwen3-8b-pretraining:latest
```

### H200 Cluster (2x p5en.48xlarge)

```bash
# 1. Change to directory
cd h200

# 2. Submit training job
sbatch slurm/run.sh
```
Logs will be written to `/fsx/ubuntu/qwen3-8b-pretraining/logs`.
Checkpoints are saved to `/fsx/ubuntu/qwen3-8b-pretraining/checkpoints`.

### B300 Cluster (2x p6-b300.48xlarge)

```bash
# 1. Change to directory
cd b300

# 2. Submit training job
sbatch slurm/run.sh
```
Logs will be written to `/fsx/ubuntu/qwen3-8b-pretraining/logs`.
Checkpoints are saved to `/fsx/ubuntu/qwen3-8b-pretraining/checkpoints`.

## Model Architecture: Qwen3-8B

| Parameter | Value |
|-----------|-------|
| Layers | 36 |
| Hidden dim (d_model) | 4096 |
| Q-heads | 32 |
| KV-heads | 8 (GQA) |
| FFN dim | 12288 (SwiGLU) |
| Vocab size | 151,936 |
| Positional encoding | RoPE |
| Normalization | RMSNorm |
| Sequence length | 4096 |
| Precision | BF16 |
| Total params | 8.2B |

## Parallelism Strategy

**Pure Data Parallelism (DP=16)** — the model fits entirely on a single GPU.

| Component | Setting |
|-----------|---------|
| Tensor Parallel | 1 |
| Pipeline Parallel | 1 |
| Data Parallel | 16 |
| Distributed Optimizer | Yes (shards Adam states across DP ranks) |
| Overlap Grad Reduce | Yes |
| Overlap Param Gather | Yes |

**Why TP=1 is optimal:** At 8.2B params, the model + optimizer states fit on one GPU with distributed optimizer. Adding tensor parallelism introduces all-reduce communication for every transformer layer — validated experimentally: TP=2 was 11% slower (868 vs 976 TFLOP/s on B300).

## Best Configuration Per Cluster

| Parameter | H200 (p5en.48xlarge) | B300 (p6-b300.48xlarge) |
|-----------|---------------------|------------------------|
| GPUs | 16× H200 (141 GB HBM3) | 16× B300 (288 GB HBM3e) |
| Parallelism | TP=1, PP=1, DP=16 | TP=1, PP=1, DP=16 |
| **Micro-batch size** | **2** | **4** |
| Global batch size | 128 (grad_accum=4) | 128 (grad_accum=2) |
| Sequence length | 4096 | 4096 |
| Precision | BF16 | BF16 |
| **Gradient checkpointing** | Selective (core_attn only) | Selective (core_attn only) |
| Distributed optimizer | Yes (sharded Adam) | Yes (sharded Adam) |
| Overlap grad reduce | Yes | Yes |
| Overlap param gather| Yes | Yes |
| Framework | Megatron-Bridge (NeMo 26.04) | Megatron-Bridge (NeMo 26.04) |

## Key Findings

1. **Both clusters are compute-saturated with perfect communication overlap.** AllReduce and AllGather are fully hidden behind compute — verified by single-GPU benchmarks showing lower TFLOP/s due to reduced batch arithmetic intensity.

2. **Both clusters use the Megatron-Bridge recipe API.** NeMo 26.04 for both H200 and B300.

3. **Pure data parallelism is optimal** when the model fits in single-GPU memory. Distributed optimizer + overlapped grad reduce eliminate the memory penalty.

4. **Selective gradient checkpointing used on both clusters:** lightweight core_attn recompute is Megatron-Core's standard behavior, keeping H200 peak at ~114 GB (MBS=2) and B300 at ~173 GB (MBS=4).

## Hardware

| | H200 Cluster | B300 Cluster |
|---|---|---|
| Instance | p5en.48xlarge | p6-b300.48xlarge |
| Nodes | 2 | 2 |
| GPUs per node | 8× H200 | 8× B300 |
| GPU Memory | 141 GB HBM3 | 288 GB HBM3e |
| Interconnect | EFA GDRDMA (3200 Gbps) | EFA GDRDMA (6400 Gbps) |
| Intra-node | NVLink (900 GB/s) | NVLink (1800 GB/s) |

## Project Structure

```
├── README.md ← You are here
│ Dockerfile ← NeMo 26.04 + EFA container
├── h200/
│ ├── train.py ← Megatron-Bridge training script
│ └── slurm/
│ └── run.sh ← Slurm submission script
└── b300/
├── train.py ← Megatron-Bridge training script
└── slurm/
└── run.sh ← Slurm submission script
```

## License

MIT-0
23 changes: 23 additions & 0 deletions 3.test_cases/megatron/nemo/qwen3-8b-pretraining/b300/slurm/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
#SBATCH --job-name=qwen3-8b-b300
#SBATCH --nodes=2
#SBATCH --ntasks-per-node=8
#SBATCH --gpus-per-node=8
#SBATCH --cpus-per-task=12
#SBATCH --exclusive
#SBATCH --output=/fsx/ubuntu/qwen3-8b-pretraining/logs/%j.out
#SBATCH --error=/fsx/ubuntu/qwen3-8b-pretraining/logs/%j.err

# EFA / NCCL environment
export FI_PROVIDER=efa
export NCCL_SOCKET_IFNAME=^docker,lo,veth
export NCCL_DEBUG=WARN
export NCCL_TUNER_PLUGIN=/opt/amazon/ofi-nccl/lib/libnccl-tuner-aws-ofi.so
export LD_LIBRARY_PATH=/opt/amazon/ofi-nccl/lib:/opt/amazon/efa/lib:${LD_LIBRARY_PATH}
export TORCH_COMPILE_DISABLE=1
export PYTORCH_CUDA_ALLOC_CONF="expandable_segments:True"

# Launch - Megatron uses SLURM env vars (SLURM_PROCID, SLURM_LOCALID) for distributed init
/opt/slurm/bin/srun --mpi=pmix --container-image=/fsx/ubuntu/qwen3-8b-pretraining/containers/nemo-efa-26.04.sqsh --container-mounts=/fsx:/fsx,/opt/slurm:/opt/slurm --container-env=FI_PROVIDER,NCCL_SOCKET_IFNAME,NCCL_DEBUG,NCCL_TUNER_PLUGIN,LD_LIBRARY_PATH,TORCH_COMPILE_DISABLE python /fsx/ubuntu/awsome-distributed-ai/3.test_cases/megatron/nemo/qwen3-8b-pretraining/h200/train.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b300/slurm/run.sh launches h200/train.py (blocking)

The final command ends in …/qwen3-8b-pretraining/h200/train.py — byte-identical to h200/slurm/run.sh (the launch line wasn't repointed when the file was copied). So cd b300 && sbatch slurm/run.sh runs the H200 config (MBS=2, checkpoints/h200), not B300 (MBS=4) — the README's B300 column isn't reproducible as wired.

Suggested change
/opt/slurm/bin/srun --mpi=pmix --container-image=/fsx/ubuntu/qwen3-8b-pretraining/containers/nemo-efa-26.04.sqsh --container-mounts=/fsx:/fsx,/opt/slurm:/opt/slurm --container-env=FI_PROVIDER,NCCL_SOCKET_IFNAME,NCCL_DEBUG,NCCL_TUNER_PLUGIN,LD_LIBRARY_PATH,TORCH_COMPILE_DISABLE python /fsx/ubuntu/awsome-distributed-ai/3.test_cases/megatron/nemo/qwen3-8b-pretraining/h200/train.py
/opt/slurm/bin/srun --mpi=pmix --container-image=/fsx/ubuntu/qwen3-8b-pretraining/containers/nemo-efa-26.04.sqsh --container-mounts=/fsx:/fsx,/opt/slurm:/opt/slurm --container-env=FI_PROVIDER,NCCL_SOCKET_IFNAME,NCCL_DEBUG,NCCL_TUNER_PLUGIN,LD_LIBRARY_PATH,TORCH_COMPILE_DISABLE python /fsx/ubuntu/awsome-distributed-ai/3.test_cases/megatron/nemo/qwen3-8b-pretraining/b300/train.py

(Separately, that /fsx/ubuntu/awsome-distributed-ai/... path is hardcoded and doesn't match the README's git clone … && cd step — see Batch 5.)

55 changes: 55 additions & 0 deletions 3.test_cases/megatron/nemo/qwen3-8b-pretraining/b300/train.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env python3
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
"""Qwen3-8B Pre-Training on B300 — Megatron-Bridge (NeMo 26.02)

Uses the Megatron-Bridge recipe API with config objects.
No gradient checkpointing needed (288 GB B300 memory).

Best config: TP=1, PP=1, DP=16, MBS=4, GBS=128, seq=4096, BF16
Result: 976 TFLOP/s/GPU, 318K tok/s on 16x B300
"""
import os

os.environ.setdefault("TORCH_COMPILE_DISABLE", "1")

from megatron.bridge.recipes.qwen.qwen3 import qwen3_8b_pretrain_config
from megatron.bridge.training.gpt_step import forward_step
from megatron.bridge.training.pretrain import pretrain


def main():
cfg = qwen3_8b_pretrain_config(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qwen3_8b_pretrain_config() takes no arguments on the pinned image — this is the real blocker (must fix)

Running the committed script end-to-end on nemo:26.02 raises:

TypeError: qwen3_8b_pretrain_config() got an unexpected keyword argument 'mock'

In the pinned image the recipe signature is def qwen3_8b_pretrain_config() -> ConfigContainerno parameters. You call it bare and mutate the returned cfg. As written it runs on neither image (the H200 path dies even earlier at the megatron.bridge.recipes.qwen import), which is the concrete reason the published throughput numbers can't have come from the committed code. When I corrected the call to the real API, it trained on 8×B200.

Suggested change
cfg = qwen3_8b_pretrain_config(
cfg = qwen3_8b_pretrain_config()
cfg.model.tensor_model_parallel_size = 1
cfg.model.pipeline_model_parallel_size = 1
# set micro/global batch, seq_length, train_iters on cfg.* per the ConfigContainer

The same fix applies to h200/train.py — though the NeMo-Run recommendation in the review summary avoids hand-rolling this entirely.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I will not use NeMo run.sh for both. Even though they are essentially the same run.sh script , they can be tuned for each platform.

the same goes with the train.py script, which clearly has different parametrisation based on each hardware type.

The only recommendation I addressed was cereating a single container for both clusters. Both use a NeMo 26.04 NGC container, so the build happens only. And both uses the same preprocessing script since they require the same dataset.

mock=True,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b300/train.py still uses the kwargs call that crashes (blocking)

b300/train.py wasn't updated when h200 was fixed — it still calls the recipe with arguments:

cfg = qwen3_8b_pretrain_config(mock=True, tensor_model_parallel_size=1, micro_batch_size=4, …)

The recipe takes no arguments (returns a ConfigContainer you mutate). One-line repro against this PR's pinned image:

docker run --rm --entrypoint python3 nvcr.io/nvidia/nemo:26.04 -c "from megatron.bridge.recipes.qwen.qwen3 import qwen3_8b_pretrain_config; qwen3_8b_pretrain_config(mock=True)"
# TypeError: qwen3_8b_pretrain_config() got an unexpected keyword argument 'mock'

(verified on nemo:26.04; the bare qwen3_8b_pretrain_config() returns a ConfigContainer.) So once run.sh is repointed (above), the B300 job fails at the constructor. Please mirror h200/train.py: call it bare, then set cfg.model.tensor_model_parallel_size, cfg.train.micro_batch_size = 4, etc. While doing so, reconcile attribute names with h200 — b300 uses cfg.train.eval_interval/cfg.train.dir where h200 uses cfg.validation.eval_interval/cfg.checkpoint.save; at most one set is correct (h200's is the path I validated live).

tensor_model_parallel_size=1,
pipeline_model_parallel_size=1,
micro_batch_size=4,
global_batch_size=128,
seq_length=4096,
train_iters=100,
lr_warmup_iters=10,
lr_decay_iters=100,
)

# No gradient checkpointing (B300 has 288 GB - fits MBS=4 without recompute)

# Optimizer
cfg.optimizer.lr = 3e-4
cfg.optimizer.min_lr = 3e-5
cfg.optimizer.weight_decay = 0.1
cfg.optimizer.adam_beta1 = 0.9
cfg.optimizer.adam_beta2 = 0.95
cfg.optimizer.clip_grad = 1.0

# Logging and checkpoints
cfg.logger.log_interval = 5
cfg.train.eval_interval = 1000
cfg.train.eval_iters = 0
cfg.train.dir = "/fsx/ubuntu/qwen3-8b/checkpoints/b300"
cfg.train.save_interval = 1000

pretrain(config=cfg, forward_step_func=forward_step)


if __name__ == "__main__":
main()
23 changes: 23 additions & 0 deletions 3.test_cases/megatron/nemo/qwen3-8b-pretraining/h200/slurm/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
#SBATCH --job-name=qwen3-8b-h200
#SBATCH --nodes=2
#SBATCH --ntasks-per-node=8
#SBATCH --gpus-per-node=8
#SBATCH --cpus-per-task=12
#SBATCH --exclusive
#SBATCH --output=/fsx/ubuntu/qwen3-8b-pretraining/logs/%j.out
#SBATCH --error=/fsx/ubuntu/qwen3-8b-pretraining/logs/%j.err

# EFA / NCCL environment
export FI_PROVIDER=efa
export NCCL_SOCKET_IFNAME=^docker,lo,veth
export NCCL_DEBUG=WARN
export NCCL_TUNER_PLUGIN=/opt/amazon/ofi-nccl/lib/libnccl-tuner-aws-ofi.so
export LD_LIBRARY_PATH=/opt/amazon/ofi-nccl/lib:/opt/amazon/efa/lib:${LD_LIBRARY_PATH}
export TORCH_COMPILE_DISABLE=1
export PYTORCH_CUDA_ALLOC_CONF="expandable_segments:True"

# Launch - Megatron uses SLURM env vars (SLURM_PROCID, SLURM_LOCALID) for distributed init
/opt/slurm/bin/srun --mpi=pmix --container-image=/fsx/ubuntu/qwen3-8b-pretraining/containers/nemo-efa-26.04.sqsh --container-mounts=/fsx:/fsx,/opt/slurm:/opt/slurm --container-env=FI_PROVIDER,NCCL_SOCKET_IFNAME,NCCL_DEBUG,NCCL_TUNER_PLUGIN,LD_LIBRARY_PATH,TORCH_COMPILE_DISABLE python /fsx/ubuntu/awsome-distributed-ai/3.test_cases/megatron/nemo/qwen3-8b-pretraining/h200/train.py
Loading