-
Notifications
You must be signed in to change notification settings - Fork 179
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
fill prompt for sampler analysis with real tokens in VLM pipeline #1247
Draft
sbalandi
wants to merge
1
commit into
openvinotoolkit:master
Choose a base branch
from
sbalandi:vlm_mask_vs_hist
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+25
−4
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,16 +93,19 @@ class ov::genai::VLMPipeline::VLMPipelineImpl { | |
|
||
ov::Tensor inputs_embeds = m_inputs_embedder->get_inputs_embeds(prompt, rgbs); | ||
|
||
Sampler sampler = Sampler(m_tokenizer); | ||
|
||
std::vector<SequenceGroup::Ptr> requests; | ||
size_t request_id = 0; | ||
size_t block_size = 1; // not used | ||
bool enable_prefix_caching = false; | ||
size_t history_size = m_language.get_tensor("attention_mask").get_shape().at(1); | ||
size_t inputs_embeds_size = inputs_embeds.get_shape().at(1); | ||
ov::Tensor prompt_ids(ov::element::i64, { history_size + inputs_embeds_size }); | ||
std::fill_n(prompt_ids.data<int64_t>(), prompt_ids.get_size(), 0); | ||
|
||
auto chat_history = m_inputs_embedder->get_tokenized_chat_history(); | ||
size_t chat_history_size = std::max(chat_history.get_shape().at(1), history_size + inputs_embeds_size); | ||
ov::Tensor prompt_ids(ov::element::i64, { chat_history_size }); | ||
std::fill_n(prompt_ids.data<int64_t>(), prompt_ids.get_size(), 1); | ||
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. why |
||
auto chat_history_data = chat_history.data<int64_t>(); | ||
std::copy(chat_history_data, chat_history_data + chat_history.get_size(), prompt_ids.data<int64_t>()); | ||
|
||
SequenceGroup::Ptr sequence_group = std::make_shared<SequenceGroup>(request_id, prompt_ids, generation_config, block_size, enable_prefix_caching); | ||
sequence_group->set_sequence_group_ptr(sequence_group); | ||
|
@@ -131,6 +134,8 @@ class ov::genai::VLMPipeline::VLMPipelineImpl { | |
ov::Tensor position_ids = ov::Tensor{ov::element::i64, { 1, inputs_embeds.get_shape()[1] }}; | ||
std::iota(position_ids.data<int64_t>(), position_ids.data<int64_t>() + position_ids.get_size(), history_size); | ||
|
||
Sampler sampler = Sampler(m_tokenizer); | ||
|
||
ov::genai::EncodedResults encoded_result; | ||
int32_t m_selected_beam = 0; | ||
std::tie(encoded_result, m_selected_beam) = ov::genai::get_lm_encoded_results(m_language, inputs_embeds, new_atten_mask, streamer_ptr, sampler, requests, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
looks like we have the same case as for LLMs, when
decode ( encode ( X ) )
provides smaller value thanX
?in this case we need to partially re-compute the history.
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.
in general, I would consider merging VLM and LLM pipelines generate functions to keep all this magic with history in one place.
Or at least to create helper function similar to
get_lm_encoded_results