nemo-automodel-recipe-development
Create and modify NeMo AutoModel training and evaluation recipes, including YAML structure, builders, and execution flow.
What this skill does
# NeMo AutoModel Recipe Development
## Instructions
For recipe questions, answer with the smallest complete path to action:
1. Name the relevant recipe file or YAML section.
2. List the builder functions or config keys involved.
3. Include a minimal YAML or command example when the question asks how to
configure something.
4. End with a local validation command or tiny CPU-compatible test.
For conceptual recipe questions, answer from this skill without inspecting the
repository or loading other AutoModel skills unless the user asks you to edit
files. Keep the response focused on recipe YAML, builders, CLI routing, tests,
and local validation.
Use these compact answer patterns for common questions:
- New finetuning recipe variant: start from the closest file under
`nemo_automodel/recipes/`, update the model, dataset or dataloader,
optimizer, loss, LR scheduler, step scheduler, and checkpoint builders,
register a CLI route only if adding a command or domain alias, add example
YAML under `examples/`, then add a tiny CPU-compatible unit test and run
`automodel finetune llm -c <config.yaml>`.
- `_target_` fields: describe `_target_` as the fully qualified Python callable,
explain that sibling keys become keyword arguments, show optimizer and dataset
examples, and mention nested CLI overrides such as `--optimizer.lr`.
- Validation and checkpointing: name `step_scheduler.val_check_interval`,
`step_scheduler.checkpoint_interval`, `validation_dataset`,
`restore_from.path`, and consolidated safetensors; include the minimal YAML
snippet from this skill.
For validation and checkpointing, always name:
- `step_scheduler.val_check_interval` for validation cadence.
- `step_scheduler.checkpoint_interval` for save cadence.
- `validation_dataset` as the validation dataloader source.
- `restore_from.path` for resume.
- Consolidated safetensors as the default checkpoint format for HF ecosystem
compatibility.
## Routing Boundary
Use this skill for recipe construction and execution-flow questions: YAML
structure, `_target_` callables, builder functions, validation datasets,
checkpoint configuration, CLI route registration, and recipe-specific tests.
Do not use this skill for standalone distributed strategy selection, cluster
launcher configuration, or model architecture onboarding unless the user is
asking how those choices appear inside an AutoModel recipe YAML.
## Recipe Architecture
### Execution Flow
```
CLI (automodel finetune llm -c config.yaml)
-> app.py parses command + domain + config
-> recipe script (e.g. train_ft.py) main(config_path)
-> Recipe class .setup() builds all components
-> .run_train_validation_loop() executes training
```
### Recipe Class
Recipes inherit from `BaseRecipe` and implement two methods:
- `setup()` -- builds model, optimizer, dataloader, loss, LR scheduler, step scheduler, and checkpoint config via builder functions.
- `run_train_validation_loop()` -- executes the training and validation loop.
### Builder Pattern
All components are constructed through dedicated builder functions:
- `build_model()` -- instantiates the model from config
- `build_optimizer()` -- creates optimizer (AdamW, etc.)
- `build_dataloader()` -- sets up train and validation dataloaders
- `build_loss_fn()` -- creates the loss function
- `build_lr_scheduler()` -- creates the learning rate scheduler
- `build_step_scheduler()` -- creates the step scheduler controlling training progression
- `build_checkpoint_config()` -- configures checkpointing
### Infrastructure Application Order
Components are applied in this strict order after building:
1. PEFT (LoRA, etc.)
2. FP8 quantization
3. QAT (quantization-aware training)
4. Checkpoint load / restore
5. Parameter freezing
6. Sharding (FSDP2, Megatron-FSDP, DDP)
7. Device placement
8. `torch.compile`
9. Context parallelism hooks
## YAML Config Anatomy
A complete recipe config follows this structure:
```yaml
step_scheduler:
max_steps: 1000
num_epochs: 1
grad_accumulation_steps: 4
val_check_interval: 100
checkpoint_interval: 500
log_interval: 10
dist_env:
master_addr: localhost
master_port: 29500
rng:
seed: 42
model:
_target_: nemo_automodel.models.llm.NemotronHForCausalLM
name_or_path: meta-llama/Llama-3.2-1B
# additional model kwargs passed to the constructor
compile:
enabled: false
backend: inductor
clip_grad_norm:
max_norm: 1.0
distributed:
strategy: fsdp2 # fsdp2 | megatron_fsdp | ddp
dp_size: auto
tp_size: 1
cp_size: 1
loss_fn:
_target_: torch.nn.CrossEntropyLoss
dataset:
_target_: nemo_automodel.datasets.squad.SquadDataset
tokenizer_name_or_path: meta-llama/Llama-3.2-1B
max_seq_length: 2048
validation_dataset:
_target_: nemo_automodel.datasets.squad.SquadDataset
split: validation
packed_sequence:
enabled: false
dataloader:
batch_size: 4
num_workers: 4
pin_memory: true
optimizer:
_target_: torch.optim.AdamW
lr: 2.0e-5
weight_decay: 0.01
lr_scheduler:
_target_: nemo_automodel.schedulers.CosineAnnealingWarmup
warmup_steps: 50
min_lr: 1.0e-6
```
### The `_target_` Pattern
The `_target_` key specifies a fully qualified Python callable. All remaining keys in that section are passed as keyword arguments:
```yaml
optimizer:
_target_: torch.optim.AdamW # callable
lr: 2.0e-5 # kwarg
weight_decay: 0.01 # kwarg
```
This is equivalent to: `torch.optim.AdamW(lr=2e-5, weight_decay=0.01)`.
### CLI Overrides
Any config value can be overridden from the command line:
```bash
automodel finetune llm -c config.yaml \
--optimizer.lr 1e-4 \
--step_scheduler.max_steps 500 \
--distributed.tp_size 2
```
## Examples
Validation and checkpointing:
```yaml
step_scheduler:
val_check_interval: 100
checkpoint_interval: 500
validation_dataset:
_target_: nemo_automodel.datasets.squad.SquadDataset
split: validation
restore_from:
path: /checkpoints/step-500
```
## Domain-Specific Notes
### LLM
- `nemo_automodel/recipes/llm/train_ft.py` handles both finetuning and pretraining. The distinction is in the config (dataset, learning rate, etc.).
- `nemo_automodel/recipes/llm/kd.py` implements knowledge distillation with a teacher and student model.
- `nemo_automodel/recipes/llm/benchmark.py` runs throughput and latency benchmarks.
### VLM
- Uses `NeMoAutoModelForImageTextToText` instead of causal LM classes.
- Config includes a `processor` section instead of a standalone tokenizer.
- Recipe lives in `nemo_automodel/recipes/vlm/finetune.py`.
### Diffusion
- Uses `NeMoAutoDiffusionPipeline`.
- Requires a `parallel_scheme` dict in config to define parallelism.
- Only supports DDP and FSDP2 strategies (no Megatron-FSDP).
- Recipe lives in `nemo_automodel/recipes/diffusion/train.py`.
### Retrieval
- Two encoder patterns:
- **Bi-encoder** (`nemo_automodel/recipes/retrieval/train_bi_encoder.py`): separate query and document encoders, contrastive loss.
- **Cross-encoder** (`nemo_automodel/recipes/retrieval/train_cross_encoder.py`): joint encoding, classification head.
- Hard negative mining: `nemo_automodel/recipes/retrieval/mine_hard_negatives.py`.
## Training Loop Details
The training loop follows this structure per epoch:
```
for epoch in range(num_epochs):
for batch_idx in range(batches_per_epoch):
# --- gradient accumulation inner loop ---
for micro_batch in micro_batches:
if pipeline_parallel:
schedule.step(micro_batch) # PP schedule
else:
loss = model(micro_batch) # direct forward
loss.backward()
# --- optimizer step ---
scale_grads_and_clip_grad_norm(model, max_norm)
optimizer.step()
lr_scheduler.step()
optimizer.zero_grad()
# --- logging ---
MetricsSample(step, epoch, loss, grad_norm, lr, mem, tps, mfu)
# --- validation (at configured intervals) ---
if Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.