# NeMo Automodel

[NeMo Automodel](https://github.com/NVIDIA-NeMo/Automodel) هو مكتبة تدريب مفتوحة المصدر من NVIDIA، مبنية على PyTorch DTensor. يدعم التدريب المسبق والتدريب الدقيق على نطاق واسع وصغير لـ [LLMs](https://docs.nvidia.com/nemo/automodel/latest/model-coverage/large-language-models/overview) و [VLMs](https://docs.nvidia.com/nemo/automodel/latest/model-coverage/vision-language-models/overview)، مما يتيح تجارب سريعة في بيئات البحث والإنتاج، مع استراتيجيات توازي تشمل FSDP2، وتوازي الموترات، وتوازي الخطوط، وتوازي الخبراء، وتوازي السياق. ولتحقيق معدل إنتاجية عالٍ، يدمج نوى من DeepEP و TransformerEngine.

حدد تشغيل التدريب الخاص بك في ملف إعدادات بصيغة YAML (انظر [ملف الإعدادات](https://github.com/NVIDIA-NeMo/Automodel/blob/106e5162ef5b5d7269a3ba1ef62bfa8941b26cc6/examples/llm_finetune/nemotron/nemotron_nano_v3_hellaswag_peft.yaml) الكامل).

```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` عبر الأمر أدناه.

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

## تكامل Transformers

- يمكن إنشاء أي نموذج LLM أو VLM مدعوم في Transformers عبر NeMo Automodel. راجع [التغطية الكاملة للنماذج](https://docs.nvidia.com/nemo/automodel/latest/model-coverage/overview).
- Built on top of Hugging Face models with [AutoModel.from_pretrained()](/docs/transformers/main/ar/model_doc/auto#transformers.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()](/docs/transformers/main/ar/model_doc/auto#transformers.AutoConfig.from_pretrained) to automatically load custom implementations like Nemotron Nano V3.
- يتبع واجهة برمجة تطبيقات Transformers عن كثب لضمان التوافق المباشر.

## الموارد

- [NeMo Automodel](https://github.com/NVIDIA-NeMo/Automodel)
- [واجهة NeMo Transformers البرمجية](https://docs.nvidia.com/nemo/automodel/latest/get-started/hf-compatibility)
- نماذج NeMo Automodel الكثيفة ونماذج مزيج الخبراء (MoE) [المعايير](https://docs.nvidia.com/nemo/automodel/latest/performance/performance-summary)
- اطّلع على دليل [التدريب المسبق](./nemo_automodel_pretraining) في NeMo لمعرفة كيفية استخدام NeMo للتدريب المسبق

