这是indexloc提供的服务,不要输入任何密码
Skip to content

Update LLaVA's next HF exporter to load ViT checkpoint from YAML #12841

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

Merged
merged 5 commits into from
Apr 4, 2025

Conversation

eagle705
Copy link
Collaborator

@eagle705 eagle705 commented Apr 1, 2025

Important

The Update branch button must only be pressed in very rare occassions.
An outdated branch is never blocking the merge of a PR.
Please reach out to the automation team before pressing that button.

What does this PR do ?

  • Modify the implementation to support exporting the ViT path from a checkpoint YAML file when using different CLIP versions, such as microsoft/LLM2CLIP-Openai-L-14-336, instead of the default openai/clip-vit-large-patch14-336.

Collection: [Note which collection this PR will affect]

Changelog

diff --git a/nemo/collections/vlm/llava_next/model/llava_next.py b/nemo/collections/vlm/llava_next/model/llava_next.py
index 423930286..564938c74 100644
--- a/nemo/collections/vlm/llava_next/model/llava_next.py
+++ b/nemo/collections/vlm/llava_next/model/llava_next.py
@@ -436,7 +436,8 @@ class HFLlavaNextExporter(io.ModelConnector[LlavaNextModel, "LlavaNextForConditi
 
         source = io.load_context(str(self), subpath="model.config")
         language_config = source.language_transformer_config
-        vision_config = CLIPVisionConfig.from_pretrained("openai/clip-vit-large-patch14-336")
+        vit_path = getattr(source.vision_transformer_config, "pretrained_model_name_or_path", "openai/clip-vit-large-patch14-336")
+        vision_config = CLIPVisionConfig.from_pretrained(vit_path)
 
         # Create text config for HuggingFace model
         text_config = HFLlamaConfig(

Usage

torchrun /opt/NeMo/scripts/vlm/llava_next_export_hf.py \
    --path <input_nemo_ckpt_path> \
    --output_path <output_hf_ckpt_path>

GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.
@abhinavg4

Additional Information

  • Related to # (issue)

Signed-off-by: Joosung Yoon <joosungy@nvidia.com>
@eagle705 eagle705 force-pushed the update-llava-next-hf-exporter branch from ffd250c to 0e66490 Compare April 1, 2025 16:26
Signed-off-by: eagle705 <eagle705@users.noreply.github.com>
Copy link
Collaborator

@abhinavg4 abhinavg4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Looks good.

@ko3n1g ko3n1g added Run CICD and removed Run CICD labels Apr 2, 2025
@ko3n1g ko3n1g merged commit 99ea53d into NVIDIA:main Apr 4, 2025
234 checks passed
rrbale-nvidia pushed a commit to rrbale-nvidia/NeMo that referenced this pull request Apr 11, 2025
…DIA#12841)

* Update LLaVA's next HF exporter to load ViT checkpoint from YAML

Signed-off-by: Joosung Yoon <joosungy@nvidia.com>

* Apply isort and black reformatting

Signed-off-by: eagle705 <eagle705@users.noreply.github.com>

---------

Signed-off-by: Joosung Yoon <joosungy@nvidia.com>
Signed-off-by: eagle705 <eagle705@users.noreply.github.com>
Co-authored-by: eagle705 <eagle705@users.noreply.github.com>
Co-authored-by: oliver könig <okoenig@nvidia.com>
Signed-off-by: Ritvik Bale <rbale@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants