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

add Qwen2-VL static generation #1512

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

Conversation

Spycsh
Copy link
Contributor

@Spycsh Spycsh commented Nov 22, 2024

What does this PR do?

Add Qwen2-VL static generation.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@Spycsh
Copy link
Contributor Author

Spycsh commented Nov 22, 2024

The pipeline test will not pass until optimum-habana matches the latest changes in transformers huggingface/transformers#34769, namely the task name image-to-text ==> image-text-to-text in examples/image-to-text/run_pipeline.py for many of the VLMs. I have currently validated the pass using my own test script https://github.com/Spycsh/qwen-vl-hpu/blob/main/qwen2_vl.py.

@jiminha
Copy link
Collaborator

jiminha commented Nov 25, 2024

age-to-text ==> image-text-to-text in examples/image-to-text/run_pipeline.py for many of the VLMs. I have currently validated the pass using my own test script https://github.com/Spycsh/qwen-vl-hpu/blob/main/qwen2_vl.py.

Are you saying we need transformer4.47 for this to work or can you update the examples/images-to-text/run_pipeline to support both cases?

@@ -974,14 +979,16 @@ def generate(
# 1. Handle `generation_config` and kwargs that might update it, and validate the `.generate()` call
self._validate_model_class()
tokenizer = kwargs.pop("tokenizer", None) # Pull this out first, we only use it for stopping criteria
#assistant_tokenizer = kwargs.pop("assistant_tokenizer", None) # only used for assisted generation
Copy link
Collaborator

Choose a reason for hiding this comment

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

please remove all this commented out codes.

Copy link
Contributor Author

@Spycsh Spycsh Nov 27, 2024

Choose a reason for hiding this comment

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

I think it is also affected by transformers 4.47. Will remove or uncomment it when transformers has its v4.47.0 release & optimum habana update to match 4.47.

if hpu_graphs and not lazy_mode:
raise ValueError(
"`hpu_graphs` is True but `lazy_mode` is False. HPU graphs require `lazy_mode` to be set to True."
)
num_virtual_tokens = kwargs.pop("num_virtual_tokens", 0)
generation_config, model_kwargs = self._prepare_generation_config(generation_config, **kwargs)
self._validate_model_kwargs(model_kwargs.copy())
self._validate_assistant(assistant_model)
#self._validate_assistant(assistant_model, tokenizer, assistant_tokenizer)
self._validate_assistant(assistant_model,)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this file(utils.py) change needed? please remove if it's not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above.

@jiminha
Copy link
Collaborator

jiminha commented Nov 25, 2024

@tthakkal Could you also review this please. THanks.

@Spycsh
Copy link
Contributor Author

Spycsh commented Nov 27, 2024

age-to-text ==> image-text-to-text in examples/image-to-text/run_pipeline.py for many of the VLMs. I have currently validated the pass using my own test script https://github.com/Spycsh/qwen-vl-hpu/blob/main/qwen2_vl.py.

Are you saying we need transformer4.47 for this to work or can you update the examples/images-to-text/run_pipeline to support both cases?

Yes. An update to latest transformers is needed here. run_pipeline.py also need to be updated correspondingly. I will look into this and get back to you later.

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.

2 participants