Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions fastdeploy/engine/args_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ class EngineArgs:
"""
The name or path of the model to be used.
"""
revision: Optional[str] = "master"
"""
The revision for downloading models.
"""
model_config_name: Optional[str] = "config.json"
"""
The name of the model configuration file.
Expand Down Expand Up @@ -344,12 +340,6 @@ def add_cli_args(parser: FlexibleArgumentParser) -> FlexibleArgumentParser:
default=EngineArgs.model,
help="Model name or path to be used.",
)
model_group.add_argument(
"--revision",
type=nullable_str,
default=EngineArgs.revision,
help="Revision for downloading models",
)
model_group.add_argument(
"--model-config-name",
type=nullable_str,
Expand Down
3 changes: 1 addition & 2 deletions fastdeploy/entrypoints/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ class LLM:
def __init__(
self,
model: str,
revision: Optional[str] = "master",
tokenizer: Optional[str] = None,
**kwargs,
):
model = retrive_model_from_server(model, revision)
model = retrive_model_from_server(model)
engine_args = EngineArgs(
model=model,
tokenizer=tokenizer,
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/entrypoints/openai/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
parser.add_argument("--controller-port", default=-1, type=int, help="port for controller server")
parser = EngineArgs.add_cli_args(parser)
args = parser.parse_args()
args.model = retrive_model_from_server(args.model, args.revision)
args.model = retrive_model_from_server(args.model)

llm_engine = None

Expand Down
2 changes: 0 additions & 2 deletions fastdeploy/envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
"FD_DEBUG": lambda: os.getenv("FD_DEBUG", "0"),
# Number of days to keep fastdeploy logs.
"FD_LOG_BACKUP_COUNT": lambda: os.getenv("FD_LOG_BACKUP_COUNT", "7"),
# Model download source, can set "AISTUDIO", "MODELSCOPE" or "HUGGINGFACE".
"FD_MODEL_SOURCE": lambda: os.getenv("FD_MODEL_SOURCE", "MODELSCOPE"),
# Model download cache directory.
"FD_MODEL_CACHE": lambda: os.getenv("FD_MODEL_CACHE", None),
# Maximum number of stop sequences.
Expand Down
60 changes: 13 additions & 47 deletions fastdeploy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@

import requests
import yaml
from aistudio_sdk.snapshot_download import snapshot_download as aistudio_download
from huggingface_hub._snapshot_download import snapshot_download as huggingface_download
from modelscope.hub.snapshot_download import snapshot_download as modelscope_download
from aistudio_sdk.snapshot_download import snapshot_download
from tqdm import tqdm
from typing_extensions import TypeIs, assert_never

Expand Down Expand Up @@ -496,53 +494,21 @@ def none_or_str(value):

def retrive_model_from_server(model_name_or_path, revision="master"):
"""
Download pretrained model from MODELSCOPE, AIStudio or HUGGINGFACE automatically
Download pretrained model from AIStudio automatically
"""
if os.path.exists(model_name_or_path):
return model_name_or_path
model_source = envs.FD_MODEL_SOURCE
local_path = envs.FD_MODEL_CACHE
repo_id = model_name_or_path
if model_source == "MODELSCOPE":
try:
if repo_id.lower().strip().startswith("baidu"):
repo_id = "PaddlePaddle" + repo_id.strip()[5:]
if local_path is None:
local_path = f'{os.getenv("HOME")}'
local_path = f"{local_path}/{repo_id}/{revision}"
modelscope_download(repo_id=repo_id, revision=revision, local_dir=local_path)
model_name_or_path = local_path
except Exception:
raise Exception(f"The setting model_name_or_path:{model_name_or_path} is not exist.")
elif model_source == "AISTUDIO":
try:
if repo_id.lower().strip().startswith("baidu"):
repo_id = "PaddlePaddle" + repo_id.strip()[5:]
if local_path is None:
local_path = f'{os.getenv("HOME")}'
local_path = f"{local_path}/{repo_id}/{revision}"
aistudio_download(repo_id=repo_id, revision=revision, local_dir=local_path)
model_name_or_path = local_path
except Exception:
raise Exception(f"The setting model_name_or_path:{model_name_or_path} is not exist.")
elif model_source == "HUGGINGFACE":
try:
if revision == "master":
revision = "main"
repo_id = model_name_or_path
if repo_id.lower().strip().startswith("PaddlePaddle"):
repo_id = "baidu" + repo_id.strip()[12:]
if local_path is None:
local_path = f'{os.getenv("HOME")}'
local_path = f"{local_path}/{repo_id}/{revision}"
huggingface_download(repo_id=repo_id, revision=revision, local_dir=local_path)
model_name_or_path = local_path
except Exception:
raise Exception(f"The setting model_name_or_path:{model_name_or_path} is not exist.")
else:
raise ValueError(
f"Unsupported model source: {model_source}, please choose one of ['MODELSCOPE', 'AISTUDIO', 'HUGGINGFACE']"
)
try:
repo_id = model_name_or_path
if repo_id.lower().strip().startswith("baidu"):
repo_id = "PaddlePaddle" + repo_id.strip()[5:]
local_path = envs.FD_MODEL_CACHE
if local_path is None:
local_path = f'{os.getenv("HOME")}/{repo_id}'
snapshot_download(repo_id=repo_id, revision=revision, local_dir=local_path)
model_name_or_path = local_path
except Exception:
raise Exception(f"The setting model_name_or_path:{model_name_or_path} is not exist.")
return model_name_or_path


Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use-triton-in-paddle
crcmod
fastsafetensors==0.1.14
msgpack
modelscope
opentelemetry-api>=1.24.0
opentelemetry-sdk>=1.24.0
opentelemetry-instrumentation-redis
Expand Down
43 changes: 0 additions & 43 deletions test/utils/test_download.py

This file was deleted.

Loading