-
-
Notifications
You must be signed in to change notification settings - Fork 10k
Support token_type_ids in V1 with less code changes #21985
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
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
7f850be
Pass token type ids as pooling param to the model runner
maxdebayser 809384e
fix errors
maxdebayser 6f330b7
fix cudagraph problem
maxdebayser 794aaf2
compress token type ids
maxdebayser a6f949d
forgot to(gpu)
maxdebayser 56dba67
Address review comments
maxdebayser cdf802a
Merge branch 'upstream_main' into v1_token_type_ids
maxdebayser 3fe425a
fix mistake
maxdebayser 4b19f4c
address review comments
maxdebayser 5d0999c
fix type hints
maxdebayser 2074d29
address review comments
maxdebayser 148ab54
Merge branch 'upstream_main' into v1_token_type_ids
maxdebayser accf2f7
Merge branch 'upstream_main' into v1_token_type_ids
maxdebayser cb935de
change comment order
maxdebayser a250e5b
fix test error message
maxdebayser 939165f
Merge branch 'upstream_main' into v1_token_type_ids
maxdebayser 2add932
fix error msg inconsistency
maxdebayser 4df6cd2
sync with gpu after changing input tensors
maxdebayser 0123dc5
Merge branch 'upstream_main' into v1_token_type_ids
maxdebayser e486790
increase test tolerance
maxdebayser 164d890
Merge branch 'upstream_main' into v1_token_type_ids
maxdebayser 7e3b671
add TODO comment
maxdebayser 2cac159
Merge branch 'upstream_main' into v1_token_type_ids
maxdebayser 29ca69b
rename method
maxdebayser ed5a7ef
fix editing mistake
maxdebayser 656059b
Merge branch 'upstream_main' into v1_token_type_ids
maxdebayser d9a8835
Merge branch 'upstream_main' into v1_token_type_ids
maxdebayser 3d089dd
Merge branch 'upstream_main' into v1_token_type_ids
maxdebayser 0471896
Merge branch 'upstream_main' into v1_token_type_ids
maxdebayser db612f7
rename argument
maxdebayser 5184a3d
Merge branch 'upstream_main' into v1_token_type_ids
maxdebayser 96e3871
rename argument
maxdebayser 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -184,15 +184,49 @@ def get_score_prompt( | |
model_config, | ||
tokenizer, | ||
) | ||
from vllm.model_executor.model_loader import get_model_cls | ||
|
||
full_prompt = apply_score_template(model_config, prompt_1, prompt_2) | ||
|
||
prompt_inputs = tokenizer(full_prompt, **tokenization_kwargs) | ||
model = get_model_cls(model_config) | ||
if supports_score_template(model): | ||
full_prompt = apply_score_template(model_config, prompt_1, prompt_2) | ||
prompt_inputs = tokenizer(full_prompt, **tokenization_kwargs) | ||
elif model_config.use_pad_token: | ||
# cross_encoder models defaults to using pad_token. | ||
prompt_inputs = tokenizer(text=prompt_1, | ||
text_pair=prompt_2, | ||
**tokenization_kwargs) | ||
full_prompt = tokenizer.decode(prompt_inputs["input_ids"]) | ||
else: | ||
# `llm as reranker` models defaults to not using pad_token. | ||
full_prompt = prompt_1 + prompt_2 | ||
prompt_inputs = tokenizer(text=full_prompt, **tokenization_kwargs) | ||
|
||
engine_prompt = TokensPrompt(prompt_token_ids=prompt_inputs["input_ids"]) | ||
|
||
if (token_type_ids := prompt_inputs.get("token_type_ids")) is not None: | ||
engine_prompt["token_type_ids"] = token_type_ids | ||
|
||
post_process_tokens(model_config, engine_prompt) | ||
|
||
if mm_data is not None: | ||
engine_prompt["multi_modal_data"] = mm_data | ||
return full_prompt, engine_prompt | ||
|
||
|
||
def compress_token_type_ids(token_type_ids: list[int]) -> int: | ||
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. This is to minimize the amount of data that is transferred between processes |
||
""" | ||
Return position of the first 1 or the length of the list | ||
if not found. | ||
""" | ||
first_one = len(token_type_ids) | ||
err_msg = "Token type ids are expected to be a sequence"\ | ||
" of zeros followed by a sequence of ones" | ||
for i, type_id in enumerate(token_type_ids): | ||
if type_id == 0 and first_one < i: | ||
raise ValueError(err_msg) | ||
elif type_id == 1 and first_one > i: | ||
first_one = i | ||
elif type_id > 1: | ||
raise ValueError(err_msg) | ||
|
||
return first_one |
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.
Uh oh!
There was an error while loading. Please reload this page.