e06fe8e8c6
Secret Leaks / trufflehog (push) Failing after 1s
Build documentation / build (push) Failing after 1s
Build documentation / build_other_lang (push) Failing after 0s
CodeQL Security Analysis / CodeQL Analysis (push) Failing after 0s
PR CI / pr-ci (push) Failing after 1s
Slow tests on important models (on Push - A10) / Get all modified files (push) Failing after 1s
Slow tests on important models (on Push - A10) / Model CI (push) Has been skipped
Self-hosted runner (benchmark) / Benchmark (aws-g5-4xlarge-cache) (push) Has been cancelled
New model PR merged notification / Notify new model (push) Has been cancelled
Update Transformers metadata / build_and_package (push) Has been cancelled
3.3 KiB
3.3 KiB
NeMo Automodel
NeMo Automodel is an open-source PyTorch DTensor-native training library from NVIDIA. It supports large and small scale pretraining and fine-tuning for LLMs and VLMs for fast experimentation in research and production environments, with parallelism strategies including FSDP2, tensor, pipeline, expert, and context parallelism. For high throughput, it integrates kernels from DeepEP and TransformerEngine.
# Instantiating Nemotron V3 Nano with Expert Parallelism, FSDP2, and TransformerEngine + DeepEP kernels.
import os
import torch
import torch.distributed as dist
from nemo_automodel import NeMoAutoModelForCausalLM
from nemo_automodel.recipes._dist_utils import create_distributed_setup_from_config
dist.init_process_group(backend="nccl")
torch.cuda.set_device(int(os.environ.get("LOCAL_RANK", 0)))
torch.manual_seed(1111)
dist_setup = create_distributed_setup_from_config(
{
"strategy": "fsdp2",
"ep_size": 8,
},
)
model = NeMoAutoModelForCausalLM.from_pretrained(
"nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16",
dtype=torch.bfloat16,
distributed_setup=dist_setup,
)
print(model)
dist.destroy_process_group()
Launch the script with torchrun using the command below.
torchrun --nproc-per-node=8 /path/to/script
Transformers integration
- Any LLM or VLM supported in Transformers can also be instantiated through NeMo Automodel. See the full model coverage.
- Built on top of Hugging Face models with [
AutoModel.from_pretrained], with dynamic high-performance layer swaps and support for more refined parallelisms like Expert Parallelism (EP). - Detects the architecture field in [
AutoConfig.from_pretrained] to automatically load custom implementations like Nemotron Nano V3. - Follows the Transformers API closely for drop-in compatibility.
Resources
- NeMo Automodel
- NeMo Transformers API
- NeMo Automodel dense models and Mixture-of-Expert (MoE) benchmarks
- See the NeMo fine-tuning guide to learn how to use NeMo for fine-tuning