Skip to content

Commit c5ef26c

Browse files
blahBlahhhJericharperpre-commit-ci[bot]lhb8125
authored
NeMo MCore llama2 support + MCore PEFT adapters (#7299)
* start adding gpt from megatron core path Signed-off-by: ericharper <complex451@gmail.com> * set model parallel config Signed-off-by: ericharper <complex451@gmail.com> * use model parallel config object Signed-off-by: ericharper <complex451@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update args Signed-off-by: ericharper <complex451@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * set vp size to none if it is 1 Signed-off-by: ericharper <complex451@gmail.com> * set vp size to none if it is 1 Signed-off-by: ericharper <complex451@gmail.com> * add TransformerConfig Signed-off-by: ericharper <complex451@gmail.com> * start updating to TransformerConfig Signed-off-by: ericharper <complex451@gmail.com> * add todo Signed-off-by: ericharper <complex451@gmail.com> * revert to model parallel config Signed-off-by: ericharper <complex451@gmail.com> * add hidden_size to model_parallel_config Signed-off-by: ericharper <complex451@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove imports Signed-off-by: ericharper <complex451@gmail.com> * revert Signed-off-by: ericharper <complex451@gmail.com> * remove import Signed-off-by: ericharper <complex451@gmail.com> * small clean up Signed-off-by: ericharper <complex451@gmail.com> * update hidden size in peft base model, add mcore commit to jenkins Signed-off-by: ericharper <complex451@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update module args Signed-off-by: ericharper <complex451@gmail.com> * add config obj to flash attention tests Signed-off-by: ericharper <complex451@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove args Signed-off-by: ericharper <complex451@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove sequence parallel arg Signed-off-by: ericharper <complex451@gmail.com> * update args Signed-off-by: ericharper <complex451@gmail.com> * add config to self Signed-off-by: ericharper <complex451@gmail.com> * update args Signed-off-by: ericharper <complex451@gmail.com> * update args Signed-off-by: ericharper <complex451@gmail.com> * update args Signed-off-by: ericharper <complex451@gmail.com> * add config to test Signed-off-by: ericharper <complex451@gmail.com> * get hidden_size from config Signed-off-by: ericharper <complex451@gmail.com> * add try except Signed-off-by: ericharper <complex451@gmail.com> * use default Signed-off-by: ericharper <complex451@gmail.com> * update config with hidden size Signed-off-by: ericharper <complex451@gmail.com> * remove arg Signed-off-by: ericharper <complex451@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * comment out jenkins test Signed-off-by: ericharper <complex451@gmail.com> * revert import Signed-off-by: ericharper <complex451@gmail.com> * build transformer config Signed-off-by: ericharper <complex451@gmail.com> * add model to provider func Signed-off-by: ericharper <complex451@gmail.com> * update forward and float16 wrapper Signed-off-by: ericharper <complex451@gmail.com> * instantiate model parallel config after init model parallel Signed-off-by: ericharper <complex451@gmail.com> * set virtual rank Signed-off-by: ericharper <complex451@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add GQA config to megatron gpt model (#7096) * Add GQA config in gpt config file Signed-off-by: jasonwan <jasonwan@nvidia.com> * Verify mcore is enabled when using GQA Signed-off-by: jasonwan <jasonwan@nvidia.com> --------- Signed-off-by: jasonwan <jasonwan@nvidia.com> * revert Signed-off-by: ericharper <complex451@gmail.com> * mcore llama2 ckpt conversion & small fix Signed-off-by: jasonwan <jasonwan@nvidia.com> * Add inference & sft config by Hongbin Co-authored-by: Hongbin Liu <hongbinl@nvidia.com> Signed-off-by: jasonwan <jasonwan@nvidia.com> * fix config Signed-off-by: jasonwan <jasonwan@nvidia.com> * add inference param. update TP/PP script to support mcore gpt Signed-off-by: jasonwan <jasonwan@nvidia.com> * p-tuning Signed-off-by: jasonwan <jasonwan@nvidia.com> * modify ckpt conversion script (adding model cast) Signed-off-by: jasonwan <jasonwan@nvidia.com> * ckpt conversion use relative path for config Signed-off-by: jasonwan <jasonwan@nvidia.com> * start adding gpt from megatron core path Signed-off-by: ericharper <complex451@gmail.com> * set model parallel config Signed-off-by: ericharper <complex451@gmail.com> * use model parallel config object Signed-off-by: ericharper <complex451@gmail.com> * update args Signed-off-by: ericharper <complex451@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * set vp size to none if it is 1 Signed-off-by: ericharper <complex451@gmail.com> * set vp size to none if it is 1 Signed-off-by: ericharper <complex451@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add TransformerConfig Signed-off-by: ericharper <complex451@gmail.com> * start updating to TransformerConfig Signed-off-by: ericharper <complex451@gmail.com> * add todo Signed-off-by: ericharper <complex451@gmail.com> * revert to model parallel config Signed-off-by: ericharper <complex451@gmail.com> * add hidden_size to model_parallel_config Signed-off-by: ericharper <complex451@gmail.com> * remove imports Signed-off-by: ericharper <complex451@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove import Signed-off-by: ericharper <complex451@gmail.com> * small clean up Signed-off-by: ericharper <complex451@gmail.com> * update hidden size in peft base model, add mcore commit to jenkins Signed-off-by: ericharper <complex451@gmail.com> * update module args Signed-off-by: ericharper <complex451@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add config obj to flash attention tests Signed-off-by: ericharper <complex451@gmail.com> * remove args Signed-off-by: ericharper <complex451@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove sequence parallel arg Signed-off-by: ericharper <complex451@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update args Signed-off-by: ericharper <complex451@gmail.com> * add config to self Signed-off-by: ericharper <complex451@gmail.com> * update args Signed-off-by: ericharper <complex451@gmail.com> * update args Signed-off-by: ericharper <complex451@gmail.com> * update args Signed-off-by: ericharper <complex451@gmail.com> * add config to test Signed-off-by: ericharper <complex451@gmail.com> * get hidden_size from config Signed-off-by: ericharper <complex451@gmail.com> * add try except Signed-off-by: ericharper <complex451@gmail.com> * use default Signed-off-by: ericharper <complex451@gmail.com> * update config with hidden size Signed-off-by: ericharper <complex451@gmail.com> * remove arg Signed-off-by: ericharper <complex451@gmail.com> * comment out jenkins test Signed-off-by: ericharper <complex451@gmail.com> * revert import Signed-off-by: ericharper <complex451@gmail.com> * remove optimizer_idx Signed-off-by: eharper <eharper@nvidia.com> * prefetch num microbatches Signed-off-by: eharper <eharper@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * start adding gpt from megatron core path Signed-off-by: ericharper <complex451@gmail.com> * set model parallel config Signed-off-by: ericharper <complex451@gmail.com> * use model parallel config object Signed-off-by: ericharper <complex451@gmail.com> * update args Signed-off-by: ericharper <complex451@gmail.com> * fix for p-tuning sequence parallel Signed-off-by: jasonwan <jasonwan@nvidia.com> * support SFT/distOpt mcore (#7207) * add inference param. update TP/PP script to support mcore gpt * p-tuning Signed-off-by: jasonwan <jasonwan@nvidia.com> * change layer names for SFT Signed-off-by: Hongbin Liu <hongbinl@nvidia.com> * fix bug in SFT Signed-off-by: Hongbin Liu <hongbinl@nvidia.com> --------- Signed-off-by: jasonwan <jasonwan@nvidia.com> Signed-off-by: Hongbin Liu <hongbinl@nvidia.com> Co-authored-by: Hongbin Liu <hongbinl@nvidia.com> Co-authored-by: jasonwan <jasonwan@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * start updating to TransformerConfig Signed-off-by: ericharper <complex451@gmail.com> * revert to model parallel config Signed-off-by: ericharper <complex451@gmail.com> * add hidden_size to model_parallel_config Signed-off-by: ericharper <complex451@gmail.com> * remove imports Signed-off-by: ericharper <complex451@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update module args Signed-off-by: ericharper <complex451@gmail.com> * add config to self Signed-off-by: ericharper <complex451@gmail.com> * build transformer config Signed-off-by: ericharper <complex451@gmail.com> * add model to provider func Signed-off-by: ericharper <complex451@gmail.com> * update forward and float16 wrapper Signed-off-by: ericharper <complex451@gmail.com> * instantiate model parallel config after init model parallel Signed-off-by: ericharper <complex451@gmail.com> * set virtual rank Signed-off-by: ericharper <complex451@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add GQA config to megatron gpt model (#7096) * Add GQA config in gpt config file Signed-off-by: jasonwan <jasonwan@nvidia.com> * Verify mcore is enabled when using GQA Signed-off-by: jasonwan <jasonwan@nvidia.com> --------- Signed-off-by: jasonwan <jasonwan@nvidia.com> * revert Signed-off-by: ericharper <complex451@gmail.com> * remove import Signed-off-by: eharper <eharper@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * rollback model cast for p-tuning Signed-off-by: jasonwan <jasonwan@nvidia.com> * update for dist adam Signed-off-by: eharper <eharper@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * use get_gpt_module_list Signed-off-by: eharper <eharper@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update ckpt conversion script Signed-off-by: jasonwan <jasonwan@nvidia.com> * ptl2.0 patch for llama config Signed-off-by: jasonwan <jasonwan@nvidia.com> * add plugins to trainer in scripts Signed-off-by: jasonwan <jasonwan@nvidia.com> * fix activation checkpointing mcore Signed-off-by: jasonwan <jasonwan@nvidia.com> * fix variable names Signed-off-by: jasonwan <jasonwan@nvidia.com> * overwrite normalization type for mcore/te Signed-off-by: jasonwan <jasonwan@nvidia.com> * Update megatron_llama_sft.yaml Signed-off-by: Jason Wang <jasonwan@nvidia.com> * add PEFT adapter support for mcore gpt path (#7276) * implementation for mcore adapter/mxins Signed-off-by: jasonwan <jasonwan@nvidia.com> * small fix for lora and ptuning Signed-off-by: jasonwan <jasonwan@nvidia.com> * support layerwise peft Signed-off-by: jasonwan <jasonwan@nvidia.com> * support multiple target layers Signed-off-by: jasonwan <jasonwan@nvidia.com> * support lora GQA Signed-off-by: jasonwan <jasonwan@nvidia.com> * support amp O2 Signed-off-by: jasonwan <jasonwan@nvidia.com> * revert & more O2 fix Signed-off-by: jasonwan <jasonwan@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * lora inject to attention Signed-off-by: jasonwan <jasonwan@nvidia.com> * support lora weight tying Signed-off-by: jasonwan <jasonwan@nvidia.com> * add copyright header Signed-off-by: jasonwan <jasonwan@nvidia.com> * rollback ptuning name change. full string match mcore target Signed-off-by: jasonwan <jasonwan@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove comment Signed-off-by: jasonwan <jasonwan@nvidia.com> --------- Signed-off-by: jasonwan <jasonwan@nvidia.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * clean up config Signed-off-by: jasonwan <jasonwan@nvidia.com> * Sync llama branch (#7297) * add inference param. update TP/PP script to support mcore gpt * p-tuning Signed-off-by: jasonwan <jasonwan@nvidia.com> * change layer names for SFT Signed-off-by: Hongbin Liu <hongbinl@nvidia.com> * fix bug in SFT Signed-off-by: Hongbin Liu <hongbinl@nvidia.com> * fix bug: cpu initialization is not really enabled Signed-off-by: Hongbin Liu <hongbinl@nvidia.com> * add use_cpu_initialization to TransformerConfig Signed-off-by: Hongbin Liu <hongbinl@nvidia.com> * fix bug: wrong config path when using relative cjpt path Signed-off-by: Hongbin Liu <hongbinl@nvidia.com> * revert mcore config change Signed-off-by: Jason Wang <jasonwan@nvidia.com> --------- Signed-off-by: jasonwan <jasonwan@nvidia.com> Signed-off-by: Hongbin Liu <hongbinl@nvidia.com> Signed-off-by: Jason Wang <jasonwan@nvidia.com> Co-authored-by: Hongbin Liu <hongbinl@nvidia.com> * clean up ckpt conversion script Signed-off-by: jasonwan <jasonwan@nvidia.com> * rollback git merge errors Signed-off-by: jasonwan <jasonwan@nvidia.com> * update mcore, add check for mcore+te Signed-off-by: jasonwan <jasonwan@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * formatting Signed-off-by: jasonwan <jasonwan@nvidia.com> * make sft test dataset optional. fix indentation in config Signed-off-by: jasonwan <jasonwan@nvidia.com> * one more fix for optional test set Signed-off-by: jasonwan <jasonwan@nvidia.com> * support merging lora weights in mcore Signed-off-by: jasonwan <jasonwan@nvidia.com> * update mcore for cpu init Signed-off-by: jasonwan <jasonwan@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update ckpt conversion for code llama Signed-off-by: jasonwan <jasonwan@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add seq_len_interpolation_factor support for long-context llama ckpts (#7312) * add inference param. update TP/PP script to support mcore gpt * p-tuning Signed-off-by: jasonwan <jasonwan@nvidia.com> * add seq_len_interpolation_factor Signed-off-by: Hongbin Liu <hongbinl@nvidia.com> --------- Signed-off-by: jasonwan <jasonwan@nvidia.com> Signed-off-by: Hongbin Liu <hongbinl@nvidia.com> Co-authored-by: jasonwan <jasonwan@nvidia.com> Co-authored-by: Hongbin Liu <hongbinl@nvidia.com> * fix old ptuning model, update mcore to support seq_len_interpolation_factor Signed-off-by: jasonwan <jasonwan@nvidia.com> * support fused layernorm linear, fix ptuning O2 Signed-off-by: jasonwan <jasonwan@nvidia.com> * drop loss mask for mcore for now Signed-off-by: jasonwan <jasonwan@nvidia.com> * disable dist ckpt in peft Signed-off-by: jasonwan <jasonwan@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix loading non dist ckpt Signed-off-by: jasonwan <jasonwan@nvidia.com> * add ckpt conversion to CI Signed-off-by: jasonwan <jasonwan@nvidia.com> * update CI Signed-off-by: jasonwan <jasonwan@nvidia.com> * mcore_mixin docstring Signed-off-by: jasonwan <jasonwan@nvidia.com> * minor change in mcore peft error message Signed-off-by: jasonwan <jasonwan@nvidia.com> * fix amp o2 in lora weight tying Signed-off-by: jasonwan <jasonwan@nvidia.com> * correct mcore fp8 config Signed-off-by: jasonwan <jasonwan@nvidia.com> * add TE installation Signed-off-by: jasonwan <jasonwan@nvidia.com> * support mcore adapter tuning Signed-off-by: jasonwan <jasonwan@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * comment out new CI test. rollback docker image Signed-off-by: jasonwan <jasonwan@nvidia.com> * ignore FA tests, try new CI on 23.08 Signed-off-by: jasonwan <jasonwan@nvidia.com> * mark new CI as L2, put to beginning to test Signed-off-by: jasonwan <jasonwan@nvidia.com> * minor fix for prompt learning Signed-off-by: jasonwan <jasonwan@nvidia.com> * rollback to 23.06. comment out CI Signed-off-by: jasonwan <jasonwan@nvidia.com> * minor fix ckpt conversion script Signed-off-by: jasonwan <jasonwan@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * minor rollback gpt model change Signed-off-by: jasonwan <jasonwan@nvidia.com> --------- Signed-off-by: ericharper <complex451@gmail.com> Signed-off-by: jasonwan <jasonwan@nvidia.com> Signed-off-by: eharper <eharper@nvidia.com> Signed-off-by: Hongbin Liu <hongbinl@nvidia.com> Signed-off-by: Jason Wang <jasonwan@nvidia.com> Co-authored-by: ericharper <complex451@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: eharper <eharper@nvidia.com> Co-authored-by: Hongbin Liu <hongbinl@nvidia.com> Co-authored-by: Kelvin Liu <lhb8125@users.noreply.github.com>
1 parent 58180ca commit c5ef26c

18 files changed

Lines changed: 1153 additions & 97 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ RUN git clone https://github.com/NVIDIA/apex.git && \
5555
# install megatron core, this can be removed once 0.3 pip package is released
5656
RUN git clone https://github.com/NVIDIA/Megatron-LM.git && \
5757
cd Megatron-LM && \
58-
git checkout 84f64880b3651c4f7cf90da337ee4e7d9968acab && \
58+
git checkout 99b044bff07f8e5d48b45223ed4bb11bd4e884e6 && \
5959
pip install -e .
6060

6161
# uninstall stuff from base container

Jenkinsfile

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ pipeline {
5959

6060
stage('Megatron Core installation') {
6161
steps {
62-
// commit has api fix for TE
62+
// pinned MCore https://github.com/NVIDIA/Megatron-LM/commit/99b044bff07f8e5d48b45223ed4bb11bd4e884e6
6363
sh 'git clone https://github.com/NVIDIA/Megatron-LM.git && \
6464
cd Megatron-LM && \
65-
git checkout 84f64880b3651c4f7cf90da337ee4e7d9968acab && \
65+
git checkout 99b044bff07f8e5d48b45223ed4bb11bd4e884e6 && \
6666
pip install -e .'
6767
}
6868
}
@@ -112,6 +112,26 @@ pipeline {
112112
}
113113
}
114114

115+
// TODO: this requires TE >= v0.11 which is not available in 23.06.
116+
// please uncomment this test once mcore CI is ready.
117+
// stage('L2: Community LLM Checkpoints tests') {
118+
// when {
119+
// anyOf {
120+
// branch 'main'
121+
// changeRequest target: 'main'
122+
// }
123+
// }
124+
// failFast true
125+
// steps {
126+
// sh 'CUDA_VISIBLE_DEVICES=0 python scripts/nlp_language_modeling/convert_hf_llama_to_nemo.py \
127+
// --in-file=/home/TestData/nlp/megatron_llama/llama-ci-hf \
128+
// --out-file=/home/TestData/nlp/megatron_llama/ci.nemo \
129+
// --fast-swiglu \
130+
// --precision=16'
131+
// sh 'rm -f /home/TestData/nlp/megatron_llama/ci.nemo'
132+
// }
133+
// }
134+
115135
stage('L2: ASR dev run') {
116136
when {
117137
anyOf {
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
name: megatron_llama
2+
restore_from_path: null # used when starting from a .nemo file
3+
4+
trainer:
5+
devices: 1
6+
num_nodes: 1
7+
accelerator: gpu
8+
precision: 32
9+
logger: False # logger provided by exp_manager
10+
enable_checkpointing: False
11+
use_distributed_sampler: False
12+
max_epochs: -1 # PTL default. In practice, max_steps will be reached first.
13+
max_steps: 100000 # consumed_samples = global_step * micro_batch_size * data_parallel_size * accumulate_grad_batches
14+
log_every_n_steps: 10
15+
val_check_interval: 100
16+
limit_val_batches: 50
17+
limit_test_batches: 500
18+
accumulate_grad_batches: 1 # do not modify, grad acc is automatic for training megatron models
19+
gradient_clip_val: 1.0
20+
benchmark: False
21+
enable_model_summary: False # default PTL callback for this does not support model parallelism, instead we log manually
22+
23+
exp_manager:
24+
explicit_log_dir: null
25+
exp_dir: null
26+
name: megatron_llama
27+
create_wandb_logger: False
28+
wandb_logger_kwargs:
29+
project: null
30+
name: null
31+
resume_if_exists: True
32+
resume_ignore_no_checkpoint: True
33+
create_checkpoint_callback: True
34+
checkpoint_callback_params:
35+
monitor: val_loss
36+
save_top_k: 10
37+
mode: min
38+
always_save_nemo: False # saves nemo file during validation, not implemented for model parallel
39+
save_nemo_on_train_end: False # not recommended when training large models on clusters with short time limits
40+
filename: 'megatron_gpt--{val_loss:.2f}-{step}-{consumed_samples}'
41+
model_parallel_size: ${multiply:${model.tensor_model_parallel_size}, ${model.pipeline_model_parallel_size}}
42+
43+
model:
44+
mcore_gpt: True
45+
# specify micro_batch_size, global_batch_size, and model parallelism
46+
# gradient accumulation will be done automatically based on data_parallel_size
47+
micro_batch_size: 4 # limited by GPU memory
48+
global_batch_size: 8 # will use more micro batches to reach global batch size
49+
tensor_model_parallel_size: 1 # intra-layer model parallelism
50+
pipeline_model_parallel_size: 1 # inter-layer model parallelism
51+
virtual_pipeline_model_parallel_size: null # interleaved pipeline
52+
53+
# model architecture
54+
encoder_seq_length: 4096
55+
max_position_embeddings: ${.encoder_seq_length}
56+
num_layers: 32 # 7b: 32 | 13b: 40 | 70b: 80
57+
hidden_size: 4096 # 7b: 4096 | 13b: 5120 | 70b: 8192
58+
ffn_hidden_size: 11008 # Transformer FFN hidden size. Usually 4 * hidden_size. | 7b: 11008 | 13b: 13824 | 70b: 28672
59+
num_attention_heads: 32 # 7b: 32 | 13b: 40 | 70b: 64
60+
init_method_std: 0.02 # Standard deviation of the zero mean normal distribution used for weight initialization.')
61+
use_scaled_init_method: True # use scaled residuals initialization
62+
hidden_dropout: 0.0 # Dropout probability for hidden state transformer.
63+
attention_dropout: 0.0 # Dropout probability for attention
64+
ffn_dropout: 0.0 # Dropout probability in the feed-forward layer.
65+
kv_channels: null # Projection weights dimension in multi-head attention. Set to hidden_size // num_attention_heads if null
66+
apply_query_key_layer_scaling: True # scale Q * K^T by 1 / layer-number.
67+
normalization: 'rmsnorm' # Normalization layer to use. Options are 'layernorm', 'rmsnorm'
68+
layernorm_epsilon: 1e-5
69+
do_layer_norm_weight_decay: False # True means weight decay on all params
70+
make_vocab_size_divisible_by: 128 # Pad the vocab size to be divisible by this value for computation efficiency.
71+
pre_process: True # add embedding
72+
post_process: True # add pooler
73+
persist_layer_norm: True # Use of persistent fused layer norm kernel.
74+
bias: False # Whether to use bias terms in all weight matrices.
75+
activation: 'fast-swiglu' # Options ['gelu', 'geglu', 'swiglu', 'reglu', 'squared-relu', 'fast-geglu', 'fast-swiglu', 'fast-reglu']
76+
headscale: False # Whether to learn extra parameters that scale the output of the each self-attention head.
77+
transformer_block_type: 'pre_ln' # Options ['pre_ln', 'post_ln', 'normformer']
78+
openai_gelu: False # Use OpenAI's GELU instead of the default GeLU
79+
normalize_attention_scores: True # Whether to scale the output Q * K^T by 1 / sqrt(hidden_size_per_head). This arg is provided as a configuration option mostly for compatibility with models that have been weight-converted from HF. You almost always want to se this to True.
80+
position_embedding_type: 'rope' # Position embedding type. Options ['learned_absolute', 'rope']
81+
rotary_percentage: 1.0 # If using position_embedding_type=rope, then the per head dim is multiplied by this.
82+
attention_type: 'multihead' # Attention type. Options ['multihead']
83+
share_embeddings_and_output_weights: False # Share embedding and output layer weights.
84+
overlap_p2p_comm: False # Overlap p2p communication with computes. This argument is valid only when `virtual_pipeline_model_parallel_size` is larger than 1
85+
batch_p2p_comm: True # Batch consecutive inter-peer send/recv operations. This argument is valid only when `virtual_pipeline_model_parallel_size` is larger than 1
86+
num_query_groups: 32 # Number of query groups for group query attention. If None, normal attention is used. | 7b: 32 | 13b: 40 | 70b: 8
87+
88+
tokenizer:
89+
library: 'sentencepiece'
90+
type: null
91+
model: ??? # /path/to/tokenizer.model
92+
vocab_file: null
93+
merge_file: null
94+
delimiter: null # only used for tabular tokenizer
95+
sentencepiece_legacy: False # Legacy=True allows you to add special tokens to sentencepiece tokenizers.
96+
97+
# Mixed precision
98+
native_amp_init_scale: 4294967296 # 2 ** 32
99+
native_amp_growth_interval: 1000
100+
hysteresis: 2 # Gradient scale hysteresis
101+
fp32_residual_connection: False # Move residual connections to fp32
102+
fp16_lm_cross_entropy: False # Move the cross entropy unreduced loss calculation for lm head to fp16
103+
104+
# Megatron O2-style half-precision
105+
megatron_amp_O2: False # Enable O2-level automatic mixed precision using main parameters
106+
grad_allreduce_chunk_size_mb: 125
107+
108+
# Fusion
109+
grad_div_ar_fusion: True # Fuse grad division into torch.distributed.all_reduce. Only used with O2 and no pipeline parallelism..
110+
gradient_accumulation_fusion: False # Fuse weight gradient accumulation to GEMMs. Only used with pipeline parallelism and O2.
111+
bias_activation_fusion: False # Use a kernel that fuses the bias addition from weight matrices with the subsequent activation function.
112+
bias_dropout_add_fusion: False # Use a kernel that fuses the bias addition, dropout and residual connection addition.
113+
masked_softmax_fusion: True # Use a kernel that fuses the attention softmax with it's mask.
114+
get_attention_mask_from_fusion: True # When using fused softmax it will create the attention mask so we won't copy it to the pipeline stages.
115+
116+
117+
# Miscellaneous
118+
seed: 1234
119+
resume_from_checkpoint: null # manually set the checkpoint file to load from
120+
use_cpu_initialization: False # Init weights on the CPU (slow for large models)
121+
onnx_safe: False # Use work-arounds for known problems with Torch ONNX exporter.
122+
apex_transformer_log_level: 30 # Python logging level displays logs with severity greater than or equal to this
123+
gradient_as_bucket_view: True # PyTorch DDP argument. Allocate gradients in a contiguous bucket to save memory (less fragmentation and buffer memory)
124+
sync_batch_comm: False # Enable stream synchronization after each p2p communication between pipeline stages
125+
126+
## Activation Checkpointing
127+
# NeMo Megatron supports 'selective' activation checkpointing where only the memory intensive part of attention is checkpointed.
128+
# These memory intensive activations are also less compute intensive which makes activation checkpointing more efficient for LLMs (20B+).
129+
# See Reducing Activation Recomputation in Large Transformer Models: https://arxiv.org/abs/2205.05198 for more details.
130+
# 'full' will checkpoint the entire transformer layer.
131+
activations_checkpoint_granularity: null # 'selective' or 'full'
132+
activations_checkpoint_method: null # 'uniform', 'block'
133+
# 'uniform' divides the total number of transformer layers and checkpoints the input activation
134+
# of each chunk at the specified granularity. When used with 'selective', 'uniform' checkpoints all attention blocks in the model.
135+
# 'block' checkpoints the specified number of layers per pipeline stage at the specified granularity
136+
activations_checkpoint_num_layers: null
137+
# when using 'uniform' this creates groups of transformer layers to checkpoint. Usually set to 1. Increase to save more memory.
138+
# when using 'block' this this will checkpoint the first activations_checkpoint_num_layers per pipeline stage.
139+
num_micro_batches_with_partial_activation_checkpoints: null
140+
# This feature is valid only when used with pipeline-model-parallelism.
141+
# When an integer value is provided, it sets the number of micro-batches where only a partial number of Transformer layers get checkpointed
142+
# and recomputed within a window of micro-batches. The rest of micro-batches in the window checkpoint all Transformer layers. The size of window is
143+
# set by the maximum outstanding micro-batch backpropagations, which varies at different pipeline stages. The number of partial layers to checkpoint
144+
# per micro-batch is set by 'activations_checkpoint_num_layers' with 'activations_checkpoint_method' of 'block'.
145+
# This feature enables using activation checkpoint at a fraction of micro-batches up to the point of full GPU memory usage.
146+
activations_checkpoint_layers_per_pipeline: null
147+
# This feature is valid only when used with pipeline-model-parallelism.
148+
# When an integer value (rounded down when float is given) is provided, it sets the number of Transformer layers to skip checkpointing at later
149+
# pipeline stages. For example, 'activations_checkpoint_layers_per_pipeline' of 3 makes pipeline stage 1 to checkpoint 3 layers less than
150+
# stage 0 and stage 2 to checkpoint 6 layers less stage 0, and so on. This is possible because later pipeline stage
151+
# uses less GPU memory with fewer outstanding micro-batch backpropagations. Used with 'num_micro_batches_with_partial_activation_checkpoints',
152+
# this feature removes most of activation checkpoints at the last pipeline stage, which is the critical execution path.
153+
154+
## Sequence Parallelism
155+
# Makes tensor parallelism more memory efficient for LLMs (20B+) by parallelizing layer norms and dropout sequentially
156+
# See Reducing Activation Recomputation in Large Transformer Models: https://arxiv.org/abs/2205.05198 for more details.
157+
sequence_parallel: False
158+
159+
## Transformer Engine
160+
transformer_engine: True
161+
fp8: False # enables fp8 in TransformerLayer forward
162+
fp8_e4m3: False # sets fp8_format = recipe.Format.E4M3
163+
fp8_hybrid: False # sets fp8_format = recipe.Format.HYBRID
164+
fp8_margin: 0 # scaling margin
165+
fp8_interval: 1 # scaling update interval
166+
fp8_amax_history_len: 1 # Number of steps for which amax history is recorded per tensor
167+
fp8_amax_compute_algo: most_recent # 'most_recent' or 'max'. Algorithm for computing amax from history
168+
reduce_amax: True # Perform reduction to sync amax tensors across GPUs after every iteration
169+
use_emha: False # Use fused multi-head attention for large sequence-length. Note this is not yet supported. Please set to False.
170+
171+
data:
172+
# Path to data must be specified by the user.
173+
# Supports List, String and Dictionary
174+
# List : can override from the CLI: "model.data.data_prefix=[.5,/raid/data/pile/my-gpt3_00_text_document,.5,/raid/data/pile/my-gpt3_01_text_document]",
175+
# Or see example below:
176+
# data_prefix:
177+
# - .5
178+
# - /raid/data/pile/my-gpt3_00_text_document
179+
# - .5
180+
# - /raid/data/pile/my-gpt3_01_text_document
181+
# Dictionary: can override from CLI "model.data.data_prefix"={"train":[1.0, /path/to/data], "validation":/path/to/data, "test":/path/to/test}
182+
# Or see example below:
183+
# "model.data.data_prefix: {train:[1.0,/path/to/data], validation:[/path/to/data], test:[/path/to/test]}"
184+
# data_prefix: ???
185+
index_mapping_dir: null # path to save index mapping .npy files, by default will save in the same location as data_prefix
186+
data_impl: mmap
187+
splits_string: 900,50,50
188+
seq_length: ${model.encoder_seq_length}
189+
skip_warmup: True
190+
num_workers: 2
191+
dataloader_type: single # cyclic
192+
reset_position_ids: False # Reset position ids after end-of-document token
193+
reset_attention_mask: False # Reset attention mask after end-of-document token
194+
eod_mask_loss: False # Mask loss for the end of document tokens
195+
validation_drop_last: True # Set to false if the last partial validation samples is to be consumed
196+
no_seqlen_plus_one_input_tokens: False # Set to True to disable fetching (sequence length + 1) input tokens, instead get (sequence length) input tokens and mask the last token
197+
pad_samples_to_global_batch_size: False # Set to True if you want to pad the last partial batch with -1's to equal global batch size
198+
shuffle_documents: True # Set to False to disable documents shuffling. Sample index will still be shuffled
199+
200+
# Nsys profiling options
201+
nsys_profile:
202+
enabled: False
203+
start_step: 10 # Global batch to start profiling
204+
end_step: 10 # Global batch to end profiling
205+
ranks: [0] # Global rank IDs to profile
206+
gen_shape: False # Generate model and kernel details including input shapes
207+
208+
optim:
209+
name: fused_adam
210+
lr: 2e-4
211+
weight_decay: 0.01
212+
betas:
213+
- 0.9
214+
- 0.98
215+
sched:
216+
name: CosineAnnealing
217+
warmup_steps: 500
218+
constant_steps: 50000
219+
min_lr: 2e-5
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
inference:
2+
greedy: False # Whether or not to use sampling ; use greedy decoding otherwise
3+
top_k: 0 # The number of highest probability vocabulary tokens to keep for top-k-filtering.
4+
top_p: 0.9 # If set to float < 1, only the most probable tokens with probabilities that add up to top_p or higher are kept for generation.
5+
temperature: 1.0 # sampling temperature
6+
add_BOS: True # add the bos token at the begining of the prompt
7+
tokens_to_generate: 30 # The minimum length of the sequence to be generated.
8+
all_probs: False # whether return the log prob for all the tokens in vocab
9+
repetition_penalty: 1.2 # The parameter for repetition penalty. 1.0 means no penalty.
10+
min_tokens_to_generate: 0 # The minimum length of the sequence to be generated.
11+
compute_logprob: False # a flag used to compute logprob of all the input text, a very special case of running inference, default False
12+
end_strings: ["</s>"] # generation will stop when one of these tokens is generated
13+
14+
trainer:
15+
devices: 1
16+
num_nodes: 1
17+
accelerator: gpu
18+
logger: False # logger provided by exp_manager
19+
precision: 32 # 16, 32, or bf16
20+
21+
tensor_model_parallel_size: -1
22+
pipeline_model_parallel_size: -1
23+
pipeline_model_parallel_split_rank: -1 # used for encoder and decoder model (0 for others)
24+
gpt_model_file: null # GPT nemo file path
25+
checkpoint_dir: null # checkpoint file dir. This is used to load the PTL checkpoint generated during the GPT training
26+
checkpoint_name: null # PTL checkpoint file name, only used for PTL checkpoint loading
27+
hparams_file: null # model configuration file, only used for PTL checkpoint loading
28+
prompts: # prompts for GPT inference
29+
- "Q: How are you?"
30+
- "Q: How big is the universe?"
31+
server: False # whether launch the API server
32+
port: 5555 # the port number for the inference server
33+
web_server: False # whether launch the web inference server
34+
share: False # whether create a public URL
35+
username: test # user name for web client
36+
password: test2 # password for web client
37+
web_port: 9889 # the port number of the web server

0 commit comments

Comments
 (0)