NeMo Automodel

NeMo Automodel (파인튜닝)

NeMo Automodel은 NVIDIA의 PyTorch DTensor 기반 학습 라이브러리예요. Transformers 모델을 NeMo Automodel로 파인튜닝하는 방법을 YAML 설정과 함께 살펴볼게요.

출처: 문서

본문

NeMo Automodel은 NVIDIA의 오픈소스 PyTorch DTensor 네이티브 학습 라이브러리예요. 연구와 프로덕션 환경에서 빠른 실험을 위해 LLM과 VLM의 대규모·소규모 사전학습과 파인튜닝을 지원하며, FSDP2, 텐서, 파이프라인, expert, 컨텍스트 병렬화 같은 병렬화 전략을 갖췄어요. 높은 처리량을 위해 DeepEP와 TransformerEngine의 커널을 통합해요.

학습 실행은 YAML 설정 파일에서 정의해요 (전체 설정 파일 참고).

# Instantiate a Nemotron V3 Nano model
model:
  _target_: nemo_automodel.NeMoAutoModelForCausalLM.from_pretrained
  pretrained_model_name_or_path: nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16

# Run SFT on HellaSwag
dataset:
  _target_: nemo_automodel.components.datasets.llm.hellaswag.HellaSwag
  path_or_dataset: rowan/hellaswag
  split: train

# Train PEFT adapters
peft:
  _target_: nemo_automodel.components._peft.lora.PeftConfig
  exclude_modules: ["*.out_proj"]  # mamba layers use custom kernels that take in the out_proj.weight directly, thus lora doesn't work here.
  dim: 8
  alpha: 32
  use_triton: True

# Use EP + FSDP2 for training
distributed:
  strategy: fsdp2
  dp_size: none
  tp_size: 1
  cp_size: 1
  ep_size: 4

# ... other parameters

아래 명령으로 torchrun을 사용해 학습을 시작해요.

torchrun --nproc-per-node=4 examples/llm_finetune/finetune.py -c /path/to/yaml

Transformers 통합 과정

  • Transformers에서 지원하는 어떤 LLM이나 VLM이든 NeMo Automodel을 통해서도 인스턴스화할 수 있어요. 전체 모델 지원 목록을 참고하세요.
  • AutoModel.from_pretrained()를 기반으로 Hugging Face 모델 위에 구축되며, 동적 고성능 레이어 교체와 Expert Parallelism(EP) 같은 더 섬세한 병렬화를 지원해요.
  • AutoConfig.from_pretrained()의 architectures 필드를 감지해 Nemotron Nano V3 같은 커스텀 구현을 자동으로 불러와요.
  • Transformers API를 밀접하게 따라가서 drop-in 호환성을 제공해요.

리소스 (Resources)

더 알아보기 (Learn more)