-
-
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
base: main
Are you sure you want to change the base?
Conversation
👋 Hi! Thank you for contributing to the vLLM project. Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can do one of these:
🚀 |
6b01faf
to
0d6123a
Compare
Thanks! This is great! Can you make sure to add some integration tests? |
vllm/model_executor/layers/pooler.py
Outdated
MEAN = 3 | ||
|
||
|
||
class PoolingConfig(): |
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.
Maybe make this a dataclass?
vllm/transformers_utils/config.py
Outdated
def get_pooling_config(model, revision='main'): | ||
""" | ||
This function gets the pooling and normalize | ||
config from the model. |
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.
Can we rename this so it's more obvious that this only applies to sentence-transformers models? We currently have embedding models that are not from sentence-transformers, so it's rather confusing why only BERT accepts PoolingConfig
.
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.
Sorry about the force push!! I made a rebase with main to solve the conflicts.
dtype=torch.half if QUANTIZATION == "gptq" else "auto", | ||
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") |
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
vllm/engine/llm_engine.py
Outdated
model_config.max_model_len, | ||
load_config.download_dir, | ||
load_config.load_format, | ||
"mm_processor_kwargs=%s, pooling_config=%s)", VLLM_VERSION, |
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.
It looks like the linter did more than it should have here. Ideally a commit should not change code lines that are unrelated.
vllm/engine/llm_engine.py
Outdated
model_config.rope_scaling, | ||
model_config.rope_theta, | ||
model_config.tokenizer_revision, | ||
model_config.trust_remote_code, | ||
model_config.dtype, | ||
model_config.max_model_len, | ||
load_config.download_dir, | ||
load_config.load_format, | ||
"mm_processor_kwargs=%s, " | ||
"pooling_config_type=%s, normalize=%s)", VLLM_VERSION, | ||
model_config.model, speculative_config, model_config.tokenizer, | ||
model_config.skip_tokenizer_init, model_config.tokenizer_mode, | ||
model_config.revision, model_config.override_neuron_config, | ||
model_config.rope_scaling, model_config.rope_theta, | ||
model_config.tokenizer_revision, model_config.trust_remote_code, | ||
model_config.dtype, model_config.max_model_len, | ||
load_config.download_dir, load_config.load_format, | ||
parallel_config.tensor_parallel_size, | ||
parallel_config.pipeline_parallel_size, | ||
parallel_config.disable_custom_all_reduce, | ||
model_config.quantization, | ||
model_config.enforce_eager, | ||
cache_config.cache_dtype, | ||
model_config.quantization_param_path, | ||
device_config.device, | ||
decoding_config, | ||
observability_config, | ||
model_config.seed, | ||
model_config.served_model_name, | ||
model_config.quantization, model_config.enforce_eager, | ||
cache_config.cache_dtype, model_config.quantization_param_path, | ||
device_config.device, decoding_config, observability_config, | ||
model_config.seed, model_config.served_model_name, | ||
scheduler_config.num_scheduler_steps, | ||
scheduler_config.chunked_prefill_enabled, | ||
scheduler_config.multi_step_stream_outputs, | ||
cache_config.enable_prefix_caching, | ||
model_config.use_async_output_proc, | ||
use_cached_outputs, | ||
model_config.mm_processor_kwargs, | ||
) | ||
model_config.use_async_output_proc, use_cached_outputs, | ||
model_config.mm_processor_kwargs, | ||
model_config.pooling_config.pooling_type, | ||
model_config.pooling_config.normalize) |
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.
Let's keep this at one argument per line.
return build_model(model_class, | ||
model_config.hf_config, | ||
cache_config=cache_config, | ||
quant_config=_get_quantization_config( | ||
model_config, load_config), | ||
lora_config=lora_config, | ||
multimodal_config=model_config.multimodal_config, | ||
scheduler_config=scheduler_config, | ||
pooling_config=model_config.pooling_config) |
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.
I think the old indentation is easier to read.
vllm/config.py
Outdated
@@ -1835,6 +1851,9 @@ def _get_and_verify_max_len( | |||
raise ValueError( | |||
f"{msg} To allow overriding this maximum, set " | |||
"the env var VLLM_ALLOW_LONG_MAX_MODEL_LEN=1") | |||
|
|||
if bert_config: |
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.
Can we put this at line 1821 like this?
if bert_config and "max_seq_lenght" in bert_config:
derived_max_model_len = bert_config["max_seq_length"]
Otherwise it will disable the user override logic.
vllm/config.py
Outdated
self.bert_config = self._get_bert_config() | ||
self.do_lower_case = self._get_bert_tokenization_config() |
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.
self.bert_config = self._get_bert_config() | |
self.do_lower_case = self._get_bert_tokenization_config() | |
self.bert_config, self.do_lower_case = self._get_bert_config() |
vllm/transformers_utils/config.py
Outdated
- dict: A dictionary containing the configuration parameters | ||
for the Sentence Transformer BERT model. | ||
""" | ||
bert_dict = get_hf_file_to_dict("sentence_bert_config.json", model, |
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.
"sentence_bert_config.json" is one of several possible names: https://github.com/UKPLab/sentence-transformers/blob/f286d9f210824d6ea1563e789f49894b19c24f0e/sentence_transformers/models/Transformer.py#L421C13-L421C24
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.
Thank you! Will be adding these.
vllm/transformers_utils/config.py
Outdated
return None | ||
|
||
|
||
def get_sentence_transformer_bert_config(model, revision='main'): |
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.
Maybe rename to get_sentence_transformer_tokenizer_config
if model_config.do_lower_case is not None: | ||
init_kwargs["do_lower_case"] = model_config.do_lower_case | ||
|
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.
if model_config.do_lower_case is not None: | |
init_kwargs["do_lower_case"] = model_config.do_lower_case | |
if model_config.bert_config is not None and "do_lower_case" in model_config.bert_config: | |
init_kwargs["do_lower_case"] = model_config.bert_config["do_lower_case"] |
Signed-off-by: Flavia Beo <flavia.beo@ibm.com>
Signed-off-by: Flavia Beo <flavia.beo@ibm.com>
Signed-off-by: Flavia Beo <flavia.beo@ibm.com>
Signed-off-by: Flavia Beo <flavia.beo@ibm.com>
This pull request has merge conflicts that must be resolved before it can be |
Sorry, can you hold this for a bit? I'm trying to get #9697 merged which will definitely introduce merge conflicts. The CI is failing on main branch right now so we are all waiting for force merge. |
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: Flavia Beo <flavia.beo@ibm.com>
Signed-off-by: Flavia Beo <flavia.beo@ibm.com>
In vllm/engine/arg_utils.py the
In before the rebase you had a version where this list was generated automatically from the Enum type. Can you add this again? |
vllm/config.py
Outdated
@@ -107,6 +108,8 @@ class ModelConfig: | |||
can not be gathered from the vllm arguments. | |||
config_format: The config format which shall be loaded. | |||
Defaults to 'auto' which defaults to 'hf'. | |||
bert_config: tokenizationconfiguration dictionary for a given |
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.
bert_config
is not actually a parameter of the __init__
method. The documentation can be moved close to the initialization of self.bert_config
or removed. Otherwise the docstring will be wrong.
Signed-off-by: Flavia Beo <flavia.beo@ibm.com>
Signed-off-by: Flavia Beo <flavia.beo@ibm.com>
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.
LGTM
This adds a method to load the pooling config file from sentence transformer models like sentence-transformers/all-MiniLM-L12-v2.
The pooling types added can be found at the sentence-transformers Pooling
FIX #9388 (link existing issues this PR will resolve)
cc: @maxdebayser
BEFORE SUBMITTING, PLEASE READ THE CHECKLIST BELOW AND FILL IN THE DESCRIPTION ABOVE
PR Checklist (Click to Expand)
Thank you for your contribution to vLLM! Before submitting the pull request, please ensure the PR meets the following criteria. This helps vLLM maintain the code quality and improve the efficiency of the review process.
PR Title and Classification
Only specific types of PRs will be reviewed. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:
[Bugfix]
for bug fixes.[CI/Build]
for build or continuous integration improvements.[Doc]
for documentation fixes and improvements.[Model]
for adding a new model or improving an existing model. Model name should appear in the title.[Frontend]
For changes on the vLLM frontend (e.g., OpenAI API server,LLM
class, etc.)[Kernel]
for changes affecting CUDA kernels or other compute kernels.[Core]
for changes in the core vLLM logic (e.g.,LLMEngine
,AsyncLLMEngine
,Scheduler
, etc.)[Hardware][Vendor]
for hardware-specific changes. Vendor name should appear in the prefix (e.g.,[Hardware][AMD]
).[Misc]
for PRs that do not fit the above categories. Please use this sparingly.Note: If the PR spans more than one category, please include all relevant prefixes.
Code Quality
The PR need to meet the following code quality standards:
format.sh
to format your code.docs/source/
if the PR modifies the user-facing behaviors of vLLM. It helps vLLM user understand and utilize the new features or changes.Adding or changing kernels
Each custom kernel needs a schema and one or more implementations to be registered with PyTorch.
Tensors
require meta-functions. Meta-functions should be implemented and registered in python so that dynamic dims can be handled automatically. See above documents for a description of meta-functions.torch.libary.opcheck()
to test the function registration and meta-function for any registered ops. Seetests/kernels
for examples.Notes for Large Changes
Please keep the changes as concise as possible. For major architectural changes (>500 LOC excluding kernel/data/config/test), we would expect a GitHub issue (RFC) discussing the technical design and justification. Otherwise, we will tag it with
rfc-required
and might not go through the PR.What to Expect for the Reviews
The goal of the vLLM team is to be a transparent reviewing machine. We would like to make the review process transparent and efficient and make sure no contributor feel confused or frustrated. However, the vLLM team is small, so we need to prioritize some PRs over others. Here is what you can expect from the review process:
action-required
label on the PR if there are changes required. The contributor should address the comments and ping the reviewer to re-review the PR.Thank You
Finally, thank you for taking the time to read these guidelines and for your interest in contributing to vLLM. Your contributions make vLLM a great tool for everyone!