Repository navigation
Closed
Closed
Copy link
Labels
bugSomething isn't workingcommunity-requestqa_rcca_donewhen RCCA finished for the issue, the qa will mark with this label .
Description
Describe the bug
Many layers are not found in generator model when converting gpt-oss checkpoint Megatron to HF format.
load_return: _IncompatibleKeys(missing_keys=['decoder.layers.0.self_attention.linear_proj._extra_state', 'decoder.layers.0.self_attention.linear_qkv._extra_state', 'decoder.layers.0.pre_mlp_layernorm._extra_state', 'decoder.layers.0.mlp.experts.linear_fc1._extra_state', 'decoder.layers.0.mlp.experts.linear_fc2._extra_state', 'decoder.layers.1.self_attention.linear_proj._extra_state',
....
ayers.22.mlp.experts.linear_fc1._extra_state', 'decoder.layers.22.mlp.experts.linear_fc2._extra_state', 'decoder.layers.23.self_attention.linear_proj._extra_state', 'decoder.layers.23.self_attention.linear_qkv._extra_state', 'decoder.layers.23.pre_mlp_layernorm._extra_state', 'decoder.layers.23.mlp.experts.linear_fc1._extra_state', 'decoder.layers.23.mlp.experts.linear_fc2._extra_state', 'decoder.final_layernorm._extra_state'], unexpected_keys=[])
tokenizer_config.json: 4.20kB [00:00, 20.5MB/s]
tokenizer.json: 100%|█████████████████████████████████████████████████| 27.9M/27.9M [00:00<00:00, 28.0MB/s]
special_tokens_map.json: 100%|██████████████████████████████████████████| 98.0/98.0 [00:00<00:00, 1.09MB/s]
chat_template.jinja: 16.7kB [00:00, 61.2MB/s]
generation_config.json: 100%|█████████████████████████████████████████████| 177/177 [00:00<00:00, 1.87MB/s]
model.safetensors.index.json: 36.4kB [00:00, 92.2MB/s] | 0/5 [00:00<?, ?it/s]
model-00002-of-00002.safetensors: 100%|████████████████████████████████| 4.17G/4.17G [00:10<00:00, 398MB/s]
model-00000-of-00002.safetensors: 100%|████████████████████████████████| 4.79G/4.79G [00:14<00:00, 337MB/s]
model-00001-of-00002.safetensors: 100%|████████████████████████████████| 4.80G/4.80G [00:19<00:00, 245MB/s]
original/model.safetensors: 100%|██████████████████████████████████████| 13.8G/13.8G [00:22<00:00, 618MB/s]
Fetching 5 files: 100%|██████████████████████████████████████████████████████| 5/5 [00:22<00:00, 4.54s/it]
[rank0]: Traceback (most recent call last):
[rank0]: File "/opt/nemo-rl/examples/converters/convert_megatron_to_hf.py", line 76, in <module> 774MB/s]
[rank0]: main()tensors: 98%|████████████████████████████████████▏| 13.5G/13.8G [00:22<00:00, 1.51GB/s]
[rank0]: File "/opt/nemo-rl/examples/converters/convert_megatron_to_hf.py", line 66, in main
[rank0]: export_model_from_megatron(
[rank0]: File "/opt/nemo-rl/nemo_rl/models/megatron/community_import.py", line 140, in
export_model_from_megatron
[rank0]: bridge.save_hf_pretrained(megatron_model, output_path)
[rank0]: File
"/opt/nemo-rl/3rdparty/Megatron-Bridge-workspace/Megatron-Bridge/src/megatron/bridge/models/conversion/auto
_bridge.py", line 494, in save_hf_pretrained
[rank0]: self.save_hf_weights(
[rank0]: File
"/opt/nemo-rl/3rdparty/Megatron-Bridge-workspace/Megatron-Bridge/src/megatron/bridge/models/conversion/auto
_bridge.py", line 573, in save_hf_weights
[rank0]: self.hf_pretrained.state.source.save_generator(
[rank0]: File
"/opt/nemo-rl/3rdparty/Megatron-Bridge-workspace/Megatron-Bridge/src/megatron/bridge/models/hf_pretrained/s
tate.py", line 749, in save_generator
[rank0]: raise KeyError(
[rank0]: KeyError: "Tensor 'model.layers.0.mlp.experts.gate_up_proj' from generator not found in the
original model structure. To ignore, set strict=False."
Converting to HuggingFace ━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4% 0:00:39 (137/3291) GPTOSSBridge
Steps/Code to reproduce bug
- Pull nvcr.io/nvidia/nemo-rl:v0.5.0.nemotron_3_super image
- root@ip:/opt/nemo-rl# uv run --extra mcore examples/converters/convert_megatron_to_hf.py --config=$CKPT_PATH/config.yaml --megatron-ckpt-path $CKPT_PATH/policy/weights/iter_0000000/ --hf-ckpt-path $CKPT_PATH/hf
- Ckpt path tree
step_40
├── config.yaml
├── policy
│ └── weights
│ ├── iter_0000000
│ │ ├── __0_0.distcp
│ │ ├── __0_1.distcp
│ │ ├── __10_0.distcp
│ │ ├── __10_1.distcp
│ │ ├── __11_0.distcp
│ │ ├── __11_1.distcp
│ │ ├── __12_0.distcp
│ │ ├── __12_1.distcp
│ │ ├── __13_0.distcp
│ │ ├── __13_1.distcp
│ │ ├── __14_0.distcp
│ │ ├── __14_1.distcp
│ │ ├── __15_0.distcp
│ │ ├── __15_1.distcp
│ │ ├── __1_0.distcp
│ │ ├── __1_1.distcp
│ │ ├── __2_0.distcp
│ │ ├── __2_1.distcp
│ │ ├── __3_0.distcp
│ │ ├── __3_1.distcp
│ │ ├── __4_0.distcp
│ │ ├── __4_1.distcp
│ │ ├── __5_0.distcp
│ │ ├── __5_1.distcp
│ │ ├── __6_0.distcp
│ │ ├── __6_1.distcp
│ │ ├── __7_0.distcp
│ │ ├── __7_1.distcp
│ │ ├── __8_0.distcp
│ │ ├── __8_1.distcp
│ │ ├── __9_0.distcp
│ │ ├── __9_1.distcp
│ │ ├── common.pt
│ │ ├── metadata.json
│ │ ├── modelopt_run_config.yaml
│ │ ├── run_config.yaml
│ │ └── train_state.pt
│ ├── latest_checkpointed_iteration.txt
│ └── latest_train_state.pt
|── train_dataloader.pt
|── training_info.json
Expected behavior
Successful conversion without any issue.
Additional context
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingcommunity-requestqa_rcca_donewhen RCCA finished for the issue, the qa will mark with this label .
Activity
dhineshkumar-r commentedon Mar 18, 2026
yuki-97 commentedon Mar 25, 2026
hi @RayenTian @yaoyu-33 , could you help to take a look?
dhineshkumar-r commentedon Mar 25, 2026
I had asked the same question in Megatron-Bridge Ref. The recommendation was to use the config of
unsloth/gpt-oss-20b-BF16and that helped resolve the issue.I update the conversion script locally to unblock myself. I can raise a PR with that change, if you folks think that'd be helpful.
yuki-97 commentedon Mar 28, 2026
hi @dhineshkumar-r , thanks for the investigation!
instead of just changing to
unsloth/gpt-oss-20b-BF16, I tend to think it's better to have a guide for gpt-oss like Megatron-Bridge, wdyt? @terrykongdhineshkumar-r commentedon Mar 29, 2026
Hey @yuki-97,
To clarify, my proposed change is to update checkpoint conversion script to take an optional argument
hf_model_nameas an override.yuki-97 commentedon Mar 30, 2026
Hey @dhineshkumar-r , I see, that sounds great, appreciate for your help!
dhineshkumar-r commentedon Apr 3, 2026
Hey @yuki-97
Here is the PR. Please take a look when you get a chance.
#2202
qiaochuz-nv commentedon May 5, 2026
QA RCCA Analysis
RCCA Status: Done
RCCA Category: missing_test_case
Test Action: create_new_test
Fix PR: #2202
Root Cause:
convert_megatron_to_hf.pyalways usedpolicy.model_nameas the HF model class/source, so GPT-OSS Megatron checkpoints could load with many missing layers unless the HF model name was explicitly overridden.Trigger Config: GPT-OSS Megatron checkpoint conversion to HF format + converter path
examples/converters/convert_megatron_to_hf.py+ missing--hf-model-nameoverride.Coverage Assessment:
nemo_llm/test_suite/rl/testcases/algorithms/test_grpo_gptoss_20b_megatron.sh--hf-model-nameconverter option.nemo_llm/test_suite/rl/testcases/sanitycheck/test_rcca_convert_megatron_to_hf_hf_model_name.sh(0-GPU static AST guard for--hf-model-namepropagation). Local direct validation passed; suite-run status pending.Conclusion: GPT-OSS training coverage exists, but converter coverage is absent.
chore(recipe): pin Gym to the convergence-study commit