[Entrypoint][Refactor] vLLM-Omni Entrypoint Refactoring (#1908)
Signed-off-by: yinpe <11810305@mail.sustech.edu.cn> Signed-off-by: Peiqi Yin <yinpeiqi809@gmail.com> Signed-off-by: yinpeiqi <yinpeiqi809@gmail.com> Signed-off-by: wuhang <whlbx@hotmail.com> Signed-off-by: linyueqian <linyueqian@outlook.com> Signed-off-by: princepride <wangzhipeng628@gmail.com> Signed-off-by: lishunyang <lishunyang12@163.com> Signed-off-by: Chenguang ZHENG <645327136@qq.com> Signed-off-by: Peiqi Yin <60515999+yinpeiqi@users.noreply.github.com> Co-authored-by: yinpe <11810305@mail.sustech.edu.cn> Co-authored-by: Peiqi Yin <yinpeiqi809@gmail.com> Co-authored-by: wuhang <whlbx@hotmail.com> Co-authored-by: Peiqi Yin <60515999+yinpeiqi@users.noreply.github.com> Co-authored-by: linyueqian <linyueqian@outlook.com> Co-authored-by: princepride <wangzhipeng628@gmail.com> Co-authored-by: lishunyang <lishunyang12@163.com>
This commit is contained in:
125 files changed
+5210
-9322
No files matched your search
@@ -0,0 +1,55 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from vllm_omni.lora.request import LoRARequest
|
||||
from vllm_omni.lora.utils import stable_lora_int_id
|
||||
|
||||
|
||||
def get_stage_type(stage_cfg: Any) -> str:
|
||||
"""Best-effort stage type resolver across dict/omegaconf/object configs."""
|
||||
if isinstance(stage_cfg, dict):
|
||||
return stage_cfg.get("stage_type", "llm")
|
||||
if hasattr(stage_cfg, "get"):
|
||||
try:
|
||||
return stage_cfg.get("stage_type", "llm")
|
||||
except Exception:
|
||||
pass
|
||||
return getattr(stage_cfg, "stage_type", "llm")
|
||||
|
||||
|
||||
def parse_lora_request(lora_body: Any) -> tuple[LoRARequest | None, float | None]:
|
||||
"""Parse a request-level LoRA object into a LoRARequest and optional scale.
|
||||
|
||||
Raises:
|
||||
ValueError: If the object shape is invalid or required fields are missing.
|
||||
"""
|
||||
if lora_body is None:
|
||||
return None, None
|
||||
|
||||
if not isinstance(lora_body, dict):
|
||||
raise ValueError("Invalid lora field: expected an object.")
|
||||
|
||||
lora_name = lora_body.get("name") or lora_body.get("lora_name") or lora_body.get("adapter")
|
||||
lora_path = (
|
||||
lora_body.get("local_path")
|
||||
or lora_body.get("path")
|
||||
or lora_body.get("lora_path")
|
||||
or lora_body.get("lora_local_path")
|
||||
)
|
||||
lora_scale = lora_body.get("scale")
|
||||
if lora_scale is None:
|
||||
lora_scale = lora_body.get("lora_scale")
|
||||
lora_int_id = lora_body.get("int_id")
|
||||
if lora_int_id is None:
|
||||
lora_int_id = lora_body.get("lora_int_id")
|
||||
if lora_int_id is None and lora_path:
|
||||
lora_int_id = stable_lora_int_id(str(lora_path))
|
||||
|
||||
if not lora_name or not lora_path:
|
||||
raise ValueError("Invalid lora object: both name and path are required.")
|
||||
|
||||
scale = float(lora_scale) if lora_scale is not None else None
|
||||
return LoRARequest(str(lora_name), int(lora_int_id), str(lora_path)), scale
|
||||
Reference in new issue
Block a user