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

[Feature] Support llava onevision #2783

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

deepindeed2022
Copy link
Contributor

@deepindeed2022 deepindeed2022 commented Nov 21, 2024

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily receiving feedbacks. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

Support llava-onevision with LMDeploy

Modification

  • support llava-onevision series
  • refactor the llava related code for device_map
  • refactor llava_next.py with transformers new features

Use cases (Optional)

git clone https://huggingface.co/lmms-lab/llava-onevision-qwen2-7b-ov
lmdeploy serve api_server llava-onevision-qwen2-7b-ov

Checklist

  1. Pre-commit or other linting tools are used to fix the potential lint issues.
  2. The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness.
  3. If the modification has a dependency on downstream projects of a newer version, this PR should be tested with all supported versions of downstream projects.
  4. The documentation has been modified accordingly, like docstring or example tutorials.

@deepindeed2022 deepindeed2022 changed the title Support llava onevision [Feature] Support llava onevision Nov 21, 2024
@lvhan028 lvhan028 added the enhancement New feature or request label Nov 21, 2024
| llava-hf/llava-1.5-7b-hf | 7B | TurboMind, PyTorch |
| liuhaotian/llava-v1.6-vicuna-7b | 7B | TurboMind, PyTorch |
| liuhaotian/llava-v1.6-mistral-7b | 7B | TurboMind, PyTorch |
| lmms-lab/llava-onevision-qwen2-7b-ov | 0.5B,7B,72B | TurboMind, PyTorch |
Copy link
Collaborator

@RunningLeon RunningLeon Nov 22, 2024

Choose a reason for hiding this comment

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

Hi, the model is not supported by pytorch engine as it fails with pipeline.

lmdeploy/lmdeploy/pytorch/models/patch.py", line 177, in _get_model_class
    raise RuntimeError(
RuntimeError: Can not found rewrite for architectures: ['LlavaQwenForCausalLM']

Copy link
Contributor Author

Choose a reason for hiding this comment

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

delete PyTorchBackend

@@ -23,7 +28,7 @@ def check_llava_install():
except ImportError:
raise ImportError(
'To use LlavaVLModel, please install llava by '
'pip install git+https://github.com/haotian-liu/LLaVA.git --no-deps' # noqa: E501
'pip install git+https://github.com/LLaVA-VL/LLaVA-NeXT.git --no-deps' # noqa: E501
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will this PR affect the deployment of liuhaotian/llava-v1.5-7b

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The model worked well on the new repo

@lvhan028
Copy link
Collaborator

Hi, @deepindeed2022 thanks for your contribution to LMDeploy
We are currently refactoring VLM modules in PR #2810, which conflicts to this PR.
I'd like to push the review of #2810 at first. After it is merged, I'll come back to this PR and resolve the conflicts.
Does it work for you?

@deepindeed2022
Copy link
Contributor Author

Hi, @deepindeed2022 thanks for your contribution to LMDeploy We are currently refactoring VLM modules in PR #2810, which conflicts to this PR. I'd like to push the review of #2810 at first. After it is merged, I'll come back to this PR and resolve the conflicts. Does it work for you?

Yes, I 'll follow up after this PR #2810 merge.

f'{self.hf_config.vision_feature_select_strategy}')
image_features = self.model.multi_modal_projector(image_features)
image_features = torch.split(image_features, image_num_patches, dim=0)
image_features = self.model.get_image_features(
Copy link
Collaborator

@RunningLeon RunningLeon Nov 26, 2024

Choose a reason for hiding this comment

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

hi, it seems llava-next models do not have this method for transformers==4.45.2

  File "/lmdeploy/lmdeploy/vl/model/llava_next.py", line 68, in forward
    image_features = self.model.get_image_features(
  File "/opt/py3/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1729, in __getattr__
    raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
AttributeError: 'LlavaNextForConditionalGeneration' object has no attribute 'get_image_features'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the new feature in recently release transformers(about 1 month), I use transformers==4.46.3.

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe we could check transformers version in the initialization of llavanext and give info of using transformers>=4.60.0 if not met

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

Successfully merging this pull request may close these issues.

3 participants