Upload nemotron3_nano_sft.yaml
#2
by NilLLM - opened
- nemotron3_nano_sft.yaml +116 -0
nemotron3_nano_sft.yaml
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# =========================================================
|
| 2 |
+
# Stage B: Supervised fine-tuning (LoRA) on instruction data
|
| 3 |
+
# =========================================================
|
| 4 |
+
|
| 5 |
+
model:
|
| 6 |
+
_target_: nemo_automodel.NeMoAutoModelForCausalLM.from_pretrained
|
| 7 |
+
pretrained_model_name_or_path: /models/nemotron3-nano-cpt-merged
|
| 8 |
+
trust_remote_code: true
|
| 9 |
+
is_meta_device: true
|
| 10 |
+
|
| 11 |
+
peft:
|
| 12 |
+
_target_: nemo_automodel.components._peft.lora.PeftConfig
|
| 13 |
+
match_all_linear: true
|
| 14 |
+
dim: 16 # lower rank than CPT: style/format, not new knowledge
|
| 15 |
+
alpha: 32
|
| 16 |
+
dropout: 0.1
|
| 17 |
+
use_triton: true
|
| 18 |
+
|
| 19 |
+
# Option A: multi-turn chat (matches Nemotron's chat template)
|
| 20 |
+
dataset:
|
| 21 |
+
_target_: nemo_automodel.components.datasets.llm.ChatDataset
|
| 22 |
+
path_or_dataset_id: /data/sft/sft_train.jsonl
|
| 23 |
+
split: train
|
| 24 |
+
tokenizer:
|
| 25 |
+
_target_: transformers.AutoTokenizer.from_pretrained
|
| 26 |
+
pretrained_model_name_or_path: /models/nemotron3-nano-cpt-merged
|
| 27 |
+
trust_remote_code: true
|
| 28 |
+
seq_length: 4096
|
| 29 |
+
start_of_turn_token: "<|im_start|>assistant\n" # see 9.3 - MUST be correct
|
| 30 |
+
|
| 31 |
+
validation_dataset:
|
| 32 |
+
_target_: nemo_automodel.components.datasets.llm.ChatDataset
|
| 33 |
+
path_or_dataset_id: /data/sft/sft_val.jsonl
|
| 34 |
+
split: train
|
| 35 |
+
tokenizer:
|
| 36 |
+
_target_: transformers.AutoTokenizer.from_pretrained
|
| 37 |
+
pretrained_model_name_or_path: /models/nemotron3-nano-cpt-merged
|
| 38 |
+
trust_remote_code: true
|
| 39 |
+
seq_length: 4096
|
| 40 |
+
start_of_turn_token: "<|im_start|>assistant\n"
|
| 41 |
+
limit_dataset_samples: 256
|
| 42 |
+
|
| 43 |
+
# Option B: column-mapped instruction data - swap in place of the two blocks above
|
| 44 |
+
# dataset:
|
| 45 |
+
# _target_: nemo_automodel.components.datasets.llm.column_mapped_text_instruction_dataset.ColumnMappedTextInstructionDataset
|
| 46 |
+
# path_or_dataset_id: /data/sft/sft_train.jsonl
|
| 47 |
+
# column_mapping:
|
| 48 |
+
# context: input
|
| 49 |
+
# question: instruction
|
| 50 |
+
# answer: output
|
| 51 |
+
# answer_only_loss_mask: true
|
| 52 |
+
# start_of_turn_token: "<SET_FROM_TOKENIZER_CONFIG>"
|
| 53 |
+
|
| 54 |
+
packed_sequence:
|
| 55 |
+
packed_sequence_size: 8192 # big throughput win on variable-length SFT data
|
| 56 |
+
split_across_pack: false
|
| 57 |
+
|
| 58 |
+
dataloader:
|
| 59 |
+
_target_: torchdata.stateful_dataloader.StatefulDataLoader
|
| 60 |
+
collate_fn:
|
| 61 |
+
_target_: nemo_automodel.components.datasets.utils.default_collater
|
| 62 |
+
pad_seq_len_divisible: 16
|
| 63 |
+
batch_size: 1
|
| 64 |
+
shuffle: true
|
| 65 |
+
|
| 66 |
+
validation_dataloader:
|
| 67 |
+
_target_: torchdata.stateful_dataloader.StatefulDataLoader
|
| 68 |
+
collate_fn:
|
| 69 |
+
_target_: nemo_automodel.components.datasets.utils.default_collater
|
| 70 |
+
pad_seq_len_divisible: 16
|
| 71 |
+
batch_size: 1
|
| 72 |
+
|
| 73 |
+
step_scheduler:
|
| 74 |
+
grad_acc_steps: 16
|
| 75 |
+
local_batch_size: 1
|
| 76 |
+
ckpt_every_steps: 100
|
| 77 |
+
val_every_steps: 50
|
| 78 |
+
num_epochs: 15 # 2-3 is typical for SFT
|
| 79 |
+
|
| 80 |
+
distributed:
|
| 81 |
+
strategy: fsdp2
|
| 82 |
+
dp_size: null
|
| 83 |
+
tp_size: 1
|
| 84 |
+
cp_size: 1
|
| 85 |
+
ep_size: 1
|
| 86 |
+
sequence_parallel: false
|
| 87 |
+
|
| 88 |
+
optimizer:
|
| 89 |
+
_target_: torch.optim.AdamW
|
| 90 |
+
betas: [0.9, 0.999]
|
| 91 |
+
eps: 1.0e-8
|
| 92 |
+
lr: 5.0e-5 # LoRA SFT. Full FT: 1e-5.
|
| 93 |
+
weight_decay: 0.0
|
| 94 |
+
|
| 95 |
+
lr_scheduler:
|
| 96 |
+
lr_decay_style: cosine
|
| 97 |
+
lr_warmup_steps: 50
|
| 98 |
+
min_lr: 0.0
|
| 99 |
+
|
| 100 |
+
loss_fn:
|
| 101 |
+
_target_: nemo_automodel.components.loss.masked_ce.MaskedCrossEntropy
|
| 102 |
+
|
| 103 |
+
checkpoint:
|
| 104 |
+
enabled: true
|
| 105 |
+
checkpoint_dir: /checkpoints/sft/
|
| 106 |
+
model_save_format: safetensors
|
| 107 |
+
save_consolidated: true # true here: you want a deployable artifact
|
| 108 |
+
|
| 109 |
+
dist_env:
|
| 110 |
+
backend: nccl
|
| 111 |
+
timeout_minutes: 10
|
| 112 |
+
|
| 113 |
+
rng:
|
| 114 |
+
_target_: nemo_automodel.components.training.rng.StatefulRNG
|
| 115 |
+
seed: 1111
|
| 116 |
+
ranked: true
|