@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 0c492b7824
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 15, 08:30 UTC

[Deprecation] Remove fallbacks for Embeddings API (#18795)

Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>

Cyrus Leung committed May 28, 2025 at 15:09 UTC 0c492b782420f9043e06a7c7f21ff62496a7a392
3 files changed +12 -60
vllm/config.py
+6 -11
@@ -797,17 +797,12 @@ class ModelConfig:
797 else:
798 # Aliases
799 if task_option == "embedding":
800 - preferred_task = self._get_preferred_task(
801 - architectures, supported_tasks)
802 - if preferred_task != "embed":
803 - msg = ("The 'embedding' task will be restricted to "
804 - "embedding models in a future release. Please "
805 - "pass `--task classify`, `--task score`, or "
806 - "`--task reward` explicitly for other pooling "
807 - "models.")
808 - warnings.warn(msg, DeprecationWarning, stacklevel=2)
809 -
810 - task_option = preferred_task or "embed"
800 + msg = ("The 'embedding' task has been renamed to "
801 + "'embed', please use the new name. The old name "
802 + "will be removed in v1.0.")
803 + warnings.warn(msg, DeprecationWarning, stacklevel=2)
804 +
805 + task_option = "embed"
806
807 if task_option not in supported_tasks:
808 msg = (
vllm/entrypoints/openai/api_server.py
+5 -34
@@ -17,7 +17,7 @@ from contextlib import asynccontextmanager
17 from functools import partial
18 from http import HTTPStatus
19 from json import JSONDecodeError
20 -from typing import Annotated, Optional, Union
20 +from typing import Annotated, Optional
21
22 import prometheus_client
23 import regex as re
@@ -59,9 +59,7 @@ from vllm.entrypoints.openai.protocol import (ChatCompletionRequest,
59 EmbeddingChatRequest,
60 EmbeddingCompletionRequest,
61 EmbeddingRequest,
62 - EmbeddingResponse,
63 - EmbeddingResponseData,
64 - ErrorResponse,
62 + EmbeddingResponse, ErrorResponse,
63 LoadLoRAAdapterRequest,
64 PoolingChatRequest,
65 PoolingCompletionRequest,
@@ -627,37 +625,10 @@ async def create_completion(request: CompletionRequest, raw_request: Request):
625 async def create_embedding(request: EmbeddingRequest, raw_request: Request):
626 handler = embedding(raw_request)
627 if handler is None:
630 - fallback_handler = pooling(raw_request)
631 - if fallback_handler is None:
632 - return base(raw_request).create_error_response(
633 - message="The model does not support Embeddings API")
628 + return base(raw_request).create_error_response(
629 + message="The model does not support Embeddings API")
630
635 - logger.warning(
636 - "Embeddings API will become exclusive to embedding models "
637 - "in a future release. To return the hidden states directly, "
638 - "use the Pooling API (`/pooling`) instead.")
639 -
640 - res = await fallback_handler.create_pooling(request, raw_request)
641 -
642 - generator: Union[ErrorResponse, EmbeddingResponse]
643 - if isinstance(res, PoolingResponse):
644 - generator = EmbeddingResponse(
645 - id=res.id,
646 - object=res.object,
647 - created=res.created,
648 - model=res.model,
649 - data=[
650 - EmbeddingResponseData(
651 - index=d.index,
652 - embedding=d.data, # type: ignore
653 - ) for d in res.data
654 - ],
655 - usage=res.usage,
656 - )
657 - else:
658 - generator = res
659 - else:
660 - generator = await handler.create_embedding(request, raw_request)
631 + generator = await handler.create_embedding(request, raw_request)
632
633 if isinstance(generator, ErrorResponse):
634 return JSONResponse(content=generator.model_dump(),
vllm/outputs.py
+1 -15
@@ -7,7 +7,7 @@ from dataclasses import dataclass
7 from typing import Any, Generic, Optional, Union
8
9 import torch
10 -from typing_extensions import TypeVar, deprecated
10 +from typing_extensions import TypeVar
11
12 from vllm.logger import init_logger
13 from vllm.lora.request import LoRARequest
@@ -76,14 +76,6 @@ class PoolingOutput:
76 return (isinstance(other, self.__class__) and bool(
77 (self.data == other.data).all()))
78
79 - @property
80 - @deprecated("`LLM.encode()` now stores raw outputs in the `data` "
81 - "attribute. To return embeddings, use `LLM.embed()`. "
82 - "To return class probabilities, use `LLM.classify()` "
83 - "and access the `probs` attribute. ")
84 - def embedding(self) -> list[float]:
85 - return self.data.tolist()
86 -
79
80 class RequestOutput:
81 """The output data of a completion request to the LLM.
@@ -506,12 +498,6 @@ class ScoringOutput:
498 def __repr__(self) -> str:
499 return f"ScoringOutput(score={self.score})"
500
509 - @property
510 - @deprecated("`LLM.score()` now returns scalar scores. "
511 - "Please access it via the `score` attribute. ")
512 - def embedding(self) -> list[float]:
513 - return [self.score]
514 -
501
502 class ScoringRequestOutput(PoolingRequestOutput[ScoringOutput]):
503