Transformers documentation
NeMo Automodel
Bắt đầu
Lớp cơ sở
Mô hình
Bộ tiền xử lý
Suy luận
Pipeline API
Tạo API
Tối ưu hóa
Trò chuyện với các model
Serving
Huấn luyện
Phần cứng
Lượng tử hóa
Tích hợp hệ sinh thái
Tài nguyên
API
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
- NeMo Automodel
- NeMo Transformers API
- Các mô hình dense và Mixture-of-Expert (MoE) của NeMo Automodel cùng với các benchmark
- Xem hướng dẫn fine-tuning của NeMo để tìm hiểu cách sử dụng NeMo để fine-tuning