Skip to content

Chunked Prefill VLM #3188

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

Merged
merged 31 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix config image_token_id error
  • Loading branch information
mht-sharma committed Apr 25, 2025
commit 60b8cb0e46838ca8681a3ff1c4e438744ba7b86b
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def get_inputs_embeds(

def forward(
self,
input_ids: torch.Tensor,
position_ids: torch.Tensor,
cu_seqlen_prefill: Optional[torch.Tensor],
kv_cache: List[Tuple[torch.Tensor, torch.Tensor]],
Expand All @@ -107,12 +106,9 @@ def forward(
max_s: int,
prefill_cache_indices: Optional[torch.Tensor] = None,
lm_head_indices: Optional[torch.Tensor] = None,
pixel_values: torch.FloatTensor = None,
# Unused here
pixel_attention_mask: Optional[torch.BoolTensor] = None,
image_sizes: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.BoolTensor] = None,
adapter_data: Optional[torch.Tensor] = None,
image_grid_thw: Optional[torch.LongTensor] = None,
inputs_embeds: Optional[torch.Tensor] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we not have both, or either input_ids and input_embeds ?

Seems like it's an antipattern to accept both (since we don't know which one is valid.
It's totally fine to handle the embeddings before this step and only accept input_embeds imho

) -> Tuple[torch.Tensor, Optional[torch.Tensor]]:
# TODO This is odd but apparently pali gemma position ids start at 1.
Expand Down
5 changes: 2 additions & 3 deletions server/text_generation_server/models/vlm_causal_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,8 @@ def batch_tokenized_inputs(
max_length = 0
vocab = tokenizer.get_vocab()

config.image_token_index = getattr(
config, "image_token_index", config.image_token_id
)
if not hasattr(config, "image_token_index"):
config.image_token_index = config.image_token_id

batch_tokenized_inputs: List[List[int]] = []
batch_image_inputs: List[Optional[List[dict]]] = []
Expand Down
Loading