Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to convert Llama3 Nemo 2.0 checkpoint to HF #11256

Open
EthanLI24 opened this issue Nov 12, 2024 · 3 comments
Open

Fail to convert Llama3 Nemo 2.0 checkpoint to HF #11256

EthanLI24 opened this issue Nov 12, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@EthanLI24
Copy link

Describe the bug

I use Nemo 2.0 to train my model and get Nemo 2.0 checkpoint like this with .distcp files:
model_name
├── context
│ ├── model_config.yaml
│ ├── io.json
│ └── tokenizer
├── weights
│ ├── distributed checkpointing directories/files in torch_dist format
│ ├── metadata.json
│ └── common.pt

but filed to use NeMo/scripts/checkpoint_converters/convert_llama_nemo_to_hf.py to export it to a HF file

Expected behavior

get HF files by Nemo2.0 checkpoint

@EthanLI24 EthanLI24 added the bug Something isn't working label Nov 12, 2024
@EthanLI24
Copy link
Author

Is there a way we can now save non .distcp files or huggingface .bin files directly after training?
If not, how to convert nemo2.0 checkpoint to the community common format?

@hemildesai
Copy link
Collaborator

Hi, the scripts/checkpoint_converters/convert_llama_nemo_to_hf.py script is only for NeMo 1.0 checkpoints. To export 2.0 checkpoints, you can use a custom script like

from pathlib import Path

from nemo.collections.llm import export_ckpt

if __name__ == "__main__":
    export_ckpt(
        path=Path("/workspace/input_ckpt"),
        target="hf",
        output_path=Path("/workspace/output_ckpt.hf"),
    )

@EthanLI24
Copy link
Author

EthanLI24 commented Nov 14, 2024

Hi, the scripts/checkpoint_converters/convert_llama_nemo_to_hf.py script is only for NeMo 1.0 checkpoints. To export 2.0 checkpoints, you can use a custom script like

from pathlib import Path

from nemo.collections.llm import export_ckpt

if name == "main":
export_ckpt(
path=Path("/workspace/input_ckpt"),
target="hf",
output_path=Path("/workspace/output_ckpt.hf"),
)

Here are my fold arch:

nemo2_llama3
├── context
│ ├── model.yaml
│ ├── io.json
│ └── nemo_tokenizer
├── weights
│ ├── __0_0.distcp
│ ├── __0_1.distcp
│ ├── metadata.json
│ └── common.pt

and I follow your instruction to use

if __name__ == "__main__":
    export_ckpt(
        path=Path("./nemo2_llama3"),
        target="hf",
        output_path=Path("./nemo2exporthf"),
    )

but i get failed again, could you help me with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants