Transformers documentation

NeMo Automodel

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

NeMo Automodel

NeMo Automodel là thư viện huấn luyện mã nguồn mở, hỗ trợ PyTorch DTensor-native từ NVIDIA. Nó hỗ trợ tiền huấn luyện và tinh chỉnh ở quy mô lớn và nhỏ cho LLMs và VLMs để thử nghiệm nhanh trong môi trường nghiên cứu và sản xuất, với các chiến lược song song bao gồm FSDP2, tensor, pipeline, expert và context parallelism. Để đạt thông lượng cao, nó tích hợp các kernel từ DeepEP và 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()

Chạy script bằng torchrun sử dụng lệnh bên dưới.

torchrun --nproc-per-node=8 /path/to/script

Tích hợp Transformers

  • Bất kỳ LLM hoặc VLM nào được hỗ trợ trong Transformers cũng có thể được khởi tạo thông qua NeMo Automodel. Xem phạm vi hỗ trợ mô hình đầy đủ.
  • Được xây dựng dựa trên các mô hình Hugging Face với AutoModel.from_pretrained(), cùng với khả năng thay thế lớp hiệu năng cao động và hỗ trợ các dạng song song hóa tinh vi hơn như Expert Parallelism (EP).
  • Phát hiện trường architecture trong AutoConfig.from_pretrained() để tự động nạp các cài đặt tùy chỉnh như Nemotron Nano V3.
  • Tuân thủ chặt chẽ API của Transformers để đảm bảo khả năng tương thích thay thế trực tiếp.

Tài nguyên

Update on GitHub