Skip to content

Commit

Permalink
Pass in rotary_base to mcore and from HF (NVIDIA#7933)
Browse files Browse the repository at this point in the history
* Pass in rotary_base to mcore and from HF

Signed-off-by: Igor Gitman <igitman@nvidia.com>

* Allow changing rotary_base from the sft config file

Signed-off-by: Igor Gitman <igitman@nvidia.com>

* Update mcore in jenkins

Signed-off-by: Igor Gitman <igitman@nvidia.com>

---------

Signed-off-by: Igor Gitman <igitman@nvidia.com>
Co-authored-by: Eric Harper <complex451@gmail.com>
  • Loading branch information
Kipok and ericharper authored Dec 3, 2023
1 parent 93b2c7f commit 16496ed
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ pipeline {
steps {
sh 'git clone https://github.com/NVIDIA/Megatron-LM.git && \
cd Megatron-LM && \
git checkout e122536b7645edcb7ebf099b5c92a443f7dbf8e7 && \
pip install -e .'
git checkout 973330e9c3681604703bf1eb6b5a265d1b9b9b38 && \
pip install .'
}
}

Expand Down
3 changes: 3 additions & 0 deletions examples/nlp/language_modeling/tuning/megatron_gpt_sft.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ def _modify_config(gpt_cfg, cfg, add_cfg_to_tree=False):
if cfg.model.get('seq_len_interpolation_factor', None) is not None:
gpt_cfg.seq_len_interpolation_factor = cfg.model.seq_len_interpolation_factor

if cfg.model.get('rotary_base', None) is not None:
gpt_cfg.rotary_base = cfg.model.rotary_base

sft_cls = MegatronGPTSFTModel
gpt_cfg.target = f"{sft_cls.__module__}.{sft_cls.__name__}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ def model_provider_func(self, pre_process, post_process):
position_embedding_type=self.cfg.get('position_embedding_type', 'learned_absolute'),
rotary_percent=self.cfg.get('rotary_percentage', 1.0),
seq_len_interpolation_factor=self.cfg.get('seq_len_interpolation_factor', None),
rotary_base=self.cfg.get('rotary_base', 10000),
)
else:
assert self.cfg.get('num_query_groups', None) is None or self.cfg.get(
Expand Down
2 changes: 2 additions & 0 deletions scripts/nlp_language_modeling/convert_hf_llama_to_nemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def load_config(args, llama_config):
nemo_config['seq_len_interpolation_factor'] = llama_config['rope_scaling']['factor']
else:
raise ValueError("Only linear rope scaling type is supported now")
if llama_config['rope_theta'] is not None:
nemo_config['rotary_base'] = llama_config['rope_theta']

base = 128
while llama_config['vocab_size'] % base != 0:
Expand Down

0 comments on commit 16496ed

Please sign in to comment.