mirror of
https://github.com/deepseek-ai/DeepSeek-VL2.git
synced 2026-11-05 01:07:23 +00:00
[GH-ISSUE #82] Problem with def apply_rotary_pos_emb(q, k, cos, sin, position_ids, unsqueeze_dim=1): (index out of bounds error) #69
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepSeek-VL2#69
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ukaprch on GitHub (Feb 14, 2025).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-VL2/issues/82
Running model for an image. Note: I am using a quantized (qint8) version of the model.
> deepseek_vl2.models.modeling_deepseek.apply_rotary_pos_emb : 360 Python deepseek_vl2.models.modeling_deepseek.forward : 886 (Current frame) Python torch.nn.modules.module._call_impl : 1750 Python torch.nn.modules.module._wrapped_call_impl : 1739 Python deepseek_vl2.models.modeling_deepseek.forward : 1298 Python torch.nn.modules.module._call_impl : 1750 Python torch.nn.modules.module._wrapped_call_impl : 1739 Python deepseek_vl2.models.modeling_deepseek.forward : 1585 Python torch.nn.modules.module._call_impl : 1750 PythonWhen calling def apply_rotary_pos_emb the COS and SIN tensors are empty resulting in an error:
So deepseek changed the LLama original code. These (buffers) apparently are not initialized in this model. How do we get around this error?
After using the chunk_size=512 # prefilling size the error above went away producing a new error:
Then I got a new error message trying to update the version on a torch tensor. 1st problem: Why in inference mode would the model be updating a torch tensor version? The 2nd problem has to do with Quanto not handling the problem internally as the tensor in question was quantized.
Here's the relevant code in def forward (modeling_deepseek.py; line number 898) where I had to make a change.
@MirkoDeVita98 commented on GitHub (Feb 25, 2025):
I have the same error, were you able to solve it?
EDIT: I found a way around it. I am now running the model using incremental prefilling that can be found in inference.py + the split model found here + the fix for multi parallelism
@ukaprch commented on GitHub (Feb 26, 2025):
Initially is used the prefill method they proposed:
# incremental_prefilling when using 40G GPU for vl2-small inputs_embeds, past_key_values = vl_gpt.incremental_prefilling( input_ids=prepare_inputs.input_ids, images=prepare_inputs.images, images_seq_mask=prepare_inputs.images_seq_mask, images_spatial_crop=prepare_inputs.images_spatial_crop, attention_mask=prepare_inputs.attention_mask, chunk_size=512 # prefilling size )Then I think instead of the above you can set this parameter:
past_key_values=None,
before you generate and thus, you may not need the prefill step.
In any event, I kept running into problems with vl2-small and opted to
just use the vl2-tiny which interestingly enough worked w/o a hitch.