[Mini-vLLM] Cut dead subsystems: models, entrypoints, backends, utils, tests
- Drop dead model modules, keeping files live imports require - Remove anthropic, cohere, codegen entrypoints and batch STT modes - Delete unused attention backends, MoE experts, and NPU/XPU util leaves - Strip dead third_party trees and ROCm leaves with no CUDA path - Remove mooncake EC connectors: dependency missing since branch base - Re-audit verified by full import sweep and Qwen3.5 smoke test Co-authored-by: Hinata <hinata@idihore.id> Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
import warnings
|
||||
|
||||
from vllm.entrypoints.launchers.grpc_server import main, serve_grpc
|
||||
|
||||
warnings.warn(
|
||||
"`vllm.entrypoints.grpc_server is deprecated and will likely be "
|
||||
"unsupported in a future version. Use the corresponding function from "
|
||||
"`vllm.entrypoints.launchers.grpc_server` instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=1,
|
||||
)
|
||||
|
||||
__all__ = ["main", "serve_grpc"]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
warnings.warn(
|
||||
"`python -m vllm.entrypoints.grpc_server is deprecated and "
|
||||
"will likely be unsupported in a future version. "
|
||||
"Please use `vllm serve <model_path> --grpc` instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=1,
|
||||
)
|
||||
|
||||
main()
|
||||
@@ -9,7 +9,7 @@ import tempfile
|
||||
from argparse import Namespace
|
||||
from collections.abc import Awaitable, Callable
|
||||
from http import HTTPStatus
|
||||
from io import BytesIO, StringIO
|
||||
from io import StringIO
|
||||
from typing import Any, NoReturn, TypeAlias
|
||||
from urllib.parse import urlparse
|
||||
|
||||
@@ -17,9 +17,8 @@ import aiohttp
|
||||
import pybase64 as base64
|
||||
import pydantic
|
||||
import torch
|
||||
from fastapi import UploadFile
|
||||
from prometheus_client import start_http_server
|
||||
from pydantic import Field, TypeAdapter, field_validator, model_validator
|
||||
from pydantic import TypeAdapter, field_validator
|
||||
from pydantic_core.core_schema import ValidationInfo
|
||||
from starlette.datastructures import State
|
||||
from starlette.responses import JSONResponse
|
||||
@@ -37,19 +36,9 @@ from vllm.entrypoints.openai.chat_completion.protocol import (
|
||||
)
|
||||
from vllm.entrypoints.serve import create_error_response
|
||||
from vllm.entrypoints.serve.engine.protocol import (
|
||||
ErrorInfo,
|
||||
ErrorResponse,
|
||||
OpenAIBaseModel,
|
||||
)
|
||||
from vllm.entrypoints.speech_to_text.transcription.protocol import (
|
||||
TranscriptionRequest,
|
||||
TranscriptionResponseVariant,
|
||||
)
|
||||
from vllm.entrypoints.speech_to_text.translation.protocol import (
|
||||
TranslationRequest,
|
||||
TranslationResponse,
|
||||
TranslationResponseVerbose,
|
||||
)
|
||||
from vllm.exceptions import VLLMValidationError
|
||||
from vllm.logger import configure_logging_from_args, init_logger
|
||||
from vllm.reasoning import ReasoningParserManager
|
||||
@@ -76,69 +65,7 @@ def _raise_audio_filesize_limit(size_bytes: int) -> NoReturn:
|
||||
)
|
||||
|
||||
|
||||
class BatchTranscriptionRequest(TranscriptionRequest):
|
||||
"""Batch transcription request that uses file_url instead of file.
|
||||
|
||||
This class extends TranscriptionRequest but replaces the file field
|
||||
with file_url to support batch processing from audio files written in JSON format.
|
||||
"""
|
||||
|
||||
file_url: str = Field(
|
||||
...,
|
||||
description=(
|
||||
"Either a URL of the audio or a data URL with base64 encoded audio data. "
|
||||
),
|
||||
)
|
||||
|
||||
# Override file to be optional and unused for batch processing
|
||||
file: UploadFile | None = Field(default=None, exclude=True) # type: ignore[assignment]
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def validate_no_file(cls, data: Any):
|
||||
"""Ensure file field is not provided in batch requests."""
|
||||
if isinstance(data, dict) and "file" in data:
|
||||
raise VLLMValidationError(
|
||||
"The 'file' field is not supported in batch requests. "
|
||||
"Use 'file_url' instead.",
|
||||
parameter="file",
|
||||
)
|
||||
return data
|
||||
|
||||
|
||||
class BatchTranslationRequest(TranslationRequest):
|
||||
"""Batch translation request that uses file_url instead of file.
|
||||
|
||||
This class extends TranslationRequest but replaces the file field
|
||||
with file_url to support batch processing from audio files written in JSON format.
|
||||
"""
|
||||
|
||||
file_url: str = Field(
|
||||
...,
|
||||
description=(
|
||||
"Either a URL of the audio or a data URL with base64 encoded audio data. "
|
||||
),
|
||||
)
|
||||
|
||||
# Override file to be optional and unused for batch processing
|
||||
file: UploadFile | None = Field(default=None, exclude=True) # type: ignore[assignment]
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def validate_no_file(cls, data: Any):
|
||||
"""Ensure file field is not provided in batch requests."""
|
||||
if isinstance(data, dict) and "file" in data:
|
||||
raise VLLMValidationError(
|
||||
"The 'file' field is not supported in batch requests. "
|
||||
"Use 'file_url' instead.",
|
||||
parameter="file",
|
||||
)
|
||||
return data
|
||||
|
||||
|
||||
BatchRequestInputBody: TypeAlias = (
|
||||
ChatCompletionRequest | BatchTranscriptionRequest | BatchTranslationRequest
|
||||
)
|
||||
BatchRequestInputBody: TypeAlias = ChatCompletionRequest
|
||||
|
||||
|
||||
class BatchRequestInput(OpenAIBaseModel):
|
||||
@@ -169,18 +96,11 @@ class BatchRequestInput(OpenAIBaseModel):
|
||||
url: str = info.data["url"]
|
||||
if url == "/v1/chat/completions":
|
||||
return ChatCompletionRequest.model_validate(value)
|
||||
if url == "/v1/audio/transcriptions":
|
||||
return BatchTranscriptionRequest.model_validate(value)
|
||||
if url == "/v1/audio/translations":
|
||||
return BatchTranslationRequest.model_validate(value)
|
||||
return TypeAdapter(BatchRequestInputBody).validate_python(value)
|
||||
|
||||
|
||||
AllResponse: TypeAlias = (
|
||||
ChatCompletionResponse
|
||||
| TranscriptionResponseVariant
|
||||
| TranslationResponse
|
||||
| TranslationResponseVerbose
|
||||
)
|
||||
|
||||
|
||||
@@ -612,78 +532,6 @@ def handle_endpoint_request(
|
||||
return run_request(handler_fn, request, tracker)
|
||||
|
||||
|
||||
def make_transcription_wrapper(
|
||||
is_translation: bool,
|
||||
allowed_media_domains: list[str] | None = None,
|
||||
) -> WrapperFn:
|
||||
"""Factory function to create a wrapper for transcription/translation handlers.
|
||||
The wrapper converts BatchTranscriptionRequest or BatchTranslationRequest
|
||||
to TranscriptionRequest or TranslationRequest and calls the appropriate handler.
|
||||
|
||||
Args:
|
||||
is_translation: If True, process as translation; otherwise process
|
||||
as transcription
|
||||
allowed_media_domains: If set, only URLs from these domains are
|
||||
permitted for HTTP/HTTPS fetches.
|
||||
|
||||
Returns:
|
||||
A function that takes a handler and returns a wrapped handler
|
||||
|
||||
"""
|
||||
|
||||
def wrapper(handler_fn: Callable):
|
||||
async def transcription_wrapper(
|
||||
batch_request_body: (BatchTranscriptionRequest | BatchTranslationRequest),
|
||||
) -> (
|
||||
TranscriptionResponseVariant
|
||||
| TranslationResponse
|
||||
| TranslationResponseVerbose
|
||||
| ErrorResponse
|
||||
):
|
||||
try:
|
||||
# Download data from URL
|
||||
audio_data = await download_bytes_from_url(
|
||||
batch_request_body.file_url,
|
||||
allowed_media_domains=allowed_media_domains,
|
||||
)
|
||||
|
||||
# Create a mock file from the downloaded audio data
|
||||
mock_file = UploadFile(
|
||||
file=BytesIO(audio_data),
|
||||
filename="audio.bin",
|
||||
)
|
||||
|
||||
# Convert batch request to regular request
|
||||
# by copying all fields except file_url and setting file to mock_file
|
||||
request_dict = batch_request_body.model_dump(exclude={"file_url"})
|
||||
request_dict["file"] = mock_file
|
||||
|
||||
if is_translation:
|
||||
# Create TranslationRequest from BatchTranslationRequest
|
||||
translation_request = TranslationRequest.model_validate(
|
||||
request_dict
|
||||
)
|
||||
return await handler_fn(audio_data, translation_request)
|
||||
else:
|
||||
# Create TranscriptionRequest from BatchTranscriptionRequest
|
||||
transcription_request = TranscriptionRequest.model_validate(
|
||||
request_dict
|
||||
)
|
||||
return await handler_fn(audio_data, transcription_request)
|
||||
except Exception as e:
|
||||
operation = "translation" if is_translation else "transcription"
|
||||
return ErrorResponse(
|
||||
error=ErrorInfo(
|
||||
message=f"Failed to process {operation}: {str(e)}",
|
||||
type="BadRequestError",
|
||||
code=HTTPStatus.BAD_REQUEST.value,
|
||||
)
|
||||
)
|
||||
|
||||
return transcription_wrapper
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
async def build_endpoint_registry(
|
||||
engine_client: EngineClient,
|
||||
@@ -712,10 +560,6 @@ async def build_endpoint_registry(
|
||||
|
||||
# Get serving objects from state (defaulting to None if not set)
|
||||
openai_serving_chat = getattr(state, "openai_serving_chat", None)
|
||||
openai_serving_transcription = getattr(state, "openai_serving_transcription", None)
|
||||
openai_serving_translation = getattr(state, "openai_serving_translation", None)
|
||||
|
||||
allowed_media_domains = getattr(args, "allowed_media_domains", None)
|
||||
|
||||
# Registry of endpoint configurations
|
||||
endpoint_registry: dict[str, dict[str, Any]] = {
|
||||
@@ -728,30 +572,6 @@ async def build_endpoint_registry(
|
||||
),
|
||||
"wrapper_fn": None,
|
||||
},
|
||||
"transcriptions": {
|
||||
"url_matcher": lambda url: url == "/v1/audio/transcriptions",
|
||||
"handler_getter": lambda: (
|
||||
openai_serving_transcription.create_transcription
|
||||
if openai_serving_transcription is not None
|
||||
else None
|
||||
),
|
||||
"wrapper_fn": make_transcription_wrapper(
|
||||
is_translation=False,
|
||||
allowed_media_domains=allowed_media_domains,
|
||||
),
|
||||
},
|
||||
"translations": {
|
||||
"url_matcher": lambda url: url == "/v1/audio/translations",
|
||||
"handler_getter": lambda: (
|
||||
openai_serving_translation.create_translation
|
||||
if openai_serving_translation is not None
|
||||
else None
|
||||
),
|
||||
"wrapper_fn": make_transcription_wrapper(
|
||||
is_translation=True,
|
||||
allowed_media_domains=allowed_media_domains,
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
return endpoint_registry
|
||||
@@ -812,8 +632,7 @@ async def run_batch(
|
||||
make_async_error_request_output(
|
||||
request,
|
||||
error_msg=f"URL {request.url} was used. "
|
||||
"Supported endpoints: /v1/chat/completions,"
|
||||
" /v1/audio/transcriptions, /v1/audio/translations.",
|
||||
"Supported endpoints: /v1/chat/completions.",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -46,14 +46,6 @@ def init_entrypoints_middleware(
|
||||
|
||||
app.add_middleware(ScalingMiddleware)
|
||||
|
||||
if "realtime" in supported_tasks:
|
||||
# Add WebSocket metrics middleware
|
||||
from vllm.entrypoints.speech_to_text.realtime.metrics import (
|
||||
WebSocketMetricsMiddleware,
|
||||
)
|
||||
|
||||
app.add_middleware(WebSocketMetricsMiddleware)
|
||||
|
||||
if envs.VLLM_DEBUG_LOG_API_SERVER_RESPONSE:
|
||||
logger.warning(
|
||||
"CAUTION: Enabling log response in the API Server. "
|
||||
|
||||
Reference in New Issue
Block a user