TypeError: TransformerBlockSubmodules.__init__() got an unexpected keyword argument 'layer_norm'
State: closed | Pull request: no
Labels: name: bug

name: stale

**Describe the bug**

When I convert qwen2-7B to nemo format, I run the command` python3 scripts/checkpoint_converters/convert_qwen2_hf_to_nemo.py --input_name_or_path=/infinity/models/qwen2/Qwen2-7B --output_path=/infinity/models/qwen2/Qwen2-7B.Nemo` in nvcr.io/nvidia/nemo:24.05, the following error occurs:
```
[NeMo W 2024-08-09 03:11:05 megatron_base_model:572] The model: MegatronGPTModel() does not have field.name: disable_parameter_transpose_cache in its cfg. Add this key to cfg or config_mapping to make to make it configurable.
[NeMo W 2024-08-09 03:11:05 megatron_base_model:572] The model: MegatronGPTModel() does not have field.name: enable_cuda_graph in its cfg. Add this key to cfg or config_mapping to make to make it configurable.
Traceback (most recent call last):
  File "/infinity/packages/NeMo_Project/NeMo/scripts/checkpoint_converters/convert_qwen2_hf_to_nemo.py", line 307, in <module>
    convert(args)
  File "/infinity/packages/NeMo_Project/NeMo/scripts/checkpoint_converters/convert_qwen2_hf_to_nemo.py", line 292, in convert
    model = load_state_dict_helper(MegatronGPTModel, nemo_config, trainer, checkpoint['state_dict'])
  File "/infinity/packages/NeMo_Project/NeMo/nemo/collections/nlp/parts/utils_funcs.py", line 220, in load_state_dict_helper
    model = cls(cfg, trainer)
  File "/infinity/packages/NeMo_Project/NeMo/nemo/collections/nlp/models/language_modeling/megatron_gpt_model.py", line 342, in __init__
    self.model = build_model(
  File "/infinity/packages/NeMo_Project/NeMo/nemo/collections/nlp/modules/common/megatron/build_model.py", line 90, in build_model
    model = model_provider_func(
  File "/infinity/packages/NeMo_Project/NeMo/nemo/collections/nlp/models/language_modeling/megatron_gpt_model.py", line 434, in model_provider_func
    transformer_layer_spec=get_specs(
  File "/infinity/packages/NeMo_Project/NeMo/nemo/collections/nlp/models/language_modeling/megatron_gpt_model.py", line 169, in get_specs
    "megatron_gpt_full_te_layer_autocast": get_gpt_full_te_layer_autocast_spec(transformer_config),
  File "/infinity/packages/NeMo_Project/NeMo/nemo/collections/nlp/models/language_modeling/megatron/gpt_full_te_layer_autocast_spec.py", line 331, in get_gpt_full_te_layer_autocast_spec
    return TransformerBlockSubmodules(
TypeError: TransformerBlockSubmodules.__init__() got an unexpected keyword argument 'layer_norm'
```

**Steps/Code to reproduce bug**

Run in docker `python3 scripts/checkpoint_converters/convert_qwen2_hf_to_nemo.py --input_name_or_path=/infinity/models/qwen2/Qwen2-7B --output_path=/infinity/models/qwen2/Qwen2-7B.Nemo`
when I encounter the error in origin docker container, I upgrade the megatron-core, but did not work.


**Expected behavior**

convert to nemo format successful

**Environment overview (please complete the following information)**

 - Environment location:Docker
 - Method of NeMo install: `docker pull  nvcr.io/nvidia/nemo:24.05 && docker run -it -w /infinity/packages/NeMo_Project/NeMo --runtime nvidia --net host --name gyj_nemo_local --cap-add IPC_LOCK --shm-size 1500g --ulimit memlock=-1 --privileged -v /mnt:/mnt -v /sys:/sys nvcr.io/nvidia/nemo:24.05 /bin/bash`

**Environment details**

If NVIDIA docker image is used you don't need to specify these.
Otherwise, please provide:
- ubuntu 22.04
- 2.3.0
- 3.10.12

**Additional context**

Add any other context about the problem here.
Example: GPU model


This PR for megatron core should fix the issue: https://github.com/NVIDIA/Megatron-LM/pull/996. Can you try it?

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

This issue was closed because it has been inactive for 7 days since being marked as stale.