-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Adding idefics2 #4937
base: main
Are you sure you want to change the base?
Adding idefics2 #4937
Conversation
@jc9123 Could you ping me when this PR is ready for review? Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! @jc9123
I did a first pass and left some comments.
The main issue that we need to address is that we should be using vLLM primitive layers whenever possible instead of directly using transformers
implementation. I would recommend read through https://docs.vllm.ai/en/latest/models/adding_model.html and compare implementations between vLLM and transformers for other models to see where the difference is.
Some other misc items:
- Instead of saving the artifacts within this repo, upload them to a public S3 bucket.
- Update our doc to include idefics2 as a supported model
- Perhaps consolidate
idefics2_example.py
andllava_example.py
as one filevision_language_model_example.py
?
|
||
# Added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove these two lines
examples/images/cherry_blossom.jpg
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put these images and .pt
files at a remote location and note it in examples/idefics2_example.py
(similar to what we did for llava). I think the same bucket should work since it's public.
|
||
def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is copied from transformers
: can you add a reference similar to what we did here
self.o_proj = nn.Linear(self.num_heads * self.head_dim, | ||
self.hidden_size, | ||
bias=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be using vllm primitive layer - example:
vllm/vllm/model_executor/models/llama.py
Lines 139 to 144 in 5f6d10c
self.o_proj = RowParallelLinear( | |
self.total_num_heads * self.head_dim, | |
hidden_size, | |
bias=bias, | |
quant_config=quant_config, | |
) |
self.q_proj = nn.Linear(self.hidden_size, | ||
self.num_heads * self.head_dim, | ||
bias=False) | ||
self.k_proj = nn.Linear(self.hidden_size, | ||
self.num_key_value_heads * self.head_dim, | ||
bias=False) | ||
self.v_proj = nn.Linear(self.hidden_size, | ||
self.num_key_value_heads * self.head_dim, | ||
bias=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you leave a note here that we're not using QKVParallelLinear
because of cross attention?
Also, shouldn't these be using ColumnParallelLinear
?
self.gate_proj = nn.Linear(hidden_size, intermediate_size, bias=False) | ||
self.up_proj = nn.Linear(hidden_size, intermediate_size, bias=False) | ||
self.down_proj = nn.Linear(intermediate_size, output_size, bias=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use vllm primitive layers here too. See example in LlamaMLP
self.image_token_id = self.config.image_token_id | ||
self._use_flash_attention_2 =\ | ||
config._attn_implementation == "flash_attention_2" | ||
# self.post_init() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# self.post_init() |
linear_method) | ||
|
||
##copied from HF | ||
self.lm_head = nn.Linear(config.text_config.hidden_size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be using ParallelLMHead
##SIGLIP vision encodder | ||
self.vision_model = SiglipVisionModel(config.vision_config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave a note that this is directly using transformers
's implementation and it's currently not tensor parallelized.
What is needed to get this merged? :) |
Hey @jvlinsta! It's been a while and we had done some major refactoring since the last update of this PR. I'm not sure if the author is still going to work on this, but if you're interested, please take a look at other implementations (for example, PaliGemma) for reference or follow our guide here. |
A quick heads-up that #7020 will implement the vision part of this model (up to |
This pull request has been automatically marked as stale because it has not had any activity within 90 days. It will be automatically closed if no further activity occurs within 30 days. Leave a comment if you feel this pull request should remain open. Thank you! |
This pull request has merge conflicts that must be resolved before it can be |
Adding support for the idefics2 model. A example usage of running the model could be found in vllm/examples/idefics2_example.py
.
FIX #4124
BEFORE SUBMITTING, PLEASE READ THE CHECKLIST BELOW AND FILL IN THE DESCRIPTION ABOVE
PR Checklist (Click to Expand)
Thank you for your contribution to vLLM! Before submitting the pull request, please ensure the PR meets the following criteria. This helps vLLM maintain the code quality and improve the efficiency of the review process.
PR Title and Classification
Only specific types of PRs will be reviewed. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:
[Bugfix]
for bug fixes.[CI/Build]
for build or continuous integration improvements.[Doc]
for documentation fixes and improvements.[Model]
for adding a new model or improving an existing model. Model name should appear in the title.[Frontend]
For changes on the vLLM frontend (e.g., OpenAI API server,LLM
class, etc.)[Kernel]
for changes affecting CUDA kernels or other compute kernels.[Core]
for changes in the core vLLM logic (e.g.,LLMEngine
,AsyncLLMEngine
,Scheduler
, etc.)[Hardware][Vendor]
for hardware-specific changes. Vendor name should appear in the prefix (e.g.,[Hardware][AMD]
).[Misc]
for PRs that do not fit the above categories. Please use this sparingly.Note: If the PR spans more than one category, please include all relevant prefixes.
Code Quality
The PR need to meet the following code quality standards:
format.sh
to format your code.docs/source/
if the PR modifies the user-facing behaviors of vLLM. It helps vLLM user understand and utilize the new features or changes.Notes for Large Changes
Please keep the changes as concise as possible. For major architectural changes (>500 LOC excluding kernel/data/config/test), we would expect a GitHub issue (RFC) discussing the technical design and justification. Otherwise, we will tag it with
rfc-required
and might not go through the PR.What to Expect for the Reviews
The goal of the vLLM team is to be a transparent reviewing machine. We would like to make the review process transparent and efficient and make sure no contributor feel confused or frustrated. However, the vLLM team is small, so we need to prioritize some PRs over others. Here is what you can expect from the review process:
action-required
label on the PR if there are changes required. The contributor should address the comments and ping the reviewer to re-review the PR.Thank You
Finally, thank you for taking the time to read these guidelines and for your interest in contributing to vLLM. Your contributions make vLLM a great tool for everyone!