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

Extended neva model to support llava_next #11390

Closed
wants to merge 0 commits into from

Conversation

yashaswikarnati
Copy link
Collaborator

What does this PR do ?

Extended neva model to support llava_next

Collection:
VLM

Changelog

  • Utility functions for image tiling
  • LLaVA Next model class
  • LLaVA Next HF checkpoint importer class
    -NeVA fwd function changes to handle image tiling

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:

  • [Y] 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.

Additional Information

  • Related to # (issue)

nemo/collections/vlm/neva/model/__init__.py Fixed Show fixed Hide fixed
nemo/collections/vlm/neva/model/__init__.py Fixed Show fixed Hide fixed
nemo/collections/vlm/neva/model/__init__.py Fixed Show fixed Hide fixed
nemo/collections/vlm/neva/model/__init__.py Fixed Show fixed Hide fixed
@@ -27,7 +27,7 @@

if TYPE_CHECKING:
from transformers import LlavaConfig as HFLlavaConfig
from transformers import LlavaForConditionalGeneration
from transformers import LlavaForConditionalGeneration, LlavaNextForConditionalGeneration

Check notice

Code scanning / CodeQL

Unused import

Import of 'LlavaForConditionalGeneration' is not used.
Copy link
Contributor

beep boop 🤖: 🚨 The following files must be fixed before merge!


Your code was analyzed with PyLint. The following annotations have been identified:

************* Module nemo.collections.vlm.neva.model.utils
nemo/collections/vlm/neva/model/utils.py:86:0: C0301: Line too long (121/119) (line-too-long)
nemo/collections/vlm/neva/model/utils.py:87:0: C0301: Line too long (188/119) (line-too-long)
nemo/collections/vlm/neva/model/utils.py:142:0: C0301: Line too long (131/119) (line-too-long)
nemo/collections/vlm/neva/model/utils.py:157:0: C0301: Line too long (139/119) (line-too-long)
nemo/collections/vlm/neva/model/utils.py:167:0: C0301: Line too long (129/119) (line-too-long)
nemo/collections/vlm/neva/model/utils.py:255:0: C0301: Line too long (127/119) (line-too-long)
nemo/collections/vlm/neva/model/utils.py:335:0: C0301: Line too long (124/119) (line-too-long)
nemo/collections/vlm/neva/model/utils.py:343:0: C0301: Line too long (203/119) (line-too-long)
nemo/collections/vlm/neva/model/utils.py:350:0: C0301: Line too long (122/119) (line-too-long)

-----------------------------------
Your code has been rated at 9.42/10

Thank you for improving NeMo's documentation!

Copy link
Contributor

beep boop 🤖: 🙏 The following files have warnings. In case you are familiar with these, please try helping us to improve the code base.


Your code was analyzed with PyLint. The following annotations have been identified:

