-
-
Notifications
You must be signed in to change notification settings - Fork 11.8k
[Bugfix] Validate custom logits processor xargs for online serving #27560
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
Changes from 10 commits
b0ed8d4
8f538eb
9809125
3dce5a1
2618941
14cd026
865d10b
69e4f8a
a66d593
4abab78
b70bdaf
706a902
ff7be0b
7b7473a
b1b365f
843866f
8c085cf
2f1a66b
b583b01
4da4f6a
c4c3167
f4f0a14
ce4904a
dd91b83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,17 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
|
|
||
| from collections.abc import Iterable | ||
| from collections.abc import Iterable, Sequence | ||
Isotr0py marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| from functools import lru_cache, partial | ||
|
|
||
| import torch | ||
|
|
||
| from vllm.sampling_params import LogitsProcessor | ||
| from vllm.sampling_params import LogitsProcessor, SamplingParams | ||
| from vllm.transformers_utils.tokenizer import AnyTokenizer | ||
| from vllm.v1.sample.logits_processor import ( | ||
| AdapterLogitsProcessor, | ||
| _load_custom_logitsprocs, | ||
| ) | ||
|
|
||
|
|
||
| class AllowedTokenIdsLogitsProcessor: | ||
|
|
@@ -90,3 +94,15 @@ def get_logits_processors( | |
| ) | ||
|
|
||
| return logits_processors | ||
|
|
||
|
|
||
| def validate_logits_processors_parameters( | ||
| logits_processors: Sequence[str | LogitsProcessor] | None, | ||
| sampling_params: SamplingParams, | ||
| ): | ||
| if logits_processors is None: | ||
| return None | ||
|
|
||
| for logits_procs in _load_custom_logitsprocs(logits_processors): # type: ignore[arg-type] | ||
|
||
| if isinstance(logits_procs, AdapterLogitsProcessor): | ||
| logits_procs.validate_params(sampling_params) | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -218,3 +218,9 @@ def __init__( | |||||||||||||||||||||
| self.global_view_pos = global_view_pos | ||||||||||||||||||||||
| self.candidate_resolutions = candidate_resolutions | ||||||||||||||||||||||
| self.vocab_size = self.text_config.vocab_size | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # update model_type for OCR model | ||||||||||||||||||||||
| if "DeepseekOCRForCausalLM" in ( | ||||||||||||||||||||||
| self.architectures or kwargs.get("architectures", []) | ||||||||||||||||||||||
| ): | ||||||||||||||||||||||
| self.model_type = "deepseek_ocr" | ||||||||||||||||||||||
|
Comment on lines
+222
to
+226
Contributor
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. The condition However, it's crucial to ensure that this change doesn't alter the behavior of the code, especially if
Suggested change
|
||||||||||||||||||||||
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 is great that you updated the documentation to reflect these changes.
Correct me if wrong, but it appears like this PR right now is only updating the documentation for the special case of adapting a request-level logits processor.
I think we will probably also want to update the documentation for
The "Programming Model" section of the logits processors design docs https://docs.vllm.ai/en/latest/design/logits_processors.html#logits-processor-programming-model
Other sections of the custom logits processor design docs, specifically "Creating a custom logits processor" (https://docs.vllm.ai/en/latest/features/custom_logitsprocs.html#creating-a-custom-logits-processor), "Passing Custom Argument to a Custom Logits Procesor" (https://docs.vllm.ai/en/latest/features/custom_logitsprocs.html#passing-custom-argument-to-a-custom-logits-processor), "Example custom logits processor implementation" (https://docs.vllm.ai/en/latest/features/custom_logitsprocs.html#example-custom-logits-processor-implementation)