-
-
Notifications
You must be signed in to change notification settings - Fork 15.9k
[Model] Fix hunyuan-vl shape mismatch #31403
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -247,6 +247,12 @@ def forward( | |||||||||||||||||||||||||||||||||||||
| qkv, _ = self.qkv(x) | ||||||||||||||||||||||||||||||||||||||
| q, k, v = qkv.chunk(3, dim=-1) | ||||||||||||||||||||||||||||||||||||||
| out = self.attn(q, k, v) | ||||||||||||||||||||||||||||||||||||||
| out = out.view( | ||||||||||||||||||||||||||||||||||||||
| x.size(0), | ||||||||||||||||||||||||||||||||||||||
| -1, | ||||||||||||||||||||||||||||||||||||||
| self.num_attention_heads_per_partition | ||||||||||||||||||||||||||||||||||||||
| * self.hidden_size_per_attention_head, | ||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+250
to
+255
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Not really, we will automatically reshape output to make sure it align with q, k, v input: vllm/vllm/attention/layers/mm_encoder_attention.py Lines 160 to 177 in 8711b21
So I think we won't hit the shape mismatch issue here. 🤔
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, it seems the issue for ascend, I'll have a further check
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thx, Confirmed it is the issue for |
||||||||||||||||||||||||||||||||||||||
| output, _ = self.o_proj(out) | ||||||||||||||||||||||||||||||||||||||
| return output | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
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.
For better maintainability and readability, you can simplify the calculation of the last dimension in the
viewoperation. Instead of re-calculating the partitioned hidden size from the number of heads and head size, you can directly use the shape of the weight from the subsequent projection layero_proj. This makes the code more robust to future changes as it directly references the expected input dimension of the next layer.