************* Module nemo.collections.vlm.neva.model.base
nemo/collections/vlm/neva/model/base.py:475:0: C0301: Line too long (139/119) (line-too-long)
nemo/collections/vlm/neva/model/base.py:478:0: C0301: Line too long (128/119) (line-too-long)
nemo/collections/vlm/neva/model/base.py:486:0: C0301: Line too long (125/119) (line-too-long)
nemo/collections/vlm/neva/model/base.py:495:0: C0301: Line too long (122/119) (line-too-long)
nemo/collections/vlm/neva/model/base.py:99:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/base.py:133:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/base.py:151:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/base.py:172:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/base.py:227:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/base.py:242:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/vlm/neva/model/base.py:261:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/base.py:282:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/vlm/neva/model/base.py:314:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/base.py:352:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/base.py:365:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/vlm/neva/model/base.py:647:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/vlm/neva/model/base.py:664:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/base.py:668:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/base.py:694:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/base.py:697:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/base.py:700:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/base.py:704:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/base.py:710:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/base.py:717:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/base.py:28:0: W0611: Unused TEDotProductAttention imported from megatron.core.extensions.transformer_engine (unused-import)
************* Module nemo.collections.vlm.neva.model.llava
nemo/collections/vlm/neva/model/llava.py:133:0: C0301: Line too long (137/119) (line-too-long)
nemo/collections/vlm/neva/model/llava.py:134:0: C0301: Line too long (122/119) (line-too-long)
nemo/collections/vlm/neva/model/llava.py:135:0: C0301: Line too long (146/119) (line-too-long)
nemo/collections/vlm/neva/model/llava.py:136:0: C0301: Line too long (144/119) (line-too-long)
nemo/collections/vlm/neva/model/llava.py:176:0: C0301: Line too long (128/119) (line-too-long)
nemo/collections/vlm/neva/model/llava.py:177:0: C0301: Line too long (161/119) (line-too-long)
nemo/collections/vlm/neva/model/llava.py:178:0: C0301: Line too long (157/119) (line-too-long)
nemo/collections/vlm/neva/model/llava.py:179:0: C0301: Line too long (150/119) (line-too-long)
nemo/collections/vlm/neva/model/llava.py:180:0: C0301: Line too long (146/119) (line-too-long)
nemo/collections/vlm/neva/model/llava.py:181:0: C0301: Line too long (158/119) (line-too-long)
nemo/collections/vlm/neva/model/llava.py:182:0: C0301: Line too long (154/119) (line-too-long)
nemo/collections/vlm/neva/model/llava.py:183:0: C0301: Line too long (135/119) (line-too-long)
nemo/collections/vlm/neva/model/llava.py:184:0: C0301: Line too long (131/119) (line-too-long)
nemo/collections/vlm/neva/model/llava.py:185:0: C0301: Line too long (135/119) (line-too-long)
nemo/collections/vlm/neva/model/llava.py:186:0: C0301: Line too long (131/119) (line-too-long)
nemo/collections/vlm/neva/model/llava.py:41:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/vlm/neva/model/llava.py:47:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/vlm/neva/model/llava.py:60:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/vlm/neva/model/llava.py:72:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/vlm/neva/model/llava.py:76:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/vlm/neva/model/llava.py:80:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/vlm/neva/model/llava.py:91:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/vlm/neva/model/llava.py:108:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/vlm/neva/model/llava.py:130:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/llava.py:207:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/llava.py:213:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/llava.py:253:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/vlm/neva/model/llava.py:364:0: C0115: Missing class docstring (missing-class-docstring)

-----------------------------------
Your code has been rated at 8.89/10

Thank you for improving NeMo's documentation!

@@ -31,7 +39,9 @@
"NevaConfig",
"NevaModel",
"LlavaConfig",
"Llava15Config7B",
"LlavaNextModel" "Llava15Config7B",

Check failure

Code scanning / CodeQL

Explicit export is not defined

The name 'LlavaNextModelLlava15Config7B' is exported by __all__ but is not defined.
@@ -31,7 +39,9 @@
"NevaConfig",
"NevaModel",
"LlavaConfig",
"Llava15Config7B",
"LlavaNextModel" "Llava15Config7B",

Check warning

Code scanning / CodeQL

Implicit string concatenation in a list

Implicit string concatenation. Maybe missing a comma?
image_newline=self.image_newline,
)
combined_embeddings, attention_mask, position_ids, final_labels, final_input_ids, final_loss_mask = (
merge_input_ids_with_image_features(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like this design here, reason -
this method is very similar function as self._preprocess_data. In self._preprocess_data we do more things to support sp and cp. It will be good if we can re-use the same method. Can you tell me how these 2 methods are different?

@@ -455,6 +459,7 @@ def forward(
self,
input_ids: torch.Tensor,
position_ids: torch.Tensor,
image_sizes: List[torch.Tensor] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

if we are going to change the signiture, it would be better we are using 2 model class? it will might break something we will use nemo / mcore llava

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It should not break anything for vanilla neva as image_sizes tensor is optional and will be used only for llava_next. The reason for using the neva model class is most of the functionality is same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants