-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Adds method to read the pooling types from model's files #9506
Open
flaviabeo
wants to merge
26
commits into
vllm-project:main
Choose a base branch
from
flaviabeo:main
base: main
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.
+324
−18
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
e1ff0f7
Adds method to read the pooling types from model's files
flaviabeo 5bc9a7d
Adds MEAN pooling type
flaviabeo 7119bb3
Make normalize variable return bool value
flaviabeo 5b0a9f3
Adds test for model loading with the params
flaviabeo d16eefd
Adds method and attribute for bert sentence_transformer config files
maxdebayser 6315c33
Adds other file names for the bert models config
flaviabeo 1bcd3e8
fix loading of non-bert models and fix tests
maxdebayser 69222e4
Extra check for if the files exists
flaviabeo 32ee574
Reverts whitespaces
flaviabeo 0b948a4
Adds pooling config as engine CLI arg
flaviabeo c3166f1
add pooling_config to models with a Pooler layer
maxdebayser 16bcacd
Fixes tests, splits the pooling config params in type and norm
flaviabeo 2cd2450
Moves get_pooling_type logic to ModelConfig
flaviabeo 9c32660
Method to treat the pooling name string from file
flaviabeo ae73f4b
Format linting
flaviabeo 02195c8
wip
flaviabeo 37167ff
test
flaviabeo 3d36a8c
Fixes and Exception for not supported pooling types
flaviabeo fbcd540
Fixing lint
flaviabeo c268d89
Fixing linting
flaviabeo 5627d2f
Merge branch 'upstream_main'
flaviabeo 0da7979
Lint
flaviabeo 4531c33
Merge branch 'upstream_main'
flaviabeo 8df9d63
Fix merge conflicts
flaviabeo 4ac1f20
Review changes requested
flaviabeo ff9705b
Simplify pooler config init
flaviabeo 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import os | ||
|
||
from vllm.model_executor.layers.pooler import PoolingType | ||
from vllm.model_executor.models.bert import BertEmbeddingModel | ||
|
||
MAX_MODEL_LEN = 128 | ||
MODEL_NAME = os.environ.get("MODEL_NAME", "BAAI/bge-base-en-v1.5") | ||
REVISION = os.environ.get("REVISION", "main") | ||
|
||
|
||
def test_model_loading_with_params(vllm_runner): | ||
""" | ||
Test parameter weight loading with tp>1. | ||
""" | ||
with vllm_runner(model_name=MODEL_NAME, | ||
revision=REVISION, | ||
dtype="float16", | ||
max_model_len=MAX_MODEL_LEN) as model: | ||
output = model.encode("Write a short story about a robot that" | ||
" dreams for the first time.\n") | ||
|
||
model_config = model.model.llm_engine.model_config | ||
|
||
model_tokenizer = model.model.llm_engine.tokenizer | ||
|
||
# asserts on the bert model config file | ||
assert model_config.bert_config["max_seq_length"] == 512 | ||
assert model_config.bert_config["do_lower_case"] | ||
|
||
# asserts on the pooling config files | ||
assert model_config.pooler_config.pooling_type == PoolingType.CLS.name | ||
assert model_config.pooler_config.pooling_norm | ||
|
||
# asserts on the tokenizer loaded | ||
assert model_tokenizer.tokenizer_id == "BAAI/bge-base-en-v1.5" | ||
assert model_tokenizer.tokenizer_config["do_lower_case"] | ||
assert model_tokenizer.tokenizer.model_max_length == 512 | ||
|
||
model = model.model.llm_engine.model_executor\ | ||
.driver_worker.model_runner.model | ||
assert isinstance(model, BertEmbeddingModel) | ||
assert model._pooler.pooling_type == PoolingType.CLS | ||
assert model._pooler.normalize | ||
# assert output | ||
assert output |
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
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
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.
Here we need to add a verification to make sure that the pooling layer is configured correctly