1docker run -d --gpus all -it --rm \
2 --shm-size=16g \
3 --ulimit memlock=-1 --ulimit stack=67108864 \
4 nvcr.io/nvidia/nemo:24.07
1git clone https://huggingface.co/vuiseng9/nemo1-sft-peft-gemma-7b
2cd nemo1-sft-peft-gemma-7b
3
4# PEFT:
5./run_peft.sh
6
7# Eval:
8./run_eval.sh
9
10# SFT:
11./run_sft.sh
12
1git clone https://huggingface.co/datasets/databricks/databricks-dolly-15k
2
3# script in container
4python3 /opt/NeMo-Framework-Launcher/launcher_scripts/nemo_launcher/collections/dataprep_scripts/dolly_dataprep/preprocess.py --input databricks-dolly-15k/databricks-dolly-15k.jsonl
5
6# split into train/val/test
7python3 split_train_val.py
Prepare Packed Dataset (optional, expect error, token not on cuda, just move it yourself)
1# need the tokenizer
2git clone https://huggingface.co/google/gemma-7b
3
4HYDRA_FULL_ERROR=1 python /opt/NeMo/scripts/nlp_language_modeling/prepare_packed_ft_dataset.py \
5 model.data.train_ds.file_names=[databricks-dolly-15k/training.jsonl] \
6 model.data.train_ds.max_seq_length=2048 \
7 +tokenizer_path=gemma-7b/tokenizer.model \
8 +output_dir=databricks-dolly-15k/ \
9 +pack_sizes=[2048,4096,8192]
10
11# [NeMo I 2025-08-17 03:02:05 prepare_packed_ft_dataset:148] Done, output written to databricks-dolly-15k/packed_8192_seed0.npy
12# [NeMo I 2025-08-17 03:02:05 prepare_packed_ft_dataset:150]
13# ✅ Packed datasets with pack sizes [2048, 4096, 8192] are prepared successfully.
14# To train with packed sequences, you need to change three things in the SFT/PEFT config file
15# 1. Turn on the packed_sequence flag
16# > +model.data.train_ds.packed_sequence=True
17# 2. Use the new dataset file instead of the original jsonl file
18# > model.data.train_ds.file_names=/path/to/packed_dataset.npy
19# 3. Specify the packed sequence length. This should be one of the ``pack_sizes`` you specified during data preparation.
20# > model.data.train_ds.max_seq_length=<pack_size>
21# 4. Adjust the batch sizes.
22# Micro batch size has to be set to 1 as a nominal constraint. This is because batches are now concatenated
23# in the preprocessing step. You can increase the pack_size to achieve the same purpose of increasing micro batch size.
24# Global batch size has to be reduced by the average number of sequences per pack `n`,
25# where n = total number of sequences / total number of packs. This ensures that each gradient iteration
26# sees (on average) the same number of sequences so that the recipe is maintained.
27# Please scroll up to see the value of n for each of your pack sizes.
28# > model.micro_batch_size=1
29# > model.global_batch_size=<previous GBS divided by n>
30
1git clone https://huggingface.co/google/gemma-7b
2
3python3 /opt/NeMo/scripts/checkpoint_converters/convert_gemma_hf_to_nemo.py \
4--input_name_or_path gemma-7b/ \
5--output_path gemma-7b.nemo \
6--tokenizer_path gemma-7b/tokenizer.model